[FFmpeg-cvslog] r25431 - trunk/ffmpeg.c
astrange
subversion
Sun Oct 10 04:17:26 CEST 2010
Author: astrange
Date: Sun Oct 10 04:17:26 2010
New Revision: 25431
Log:
ffmpeg: Use guess_correct_pts() to set decoded picture timestamps
Modified:
trunk/ffmpeg.c
Modified: trunk/ffmpeg.c
==============================================================================
--- trunk/ffmpeg.c Sun Oct 10 02:50:37 2010 (r25430)
+++ trunk/ffmpeg.c Sun Oct 10 04:17:26 2010 (r25431)
@@ -312,6 +312,7 @@ typedef struct AVInputStream {
int64_t next_pts; /* synthetic pts for cases where pkt.pts
is not defined */
int64_t pts; /* current pts */
+ PtsCorrectionContext pts_ctx;
int is_start; /* is 1 at the start and after a discontinuity */
int showed_multi_packet_warning;
int is_past_recording_time;
@@ -1542,6 +1543,7 @@ static int output_packet(AVInputStream *
void *buffer_to_free;
static unsigned int samples_size= 0;
AVSubtitle subtitle, *subtitle_to_free;
+ int64_t pkt_pts = AV_NOPTS_VALUE;
#if CONFIG_AVFILTER
int frame_available;
#endif
@@ -1564,6 +1566,8 @@ static int output_packet(AVInputStream *
if(pkt->dts != AV_NOPTS_VALUE)
ist->next_pts = ist->pts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
+ if(pkt->pts != AV_NOPTS_VALUE)
+ pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
//while we have more to decode or while the decoder did output something on EOF
while (avpkt.size > 0 || (!pkt && ist->next_pts != ist->pts)) {
@@ -1616,6 +1620,8 @@ static int output_packet(AVInputStream *
decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
/* XXX: allocate picture correctly */
avcodec_get_frame_defaults(&picture);
+ ist->st->codec->reordered_opaque = pkt_pts;
+ pkt_pts = AV_NOPTS_VALUE;
ret = avcodec_decode_video2(ist->st->codec,
&picture, &got_picture, &avpkt);
@@ -1626,6 +1632,7 @@ static int output_packet(AVInputStream *
/* no picture yet */
goto discard_packet;
}
+ ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, picture.reordered_opaque, ist->pts);
if (ist->st->codec->time_base.num != 0) {
int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
ist->next_pts += ((int64_t)AV_TIME_BASE *
@@ -2414,6 +2421,7 @@ static int transcode(AVFormatContext **o
st= ist->st;
ist->pts = st->avg_frame_rate.num ? - st->codec->has_b_frames*AV_TIME_BASE / av_q2d(st->avg_frame_rate) : 0;
ist->next_pts = AV_NOPTS_VALUE;
+ init_pts_correction(&ist->pts_ctx);
ist->is_start = 1;
}
More information about the ffmpeg-cvslog
mailing list