aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-03 13:53:08 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-03 13:53:08 +0200
commit22dc25cb29ab7b84d6d03f56766a15b6556a7b11 (patch)
tree2baa43c1842984e04e46dd28dcc09b19bf0c7455 /ffmpeg.c
parent6537827189153cd1c6944403a48d7ff76f7b8228 (diff)
parentb4a5a292274f904f404f40f826c51e6fc9cfb8fe (diff)
downloadffmpeg-22dc25cb29ab7b84d6d03f56766a15b6556a7b11.tar.gz
Merge commit 'b4a5a292274f904f404f40f826c51e6fc9cfb8fe'
* commit 'b4a5a292274f904f404f40f826c51e6fc9cfb8fe': avconv: improve -re implementation Conflicts: ffmpeg.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 776312a96d..111551fe76 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1450,16 +1450,6 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
ost->st->codec->frame_number++;
}
-static void rate_emu_sleep(InputStream *ist)
-{
- if (input_files[ist->file_index]->rate_emu) {
- int64_t pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
- int64_t now = av_gettime() - ist->start;
- if (pts > now)
- av_usleep(pts - now);
- }
-}
-
int guess_input_channel_layout(InputStream *ist)
{
AVCodecContext *dec = ist->st->codec;
@@ -1526,8 +1516,6 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
avctx->sample_rate;
#endif
- rate_emu_sleep(ist);
-
resample_changed = ist->resample_sample_fmt != decoded_frame->format ||
ist->resample_channels != avctx->channels ||
ist->resample_channel_layout != decoded_frame->channel_layout ||
@@ -1674,8 +1662,6 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
pkt->size = 0;
- rate_emu_sleep(ist);
-
if (ist->st->sample_aspect_ratio.num)
decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio;
@@ -1764,8 +1750,6 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
if (!*got_output || !subtitle.num_rects)
return ret;
- rate_emu_sleep(ist);
-
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
@@ -1882,7 +1866,6 @@ static int output_packet(InputStream *ist, const AVPacket *pkt)
/* handle stream copy */
if (!ist->decoding_needed) {
- rate_emu_sleep(ist);
ist->dts = ist->next_dts;
switch (ist->st->codec->codec_type) {
case AVMEDIA_TYPE_AUDIO:
@@ -2817,6 +2800,17 @@ static int get_input_packet_mt(InputFile *f, AVPacket *pkt)
static int get_input_packet(InputFile *f, AVPacket *pkt)
{
+ if (f->rate_emu) {
+ int i;
+ for (i = 0; i < f->nb_streams; i++) {
+ InputStream *ist = input_streams[f->ist_index + i];
+ int64_t pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
+ int64_t now = av_gettime() - ist->start;
+ if (pts > now)
+ return AVERROR(EAGAIN);
+ }
+ }
+
#if HAVE_PTHREADS
if (nb_input_files > 1)
return get_input_packet_mt(f, pkt);