[FFmpeg-devel] [PATCH] lavfi/vf_fps: allow to set the rounding method.

Michael Niedermayer michaelni at gmx.at
Thu Oct 25 19:30:21 CEST 2012


On Thu, Oct 25, 2012 at 07:23:01PM +0200, Nicolas George wrote:
> By default, fps selects frames near PTS 0, 0.5, 1.5, 2.5, etc.
> With round=down, it selects the frames near PTS 0, 1, 2, 3, etc.
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  doc/filters.texi     |    3 +++
>  libavfilter/vf_fps.c |   11 +++++++++--
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index adec96e..93fdcec 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -2186,6 +2186,9 @@ This filter accepts the following named parameters:
>  @item fps
>  Desired output framerate.
>  
> + at item round
> +Rounding method. The default is @code{near}.
> +
>  @end table
>  
>  @section framestep
> diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
> index 114b062..c0183a8 100644
> --- a/libavfilter/vf_fps.c
> +++ b/libavfilter/vf_fps.c
> @@ -46,6 +46,7 @@ typedef struct FPSContext {
>  
>      AVRational framerate;   ///< target framerate
>      char *fps;              ///< a string describing target framerate
> +    int rounding;           ///< AVRounding method for timestamps
>  
>      /* statistics */
>      int frames_in;             ///< number of frames on input
> @@ -59,6 +60,12 @@ typedef struct FPSContext {
>  #define F AV_OPT_FLAG_FILTERING_PARAM
>  static const AVOption fps_options[] = {
>      { "fps", "A string describing desired output framerate", OFFSET(fps), AV_OPT_TYPE_STRING, { .str = "25" }, .flags = V|F },
> +    { "round", "set rounding method for timestamps", OFFSET(rounding), AV_OPT_TYPE_INT, { .i64 = AV_ROUND_NEAR_INF }, 0, 5, V|F, "round" },
> +    { "zero", "round towards 0",      OFFSET(rounding), AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_ZERO     }, 0, 5, V|F, "round" },
> +    { "inf",  "round away from 0",    OFFSET(rounding), AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_INF      }, 0, 5, V|F, "round" },

> +    { "down", "round towards -infty", OFFSET(rounding), AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_DOWN     }, 0, 5, V|F, "round" },
> +    { "up",   "round towards -infty", OFFSET(rounding), AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_UP       }, 0, 5, V|F, "round" },
                                ^^^^^^
these 2 should have differing descriptions

otherwise LGTM

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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- 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/20121025/90946cd8/attachment.asc>


More information about the ffmpeg-devel mailing list