[FFmpeg-devel] [PATCH] libavdevice/lavfi.c: adjust subcc_packet->pts to correct timebase with av_rescale_q

Chris Landry chris.landry at vidyard.com
Sat Oct 1 21:06:09 EEST 2016


Sorry, this was supposed to be submitted in response to my thread on this
one. New to sending email with git.

On Sat, Oct 1, 2016 at 2:04 PM, Chris Landry <topher.p.landry at gmail.com>
wrote:

> From: Chris Landry <topher.p.landry at gmail.com>
>
> Should have used av_rescale_q to do the timebase adjustment. Fixed
> compiler warning for variable declaration.
>
> Signed-off-by: Chris Landry <topher.p.landry at gmail.com>
> ---
>  libavdevice/lavfi.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
> index ffe5e0e..89979db 100644
> --- a/libavdevice/lavfi.c
> +++ b/libavdevice/lavfi.c
> @@ -364,6 +364,7 @@ static int create_subcc_packet(AVFormatContext
> *avctx, AVFrame *frame,
>      LavfiContext *lavfi = avctx->priv_data;
>      AVFrameSideData *sd;
>      int stream_idx, i, ret;
> +    int64_t pts;
>
>      if ((stream_idx = lavfi->sink_stream_subcc_map[sink_idx]) < 0)
>          return 0;
> @@ -377,10 +378,7 @@ static int create_subcc_packet(AVFormatContext
> *avctx, AVFrame *frame,
>          return ret;
>      memcpy(lavfi->subcc_packet.data, sd->data, sd->size);
>
> -    AVRational time_base = lavfi->video_time_base;
> -
> -    double adjust_factor = time_base.den / (90000.0 * time_base.num);
> -    double pts = frame->pts / adjust_factor;
> +    pts = av_rescale_q(frame->pts, lavfi->video_time_base,
> (AVRational){1, 90000});
>
>      lavfi->subcc_packet.stream_index = stream_idx;
>      lavfi->subcc_packet.pts = (int64_t)pts;
> --
> 2.8.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list