[vlc-devel] [PATCH 2/2] avcodec: don't enqueue empty encoded block

Steve Lhomme robux4 at videolabs.io
Wed Aug 30 17:06:03 CEST 2017


There's no data, no timestamp and no flag to signal anything.
---
 modules/codec/avcodec/encoder.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 7b5e15a245..009ddcd235 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -1124,6 +1124,10 @@ static void vlc_av_packet_Release(block_t *block)
 
 static block_t *vlc_av_packet_Wrap(AVPacket *packet, mtime_t i_length, AVCodecContext *context )
 {
+    if ( packet->data==NULL && packet->flags==0 &&
+         packet->pts==AV_NOPTS_VALUE && packet->dts==AV_NOPTS_VALUE )
+        return NULL; /* totally empty AVPacket */
+
     vlc_av_packet_t *b = malloc( sizeof( *b ) );
     if( unlikely(b == NULL) )
         return NULL;
-- 
2.12.1



More information about the vlc-devel mailing list