FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/prores_raw_parser.c
Date: 2025-11-28 00:28:25
Exec Total Coverage
Lines: 0 50 0.0%
Functions: 0 1 0.0%
Branches: 0 15 0.0%

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 #include "parser_internal.h"
24
25 static int prores_raw_parse(AVCodecParserContext *s, AVCodecContext *avctx,
26 const uint8_t **poutbuf, int *poutbuf_size,
27 const uint8_t *buf, int buf_size)
28 {
29 GetByteContext gb;
30
31 switch (avctx->codec_tag) {
32 case 0:
33 break;
34 case MKTAG('a','p','r','n'):
35 avctx->profile = AV_PROFILE_PRORES_RAW;
36 break;
37 case MKTAG('a','p','r','h'):
38 avctx->profile = AV_PROFILE_PRORES_RAW_HQ;
39 break;
40 default:
41 avpriv_request_sample(avctx, "Profile %d", avctx->codec_tag);
42 return buf_size;
43 break;
44 }
45
46 bytestream2_init(&gb, buf, buf_size);
47 if (bytestream2_get_be32(&gb) != buf_size) /* Packet size */
48 return buf_size;
49
50 if (bytestream2_get_be32(&gb) != MKBETAG('p','r','r','f')) /* Frame header */
51 return buf_size;
52
53 int header_size = bytestream2_get_be16(&gb);
54 if (header_size < 62)
55 return buf_size;
56
57 bytestream2_skip(&gb, 1);
58 int version = bytestream2_get_byte(&gb);
59 if (version > 1) {
60 avpriv_request_sample(avctx, "Version %d", version);
61 return buf_size;
62 }
63
64 /* Vendor header (e.g. "peac" for Panasonic or "atm0" for Atmos) */
65 switch (bytestream2_get_be32(&gb)) {
66 case MKBETAG('p','e','a','c'):
67 /* Internal recording from a Panasonic camera, V-Log */
68 avctx->color_primaries = AVCOL_PRI_V_GAMUT;
69 avctx->color_trc = AVCOL_TRC_V_LOG;
70 break;
71 case MKBETAG('a','t','m','0'):
72 /* External recording from an Atomos recorder. Cameras universally
73 * record in their own native log curve internally, but linearize it
74 * when outputting RAW externally */
75 avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
76 avctx->color_trc = AVCOL_TRC_LINEAR;
77 break;
78 default:
79 avctx->color_trc = AVCOL_TRC_UNSPECIFIED;
80 break;
81 };
82
83 s->width = bytestream2_get_be16(&gb);
84 s->height = bytestream2_get_be16(&gb);
85 s->coded_width = FFALIGN(s->width, 16);
86 s->coded_height = FFALIGN(s->height, 16);
87 s->format = AV_PIX_FMT_BAYER_RGGB16;
88 s->key_frame = 1;
89 s->pict_type = AV_PICTURE_TYPE_I;
90 s->field_order = AV_FIELD_PROGRESSIVE;
91 s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
92
93 /* This parser only performs analysis */
94 *poutbuf = buf;
95 *poutbuf_size = buf_size;
96
97 return buf_size;
98 }
99
100 const FFCodecParser ff_prores_raw_parser = {
101 PARSER_CODEC_LIST(AV_CODEC_ID_PRORES_RAW),
102 .parse = prores_raw_parse,
103 };
104