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 0C35248CA1 for ; Wed, 24 Jan 2024 08:21:26 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EEE8068D1F2; Wed, 24 Jan 2024 10:17:57 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7946768D114 for ; Wed, 24 Jan 2024 10:17:26 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=iFf5kViH; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id EECC519B9 for ; Wed, 24 Jan 2024 09:17:21 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id zMKl6gzwIq5G for ; Wed, 24 Jan 2024 09:17:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1706084239; bh=0LJfUVsulQgUx/yPqX9Vrbdfru2TRMBUxf6Dn/2Fzu4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iFf5kViHUS/Y2BmzOVKSMDqgtAU2wTWb4qU/aEvTF1wOxXJGWMXRRgOnvCchhwlh0 anonspPD5uVDdDfYdGAuVNymjd3NxOlpW9vi48UHoAB29kZnS6IfOBmsSd6PTl2qI1 4EdnG+/RymmhZUkWhUZ/ZDhd9QiHgLDttX8A7PR+pFAQuaV8N4jRcz6T39PtDoyQp1 BoLgssmzG/xg1xLM76Xu2pR0WlokglRFb0z6BSKqj7aZhLAuDw7+LlueXxfI3/4kdY 5HpV9PH9oojXr+5ahQxNL5e9pn7tS8fkOX0jE3cQpZYhaY+x/er1A12aR2T2EeET0C kiXs4tRKfK3Zg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 8F15A19D4 for ; Wed, 24 Jan 2024 09:17:19 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5F4203A07AE for ; Wed, 24 Jan 2024 09:17:19 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Jan 2024 09:16:36 +0100 Message-ID: <20240124081702.4759-6-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240124081702.4759-1-anton@khirnov.net> References: <20240124081702.4759-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/31] fftools/ffmpeg_dec: pass decoder options as an argument to dec_open() 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: Rather than access the dictionary in InputStream. This is a step towards decoupling Decoder and InputStream. --- fftools/ffmpeg.h | 7 ++++++- fftools/ffmpeg_dec.c | 17 +++++++++-------- fftools/ffmpeg_demux.c | 3 ++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 9e29ae1785..227929b022 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -731,7 +731,12 @@ AVBufferRef *hw_device_for_filter(void); int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input); -int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx); +/** + * @param dec_opts Dictionary filled with decoder options. Its ownership + * is transferred to the decoder. + */ +int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx, + AVDictionary **dec_opts); void dec_free(Decoder **pdec); int dec_add_filter(Decoder *dec, InputFilter *ifilter); diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 6dca730e51..15d49d0d69 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -918,7 +918,8 @@ static const AVClass dec_class = { .item_name = dec_item_name, }; -int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx) +int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx, + AVDictionary **dec_opts) { DecoderPriv *dp; const AVCodec *codec = ist->dec; @@ -970,7 +971,7 @@ int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx) if (dp->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE && (ist->decoding_needed & DECODING_FOR_OST)) { - av_dict_set(&ist->decoder_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE); + av_dict_set(dec_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE); if (ist->decoding_needed & DECODING_FOR_FILTER) av_log(dp, AV_LOG_WARNING, "Warning using DVB subtitles for filtering and output at the " @@ -981,13 +982,13 @@ int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx) * audio, and video decoders such as cuvid or mediacodec */ dp->dec_ctx->pkt_timebase = ist->st->time_base; - if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0)) - av_dict_set(&ist->decoder_opts, "threads", "auto", 0); + if (!av_dict_get(*dec_opts, "threads", NULL, 0)) + av_dict_set(dec_opts, "threads", "auto", 0); /* Attached pics are sparse, therefore we would not want to delay their decoding till EOF. */ if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC) - av_dict_set(&ist->decoder_opts, "threads", "1", 0); + av_dict_set(dec_opts, "threads", "1", 0); - av_dict_set(&ist->decoder_opts, "flags", "+copy_opaque", AV_DICT_MULTIKEY); + av_dict_set(dec_opts, "flags", "+copy_opaque", AV_DICT_MULTIKEY); ret = hw_device_setup_for_decode(ist, dp); if (ret < 0) { @@ -997,13 +998,13 @@ int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx) return ret; } - if ((ret = avcodec_open2(dp->dec_ctx, codec, &ist->decoder_opts)) < 0) { + if ((ret = avcodec_open2(dp->dec_ctx, codec, dec_opts)) < 0) { av_log(dp, AV_LOG_ERROR, "Error while opening decoder: %s\n", av_err2str(ret)); return ret; } - ret = check_avoptions(ist->decoder_opts); + ret = check_avoptions(*dec_opts); if (ret < 0) return ret; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 8e904d2150..b2cbde2aa5 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -895,7 +895,8 @@ static int ist_use(InputStream *ist, int decoding_needed) if (ret < 0) return ret; - ret = dec_open(ist, d->sch, ds->sch_idx_dec); + ret = dec_open(ist, d->sch, ds->sch_idx_dec, + &ist->decoder_opts); if (ret < 0) return ret; -- 2.42.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".