[FFmpeg-devel] [PATCH] interpolate last pts when genpts is activated

Baptiste Coudurier baptiste.coudurier
Tue Jun 30 20:09:46 CEST 2009


baptiste.coudurier at gmail.com wrote:
> From: bcoudurier <baptiste.coudurier at gmail.com>
> 
> ---
>  libavformat/utils.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index fd28d1d..ced035c 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -952,6 +952,7 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
>          pktl = s->packet_buffer;
>          if (pktl) {
>              AVPacket *next_pkt= &pktl->pkt;
> +            int64_t max_pts = AV_NOPTS_VALUE;
>  
>              if(genpts && next_pkt->dts != AV_NOPTS_VALUE){
>                  while(pktl && next_pkt->pts == AV_NOPTS_VALUE){
> @@ -961,6 +962,7 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
>                         /*&& pktl->pkt.dts != AV_NOPTS_VALUE*/){
>                          next_pkt->pts= pktl->pkt.dts;
>                      }
> +                    max_pts = FFMAX(max_pts, pktl->pkt.pts);
>                      pktl= pktl->next;
>                  }
>                  pktl = s->packet_buffer;
> @@ -971,6 +973,8 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
>                 || !genpts || eof){
>                  /* read packet from packet buffer, if there is data */
>                  *pkt = *next_pkt;
> +                if (eof && max_pts != AV_NOPTS_VALUE && pkt->duration)
> +                    pkt->pts = max_pts + pkt->duration;

Autoreview: check for pkt->pts == AV_NOPTS_VALUE must be added also.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list