From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 6CB3C4E8F1 for ; Sat, 12 Jul 2025 18:52:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id C7F4268F20E; Sat, 12 Jul 2025 21:51:58 +0300 (EEST) Received: from vidala.pars.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 6581C68F1E4 for ; Sat, 12 Jul 2025 21:51:51 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; s=202405r; d=lynne.ee; c=relaxed/relaxed; h=Message-ID:Date:Subject:To:From; t=1752346311; bh=UUN9SmLTAdTJAOM7IKpVrMO itusVHPlr7JKuio/mkIg=; b=RKVJ5LA/vJStc1a/xjp70A5Rg4WKrlz3/qKJJvIpRiK4/mbymp O0ooeSNEcj/z4ZW+R4cgqG0N8iYbCf5UwRdswTMtnXy8KCCSLeZPYgStFiU2/6DFGNM+MeyDp3e Tk7iV0/R0omKE8JicWMHRslClCZfYgpzhV83qry5QMvu0qcoCiqRa1ofASjz7Alok9x/H50jyDl gwoQ2oN/kweLHkxLyNa5/m/LBRfD+3UH0CVEkM+h65cGCh2YsJcGRBxzyuBnDk5sqGI9TjwT2wO evw6lDhsOK0QzdFODfUZ0HiPOdmVfcwi/C1b/BQHuKbCnuW9w3/aPyso7F2XlCXpLFQ==; DKIM-Signature: v=1; a=ed25519-sha256; s=202405e; d=lynne.ee; c=relaxed/relaxed; h=Message-ID:Date:Subject:To:From; t=1752346311; bh=UUN9SmLTAdTJAOM7IKpVrMO itusVHPlr7JKuio/mkIg=; b=QasDkTgrffa+hHAjUq+fcTngXqlY2sILAsgGy3yzbUyb6FabfZ cu6a02Nq1xb9OhVjZy58mYZaGpyA+Pdo0DCg==; From: Lynne To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Jul 2025 03:51:16 +0900 Message-ID: <20250712185128.862167-7-dev@lynne.ee> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250712185128.862167-1-dev@lynne.ee> References: <20250712185128.862167-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 07/13] lavc: add a ProRes RAW parser X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Lynne Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 + * + * 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".