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 D6CA5459EA for ; Tue, 28 Feb 2023 22:29:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 67D6068AFCE; Wed, 1 Mar 2023 00:29:06 +0200 (EET) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D41D868AFAC for ; Wed, 1 Mar 2023 00:28:59 +0200 (EET) Received: by mail-wm1-f46.google.com with SMTP id o38-20020a05600c512600b003e8320d1c11so320060wms.1 for ; Tue, 28 Feb 2023 14:28:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uUBQYGiWCht6EqB/AMt6zVE9y/fN9/YpXGe8uU7lMTQ=; b=Uyv3lphN9WMEazJ5xfivtTu7wK4JsrQKi1O2dD99uN4tydv2kPmt8iwliFJ2eFiciE MKjpbBmK6oBGS2pdMPtic+9gopT9RNifz7q8HagrfcK1CmprRKk8j2vM84+bGnSW4mMI DZB/AXslbXZEiknPK1MX/rScrxFOzx/q4JB35TEE+8sc7ZZwtX9DptOA52Ysbg7FgIbj /EuZFcn8X8iUSi20hFy8C3xHV/sni+3zuyNN2BQQ/S4WUtN+PBm4TatzlbC0Er0OVQnZ eNRdvwdR69VWyLNu+E5VVd+Df5ndyyOnZZyQ11ZNaf6V/1nKigF1gGgJCWkxqpz6ejTW kTzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uUBQYGiWCht6EqB/AMt6zVE9y/fN9/YpXGe8uU7lMTQ=; b=GqQcDuvmn8fYPyxl52eQLiJwR2JBXVCmwyYzwynW06bJnp5mgSvDHcu5aAch1exuyI zHhRJigv6uUMO8v8H8lwYSkf/vQaMJbBkoaXYyaHLFkIJ/hjYSXbyXwDxTBp5Tue0Vgj NreaAJZmIFEEsUi5EfCCIllHEZChY1JDsgaXhU1wddk3rG6Vamaca9+XtKxkpfq4nXxy 1CdAmeubbh/Cn7kH03OozzlejpcU8wuwXmC6Vd/4Al/liLQmGmKvyscd6x7PPx44OQ3y vLuAUwZmn63B7GdJpyPiudolnvlz/cJe+Rl1HfxRpNGA/MtRzx4Qucodg2ONI8dzoFPF +alQ== X-Gm-Message-State: AO0yUKUvmV/HRsRX6D5F9ssC56e3KbdCSmlVH2JSGrWO5b0BEHoUsmkH +gQD35mTur2Zl7r5aBfXTW2nTQbb2onYFA== X-Google-Smtp-Source: AK7set9JHRxjSQw9LijC8p3JKlIaUoT9hcevMm6UHsB1frzRoGDZei2KkeMOulThR0Tas7oHIgcPVg== X-Received: by 2002:a05:600c:3b26:b0:3ea:f05b:50cc with SMTP id m38-20020a05600c3b2600b003eaf05b50ccmr3895561wms.8.1677623338490; Tue, 28 Feb 2023 14:28:58 -0800 (PST) Received: from mariano (94-37-133-75.adsl-ull.clienti.tiscali.it. [94.37.133.75]) by smtp.gmail.com with ESMTPSA id ja18-20020a05600c557200b003eb0d6f48f3sm16608079wmb.27.2023.02.28.14.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 14:28:57 -0800 (PST) Received: by mariano (Postfix, from userid 1000) id 70FA0BFB73; Tue, 28 Feb 2023 23:28:56 +0100 (CET) From: Stefano Sabatini To: FFmpeg development discussions and patches Date: Tue, 28 Feb 2023 23:28:56 +0100 Message-Id: <20230228222856.39722-1-stefasab@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/avcodec.h: extend documentation for avcodec_open2() 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 Cc: Stefano Sabatini 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: In particular, clarify how to set options in the codec context, and mention when to use avcodec_parameters_to_context(). Fix trac issue http://trac.ffmpeg.org/ticket/5781. --- libavcodec/avcodec.h | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 9a0fe97cad..2b7fb27721 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2418,8 +2418,9 @@ int avcodec_parameters_to_context(AVCodecContext *codec, * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for * retrieving a codec. * - * @note Always call this function before using decoding routines (such as - * @ref avcodec_receive_frame()). + * Options on the codec context can be either set by providing the options + * specified in an AVDictionary, or by setting the values on the context itself, + * directly or by using the av_opt_set() API. * * @code * av_dict_set(&opts, "b", "2.5M", 0); @@ -2433,17 +2434,35 @@ int avcodec_parameters_to_context(AVCodecContext *codec, * exit(1); * @endcode * + * In case AVCodecParameters are available (e.g. when demuxing a stream using + * libavformat, and accessing the AVStream contained in the demuxer), the codec + * parameters can be copied to the codec context using + * avcodec_parameters_to_context(), as in the following code: + * + * @code + * context = avcodec_alloc_context3(codec); + * if (avcodec_parameters_to_context(*dec_ctx, codecpar) < 0) + * exit(1); + * if (avcodec_open2(context, codec, NULL) < 0) + * exit(1); + * @endcode + * + * @note Always call this function before using decoding routines (such as + * @ref avcodec_receive_frame()). + * * @param avctx The context to initialize. * @param codec The codec to open this context for. If a non-NULL codec has been * previously passed to avcodec_alloc_context3() or * for this context, then this parameter MUST be either NULL or * equal to the previously passed codec. - * @param options A dictionary filled with AVCodecContext and codec-private options. - * On return this object will be filled with options that were not found. + * @param options A dictionary filled with AVCodecContext and codec-private + * options, which are set on top of the options already set in + * avctx, can be NULL. On return this object will be filled with + * options that were not found in avctx. * * @return zero on success, a negative value on error * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(), - * av_dict_set(), av_opt_find(). + * av_dict_set(), av_opt_set(), av_opt_find(), avcodec_parameters_to_context() */ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); -- 2.25.1 _______________________________________________ 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".