From 32cde962969363bebc4ad49b770ffff39487d3f8 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Thu, 26 Sep 2013 03:13:38 +0200
Subject: avformat/mpegenc: Better heuristic for ordering packets

This prevents underflows in quite constrained cases

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
---
 libavformat/mpegenc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'libavformat/mpegenc.c')

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 47a7cedfe1..811fe2d9c3 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -955,7 +955,9 @@ retry:
 
         if(next_pkt && next_pkt->dts - scr > max_delay)
             continue;
-
+        if (   stream->predecode_packet
+            && stream->predecode_packet->size > stream->buffer_index)
+            rel_space += 1<<28;
         if(rel_space > best_score){
             best_score= rel_space;
             best_i = i;
-- 
cgit v1.2.3