1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

lavc: add a ProRes RAW parser

Simple parser that only parses frame information.
This helps avoid requiring the software decoder on init to decode a
single frame, since the decoder can be quite slow.
This commit is contained in:
Lynne
2025-07-12 00:50:55 +09:00
parent 4ad35d78c9
commit 5ff2886e9a
4 changed files with 89 additions and 0 deletions

View File

@@ -1254,6 +1254,7 @@ OBJS-$(CONFIG_MPEGVIDEO_PARSER) += mpegvideo_parser.o \
OBJS-$(CONFIG_OPUS_PARSER) += vorbis_data.o OBJS-$(CONFIG_OPUS_PARSER) += vorbis_data.o
OBJS-$(CONFIG_PNG_PARSER) += png_parser.o OBJS-$(CONFIG_PNG_PARSER) += png_parser.o
OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o
OBJS-$(CONFIG_PRORES_RAW_PARSER) += prores_raw_parser.o
OBJS-$(CONFIG_QOI_PARSER) += qoi_parser.o OBJS-$(CONFIG_QOI_PARSER) += qoi_parser.o
OBJS-$(CONFIG_RV34_PARSER) += rv34_parser.o OBJS-$(CONFIG_RV34_PARSER) += rv34_parser.o
OBJS-$(CONFIG_SBC_PARSER) += sbc_parser.o OBJS-$(CONFIG_SBC_PARSER) += sbc_parser.o

View File

@@ -68,6 +68,7 @@ extern const AVCodecParser ff_mpegvideo_parser;
extern const AVCodecParser ff_opus_parser; extern const AVCodecParser ff_opus_parser;
extern const AVCodecParser ff_png_parser; extern const AVCodecParser ff_png_parser;
extern const AVCodecParser ff_pnm_parser; extern const AVCodecParser ff_pnm_parser;
extern const AVCodecParser ff_prores_raw_parser;
extern const AVCodecParser ff_qoi_parser; extern const AVCodecParser ff_qoi_parser;
extern const AVCodecParser ff_rv34_parser; extern const AVCodecParser ff_rv34_parser;
extern const AVCodecParser ff_sbc_parser; extern const AVCodecParser ff_sbc_parser;

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2025 Lynne <dev@lynne.ee>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "parser.h"
#include "bytestream.h"
static int prores_raw_parse(AVCodecParserContext *s, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
GetByteContext gb;
switch (avctx->codec_tag) {
case 0:
break;
case MKTAG('a','p','r','n'):
avctx->profile = AV_PROFILE_PRORES_RAW;
break;
case MKTAG('a','p','r','h'):
avctx->profile = AV_PROFILE_PRORES_RAW_HQ;
break;
default:
avpriv_request_sample(avctx, "Profile %d", avctx->codec_tag);
return buf_size;
break;
}
bytestream2_init(&gb, buf, buf_size);
if (bytestream2_get_be32(&gb) != buf_size) /* Packet size */
return buf_size;
if (bytestream2_get_le32(&gb) != MKTAG('p','r','r','f')) /* Frame header */
return buf_size;
int header_size = bytestream2_get_be16(&gb);
if (header_size < 62)
return buf_size;
bytestream2_skip(&gb, 1);
int version = bytestream2_get_byte(&gb);
if (version > 1) {
avpriv_request_sample(avctx, "Version %d", version);
return buf_size;
}
/* Vendor header (e.g. "peac" for Panasonic or "atm0" for Atmos) */
bytestream2_skip(&gb, 4);
s->width = bytestream2_get_be16(&gb);
s->height = bytestream2_get_be16(&gb);
s->coded_width = FFALIGN(s->width, 16);
s->coded_height = FFALIGN(s->height, 16);
s->format = AV_PIX_FMT_BAYER_RGGB16;
s->key_frame = 1;
s->pict_type = AV_PICTURE_TYPE_I;
s->field_order = AV_FIELD_PROGRESSIVE;
s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
/* This parser only performs analysis */
*poutbuf = buf;
*poutbuf_size = buf_size;
return buf_size;
}
const AVCodecParser ff_prores_raw_parser = {
.codec_ids = { AV_CODEC_ID_PRORES_RAW },
.parser_parse = prores_raw_parse,
};

View File

@@ -2989,6 +2989,7 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb,
case AV_CODEC_ID_VP9: case AV_CODEC_ID_VP9:
sti->need_parsing = AVSTREAM_PARSE_FULL; sti->need_parsing = AVSTREAM_PARSE_FULL;
break; break;
case AV_CODEC_ID_PRORES_RAW:
case AV_CODEC_ID_APV: case AV_CODEC_ID_APV:
case AV_CODEC_ID_EVC: case AV_CODEC_ID_EVC:
case AV_CODEC_ID_AV1: case AV_CODEC_ID_AV1: