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 A09194623B for ; Wed, 10 May 2023 11:52:30 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4DD6168C0FE; Wed, 10 May 2023 14:52:27 +0300 (EEST) Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E2C7A68BFDF for ; Wed, 10 May 2023 14:52:20 +0300 (EEST) Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-192814aa343so5657484fac.1 for ; Wed, 10 May 2023 04:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683719539; x=1686311539; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=DcmQzuLin5f5xvY18gSzyB0k1IHNWue9hrli7WPvAIY=; b=J/CtxxEijA5mOs55izUNgXVpDhumd2uiXNpjqfvo7mjl93CNNjbizvS8sgAViHJNpf 3T9YpyeoO0hVa/nE7WJSwV1UY2G+VABivTjcHod9GI0tEAOIIReFOg2HQstwIEJGNWSA +85eNh8O8C5pD1dJNVCht9tkgCYK8sxlLMZhQ1OqGkHRNOcAxSQiueRiuYU5Few+WYcc Ux8W+Tb8uSLdYEhZoLpGdV3XpkkrGOoHkRFmg1oxkzyKj5TPca8MDKOrslZ25Wsflgp1 dJzpleGMQEFC9ctqaRR7N15mo9KcSx4j3uLeJUA1cdo+qoCUaQLhNegUo1b5bXVXaX0A +tsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683719539; x=1686311539; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DcmQzuLin5f5xvY18gSzyB0k1IHNWue9hrli7WPvAIY=; b=flrFAVQM6o9FCPmqWUAsgK+BV3rDHg1MabJZIxcQhFOeglYHOGuka0JRr/8YtVruIS 6N3KEiWy54/WZSLYhuzMdAgqAmqAK7u0Thu8oU6kdJzUeD2jnNIcUZ7iFwKg47BrAgsK D6oQM8PPET0sPfMUigbZtzG4u1Lk32P+h4PYYViOFnVMEB8+dQdawYBOOELrWXXnU2pF pgHPAY4L+eMkdLOv2LyAUW2l48xnzqPywuq9SJtOl7HlEXxzE6u+SpKB+v/EeX1nuKwK O84R8q1gZ3UN/7bX5ZfZcWwnABB6rdBtJl4FXoDTTHpxsl4+RjHvrPJZi4rTKaPrJZHR 1PDA== X-Gm-Message-State: AC+VfDxwBW2yQQFIdIEKkAu4z6pscqqSoIQ5hMhy9C45zMwFG/fVA/on MUJnVuq5q/1QFCAAh//WzhGtp/6VuX8= X-Google-Smtp-Source: ACHHUZ70yrnS80Pzb4byvpeS+M0AgpNCwAN3yEA37G2ZOB3dJDFUXuVybqhqmJkBzXkPsBJc3BMcsg== X-Received: by 2002:a05:6870:5b13:b0:196:43e8:3023 with SMTP id ds19-20020a0568705b1300b0019643e83023mr2016120oab.52.1683719538726; Wed, 10 May 2023 04:52:18 -0700 (PDT) Received: from [192.168.0.12] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id a19-20020a056870e35300b0018456166c7asm6933384oae.39.2023.05.10.04.52.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 May 2023 04:52:18 -0700 (PDT) Message-ID: Date: Wed, 10 May 2023 08:52:34 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 To: ffmpeg-devel@ffmpeg.org References: <20230507133255.20881-1-anton@khirnov.net> <20230507133255.20881-5-anton@khirnov.net> Content-Language: en-US From: James Almer In-Reply-To: <20230507133255.20881-5-anton@khirnov.net> Subject: Re: [FFmpeg-devel] [PATCH 05/13] lavc/av1*: fix exporting framerate 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 5/7/2023 10:32 AM, Anton Khirnov wrote: > * take num_ticks_per_picture_minus_1 into account, since that is a part > of the framerate computation > * stop exporting num_ticks_per_picture_minus_1 into > AVCodecContext.ticks_per_frame, as that field is used for other > purposes (in conjunction with repeat_pict, which is not used at all by > av1) > --- > libavcodec/Makefile | 2 +- > libavcodec/av1_parse.c | 15 +++++++++++++++ > libavcodec/av1_parse.h | 4 ++++ > libavcodec/av1_parser.c | 9 ++++----- > libavcodec/av1dec.c | 12 +++--------- > 5 files changed, 27 insertions(+), 15 deletions(-) > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index b0971ce833..8162bcf4fa 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1143,7 +1143,7 @@ OBJS-$(CONFIG_AC3_PARSER) += aac_ac3_parser.o ac3tab.o \ > ac3_channel_layout_tab.o > OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o > OBJS-$(CONFIG_AMR_PARSER) += amr_parser.o > -OBJS-$(CONFIG_AV1_PARSER) += av1_parser.o > +OBJS-$(CONFIG_AV1_PARSER) += av1_parser.o av1_parse.o > OBJS-$(CONFIG_AVS2_PARSER) += avs2.o avs2_parser.o > OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o > OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o > diff --git a/libavcodec/av1_parse.c b/libavcodec/av1_parse.c > index 59ea0bc6e7..cf325e09b9 100644 > --- a/libavcodec/av1_parse.c > +++ b/libavcodec/av1_parse.c > @@ -24,6 +24,7 @@ > > #include "av1.h" > #include "av1_parse.h" > +#include "cbs_av1.h" > #include "bytestream.h" > > int ff_av1_extract_obu(AV1OBU *obu, const uint8_t *buf, int length, void *logctx) > @@ -108,3 +109,17 @@ void ff_av1_packet_uninit(AV1Packet *pkt) > av_freep(&pkt->obus); > pkt->obus_allocated = pkt->obus_allocated_size = 0; > } > + > +AVRational ff_av1_framerate(const AV1RawTimingInfo *ti) Could i ask you to instead pass num_units_in_display_tick, time_scale and num_ticks_per_picture as arguments to this function, instead of including cbs_av1 in av1_parse? I devised that module as a lightweight and reduced alternative to the full bitstream parser that's CBS, used by the extract_extradata bsf and even included by the av1 demuxer (for the couple inlined functions in the header). It should also let you reuse it in libdav1d.c, afaict. > +{ > + const int ticks = ti->num_ticks_per_picture_minus_1 + 1; > + AVRational fr = (AVRational){ 0, 1 }; > + > + if (ti->num_units_in_display_tick && ti->time_scale && > + ticks < INT_MAX / ti->num_units_in_display_tick) { > + av_reduce(&fr.den, &fr.num, ti->num_units_in_display_tick * ticks, > + ti->time_scale, INT_MAX); > + } > + > + return fr; > +} > diff --git a/libavcodec/av1_parse.h b/libavcodec/av1_parse.h > index f4a5d2830e..60a6fd0ba2 100644 > --- a/libavcodec/av1_parse.h > +++ b/libavcodec/av1_parse.h > @@ -181,4 +181,8 @@ static inline int get_obu_bit_length(const uint8_t *buf, int size, int type) > return size; > } > > +struct AV1RawTimingInfo; > + > +AVRational ff_av1_framerate(const struct AV1RawTimingInfo *ti); > + > #endif /* AVCODEC_AV1_PARSE_H */ > diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c > index 14dae92fe9..978bbebe30 100644 > --- a/libavcodec/av1_parser.c > +++ b/libavcodec/av1_parser.c > @@ -21,6 +21,8 @@ > */ > > #include "libavutil/avassert.h" > + > +#include "av1_parse.h" > #include "cbs.h" > #include "cbs_av1.h" > #include "parser.h" > @@ -162,11 +164,8 @@ static int av1_parser_parse(AVCodecParserContext *ctx, > avctx->color_trc = (enum AVColorTransferCharacteristic) color->transfer_characteristics; > avctx->color_range = color->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; > > - if (seq->timing_info_present_flag) { > - const AV1RawTimingInfo *timing = &seq->timing_info; > - av_reduce(&avctx->framerate.den, &avctx->framerate.num, > - timing->num_units_in_display_tick, timing->time_scale, INT_MAX); > - } > + if (seq->timing_info_present_flag) > + avctx->framerate = ff_av1_framerate(&seq->timing_info); > > end: > ff_cbs_fragment_reset(td); > diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c > index c90c9c1a69..693673b436 100644 > --- a/libavcodec/av1dec.c > +++ b/libavcodec/av1dec.c > @@ -26,6 +26,7 @@ > #include "libavutil/pixdesc.h" > #include "libavutil/opt.h" > #include "avcodec.h" > +#include "av1_parse.h" > #include "av1dec.h" > #include "atsc_a53.h" > #include "bytestream.h" > @@ -709,15 +710,8 @@ static int set_context_with_sequence(AVCodecContext *avctx, > } > avctx->sample_aspect_ratio = (AVRational) { 1, 1 }; > > - if (seq->timing_info.num_units_in_display_tick && > - seq->timing_info.time_scale) { > - av_reduce(&avctx->framerate.den, &avctx->framerate.num, > - seq->timing_info.num_units_in_display_tick, > - seq->timing_info.time_scale, > - INT_MAX); > - if (seq->timing_info.equal_picture_interval) > - avctx->ticks_per_frame = seq->timing_info.num_ticks_per_picture_minus_1 + 1; > - } > + if (seq->timing_info_present_flag) > + avctx->framerate = ff_av1_framerate(&seq->timing_info); > > return 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".