[FFmpeg-devel] [PATCH 3/8] lavf/mux: add avformat_init_output

Michael Niedermayer michael at niedermayer.cc
Wed Apr 13 16:07:44 CEST 2016


On Wed, Apr 13, 2016 at 04:28:33AM -0500, Rodger Combs wrote:
> This allows a consumer to run the muxer's init function without actually
> writing the header, which is useful in chained muxers that support
> automatic bitstream filtering.
> ---
>  libavformat/avformat.h | 30 +++++++++++++++++++++++--
>  libavformat/internal.h | 10 +++++++++
>  libavformat/mux.c      | 59 +++++++++++++++++++++++++++++++++++++++-----------
>  libavformat/version.h  |  2 +-
>  4 files changed, 85 insertions(+), 16 deletions(-)
> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index f240ab3..c7b1b0a 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -616,6 +616,8 @@ typedef struct AVOutputFormat {
>       * AVStream parameters that need to be set before packets are sent.
>       * This method must not write output.
>       *
> +     * Return 0 if streams were fully configured, 1 if not, negative AVERROR on failure
> +     *
>       * Any allocations made here must be freed in deinit().
>       */
>      int (*init)(struct AVFormatContext *);
> @@ -2368,14 +2370,38 @@ void avformat_close_input(AVFormatContext **s);
>   *                 On return this parameter will be destroyed and replaced with a dict containing
>   *                 options that were not found. May be NULL.
>   *
> - * @return 0 on success, negative AVERROR on failure.
> + * @return 0 on success if the codec had not already been fully initialized in avformat_init,
> + *         1 on success if the codec had already been fully initialized in avformat_init,
> + *         negative AVERROR on failure.
>   *
> - * @see av_opt_find, av_dict_set, avio_open, av_oformat_next.
> + * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_init_output.
>   */
>  av_warn_unused_result
>  int avformat_write_header(AVFormatContext *s, AVDictionary **options);
>  
>  /**
> + * Allocate the stream private data and initialize the codec, but do not write the header.
> + * May optionally be used before avformat_write_header to initialize stream parameters
> + * before actually writing the header.
> + * If using this function, do not pass the same options to avformat_write_header.
> + *
> + * @param s Media file handle, must be allocated with avformat_alloc_context().
> + *          Its oformat field must be set to the desired output format;
> + *          Its pb field must be set to an already opened AVIOContext.
> + * @param options  An AVDictionary filled with AVFormatContext and muxer-private options.
> + *                 On return this parameter will be destroyed and replaced with a dict containing
> + *                 options that were not found. May be NULL.
> + *
> + * @return 0 on success if the codec has been fully initialized,
> + *         1 on success if the codec requires avformat_write_header to fully initialize,
> + *         negative AVERROR on failure.
> + *
> + * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_write_header.
> + */
> +av_warn_unused_result
> +int avformat_init_output(AVFormatContext *s, AVDictionary **options);

this should still use named identifers instead of 0/1 litteral return
codes
did you see my previous reply ?

code like ret = avformat_init_output() ... if (ret == 1)
is confusing to the reader one always would have to check the docs
to understand it, a named identifer avoids that 

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160413/52ce1b32/attachment.sig>


More information about the ffmpeg-devel mailing list