FFmpeg
Loading...
Searching...
No Matches
prores_raw_parser.c
Go to the documentation of this file.
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
26 const uint8_t **poutbuf, int *poutbuf_size,
27 const uint8_t *buf, int buf_size)
28{
30
31 switch (avctx->codec_tag) {
32 case 0:
33 break;
34 case MKTAG('a','p','r','n'):
36 break;
37 case MKTAG('a','p','r','h'):
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 bytestream2_skip(&gb, 4);
66
70 s->width = bytestream2_get_be16(&gb);
71 s->height = bytestream2_get_be16(&gb);
72 s->coded_width = FFALIGN(s->width, 16);
73 s->coded_height = FFALIGN(s->height, 16);
74 s->format = AV_PIX_FMT_BAYER_RGGB16;
75 s->key_frame = 1;
76 s->pict_type = AV_PICTURE_TYPE_I;
77 s->field_order = AV_FIELD_PROGRESSIVE;
78 s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
79
80 /* This parser only performs analysis */
81 *poutbuf = buf;
82 *poutbuf_size = buf_size;
83
84 return buf_size;
85}
86
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition bytestream.h:137
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition bytestream.h:168
#define s(width, name)
Definition cbs_vp9.c:198
@ AV_FIELD_PROGRESSIVE
Definition defs.h:213
#define AV_PROFILE_PRORES_RAW_HQ
Definition defs.h:189
#define AV_PROFILE_PRORES_RAW
Definition defs.h:188
@ AV_CODEC_ID_PRORES_RAW
Definition codec_id.h:324
@ AV_PICTURE_STRUCTURE_FRAME
coded as frame
Definition avcodec.h:2614
@ AV_PICTURE_TYPE_I
Intra.
Definition avutil.h:278
version
Definition libkvazaar.c:313
#define MKTAG(a, b, c, d)
Definition macros.h:55
#define MKBETAG(a, b, c, d)
Definition macros.h:56
#define FFALIGN(x, a)
Definition macros.h:78
#define PARSER_CODEC_LIST(...)
const FFCodecParser ff_prores_raw_parser
#define AV_PIX_FMT_BAYER_RGGB16
Definition pixfmt.h:578
@ AVCOL_PRI_UNSPECIFIED
Definition pixfmt.h:645
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition pixfmt.h:681
@ AVCOL_SPC_UNSPECIFIED
Definition pixfmt.h:709
static int prores_raw_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
main external API structure.
Definition avcodec.h:443
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition avcodec.h:468
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition avcodec.h:657
int profile
profile
Definition avcodec.h:1636
enum AVColorSpace colorspace
YUV colorspace type.
Definition avcodec.h:671
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition avcodec.h:664
#define avpriv_request_sample(...)