From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0A85944D79 for ; Mon, 24 Jul 2023 07:24:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8CB1468C72E; Mon, 24 Jul 2023 10:24:39 +0300 (EEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2067.outbound.protection.outlook.com [40.92.89.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1551C68C68D for ; Mon, 24 Jul 2023 10:24:33 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fYhiRmOxOQJt9/z+i92axO/ZsGejBS7ZtmGTi+Dqm6T5dFAgd8xBGpFi7ftVSTxgfPC+ZbEUGUqTjvN0tnEVwzQ0r4RHc29VASLwFNu/E9laKzxLB8oNTkDPptgiRoHo3cAp8a5NgbwnK7qyJ6wncNRxeZeyOV0T9PJDVws2UIp2qRtEo5LP1YlqufhG/5/zf9fLswuWh1r4t/nieRrpHvlCHksG8/OKyhWMI1ZudqxExMV9bajvDdILTLj04CLc4HuFGb4WI2ENC4ZifoT0coULmcV6hHe0ktNSWkJMCVoapKU55BYCT+4jteaoPdBGk3yOm7I+K3J+xFqJHOvkLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W06lntdHO9ZHxIa020ETnZ7NHuf4nCXrlERMjaHYrgQ=; b=VZ2ddE/717/Yz3mLqQkGYYjg8NVfe6f2jpakBZqM0B6GO4VNulZM1L1HFrTJKCcN3Zh5ZG+xWeux5urBG5TFFqVKbMe8bjWw/u/gAOZ+VebIuTrN6yC5zmbjK+sRqqqwqBfKzz50vIjtTZyVTDhXEpNjVljlGy6YbjA2cgjykkJLIRR+/BLu+af1MKG1iCZa66GMX9OfnbQGuXgJdXSRrFFgGs9ARVh98ov5XTPlilaDCkpg5iUbrdv4rCGKY6Za4zQ1hbDj3m5FYYYUGxUAvWdeSynlBfiughqIyPAnzA12UQP3Y3MGutr7aXpR01adztUbt0mEwDdi+82utfgVUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W06lntdHO9ZHxIa020ETnZ7NHuf4nCXrlERMjaHYrgQ=; b=lZ7PO2sPpIJAg/zXSsOidb4GM/Vrs4tC/CoG4E1QEibnctpN2oFm7AoVOE1qvX79KONubChxn3cjoXp3p2DvFg83KhspLkekeffIJYsrZIDYO0vOSy+0pOh8a71/2dlaxPhR1CgLB+1pgfFtOFab9ixWgXQ0dKgmcRvVlXdpCwH2oYYahCbCCecEA3ClhsKLTRDEhzPaKInI17nBpONmvFJTZncIn5MQSm0VRxGn1AC+vT0M06pi6/mxWTfWKaTCe80/b+YbFUltRKne4NefljrexTZTMe02SOhAImRjU5T5GKuKOfSoKuVWj6EyVSYPTqpnOOC0f9kDap5rzA9FHA== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS8P250MB0345.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:37c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 07:24:30 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::9bda:3062:4e88:521]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::9bda:3062:4e88:521%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 07:24:30 +0000 Message-ID: Date: Mon, 24 Jul 2023 09:25:35 +0200 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: From: Andreas Rheinhardt In-Reply-To: X-TMN: [3ph0GLSZNAXpCwZbFM2mJ2IFKuNlZEq8] X-ClientProxiedBy: FR0P281CA0241.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:af::19) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <6d1069ce-459b-52e1-d990-49facb865927@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS8P250MB0345:EE_ X-MS-Office365-Filtering-Correlation-Id: 412bb7c0-cd43-40e6-c5af-08db8c170518 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4teO7q0i1HE212UL+wq5yDoitAj8hf0YkwpmF8n19bdhxqy1BqbX+0YYioyZc4cCnZpm5ptqNJIT3EzB6B0uFiqfzPvNEOesWZyzVi+UmsB+V66Vu5X1Tbjy5m486VKPpIXwRt4VoXpLDZRPGsN0Q9i8fDOcrIPaT2oKEneDAABgB4YLAN/sPtUFaD33zLRWqIo6gJapZaWKTFDNzT4HY2WeXn/5e0S2wCsMpEM6JU7QkBkZaUdfWwCfPWT2kDRqY9S5I8Ik1wApupTF7otvHR9kWfHvSYFcqxYeInXarexAYYhDzDn2KIH4xajxUGSAO4waTS6/me8YCno72v4jsmGvh2Sg4unJQPeIVXZe2Sqt23qhH7M+jlhgDACN2ZcyIccyA3zqzHsURsubuYXWTfUHiAFPTwdVUmIhPk8TKvYLa9x4Gtl9vW8+wx2n1CYBbTmaHk5k7jK7euNnkcJSkpnOwi6HdDyQag803+HNxkbvoC7qbL6z3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f-8?Q?EKHYqjcpI/jhIus/H42P?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 412bb7c0-cd43-40e6-c5af-08db8c170518 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 07:24:30.4585 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P250MB0345 Subject: Re: [FFmpeg-devel] [PATCH] add prores bitstream demuxer and muxer 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 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: hung kuishing: > --- > libavcodec/Makefile | 1 + > libavcodec/parsers.c | 1 + > libavcodec/prores_parser.c | 91 ++++++++++++++++++++++++++++++++++++++ > libavformat/Makefile | 2 + > libavformat/allformats.c | 2 + > libavformat/proresdec.c | 62 ++++++++++++++++++++++++++ > libavformat/rawenc.c | 13 ++++++ > 7 files changed, 172 insertions(+) > create mode 100644 libavcodec/prores_parser.c > create mode 100644 libavformat/proresdec.c > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 1b0226c089..b6ebbfb340 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1214,6 +1214,7 @@ OBJS-$(CONFIG_WEBP_PARSER) += webp_parser.o > OBJS-$(CONFIG_XBM_PARSER) += xbm_parser.o > OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o > OBJS-$(CONFIG_XWD_PARSER) += xwd_parser.o > +OBJS-$(CONFIG_PRORES_PARSER) += prores_parser.o > > # bitstream filters > OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o > diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c > index 285f81a901..ff7c15b7d1 100644 > --- a/libavcodec/parsers.c > +++ b/libavcodec/parsers.c > @@ -80,6 +80,7 @@ extern const AVCodecParser ff_webp_parser; > extern const AVCodecParser ff_xbm_parser; > extern const AVCodecParser ff_xma_parser; > extern const AVCodecParser ff_xwd_parser; > +extern const AVCodecParser ff_prores_parser; These lists are supposed to be sorted alphabetically. > > #include "libavcodec/parser_list.c" > > diff --git a/libavcodec/prores_parser.c b/libavcodec/prores_parser.c > new file mode 100644 > index 0000000000..4b50147768 > --- /dev/null > +++ b/libavcodec/prores_parser.c > @@ -0,0 +1,91 @@ > +/* > + * ProRes bitstream parser > + * Copyright (c) 2023 clarkh > + * > + * 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 "libavutil/intreadwrite.h" > + > +static int prores_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size) > +{ > + int pic_found = pc->frame_start_found; > + uint32_t state = pc->state; > + int cur = 0; > + > + int flag = AV_RB32("icpf"); MKBETAG; also use uint32_t for flag. > + if (!pic_found) { > + for (; cur < buf_size; cur++) { > + state = (state<<8) | buf[cur]; > + if (state == flag){ > + ++cur; > + pic_found = 1; > + break; > + } > + } > + } > + > + if (pic_found) { > + if (!buf_size) > + return END_NOT_FOUND; > + for (; cur < buf_size; ++cur) { > + state = (state << 8) | buf[cur]; > + if (state == flag) { > + pc->frame_start_found = 0; > + pc->state = -1; > + return cur - 7; > + } > + } > + } > + > + pc->frame_start_found = pic_found; > + pc->state = state; > + > + return END_NOT_FOUND; > +} > + > +static int prores_parse(AVCodecParserContext *s, AVCodecContext *avctx, > + const uint8_t **poutbuf, int *poutbuf_size, > + const uint8_t *buf, int buf_size) > +{ > + ParseContext *pc = s->priv_data; > + int next; > + > + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { > + next = buf_size; > + } else { > + next = prores_find_frame_end(pc, buf, buf_size); > + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { > + *poutbuf = NULL; > + *poutbuf_size = 0; > + return buf_size; > + } > + } > + > + *poutbuf = buf; > + *poutbuf_size = buf_size; > + > + return next; > +} > + > +const AVCodecParser ff_prores_parser = { > + .codec_ids = { AV_CODEC_ID_PRORES }, > + .priv_data_size = sizeof(ParseContext), > + .parser_parse = prores_parse, > + .parser_close = ff_parse_close > +}; > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 4cb00f8700..a7f265252d 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -639,6 +639,8 @@ OBJS-$(CONFIG_XWMA_DEMUXER) += xwma.o > OBJS-$(CONFIG_YOP_DEMUXER) += yop.o > OBJS-$(CONFIG_YUV4MPEGPIPE_DEMUXER) += yuv4mpegdec.o > OBJS-$(CONFIG_YUV4MPEGPIPE_MUXER) += yuv4mpegenc.o > +OBJS-$(CONFIG_PRORES_DEMUXER) += proresdec.o rawdec.o > +OBJS-$(CONFIG_PRORES_MUXER) += rawenc.o > > # external library muxers/demuxers > OBJS-$(CONFIG_AVISYNTH_DEMUXER) += avisynth.o > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index 6324952bd2..89533eb686 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -520,6 +520,8 @@ extern const AVInputFormat ff_xwma_demuxer; > extern const AVInputFormat ff_yop_demuxer; > extern const AVInputFormat ff_yuv4mpegpipe_demuxer; > extern const FFOutputFormat ff_yuv4mpegpipe_muxer; > +extern const AVInputFormat ff_prores_demuxer; > +extern const FFOutputFormat ff_prores_muxer; > /* image demuxers */ > extern const AVInputFormat ff_image_bmp_pipe_demuxer; > extern const AVInputFormat ff_image_cri_pipe_demuxer; > diff --git a/libavformat/proresdec.c b/libavformat/proresdec.c > new file mode 100644 > index 0000000000..11541f8cd3 > --- /dev/null > +++ b/libavformat/proresdec.c > @@ -0,0 +1,62 @@ > +/* > + * ProRes bitstream demuxer > + * Copyright (c) 2023 clarkh > + * > + * 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 "libavutil/intreadwrite.h" > +#include "avformat.h" > +#include "rawdec.h" > + > +static int prores_check_frame_header(const uint8_t *buf, const int data_size) > +{ > + int hdr_size, width, height; > + int version, alpha_info; > + > + hdr_size = AV_RB16(buf); > + if (hdr_size < 20) > + return AVERROR_INVALIDDATA; > + > + version = buf[3]; > + if (version > 1) > + return AVERROR_INVALIDDATA; > + > + width = AV_RB16(buf + 8); > + height = AV_RB16(buf + 10); > + if (!width || !height) > + return AVERROR_INVALIDDATA; > + > + alpha_info = buf[17] & 0x0f; > + if (alpha_info > 2) > + return AVERROR_INVALIDDATA; > + > + return 0; > +} > + > +static int prores_probe(const AVProbeData *p) > +{ > + if (p->buf_size < 28 || AV_RL32(p->buf + 4) != AV_RL32("icpf")) There is no need to use little-endian here (it is unnatural for a big-endian format anyway). You can e.g. use AV_RN32 for both. > + return 0; > + > + if (prores_check_frame_header(p->buf + 8, p->buf_size - 8) < 0) > + return 0; > + > + return AVPROBE_SCORE_MAX; > +} > + > +FF_DEF_RAWVIDEO_DEMUXER(prores, "raw ProRes", prores_probe, NULL, AV_CODEC_ID_PRORES) IIRC ProRes's subblocks have an ISOBMFF-style length-field prefixed to the block, yet you do not use this and simply return a small amount of data (RAW_PACKET_SIZE (=1024B) by default) in each packet. This doesn't seem reasonable. The parser, too, just ignores this and simply searches for the sync code. In this case, I am actually wondering whether this is correct at all: Is it guaranteed that "icpf" can't appear inside one of these subblocks, causing misparsing with your proposed parser? If it is length-prefixed, there is no need for escaping the startcode. > diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c > index f916db13a2..db7d88e782 100644 > --- a/libavformat/rawenc.c > +++ b/libavformat/rawenc.c > @@ -588,3 +588,16 @@ const FFOutputFormat ff_vc1_muxer = { > .p.flags = AVFMT_NOTIMESTAMPS, > }; > #endif > + > +#if CONFIG_PRORES_MUXER > +const FFOutputFormat ff_prores_muxer = { > + .p.name = "prores", > + .p.long_name = NULL_IF_CONFIG_SMALL("raw prores video"), > + .p.extensions = "prores", > + .p.audio_codec = AV_CODEC_ID_NONE, > + .p.video_codec = AV_CODEC_ID_PRORES, > + .init = force_one_stream, > + .write_packet = ff_raw_write_packet, > + .p.flags = AVFMT_NOTIMESTAMPS, > +}; > +#endif _______________________________________________ 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".