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 827204851D for ; Sat, 6 Jan 2024 11:31:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 300F368CCB5; Sat, 6 Jan 2024 13:31:56 +0200 (EET) Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EFE9F68C7A7 for ; Sat, 6 Jan 2024 13:31:49 +0200 (EET) Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a28a6cef709so33413966b.1 for ; Sat, 06 Jan 2024 03:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704540708; x=1705145508; darn=ffmpeg.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=erPSwDCzEENjCVI+mq703DZFh37SW1lU/xD8c1XE5Bo=; b=budnGMzZYfeMrW5/pnxPKSUsSGeKa0hRK4VX5L3OGRUpJu5L7hY6sUMYEuqObqreUu eqf01DaE5ZpvlkKFApmvsP9AL7NOPx8YUW5lnE7Dk1BuCXvfdVn322LjRFDzSjfHj8Lu BYiCS0CXf1Rga2zW//TYIlfFMSPb2QwnhuIGlYIpsIHIQNVloPXJUAEu3Six75tMKivD beiaVVH5vhw/4lWKX8c4phzgXcjn7LdGIvEO636bLIOJBj3+ZesFx/++v9eLamJ27ffn I2T/NvC+PGO9pctcYkH0iTLOxbllzlZnbUqv+HdB8+3MHmFEPo+cGTm+6y89jZlcyHO8 cpYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704540708; x=1705145508; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=erPSwDCzEENjCVI+mq703DZFh37SW1lU/xD8c1XE5Bo=; b=COjKbyKcpwfZiz/rOgyCLNdZd/cKPSF3iyS/XIqMbdE36BwqJZTM+xx6HsOvZuOHFn BJ45YrfHqBAUzNODa2m9TBi8gSrxGB0vjqXUXm6tXD46EsblDcN28n28V66eq2cCo5kk VXzXFZOQf9TRwJWxti/lVVWyf9AtOU4d/4vVwORo02gzal1gTq7LJWYZEzbZ9UKyy3Zm 4DiwveJ6SsaJG/CVruyUycK/0GWz7uBIqqNLN7fkVZf7mJjvvhRK76cMd6fmpmd4sffk 5ZogXwc5J+QVUWcWTJqGjuefwvR9UygHmSmnoNpPeu7oRRHoGdRssRk3T9GpshqAedvf rW3w== X-Gm-Message-State: AOJu0YyP8ve6fvpSxr8NGJsmL1uOEKH8w0isxHXlCPId0oQ6RwfnGYx7 et/RDLAkgSWZwCp4IxTOKWRom4zvuzM= X-Google-Smtp-Source: AGHT+IGecd8ydnhH1VxVVT6Es04n5YNEpldP0Lx/Jb3GfA9tAL4vLcTcVfbX6eGg8LY4p3TJ1Jf5Cg== X-Received: by 2002:a17:906:1159:b0:a28:e7f2:43bb with SMTP id i25-20020a170906115900b00a28e7f243bbmr294896eja.53.1704540707722; Sat, 06 Jan 2024 03:31:47 -0800 (PST) Received: from mariano (dynamic-adsl-84-220-189-10.clienti.tiscali.it. [84.220.189.10]) by smtp.gmail.com with ESMTPSA id z23-20020a1709060f1700b00a26f1e3093asm1868727eji.49.2024.01.06.03.31.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 03:31:47 -0800 (PST) Received: by mariano (Postfix, from userid 1000) id 5424CBFCDC; Sat, 6 Jan 2024 12:31:46 +0100 (CET) Date: Sat, 6 Jan 2024 12:31:46 +0100 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches References: <20240105164251.28935-1-anton@khirnov.net> <20240105164251.28935-4-anton@khirnov.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240105164251.28935-4-anton@khirnov.net> User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [FFmpeg-devel] [PATCH 4/8] fftools/ffmpeg_demux: set options on codec parameters rather than decoder 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: On date Friday 2024-01-05 17:42:47 +0100, Anton Khirnov wrote: > This avoids the requirement to always have a decoder context. > --- > fftools/ffmpeg_demux.c | 43 +++++++++++++++++++++--------------------- > 1 file changed, 21 insertions(+), 22 deletions(-) > > diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c > index cacdc76a71..892094c512 100644 > --- a/fftools/ffmpeg_demux.c > +++ b/fftools/ffmpeg_demux.c > @@ -899,19 +899,18 @@ static int choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream > } > } > > -static int guess_input_channel_layout(InputStream *ist, int guess_layout_max) > +static int guess_input_channel_layout(InputStream *ist, AVCodecParameters *par, > + int guess_layout_max) > { > - AVCodecContext *dec = ist->dec_ctx; > - > - if (dec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) { > + if (par->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) { > char layout_name[256]; > > - if (dec->ch_layout.nb_channels > guess_layout_max) > + if (par->ch_layout.nb_channels > guess_layout_max) > return 0; > - av_channel_layout_default(&dec->ch_layout, dec->ch_layout.nb_channels); > - if (dec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) > + av_channel_layout_default(&par->ch_layout, par->ch_layout.nb_channels); > + if (par->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) > return 0; > - av_channel_layout_describe(&dec->ch_layout, layout_name, sizeof(layout_name)); > + av_channel_layout_describe(&par->ch_layout, layout_name, sizeof(layout_name)); > av_log(ist, AV_LOG_WARNING, "Guessed Channel Layout: %s\n", layout_name); > } > return 1; > @@ -1145,16 +1144,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) > ist->user_set_discard = ist->st->discard; > } > > - ist->dec_ctx = avcodec_alloc_context3(ist->dec); > - if (!ist->dec_ctx) > - return AVERROR(ENOMEM); > - > - ret = avcodec_parameters_to_context(ist->dec_ctx, par); > - if (ret < 0) { > - av_log(ist, AV_LOG_ERROR, "Error initializing the decoder context.\n"); > - return ret; > - } > - > if (o->bitexact) > av_dict_set(&ist->decoder_opts, "flags", "+bitexact", AV_DICT_MULTIKEY); > > @@ -1181,7 +1170,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) > case AVMEDIA_TYPE_AUDIO: { > int guess_layout_max = INT_MAX; > MATCH_PER_STREAM_OPT(guess_layout_max, i, guess_layout_max, ic, st); > - guess_input_channel_layout(ist, guess_layout_max); > + guess_input_channel_layout(ist, par, guess_layout_max); > break; > } > case AVMEDIA_TYPE_DATA: > @@ -1190,7 +1179,7 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) > MATCH_PER_STREAM_OPT(fix_sub_duration, i, ist->fix_sub_duration, ic, st); > MATCH_PER_STREAM_OPT(canvas_sizes, str, canvas_size, ic, st); > if (canvas_size) { > - ret = av_parse_video_size(&ist->dec_ctx->width, &ist->dec_ctx->height, > + ret = av_parse_video_size(&par->width, &par->height, > canvas_size); > if (ret < 0) { > av_log(ist, AV_LOG_FATAL, "Invalid canvas size: %s.\n", canvas_size); > @@ -1201,8 +1190,8 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) > /* Compute the size of the canvas for the subtitles stream. > If the subtitles codecpar has set a size, use it. Otherwise use the > maximum dimensions of the video streams in the same file. */ > - ist->sub2video.w = ist->dec_ctx->width; > - ist->sub2video.h = ist->dec_ctx->height; > + ist->sub2video.w = par->width; > + ist->sub2video.h = par->height; > if (!(ist->sub2video.w && ist->sub2video.h)) { > for (int j = 0; j < ic->nb_streams; j++) { > AVCodecParameters *par1 = ic->streams[j]->codecpar; > @@ -1226,6 +1215,16 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) > default: av_assert0(0); > } > > + ist->dec_ctx = avcodec_alloc_context3(ist->dec); > + if (!ist->dec_ctx) > + return AVERROR(ENOMEM); > + > + ret = avcodec_parameters_to_context(ist->dec_ctx, par); > + if (ret < 0) { > + av_log(ist, AV_LOG_ERROR, "Error initializing the decoder context.\n"); > + return ret; > + } > + LGTM. _______________________________________________ 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".