[FFmpeg-devel] Negative DTS

Frédéric Jolliton ffmpeg-devel
Wed Aug 13 00:04:32 CEST 2008


Hi,

In the code introduced by revision 8431 (march 2007), I'm wondering if
the code is correct. The line 901 looks suspicious to me. For example,
when delay is greater than 1, the computed value is negative. Is that
normal? Since line 902-903 move the highest value to the end, the
negative value become the first and is used at line 905 to set the dts.

I observed this behavior with a Matroska video, and tracked it down to
this line.

What do you think?

The same code can be found at line 2540.

898     if(pkt->pts != AV_NOPTS_VALUE){
899         st->pts_buffer[0]= pkt->pts;
900         for(i=1; i<delay+1 && st->pts_buffer[i] == AV_NOPTS_VALUE; i++)
901             st->pts_buffer[i]= (i-delay-1) * pkt->duration;
902         for(i=0; i<delay && st->pts_buffer[i] > st->pts_buffer[i+1]; i++)
903             FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i+1]);
904         if(pkt->dts == AV_NOPTS_VALUE)
905             pkt->dts= st->pts_buffer[0];
906         if(delay>1){
907             update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts); // this should happen on the first packet
908         }
909         if(pkt->dts > st->cur_dts)
910             st->cur_dts = pkt->dts;
911     }

-- 
Fr?d?ric Jolliton




More information about the ffmpeg-devel mailing list