[FFmpeg-devel] [PATCH]Set pts offset in decimate filter

Clément Bœsch u at pkh.me
Wed Oct 30 19:37:57 CET 2013


On Wed, Oct 30, 2013 at 07:24:07PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #3019 for me.
> 
> Please comment, Carl Eugen

> diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
> index 034d524..d8cd124 100644
> --- a/libavfilter/vf_decimate.c
> +++ b/libavfilter/vf_decimate.c
> @@ -43,6 +43,7 @@ typedef struct {
>      AVFrame **clean_src;    ///< frame queue for the clean source
>      int got_frame[2];       ///< frame request flag for each input stream
>      double ts_unit;         ///< timestamp units for the output frames
> +    int64_t pts_offset;     ///< offset to add to output timestamps

nit: start_pts; ///< base for output timestamps

...but feel free to keep as is.

>      uint32_t eof;           ///< bitmask for end of stream
>      int hsub, vsub;         ///< chroma subsampling values
>      int depth;
> @@ -210,11 +211,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>              av_frame_free(&dm->queue[i].frame);
>          } else {
>              AVFrame *frame = dm->queue[i].frame;
> +            if (frame->pts != AV_NOPTS_VALUE && dm->pts_offset == AV_NOPTS_VALUE)
> +                dm->pts_offset = frame->pts;
>              if (dm->ppsrc) {
>                  av_frame_free(&frame);
>                  frame = dm->clean_src[i];
>              }
> -            frame->pts = outlink->frame_count * dm->ts_unit;
> +            frame->pts = outlink->frame_count * dm->ts_unit +
> +                         (dm->pts_offset == AV_NOPTS_VALUE ? 0 : dm->pts_offset);
>              ret = ff_filter_frame(outlink, frame);
>              if (ret < 0)
>                  break;
> @@ -259,7 +263,7 @@ static int config_input(AVFilterLink *inlink)
>  
>  static av_cold int decimate_init(AVFilterContext *ctx)
>  {
> -    const DecimateContext *dm = ctx->priv;
> +    DecimateContext *dm = ctx->priv;
>      AVFilterPad pad = {
>          .name         = av_strdup("main"),
>          .type         = AVMEDIA_TYPE_VIDEO,
> @@ -285,6 +289,8 @@ static av_cold int decimate_init(AVFilterContext *ctx)
>          return AVERROR(EINVAL);
>      }
>  
> +    dm->pts_offset = AV_NOPTS_VALUE;
> +
>      return 0;
>  }
>  

Should be fine until we find a better solution, thanks.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131030/0b6c2e65/attachment.asc>


More information about the ffmpeg-devel mailing list