From: Lynne <dev@lynne.ee> To: ffmpeg-devel@ffmpeg.org Cc: Lynne <dev@lynne.ee> Subject: [FFmpeg-devel] [PATCH v2 07/13] lavc: add a ProRes RAW parser Date: Sun, 13 Jul 2025 03:51:16 +0900 Message-ID: <20250712185128.862167-7-dev@lynne.ee> (raw) In-Reply-To: <20250712185128.862167-1-dev@lynne.ee> 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. --- libavcodec/Makefile | 1 + libavcodec/parsers.c | 1 + libavcodec/prores_raw_parser.c | 72 ++++++++++++++++++++++++++++++++++ libavformat/mov.c | 1 + 4 files changed, 75 insertions(+) create mode 100644 libavcodec/prores_raw_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 215577f7c9..78e099ce5d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1250,6 +1250,7 @@ OBJS-$(CONFIG_MPEGVIDEO_PARSER) += mpegvideo_parser.o \ OBJS-$(CONFIG_OPUS_PARSER) += vorbis_data.o OBJS-$(CONFIG_PNG_PARSER) += png_parser.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_RV34_PARSER) += rv34_parser.o OBJS-$(CONFIG_SBC_PARSER) += sbc_parser.o diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index 21164f3751..b12c48f79f 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -68,6 +68,7 @@ extern const AVCodecParser ff_mpegvideo_parser; extern const AVCodecParser ff_opus_parser; extern const AVCodecParser ff_png_parser; extern const AVCodecParser ff_pnm_parser; +extern const AVCodecParser ff_prores_raw_parser; extern const AVCodecParser ff_qoi_parser; extern const AVCodecParser ff_rv34_parser; extern const AVCodecParser ff_sbc_parser; diff --git a/libavcodec/prores_raw_parser.c b/libavcodec/prores_raw_parser.c new file mode 100644 index 0000000000..a286d674b2 --- /dev/null +++ b/libavcodec/prores_raw_parser.c @@ -0,0 +1,72 @@ +/* + * 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; + uint32_t header_size; + int version; + + 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; + + header_size = bytestream2_get_be16(&gb) + 8; + version = bytestream2_get_be16(&gb); + if (version > 1) { + avpriv_request_sample(avctx, "Version %d", version); + return buf_size; + } + + if (header_size < (version == 0 ? 144 : 96)) + 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, +}; diff --git a/libavformat/mov.c b/libavformat/mov.c index c935bbf0bf..39c1d6c286 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2987,6 +2987,7 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, case AV_CODEC_ID_VP9: sti->need_parsing = AVSTREAM_PARSE_FULL; break; + case AV_CODEC_ID_PRORES_RAW: case AV_CODEC_ID_APV: case AV_CODEC_ID_EVC: case AV_CODEC_ID_AV1: -- 2.50.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-07-12 18:52 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-07-12 18:51 [FFmpeg-devel] [PATCH v2 01/13] vf_libplacebo: add support for specifying a LUT for the input Lynne 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 02/13] hwcontext_vulkan: temporarily disable host_image_copy Lynne 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 03/13] hwcontext_vulkan: enable uniformBufferStandardLayout Lynne 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 04/13] vulkan: add support for 16-bit RGGB Bayer pixfmt Lynne 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 05/13] lavc/vulkan/common: sign-ify lengths Lynne 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 06/13] lavc: add codec ID and profiles for ProRes RAW Lynne 2025-07-12 18:51 ` Lynne [this message] 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 08/13] lavc: add a ProRes RAW decoder Lynne 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 09/13] lavc: add a ProRes RAW Vulkan hwaccel Lynne 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 10/13] scale_vulkan: refactor shader initialization Lynne 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 11/13] scale_vulkan: add support for basic Debayering Lynne 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 12/13] lavc/vp9dec: use cbs_vp9 to parse the frame header Lynne 2025-07-12 18:51 ` [FFmpeg-devel] [PATCH v2 13/13] WIP vp9: add Vulkan VP9 hwaccel Lynne
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250712185128.862167-7-dev@lynne.ee \ --to=dev@lynne.ee \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git