diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-10-27 14:04:47 +0100 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-10-27 14:04:47 +0100 |
commit | 0a830b95d597633905074744fc8391229ac03bec (patch) | |
tree | ad77cff5fbd6bcdd1b9369858504b122c9aadd4e | |
parent | a4b5ada36bec6250fd6255b5285a10ca19dafbec (diff) | |
parent | 447b5b278c689b21bbb7b5747c8773145cbd9448 (diff) | |
download | ffmpeg-0a830b95d597633905074744fc8391229ac03bec.tar.gz |
Merge commit '447b5b278c689b21bbb7b5747c8773145cbd9448'
* commit '447b5b278c689b21bbb7b5747c8773145cbd9448':
mpegvideo_enc: Fix encoding videos with less frames than the delay of the encoder
Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
-rw-r--r-- | libavcodec/mpegvideo_enc.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index d4e053297c..e87f4258fe 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1123,10 +1123,10 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) Picture *pic = NULL; int64_t pts; int i, display_picture_number = 0, ret; - int encoding_delay = s->max_b_frames ? s->max_b_frames : - (s->low_delay ? 0 : 1); + int encoding_delay = s->max_b_frames ? s->max_b_frames + : (s->low_delay ? 0 : 1); + int flush_offset = 1; int direct = 1; - int shift = 1; if (pic_arg) { pts = pic_arg->pts; @@ -1249,15 +1249,19 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) } else { /* Flushing: When we have not received enough input frames, * ensure s->input_picture[0] contains the first picture */ - for (shift = 0; shift < encoding_delay + 1; shift++) - if (s->input_picture[shift]) break; - if (shift <= 1) shift = 1; - else encoding_delay = encoding_delay - shift + 1; + for (flush_offset = 0; flush_offset < encoding_delay + 1; flush_offset++) + if (s->input_picture[flush_offset]) + break; + + if (flush_offset <= 1) + flush_offset = 1; + else + encoding_delay = encoding_delay - flush_offset + 1; } /* shift buffer entries */ - for (i = shift; i < MAX_PICTURE_COUNT /*s->encoding_delay + 1*/; i++) - s->input_picture[i - shift] = s->input_picture[i]; + for (i = flush_offset; i < MAX_PICTURE_COUNT /*s->encoding_delay + 1*/; i++) + s->input_picture[i - flush_offset] = s->input_picture[i]; s->input_picture[encoding_delay] = (Picture*) pic; |