vlc | branch: master | Francois Cartegnie <[email protected]> | Thu Jun  8 
10:54:47 2017 +0200| [c202faa3cfa37e74f80f1c7ea25eac81f27bd405] | committer: 
Francois Cartegnie

codec: avcodec: flush decoder on eof

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c202faa3cfa37e74f80f1c7ea25eac81f27bd405
---

 modules/codec/avcodec/audio.c | 8 +++++++-
 modules/codec/avcodec/video.c | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index dc79c3807b..884e4e357b 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -447,7 +447,13 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t 
**pp_block, bool *error )
             if (unlikely(frame == NULL))
                 break;
         }
-        else av_frame_free( &frame );
+        else
+        {
+            /* After draining, we need to reset decoder with a flush */
+            if( ret == AVERROR_EOF )
+                avcodec_flush_buffers( p_sys->p_context );
+            av_frame_free( &frame );
+        }
     };
 
     return ( p_sys->p_decoded ) ? DequeueOneDecodedFrame( p_sys ) : NULL;
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 52736c119b..55aae2d2da 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -917,6 +917,9 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t 
**pp_block, bool *error
                 *error = true;
             }
             av_frame_free(&frame);
+            /* After draining, we need to reset decoder with a flush */
+            if( ret == AVERROR_EOF )
+                avcodec_flush_buffers( p_sys->p_context );
             break;
         }
         bool not_received_frame = ret;

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to