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 1FAAA44A08 for ; Mon, 31 Oct 2022 20:02:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9ACD568BE0E; Mon, 31 Oct 2022 22:02:14 +0200 (EET) Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D746068BC30 for ; Mon, 31 Oct 2022 22:02:07 +0200 (EET) Received: by mail-oo1-f50.google.com with SMTP id v8-20020a4ab688000000b00486ac81143fso1788742ooo.1 for ; Mon, 31 Oct 2022 13:02:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QC9GWa4aI/nocbY3saxBoCW2RiZpg6lJOPeKQqvaf7s=; b=Hqj4lXJm0yuXoEuCdLdsoefksMKxDcFFNirbLaMAJbTkZBubav7GkHC/TWMY4cvje5 2QtCKfdmh9aRPuHhR/ONyVQE8V0uR60u87/7tzkuAvWmVSPQnY8mDrJD1hZ0suYl3WOs GQWBngieu+QHVrXuznBoCJ+KObtv0KD9TfcjE2amH+LSSiZqV9ZLEWA9GuO1CHUKvhVH /qWOsEC2jK/VN51yGTn4pIWW/TG73qHrRl3YjUOIggDjT/2P/P/UY7MdT4uF9wJJ0ds9 Lyu/0652gakQsoPO5FOP0Pr4lOFw+IGranZuDb663ANDvAORMLPXwsu8ZKUI/sw1SjQ/ IuaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QC9GWa4aI/nocbY3saxBoCW2RiZpg6lJOPeKQqvaf7s=; b=bjJbk/XJI5wDSOmQ8MJfPVw4ivRZSMD6u69p7nnxCzMEUBaUTaJ7e0fUB1zxvUWZJH bd9UXisaXOKxOTKyt0TZE7fpYIaClk+EFAGQUcnXULocYVdFxQVRGTgoStxxr0clruA/ LVEF6lcQ3KO0fPKXvQE5RFTNw/whlHP3Ui8MmynqNg1J9rWTp++xuiQEASAvh5QVr++V jJC8GTJfTaXM0r8WKl3rXZ4gWBPxj6TeXvT0nM2JUhtgPGjHDPH+6MVRtADIF/9Es7fF 51jB+9OAdPKVLj8IHBC4KN5BGVyzS4/YerE5G95UVdODvIXgBzz1CifLs9uAkiPvB/eK 8W2g== X-Gm-Message-State: ACrzQf3FrzDfuv104bs04QInbE/2wnyCPbz+D/SNWO69Vq0DCRlHaD2V /q6Bjob+/4ChYSGXfnPbeG2lRW1xJ8Y= X-Google-Smtp-Source: AMsMyM7DDbT8+TgLGcivXDNudA6SMTlMIXJMNsJX3draDJ5uN2RtXCkgv1WUzjGMgDnQhrMgsm5ItQ== X-Received: by 2002:a05:6820:1746:b0:47f:926a:286d with SMTP id bf6-20020a056820174600b0047f926a286dmr6118676oob.5.1667246525563; Mon, 31 Oct 2022 13:02:05 -0700 (PDT) Received: from [192.168.0.13] ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id d94-20020a9d2967000000b0066b9a6bf3bcsm3109261otb.12.2022.10.31.13.02.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Oct 2022 13:02:05 -0700 (PDT) Message-ID: <64f60f1c-dfb5-8ab4-a1ed-9a3dda3a5780@gmail.com> Date: Mon, 31 Oct 2022 17:02:05 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20221024140645.4945-1-thomas.ff@spin-digital.com> <20221024140645.4945-4-thomas.ff@spin-digital.com> <621697ae-1c24-811d-c2e9-6c044699f37f@gmail.com> From: James Almer In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH v2 03/10] avcodec: add bitstream parser for H266/VVC 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 10/31/2022 7:16 AM, Thomas Siedel wrote: > On Mon, 24 Oct 2022 at 16:38, James Almer wrote: > >> On 10/24/2022 11:06 AM, Thomas Siedel wrote: >>> +static int combine_au(AVCodecParserContext *ctx, AVCodecContext *avctx, >>> + const uint8_t **buf, int *buf_size) >>> +{ >> >> This is being called only when you first assembled AUs from what's >> assumed to be raw input. When PARSER_FLAG_COMPLETE_FRAMES is set, it >> should also parse the AU for bitstream information. >> > > Yes, currently, "combine_au" is only called when > PARSER_FLAG_COMPLETE_FRAMES is disabled, but I do not really understand > what the issue is here. I'm not talking about combine_au() but parse_nal_units(), which is only called from within combine_au(). My comment was about bitstream parsing, not AU assembling. Apologies if it wasn't clear. > As far as I know, all bitstream information is parsed properly for any kind > of supported content (currently, ES, MP4, and TS are supported). > Would you happen to have an example of a use case where > PARSER_FLAG_COMPLETE_FRAMES is enabled, and the bitstream information is > needed or not parsed correctly from the current implementation? libavformat and its demuxers are not the only user of AVCodecParsers. > > The current behavior is pretty similar to other codec > parser implementations like hevc, avc, and av1. Why should the vvc parser > code differ from the (default) behavior of other codecs? Both h264 and hevc parsers call parse_nal_units() regardless of PARSER_FLAG_COMPLETE_FRAMES being set or not. AVCodecParsers have two purposes. One is assembling a full packet for a given timestamp (access unit for these codecs, temporal unit for av1, the like) depending on the value of AVCodecParserContext.flags, and the other is parsing the full packet for bitstream information. If a parser does the latter, it should do it regardless of having assembled a packet before that or not. The parser doesn't know where the packet came from. It could have been a lavf demuxer, or it could have been from some other lavc user, because this API after all is from lavc and not lavf. So it must always fill the AVCodecParserContext struct with the parsed information if it's present and readable. If i set the PARSER_FLAG_COMPLETE_FRAMES flag, this parser as you wrote it is a no-op. > > >>> + VVCParserContext *s = ctx->priv_data; >>> + CodedBitstreamFragment *pu = &s->picture_unit; >>> + int ret; >>> + >>> + s->cbc->log_ctx = avctx; >>> + >>> + if (avctx->extradata_size && !s->parsed_extradata) { >>> + s->parsed_extradata = 1; >>> + >>> + if ((ret = ff_cbs_read(s->cbc, pu, avctx->extradata, >> avctx->extradata_size)) < 0) >> >> ff_cbs_read_extradata_from_codec() >> >>> + av_log(avctx, AV_LOG_WARNING, "Failed to parse >> extradata.\n"); >>> + >>> + ff_cbs_fragment_reset(pu); >>> + } >>> + av_packet_unref(&s->last_au); >>> + ret = parse_nal_units(ctx, *buf, *buf_size, avctx); >>> + if (ret == 0) { >>> + if (s->last_au.size) { >>> + *buf = s->last_au.data; >>> + *buf_size = s->last_au.size; >>> + } else { >>> + //no output >>> + ret = 1; >>> + } >>> + } >>> + s->cbc->log_ctx = NULL; >>> + return ret; >>> +} >>> + >>> +static int vvc_parser_parse(AVCodecParserContext *ctx, AVCodecContext >> *avctx, >>> + const uint8_t **poutbuf, int *poutbuf_size, >>> + const uint8_t *buf, int buf_size) >>> +{ >>> + int next; >>> + VVCParserContext *s = ctx->priv_data; >>> + ParseContext *pc = &s->pc; >>> + >>> + if (avctx->extradata && !s->parsed_extradata) { >>> + av_log(avctx, AV_LOG_INFO, "extra data is not supported >> yet.\n"); >>> + return AVERROR_PATCHWELCOME; >>> + } >>> + >>> + if (ctx->flags & PARSER_FLAG_COMPLETE_FRAMES) { >>> + next = buf_size; >>> + } else { >>> + int ret, flush = !buf_size; >>> + next = find_frame_end(ctx, buf, buf_size); >>> + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) >>> + goto no_out; >>> + ret = combine_au(ctx, avctx, &buf, &buf_size); >>> + if (ret > 0 && flush) { >>> + buf_size = 0; >>> + ret = combine_au(ctx, avctx, &buf, &buf_size); >>> + } >>> + if (ret != 0) { >>> + buf_size = next; >>> + goto no_out; >>> + } >>> + } >>> + *poutbuf = buf; >>> + *poutbuf_size = buf_size; >>> + return next; >>> +no_out: >>> + *poutbuf = NULL; >>> + *poutbuf_size = 0; >>> + return buf_size; >>> +} >> _______________________________________________ >> 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". >> > _______________________________________________ > 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". _______________________________________________ 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".