[FFmpeg-devel] [PATCH] lswr/swresample: use AV_OPT_TYPE_SAMPLE_FMT for sample format options

Michael Niedermayer michaelni at gmx.at
Fri Nov 30 04:24:42 CET 2012


On Fri, Nov 30, 2012 at 01:11:14AM +0100, Stefano Sabatini wrote:
> Improve usability and robustness. This is technically an API/ABI break.

please elaborate why this is a API/ABI break, so i dont misunderstand
the implications by mistake


> ---
>  doc/ffmpeg-resampler.texi  |   12 +++---------
>  libswresample/swresample.c |   18 +++++++++---------
>  libswresample/swresample.h |    4 ++--
>  3 files changed, 14 insertions(+), 20 deletions(-)
> 
> diff --git a/doc/ffmpeg-resampler.texi b/doc/ffmpeg-resampler.texi
> index 1bdb5b0..3558772 100644
> --- a/doc/ffmpeg-resampler.texi
> +++ b/doc/ffmpeg-resampler.texi
> @@ -52,19 +52,13 @@ Set the input sample rate. Default value is 0.
>  Set the output sample rate. Default value is 0.
>  
>  @item isf, in_sample_fmt
> -Specify the input sample format. Must be an integer representing the
> -corresponding sample format specified in
> - at file{libavutil/samplefmt.h} header. Default value is -1
> -(corresponding to @code{AV_SAMPLE_FMT_NONE}).
> +Specify the input sample format. It is set by default to @code{none}.
>  
>  @item osf, out_sample_fmt
> -Specify the output sample format. Must be an integer representing the
> -corresponding sample format specified in
> - at file{libavutil/samplefmt.h} header. Default value is -1
> -(corresponding to @code{AV_SAMPLE_FMT_NONE}).
> +Specify the output sample format. It is set by default to @code{none}.
>  
>  @item tsf, internal_sample_fmt
> -Set the internal sample format. Default value is -1.
> +Set the internal sample format. Default value is @code{none}.
>  
>  @item icl, in_channel_layout
>  Set the input channel layout.
> diff --git a/libswresample/swresample.c b/libswresample/swresample.c
> index 28388b5..2dbaf04 100644
> --- a/libswresample/swresample.c
> +++ b/libswresample/swresample.c
> @@ -51,12 +51,12 @@ static const AVOption options[]={
>  {"in_sample_rate"       , "set input sample rate"       , OFFSET( in_sample_rate), AV_OPT_TYPE_INT  , {.i64=0                     }, 0      , INT_MAX   , PARAM},
>  {"osr"                  , "set output sample rate"      , OFFSET(out_sample_rate), AV_OPT_TYPE_INT  , {.i64=0                     }, 0      , INT_MAX   , PARAM},
>  {"out_sample_rate"      , "set output sample rate"      , OFFSET(out_sample_rate), AV_OPT_TYPE_INT  , {.i64=0                     }, 0      , INT_MAX   , PARAM},
> -{"isf"                  , "set input sample format"     , OFFSET( in_sample_fmt ), AV_OPT_TYPE_INT  , {.i64=AV_SAMPLE_FMT_NONE    }, -1     , AV_SAMPLE_FMT_NB-1+256, PARAM},
> -{"in_sample_fmt"        , "set input sample format"     , OFFSET( in_sample_fmt ), AV_OPT_TYPE_INT  , {.i64=AV_SAMPLE_FMT_NONE    }, -1     , AV_SAMPLE_FMT_NB-1+256, PARAM},
> -{"osf"                  , "set output sample format"    , OFFSET(out_sample_fmt ), AV_OPT_TYPE_INT  , {.i64=AV_SAMPLE_FMT_NONE    }, -1     , AV_SAMPLE_FMT_NB-1+256, PARAM},
> -{"out_sample_fmt"       , "set output sample format"    , OFFSET(out_sample_fmt ), AV_OPT_TYPE_INT  , {.i64=AV_SAMPLE_FMT_NONE    }, -1     , AV_SAMPLE_FMT_NB-1+256, PARAM},
> -{"tsf"                  , "set internal sample format"  , OFFSET(int_sample_fmt ), AV_OPT_TYPE_INT  , {.i64=AV_SAMPLE_FMT_NONE    }, -1     , AV_SAMPLE_FMT_FLTP, PARAM},
> -{"internal_sample_fmt"  , "set internal sample format"  , OFFSET(int_sample_fmt ), AV_OPT_TYPE_INT  , {.i64=AV_SAMPLE_FMT_NONE    }, -1     , AV_SAMPLE_FMT_FLTP, PARAM},
> +{"isf"                  , "set input sample format"     , OFFSET( in_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, 0    , 0         , PARAM},
> +{"in_sample_fmt"        , "set input sample format"     , OFFSET( in_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, 0    , 0         , PARAM},
> +{"osf"                  , "set output sample format"    , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, 0    , 0         , PARAM},
> +{"out_sample_fmt"       , "set output sample format"    , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, 0    , 0         , PARAM},
> +{"tsf"                  , "set internal sample format"  , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, 0    , 0         , PARAM},
> +{"internal_sample_fmt"  , "set internal sample format"  , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, 0    , 0         , PARAM},

the min/max values should not be 0 i think


>  {"icl"                  , "set input channel layout"    , OFFSET( in_ch_layout  ), AV_OPT_TYPE_INT64, {.i64=0                     }, 0      , INT64_MAX , PARAM, "channel_layout"},
>  {"in_channel_layout"    , "set input channel layout"    , OFFSET( in_ch_layout  ), AV_OPT_TYPE_INT64, {.i64=0                     }, 0      , INT64_MAX , PARAM, "channel_layout"},
>  {"ocl"                  , "set output channel layout"   , OFFSET(out_ch_layout  ), AV_OPT_TYPE_INT64, {.i64=0                     }, 0      , INT64_MAX , PARAM, "channel_layout"},
> @@ -171,12 +171,12 @@ struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,
>      s->log_ctx= log_ctx;
>  
>      av_opt_set_int(s, "ocl", out_ch_layout,   0);
> -    av_opt_set_int(s, "osf", out_sample_fmt,  0);
> +    av_opt_set_sample_fmt(s, "osf", out_sample_fmt,  0);
>      av_opt_set_int(s, "osr", out_sample_rate, 0);
>      av_opt_set_int(s, "icl", in_ch_layout,    0);
> -    av_opt_set_int(s, "isf", in_sample_fmt,   0);
> +    av_opt_set_sample_fmt(s, "isf", in_sample_fmt,   0);
>      av_opt_set_int(s, "isr", in_sample_rate,  0);
> -    av_opt_set_int(s, "tsf", AV_SAMPLE_FMT_NONE,   0);
> +    av_opt_set_sample_fmt(s, "tsf", AV_SAMPLE_FMT_NONE,   0);
>      av_opt_set_int(s, "ich", av_get_channel_layout_nb_channels(s-> in_ch_layout), 0);
>      av_opt_set_int(s, "och", av_get_channel_layout_nb_channels(s->out_ch_layout), 0);
>      av_opt_set_int(s, "uch", 0, 0);

i assume this is not strictly needed and the code would work without
this hunk

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

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121130/8dda6618/attachment.asc>


More information about the ffmpeg-devel mailing list