diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-08 16:16:42 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-08 16:16:42 +0100 |
commit | 6028bd0dc69c7716fd886fc0a79aacde186a5d99 (patch) | |
tree | 141f994b118ad5deec5b28aba2724d7a55dfd8dd /ffmpeg.c | |
parent | 7665da46ce454b9ce619241375639947d58e9c43 (diff) | |
download | ffmpeg-6028bd0dc69c7716fd886fc0a79aacde186a5d99.tar.gz |
ffmpeg: move next_dts/pts update out of transcode_video()
this makes it placed similar to qatar
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r-- | ffmpeg.c | 34 |
1 files changed, 18 insertions, 16 deletions
@@ -2057,7 +2057,6 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int #if CONFIG_AVFILTER int frame_available = 1; #endif - int duration=0; int64_t *best_effort_timestamp; AVRational *frame_sample_aspect; @@ -2070,20 +2069,6 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int pkt->dts = ist->dts; *pkt_pts = AV_NOPTS_VALUE; - if (pkt->duration) { - duration = av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); - } else 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; - duration = ((int64_t)AV_TIME_BASE * - ist->st->codec->time_base.num * ticks) / - ist->st->codec->time_base.den; - } - - if(ist->dts != AV_NOPTS_VALUE && duration) { - ist->next_dts += duration; - }else - ist->next_dts = AV_NOPTS_VALUE; - ret = avcodec_decode_video2(ist->st->codec, decoded_frame, got_output, pkt); if (ret < 0) @@ -2099,7 +2084,6 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int if(*best_effort_timestamp != AV_NOPTS_VALUE) ist->next_pts = ist->pts = *best_effort_timestamp; - ist->next_pts += duration; pkt->size = 0; pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free); @@ -2251,6 +2235,7 @@ static int output_packet(InputStream *ist, // while we have more to decode or while the decoder did output something on EOF while (ist->decoding_needed && (avpkt.size > 0 || (!pkt && got_output))) { + int duration; handle_eof: ist->pts = ist->next_pts; @@ -2268,6 +2253,23 @@ static int output_packet(InputStream *ist, break; case AVMEDIA_TYPE_VIDEO: ret = transcode_video (ist, &avpkt, &got_output, &pkt_pts); + if (avpkt.duration) { + duration = av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q); + } else 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; + duration = ((int64_t)AV_TIME_BASE * + ist->st->codec->time_base.num * ticks) / + ist->st->codec->time_base.den; + } else + duration = 0; + + if(ist->dts != AV_NOPTS_VALUE && duration) { + ist->next_dts += duration; + }else + ist->next_dts = AV_NOPTS_VALUE; + + if (got_output) + ist->next_pts += duration; //FIXME the duration is not correct in some cases break; case AVMEDIA_TYPE_SUBTITLE: ret = transcode_subtitles(ist, &avpkt, &got_output); |