Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* Copyright (c) 2025 Lynne <dev@lynne.ee> |
3 |
|
|
* |
4 |
|
|
* This file is part of FFmpeg. |
5 |
|
|
* |
6 |
|
|
* FFmpeg is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU Lesser General Public |
8 |
|
|
* License as published by the Free Software Foundation; either |
9 |
|
|
* version 2.1 of the License, or (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* FFmpeg is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
|
|
* Lesser General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU Lesser General Public |
17 |
|
|
* License along with FFmpeg; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include "parser.h" |
22 |
|
|
#include "bytestream.h" |
23 |
|
|
|
24 |
|
✗ |
static int prores_raw_parse(AVCodecParserContext *s, AVCodecContext *avctx, |
25 |
|
|
const uint8_t **poutbuf, int *poutbuf_size, |
26 |
|
|
const uint8_t *buf, int buf_size) |
27 |
|
|
{ |
28 |
|
|
GetByteContext gb; |
29 |
|
|
|
30 |
|
✗ |
switch (avctx->codec_tag) { |
31 |
|
✗ |
case 0: |
32 |
|
✗ |
break; |
33 |
|
✗ |
case MKTAG('a','p','r','n'): |
34 |
|
✗ |
avctx->profile = AV_PROFILE_PRORES_RAW; |
35 |
|
✗ |
break; |
36 |
|
✗ |
case MKTAG('a','p','r','h'): |
37 |
|
✗ |
avctx->profile = AV_PROFILE_PRORES_RAW_HQ; |
38 |
|
✗ |
break; |
39 |
|
✗ |
default: |
40 |
|
✗ |
avpriv_request_sample(avctx, "Profile %d", avctx->codec_tag); |
41 |
|
✗ |
return buf_size; |
42 |
|
|
break; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
✗ |
bytestream2_init(&gb, buf, buf_size); |
46 |
|
✗ |
if (bytestream2_get_be32(&gb) != buf_size) /* Packet size */ |
47 |
|
✗ |
return buf_size; |
48 |
|
|
|
49 |
|
✗ |
if (bytestream2_get_le32(&gb) != MKTAG('p','r','r','f')) /* Frame header */ |
50 |
|
✗ |
return buf_size; |
51 |
|
|
|
52 |
|
✗ |
int header_size = bytestream2_get_be16(&gb); |
53 |
|
✗ |
if (header_size < 62) |
54 |
|
✗ |
return buf_size; |
55 |
|
|
|
56 |
|
✗ |
bytestream2_skip(&gb, 1); |
57 |
|
✗ |
int version = bytestream2_get_byte(&gb); |
58 |
|
✗ |
if (version > 1) { |
59 |
|
✗ |
avpriv_request_sample(avctx, "Version %d", version); |
60 |
|
✗ |
return buf_size; |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
/* Vendor header (e.g. "peac" for Panasonic or "atm0" for Atmos) */ |
64 |
|
✗ |
bytestream2_skip(&gb, 4); |
65 |
|
|
|
66 |
|
✗ |
s->width = bytestream2_get_be16(&gb); |
67 |
|
✗ |
s->height = bytestream2_get_be16(&gb); |
68 |
|
✗ |
s->coded_width = FFALIGN(s->width, 16); |
69 |
|
✗ |
s->coded_height = FFALIGN(s->height, 16); |
70 |
|
✗ |
s->format = AV_PIX_FMT_BAYER_RGGB16; |
71 |
|
✗ |
s->key_frame = 1; |
72 |
|
✗ |
s->pict_type = AV_PICTURE_TYPE_I; |
73 |
|
✗ |
s->field_order = AV_FIELD_PROGRESSIVE; |
74 |
|
✗ |
s->picture_structure = AV_PICTURE_STRUCTURE_FRAME; |
75 |
|
|
|
76 |
|
|
/* This parser only performs analysis */ |
77 |
|
✗ |
*poutbuf = buf; |
78 |
|
✗ |
*poutbuf_size = buf_size; |
79 |
|
|
|
80 |
|
✗ |
return buf_size; |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
const AVCodecParser ff_prores_raw_parser = { |
84 |
|
|
.codec_ids = { AV_CODEC_ID_PRORES_RAW }, |
85 |
|
|
.parser_parse = prores_raw_parse, |
86 |
|
|
}; |
87 |
|
|
|