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 4D66A4898D for ; Fri, 22 Mar 2024 20:29:13 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E21EA68D541; Fri, 22 Mar 2024 22:29:02 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4847568D3F1 for ; Fri, 22 Mar 2024 22:28:56 +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=ovVtMkH3; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 4784A4D66 for ; Fri, 22 Mar 2024 21:28:55 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 0GIoyABnnfw1 for ; Fri, 22 Mar 2024 21:28:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1711139334; bh=xVgDMwcys9ZONkICqIM8eOcRnR8zJGmEF0g6cbQTg6o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ovVtMkH3QlZ0VZhKozZNYlvkfQMZlwAnUpIrHrHb1Zq/Vs7BAWB4FQ8Jiq5SYYCVl ezhfaTODRgATrP2cAv3jRmRlElGy5j1q/+vNUngzlxLgIg3es0KFKu8C6FoQYlB+pR brJ9Gq/t83Io58SU/Mn2MeW97l3J9W2KVNelWlV3nuFlHsH5pVrfJlUQQhTO720FBB OXUooI15TxW0WBlkpoABq3SUNGADhuFxLl8Kh7z1SCkAbnqrf0sjj2mib4UMWOk9gI RSoPi5jiKnI5PdUq8CU67joDbaQp67puZRndL13OEsLEi6TW14UjJcnDK9FnQQsOQf x+Sg/zC7ZNMvg== 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 126CA4496 for ; Fri, 22 Mar 2024 21:28:54 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 4C6AA3A0A6B for ; Fri, 22 Mar 2024 21:28:45 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Mar 2024 21:28:33 +0100 Message-ID: <20240322202841.31730-4-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322202841.31730-1-anton@khirnov.net> References: <20240322202841.31730-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/12] fftools/ffmpeg_dec: apply decoder options manually 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: Do not pass an options dictionary to avcodec_open2(). This should be equivalent to current behaviour, but will allow overriding caller-supplied options in a cleaner and more robust manner. We can now set the COPY_OPAQUE flag directly rather going through dec_opts. --- fftools/ffmpeg_dec.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index ed411b6bf8..ad02a64b60 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -21,6 +21,7 @@ #include "libavutil/dict.h" #include "libavutil/error.h" #include "libavutil/log.h" +#include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/pixfmt.h" #include "libavutil/time.h" @@ -1191,8 +1192,6 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts, if (!av_dict_get(*dec_opts, "threads", NULL, 0)) av_dict_set(dec_opts, "threads", "auto", 0); - av_dict_set(dec_opts, "flags", "+copy_opaque", AV_DICT_MULTIKEY); - ret = hw_device_setup_for_decode(dp, codec, o->hwaccel_device); if (ret < 0) { av_log(dp, AV_LOG_ERROR, @@ -1201,7 +1200,19 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts, return ret; } - if ((ret = avcodec_open2(dp->dec_ctx, codec, dec_opts)) < 0) { + ret = av_opt_set_dict2(dp->dec_ctx, dec_opts, AV_OPT_SEARCH_CHILDREN); + if (ret < 0) { + av_log(dp, AV_LOG_ERROR, "Error applying decoder options: %s\n", + av_err2str(ret)); + return ret; + } + ret = check_avoptions(*dec_opts); + if (ret < 0) + return ret; + + dp->dec_ctx->flags |= AV_CODEC_FLAG_COPY_OPAQUE; + + if ((ret = avcodec_open2(dp->dec_ctx, codec, NULL)) < 0) { av_log(dp, AV_LOG_ERROR, "Error while opening decoder: %s\n", av_err2str(ret)); return ret; @@ -1220,10 +1231,6 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts, dp->dec_ctx->extra_hw_frames = extra_frames; } - ret = check_avoptions(*dec_opts); - if (ret < 0) - return ret; - dp->dec.subtitle_header = dp->dec_ctx->subtitle_header; dp->dec.subtitle_header_size = dp->dec_ctx->subtitle_header_size; -- 2.43.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".