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 EEB85459ED for ; Tue, 28 Feb 2023 22:40:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5933968AFD7; Wed, 1 Mar 2023 00:40:20 +0200 (EET) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 92483689D71 for ; Wed, 1 Mar 2023 00:40:13 +0200 (EET) Received: by mail-wr1-f52.google.com with SMTP id t15so11380048wrz.7 for ; Tue, 28 Feb 2023 14:40:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=qcD4mE9kXmEbQeQ4rgZStGfjqA/Fwaqn6Csm1RuxmJQ=; b=aEzdlnZclRj+QO7RoDHjI8Hqgb/NonoE+NtYG+Tps/YlgJ/X08WUIxWUd99el0w+4S ICpRkjy/l5EhqGv8MI/DnVfrgTaUDDUQ/VwzH16IOUTUzeYBbUSsE2TYjtLNJkloRrnr y/PU7DW6rY2AvyqoMN/QA2YLYHiZsnJfU1GWGt7v8qN1PiCA8whFNmcAYyOSjkbN7cPh AEIjxpD/8HO11rmzuPpbmqtqWH49IUUrHozk7h76+QgjQMmeMZfsgA9xYbp4da7EA1+A ACbYQ4EHFivnGbiGKAfgpatSE+b/iI+u+FmXFvEMPV35uUtU87ZLFRsVgABdLOy3GCuS s5UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=qcD4mE9kXmEbQeQ4rgZStGfjqA/Fwaqn6Csm1RuxmJQ=; b=P/lTtn6qEJQ6gkc9z30FjoJ5J+lg3zFXW7/Lw0FGNYGX5lYFss9retGDctiywLws2F eGJWepDVv5oX14q/HbhGCuMRFZ3e6QdT7+pmyAbDresL1YEuL1tPgwyWtCuqTrux5NC9 IlsPw6xZj9FAoojmIVq6Ms6rrOzpJ5NYhRxXbBiPU2CY6IQr3GM9+ZX/KxBdqezt/iQq zgU4rHca/iQwS8fHEYv9dqrYxqpQH6cvJGlcEZqW+cKZBvzuhSEr6jTqRonh75jaNiAi hM4PvPXzIMLWcf1k7gFO49FhiJmM3Ns3MRkrHEqycyaNaRXmdPT8CBRqhnzDYPcr/e+M kqrw== X-Gm-Message-State: AO0yUKXmuT9A9smQDzV5eNi8/dE1EuDmhs3WSPI69V1PhV11be6LwZjN zD7b9ZcqSpXMgNlSsNUgzqBbGP9LtB/eCg== X-Google-Smtp-Source: AK7set+oCOD14IhDLO9C9SkZjdl6ycp8CoR5eDPZ1FJMFBtwyv7V9ocScim8ykcwqnLkHnXR5JwCIA== X-Received: by 2002:a05:6000:601:b0:2c5:4a22:937c with SMTP id bn1-20020a056000060100b002c54a22937cmr9810437wrb.27.1677624012142; Tue, 28 Feb 2023 14:40:12 -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 m33-20020a05600c3b2100b003eaee9e0d22sm15003966wms.33.2023.02.28.14.40.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 14:40:11 -0800 (PST) Received: by mariano (Postfix, from userid 1000) id 53A62BFB73; Tue, 28 Feb 2023 23:40:10 +0100 (CET) Date: Tue, 28 Feb 2023 23:40:10 +0100 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: <20230228224010.GC25822@mariano> Mail-Followup-To: FFmpeg development discussions and patches References: <20230228222856.39722-1-stefasab@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="azLHFNyN32YCQGCU" Content-Disposition: inline In-Reply-To: <20230228222856.39722-1-stefasab@gmail.com> User-Agent: Mutt/1.13.2 (2019-12-18) Subject: Re: [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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --azLHFNyN32YCQGCU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On date Tuesday 2023-02-28 23:28:56 +0100, Stefano Sabatini wrote: > 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(-) Updated with some more information, after I realized there was another related issue. --azLHFNyN32YCQGCU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-lavc-avcodec.h-extend-documentation-for-avcodec_open.patch" >From e4e5622d1c4eac5dde4065b260523e4fd9ada85c Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 28 Feb 2023 23:26:43 +0100 Subject: [PATCH] lavc/avcodec.h: extend documentation for avcodec_open2() In particular, clarify how to set options in the codec context, and mention when to use avcodec_parameters_to_context(). Fix trac issues: http://trac.ffmpeg.org/ticket/5781 http://trac.ffmpeg.org/ticket/5838 --- libavcodec/avcodec.h | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 9a0fe97cad..fbf1d3d83c 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2418,8 +2418,14 @@ 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()). + * Depending on the codec, you might need to set options in the codec context + * also for decoding (e.g. width, height, or the pixel or audio sample format in + * case the information is not is not available in the bitstream, e.g. as in + * case of decoding raw audio or video). + * + * 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 +2439,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 --azLHFNyN32YCQGCU Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --azLHFNyN32YCQGCU--