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 D28C340164 for ; Sun, 5 Mar 2023 11:57:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 39FE568B2F6; Sun, 5 Mar 2023 13:57:48 +0200 (EET) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1515568B14C for ; Sun, 5 Mar 2023 13:57:42 +0200 (EET) Received: by mail-ed1-f47.google.com with SMTP id da10so27732063edb.3 for ; Sun, 05 Mar 2023 03:57:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678017461; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:to:from:date:from:to:cc:subject:date:message-id :reply-to; bh=wQKPXqX+syP7mlNv6AE0phj9xmHcqI9X+8si8KdHzxQ=; b=U3+OGGugFEZKmeYIWW9POQbyVMFBe+CRRBP+xE5Sec8zopDmwxIZlkBQnGurT2g7wf pbXjbFuXbvHRV0kEKsEaqoINUuzrbd1Mqo15mw/uCijm9WQrumSXJnsBUIpUTn1NM/IA 9+l0KOVYuhuyAYfiU6+ntRQC7/1dEYAD4BgDdetBccIUtDlSpKZbEquXGnPjTv73iOaL zsRS33bIL8fAq8Yt/hJRXwY3mxpa0QvbBFu4Wjl8ArGAq/UQZNAToDTYXYGMyrxLLLC5 ajnEng9XXXaWWFA9V+OVMh8cSXbYOC5gCsmpm07FRmQ5Wt8H2FrEWm3NgjvftsQg0aY+ E2hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678017461; h=user-agent:in-reply-to:content-transfer-encoding :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=wQKPXqX+syP7mlNv6AE0phj9xmHcqI9X+8si8KdHzxQ=; b=ZKJdN1xBchPmeM6xjlBg7Fh2YPf1T3uNLNCyPoR5gaabdiT6cn80NOU5XJns2fc930 7Ug1IPkCyhfWaFf+76/XTkbfj/xdCFGgYZjgn0rO+E9qNToz4ovh8u4aLMmyfH+siW1h 7cT4VqKtwtWNupok4QhzTsLMxbQu8qb5XFpyLDz6gkJZZrLxR4/q9y/oCBcrR4AzAWKg 6TrtIES/8exPXC9jo+ySmDn3QaT9tXm/+YaoIb8gbD5AHR7XtBRrvAdHazgVZBYOvIDy jHPWCy7QF/9xfBBYIbkFwDEVGy5tVt0bvvG9BslHGw1l/7mOIhwxZn7cwVxRnYXDInXj dPKA== X-Gm-Message-State: AO0yUKUyruboPYSuuiN6B6IJo0bJSI+19sT9qvOzxBFRdPMxWctUPl/H akrRgb7r+SjJwdDwtkuotnGgYYr4NOSBtA== X-Google-Smtp-Source: AK7set8PpsYeD5HcGN3O3o/JJBsv/bK1S05VNxVJw1STHLuLTm2kBekuWPpiTzfVG390ptkxSW0wIg== X-Received: by 2002:a17:907:7216:b0:86a:316:d107 with SMTP id dr22-20020a170907721600b0086a0316d107mr9938790ejc.72.1678017460730; Sun, 05 Mar 2023 03:57:40 -0800 (PST) Received: from mariano (dynamic-adsl-62-10-93-138.clienti.tiscali.it. [62.10.93.138]) by smtp.gmail.com with ESMTPSA id gy6-20020a170906f24600b008d606b1bbb1sm3119883ejb.9.2023.03.05.03.57.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Mar 2023 03:57:39 -0800 (PST) Received: by mariano (Postfix, from userid 1000) id 9530ABFB73; Sun, 5 Mar 2023 12:57:38 +0100 (CET) Date: Sun, 5 Mar 2023 12:57:38 +0100 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: <20230305115738.GC195575@mariano> Mail-Followup-To: FFmpeg development discussions and patches References: <20230228222856.39722-1-stefasab@gmail.com> <20230228224010.GC25822@mariano> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tKW2IUtsqtDRztdT" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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: --tKW2IUtsqtDRztdT Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On date Wednesday 2023-03-01 15:04:16 +0800, "zhilizhao(赵志立)" wrote: > > 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 > > 'is not is not' > > > + * case of decoding raw audio or video). > > in ’the’ case of. > > > + * > > + * 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); > > What’s the dec_ctx? Updated, thanks for the feedback. --tKW2IUtsqtDRztdT Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-lavc-avcodec.h-extend-documentation-for-avcodec_open.patch" >From 672de0e5d15ab8a22f3957222680d847f60bced8 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 28 Feb 2023 23:26:43 +0100 Subject: [PATCH 1/2] 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 | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 87ebee22b1..f630fafe24 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2429,8 +2429,15 @@ 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 + * the case the information is not available in the bitstream, as when decoding + * raw audio or video). + * + * Options on the codec context can be set either by setting them in the + * provided options AVDictionary, or by setting the values on the context + * itself, directly or by using the av_opt_set() API before calling the + * function. * * @code * av_dict_set(&opts, "b", "2.5M", 0); @@ -2444,17 +2451,36 @@ 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 + * AVStream *stream = ...; + * context = avcodec_alloc_context3(codec); + * if (avcodec_parameters_to_context(context, stream->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 the avctx codec context. * * @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 --tKW2IUtsqtDRztdT 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". --tKW2IUtsqtDRztdT--