]> granicus.if.org Git - handbrake/commitdiff
libhb: Use a buffer flat to indicate EOF
authorjstebbins <jstebbins.hb@gmail.com>
Fri, 1 May 2015 14:47:35 +0000 (14:47 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Fri, 1 May 2015 14:47:35 +0000 (14:47 +0000)
... instead of a 0 length buffer.
This fixes this issue:
https://forum.handbrake.fr/viewtopic.php?f=12&t=31959

Theora can create 0 length output. These 0 length frames indicate
duplicate frames. So we can't use 0 length buffers to indicate the end
of the stream.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7143 b64f7644-9d1e-0410-96f1-a4d463321fa5

36 files changed:
libhb/cropscale.c
libhb/deblock.c
libhb/decavcodec.c
libhb/deccc608sub.c
libhb/declpcm.c
libhb/decomb.c
libhb/decpgssub.c
libhb/decssasub.c
libhb/dectx3gsub.c
libhb/decutf8sub.c
libhb/decvobsub.c
libhb/deinterlace.c
libhb/denoise.c
libhb/detelecine.c
libhb/enc_qsv.c
libhb/encavcodec.c
libhb/encavcodecaudio.c
libhb/enclame.c
libhb/enctheora.c
libhb/encvobsub.c
libhb/encvorbis.c
libhb/encx264.c
libhb/encx265.c
libhb/fifo.c
libhb/internal.h
libhb/muxcommon.c
libhb/nlmeans.c
libhb/platform/macosx/encca_aac.c
libhb/qsv_filter.c
libhb/qsv_filter_pp.c
libhb/reader.c
libhb/rendersub.c
libhb/rotate.c
libhb/stream.c
libhb/sync.c
libhb/vfr.c

index d1ef0f9bbb4d8dc1a2ffbcaf79bdbe5fa26feffa..fc88e32a4d0d12ad8e91c565a989fb04e096a173 100644 (file)
@@ -222,7 +222,7 @@ static int hb_crop_scale_work( hb_filter_object_t * filter,
     hb_filter_private_t * pv = filter->private_data;
     hb_buffer_t * in = *buf_in;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
index 5acb3f5d04bacd5dcabdc5f45664a4c247d04af0..e05f2e21ece5ceeb9ac38485175c889be878a2c6 100644 (file)
@@ -400,7 +400,7 @@ static int hb_deblock_work( hb_filter_object_t * filter,
     hb_filter_private_t * pv = filter->private_data;
     hb_buffer_t * in = *buf_in, * out;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
index 32eb4a21aa3af92e9defc10caf16e026d53a5c98..bdca1e1806bc780a2219bf98b01ffd84ada27e28 100644 (file)
@@ -535,7 +535,7 @@ static int decavcodecaWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_work_private_t * pv = w->private_data;
     hb_buffer_t * in = *buf_in;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         /* EOF on input stream - send it downstream & say that we're done */
         *buf_out = in;
@@ -1564,7 +1564,7 @@ static void decodeVideo( hb_work_object_t *w, uint8_t *data, int size, int seque
 #endif
         flushDelayQueue(pv);
         if (pv->list_subtitle != NULL)
-            cc_send_to_decoder(pv, hb_buffer_init(0));
+            cc_send_to_decoder(pv, hb_buffer_eof_init());
     }
 }
 
@@ -1810,11 +1810,11 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     *buf_out = NULL;
 
     /* if we got an empty buffer signaling end-of-stream send it downstream */
-    if ( in->size == 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         if (pv->context != NULL && pv->context->codec != NULL)
         {
-            decodeVideo( w, in->data, in->size, in->sequence, pts, dts, in->s.frametype );
+            decodeVideo(w, in->data, 0, 0, pts, dts, 0);
         }
         hb_list_add( pv->list, in );
         *buf_out = link_buf_list( pv );
@@ -1841,7 +1841,7 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         if ( codec == NULL )
         {
             hb_log( "decavcodecvWork: failed to find codec for id (%d)", w->codec_param );
-            *buf_out = hb_buffer_init( 0 );;
+            *buf_out = hb_buffer_eof_init();
             return HB_WORK_DONE;
         }
 
@@ -1882,7 +1882,7 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         {
             av_dict_free( &av_opts );
             hb_log( "decavcodecvWork: avcodec_open failed" );
-            *buf_out = hb_buffer_init( 0 );;
+            *buf_out = hb_buffer_eof_init();
             return HB_WORK_DONE;
         }
         av_dict_free( &av_opts );
index 4a5e4af8bd46fe545d847b60de60fbe491f2db9b..3b3f953932a1f947e173789b9189e018b98be037 100644 (file)
@@ -1825,7 +1825,7 @@ static int decccWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_work_private_t * pv = w->private_data;
     hb_buffer_t * in = *buf_in;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         /* EOF on input stream - send it downstream & say that we're done */
         handle_end_of_data(pv->cc608);
index 42cc13e50685c5d8eb38330df6e4804d781ba82c..c85c803e9875019eba49ac080da37ada1ae98489 100644 (file)
@@ -189,7 +189,7 @@ static int declpcmWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_buffer_t *in = *buf_in;
     hb_buffer_t *buf = NULL;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         /* EOF on input stream - send it downstream & say that we're done */
         *buf_out = in;
index 7a1b4bf660b0824b4c26ad1ce938a503c6fd68f7..60aa95f1a30f38e244070f56852d8adac9d26fdb 100644 (file)
@@ -2523,7 +2523,7 @@ static int hb_decomb_work( hb_filter_object_t * filter,
     hb_buffer_t * in = *buf_in;
     hb_buffer_t * last = NULL, * out = NULL;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
index 99ed8be3600a034f402b43579b0dce1c0b8e18da..4f60f572212882be2dc0cc66fc784b1f403e829d 100644 (file)
@@ -165,7 +165,7 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_work_private_t * pv = w->private_data;
     hb_buffer_t * in = *buf_in;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         /* EOF on input stream - send it downstream & say that we're done */
         if ( pv->list_buffer == NULL )
index 3aec3a0bcff96721763f127b78189ec71b1f432b..4a974ac383e7d50340ec667d21892bb4bd45ce90 100644 (file)
@@ -439,7 +439,7 @@ static int decssaWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     printf("\nPACKET(%"PRId64",%"PRId64"): %.*s\n", in->s.start/90, in->s.stop/90, in->size, in->data);
 #endif
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
index 76dc3b67d907f57f7bf82688d111c2cf5042814f..9fe9ced6ca5be63b10bcc64831864a59d8e669d9 100644 (file)
@@ -267,7 +267,7 @@ static int dectx3gWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         hb_log( "dectx3gsub: subtitle packet lacks duration" );
     }
 
-    if (in->size == 0)
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
index 4461f1ef4687ed1db9a2e062f128a9f343a18a68..5a278c786240237d13bd84d45531747b64e316ef 100644 (file)
@@ -48,10 +48,15 @@ static int decutf8Work(hb_work_object_t * w,
                        hb_buffer_t **buf_in, hb_buffer_t **buf_out)
 {
     hb_work_private_t * pv = w->private_data;
-    // Pass the packets through without modification
+    hb_buffer_t * in = *buf_in;
     hb_buffer_t *out = *buf_in;
 
-    out->s.frametype = HB_FRAME_SUBTITLE;
+    *buf_in = NULL;
+    if (in->s.flags & HB_BUF_FLAG_EOF)
+    {
+        *buf_out = in;
+        return HB_WORK_DONE;
+    }
 
     // Warn if the subtitle's duration has not been passed through by the
     // demuxer, which will prevent the subtitle from displaying at all
@@ -61,12 +66,9 @@ static int decutf8Work(hb_work_object_t * w,
     }
 
     hb_srt_to_ssa(out, ++pv->line);
-
-    *buf_in  = NULL;
+    out->s.frametype = HB_FRAME_SUBTITLE;
     *buf_out = out;
 
-    if (out->size == 0)
-        return HB_WORK_DONE;
     return HB_WORK_OK;
 }
 
index 7109b506b7f82810e7710f37dfd223a2c51a0adb..fa247ab28bf058e768f97c3d2e899ec64ef64435 100644 (file)
@@ -97,7 +97,7 @@ int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_buffer_t * in = *buf_in;
     int size_sub, size_rle;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         /* EOF on input stream - send it downstream & say that we're done */
         *buf_out = in;
index dadbd397d8055e3b7728ee8eb7ab7955409a589f..0e8de8d8e986452537be5a0c223870e61a4b6478 100644 (file)
@@ -433,7 +433,7 @@ static hb_buffer_t * deint_fast(hb_filter_private_t * pv, hb_buffer_t * in)
     if (in == NULL)
     {
         // Flushing final buffers.  Append EOS marker buffer.
-        dst = hb_buffer_init(0);
+        dst = hb_buffer_eof_init();
         if (first == NULL)
         {
             first = dst;
@@ -583,7 +583,7 @@ static int hb_deinterlace_work( hb_filter_object_t * filter,
     hb_buffer_t * in = *buf_in;
     hb_buffer_t * last = NULL, * out = NULL;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
index dbeb9866481933d260c6ebaa6729a8d72e9a9963..8057b6c7df9093da7e13ccd42bd919f02e69b4e7 100644 (file)
@@ -334,7 +334,7 @@ static int hb_denoise_work( hb_filter_object_t * filter,
     hb_filter_private_t * pv = filter->private_data;
     hb_buffer_t * in = *buf_in, * out;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
index 0192860118b68257555324d2435713c1ceafb3bf..983db217f8f77e66988501fe36f1f8f19c4ba06c 100644 (file)
@@ -903,7 +903,7 @@ static int hb_detelecine_work( hb_filter_object_t * filter,
     hb_filter_private_t * pv = filter->private_data;
     hb_buffer_t * in = *buf_in, * out;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
index 8bd5fbcd76fc336e551609c5238f3161be309d43..91405eaeae0d0483165bcd37168ccf750363f5bf 100644 (file)
@@ -1744,7 +1744,7 @@ int encqsvWork(hb_work_object_t *w, hb_buffer_t **buf_in, hb_buffer_t **buf_out)
      * EOF on input. Flush the decoder, then send the
      * EOF downstream to let the muxer know we're done.
      */
-    if (in->size <= 0)
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         qsv_enc_work(pv, NULL, NULL);
         hb_list_add(pv->encoded_frames, in);
index 7b1c01ccca82f305f797590912692a7b3eb4bec8..856fff31a9940f51e9698b8572b9db63bd0a7661 100644 (file)
@@ -518,7 +518,7 @@ int encavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_job_t * job = pv->job;
     AVFrame  * frame;
     hb_buffer_t * in = *buf_in, * buf;
-    char final_flushing_call = (in->size <= 0);
+    char final_flushing_call = !!(in->s.flags & HB_BUF_FLAG_EOF);
     if ( final_flushing_call )
     {
         //make a flushing call to encode for codecs that can encode out of order
index 784ba5e2f5a3c7d3a708603b24a816aa34ad8370..78c99328609bca9f1dbaa7161e142fb4ce121339 100644 (file)
@@ -431,11 +431,11 @@ static hb_buffer_t * Flush( hb_work_object_t * w )
 
     if( last )
     {
-        last->next = hb_buffer_init( 0 );
+        last->next = hb_buffer_eof_init();
     }
     else
     {
-        first = hb_buffer_init( 0 );
+        first = hb_buffer_eof_init();
     }
 
     return first;
@@ -452,7 +452,7 @@ static int encavcodecaWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_work_private_t * pv = w->private_data;
     hb_buffer_t * in = *buf_in, * buf;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         /* EOF on input - send it downstream & say we're done */
         *buf_out = Flush( w );
index ef34b40f8f9cfe44f1aa79929bb31697f933d06b..0efe219060fcd195b54213d93293c524ccee834d 100644 (file)
@@ -186,7 +186,7 @@ int enclameWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_buffer_t * in = *buf_in;
     hb_buffer_t * buf;
 
-    if ( (*buf_in)->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         /* EOF on input - send it downstream & say we're done */
 
index 3b9dacebb2eb28908e8eea39c2fe340f1cbcc230..a49d7ff6beb8a008bc88894d7edb2149c491810b 100644 (file)
@@ -225,7 +225,7 @@ int enctheoraWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
 
     int frame_width, frame_height;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         // EOF on input - send it downstream & say we're done.
         // XXX may need to flush packets via a call to
index e9aefac265b30ca0c6181e8478ac3b6c0efabb6d..3994a491af6949bfe800331bbb8a1bf271dcd09b 100644 (file)
@@ -36,9 +36,9 @@ int encsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         // Invalid source, send EOF, this shouldn't ever happen
         hb_log("encvobsub: invalid subtitle source");
         hb_buffer_close( buf_in );
-        *buf_out = hb_buffer_init(0);
+        *buf_out = hb_buffer_eof_init();
     }
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         /* EOF on input stream - send it downstream & say that we're done */
         *buf_out = in;
index 226c8ff814e9ae9b09ffe1ec9a6f7a1e3ea97fe8..aee7b9d80a5f62187b54a46d5ed888fc7b9a6bd4 100644 (file)
@@ -256,21 +256,20 @@ int encvorbisWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
                    hb_buffer_t ** buf_out )
 {
     hb_work_private_t * pv = w->private_data;
+    hb_buffer_t * in = *buf_in;
     hb_buffer_t * buf;
 
-    if ( (*buf_in)->size <= 0 )
+    *buf_in = NULL;
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         /* EOF on input - send it downstream & say we're done */
-        *buf_out = *buf_in;
-        *buf_in = NULL;
+        *buf_out = in;
        return HB_WORK_DONE;
     }
 
     hb_list_add( pv->list, *buf_in );
-    *buf_in = NULL;
 
     *buf_out = buf = Encode( w );
-
     while( buf )
     {
         buf->next = Encode( w );
index ce7018278f5058103eafb85905a237050db5b100..a6989fcf5465d731c30a8c3644ce97cf31039278 100644 (file)
@@ -662,7 +662,7 @@ int encx264Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
 
     *buf_out = NULL;
 
-    if( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         // EOF on input. Flush any frames still in the decoder then
         // send the eof downstream to tell the muxer we're done.
index b09b0b4d275a5419fb2963f84fb80b3f017881b9..ba55ab7037ed883c1eb4e3458921ef7d4cd50311 100644 (file)
@@ -536,7 +536,7 @@ int encx265Work(hb_work_object_t *w, hb_buffer_t **buf_in, hb_buffer_t **buf_out
     hb_work_private_t *pv = w->private_data;
     hb_buffer_t       *in = *buf_in;
 
-    if (in->size <= 0)
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         uint32_t nnal;
         x265_nal *nal;
index f88c43bfb9b8c0e83a3105eac8fee47355ef8d0b..72c1c181fb3f42158eec2283ac33ce3022f27324 100644 (file)
@@ -447,6 +447,13 @@ hb_buffer_t * hb_buffer_init( int size )
     return hb_buffer_init_internal(size, 0);
 }
 
+hb_buffer_t * hb_buffer_eof_init(void)
+{
+    hb_buffer_t * buf = hb_buffer_init(0);
+    buf->s.flags = HB_BUF_FLAG_EOF;
+    return buf;
+}
+
 void hb_buffer_realloc( hb_buffer_t * b, int size )
 {
     if ( size > b->alloc || b->data == NULL )
index 85ceb747467d875e92c1a6a5e634d34624452f2f..30d8c24c892fc662e66d8aa2bea878c266534f95 100644 (file)
@@ -83,6 +83,19 @@ struct hb_buffer_settings_s
 #define HB_FRAME_KEY      0x0F
 #define HB_FRAME_REF      0xF0
     uint8_t       frametype;
+
+// Picture flags used by filters
+#ifndef PIC_FLAG_REPEAT_FIRST_FIELD
+#define PIC_FLAG_REPEAT_FIRST_FIELD 0x0100
+#endif
+#ifndef PIC_FLAG_TOP_FIELD_FIRST
+#define PIC_FLAG_TOP_FIELD_FIRST    0x0008
+#endif
+#ifndef PIC_FLAG_PROGRESSIVE_FRAME
+#define PIC_FLAG_PROGRESSIVE_FRAME  0x0010
+#endif
+#define PIC_FLAG_REPEAT_FRAME       0x0200
+#define HB_BUF_FLAG_EOF             0x0400
     uint16_t      flags;
 };
 
@@ -165,6 +178,7 @@ void hb_buffer_pool_init( void );
 void hb_buffer_pool_free( void );
 
 hb_buffer_t * hb_buffer_init( int size );
+hb_buffer_t * hb_buffer_eof_init( void );
 hb_buffer_t * hb_frame_buffer_init( int pix_fmt, int w, int h);
 void          hb_buffer_init_planes( hb_buffer_t * b );
 void          hb_buffer_realloc( hb_buffer_t *, int size );
@@ -458,19 +472,6 @@ extern hb_filter_object_t hb_filter_qsv_pre;
 extern hb_filter_object_t hb_filter_qsv_post;
 #endif
 
-// Picture flags used by filters
-#ifndef PIC_FLAG_REPEAT_FIRST_FIELD
-#define PIC_FLAG_REPEAT_FIRST_FIELD 256
-#endif
-#ifndef PIC_FLAG_TOP_FIELD_FIRST
-#define PIC_FLAG_TOP_FIELD_FIRST 8
-#endif
-#ifndef PIC_FLAG_PROGRESSIVE_FRAME
-#define PIC_FLAG_PROGRESSIVE_FRAME 16
-#endif
-
-#define PIC_FLAG_REPEAT_FRAME 512
-
 extern hb_work_object_t * hb_objects;
 
 #define HB_WORK_IDLE     0
index 9b15ee97a96a1dcd4085ae12e85cbb700d69a81e..afda745bee9be60bc9f5a8e64e0f677d5806e146 100644 (file)
@@ -366,7 +366,7 @@ static int muxWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         return HB_WORK_DONE;
     }
 
-    if ( buf->size <= 0 )
+    if (buf->s.flags & HB_BUF_FLAG_EOF)
     {
         // EOF - mark this track as done
         hb_buffer_close( &buf );
index e0aac23c7409fc5e7f6f79abc2c06e6019c53546..3e78ab95a5399b1fc4fb73e51a5889f2c080eff9 100644 (file)
@@ -1160,7 +1160,7 @@ static int nlmeans_work(hb_filter_object_t *filter,
     hb_filter_private_t *pv = filter->private_data;
     hb_buffer_t *in = *buf_in;
 
-    if (in->size <= 0)
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         hb_buffer_t *last;
         // Flush buffered frames
index e199f3640e45c80228ae4a354d47d843f2876327..96ee1f04db9d72ab6885c30203dbf024d8f84c94 100644 (file)
@@ -503,19 +503,19 @@ int encCoreAudioWork(hb_work_object_t *w, hb_buffer_t **buf_in,
                      hb_buffer_t **buf_out)
 {
     hb_work_private_t *pv = w->private_data;
+    hb_buffer_t * in = *buf_in;
     hb_buffer_t *buf;
 
-    if ((*buf_in)->size <= 0)
+    *buf_in = NULL;
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         // EOF on input. Finish encoding what we have buffered then send
         // it & the eof downstream.
-        *buf_out = Flush(w, *buf_in);
-        *buf_in = NULL;
+        *buf_out = Flush(w, in);
         return HB_WORK_DONE;
     }
 
-    hb_list_add(pv->list, *buf_in);
-    *buf_in = NULL;
+    hb_list_add(pv->list, in);
 
     *buf_out = buf = Encode(w);
 
index 8487865fea38ae98aa5e77e866eb8e2bfab8853a..87e10ee284eadd04b735e577857f7bbdfbf55469 100644 (file)
@@ -608,7 +608,7 @@ static int hb_qsv_filter_work( hb_filter_object_t * filter,
 
     *buf_in = NULL;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         while(1){
             sts = process_frame(in->qsv_details.qsv_atom, qsv, pv);
index e05050a2034d13c574cdc8ad60a00bb8ae5285dc..250e2b52cc92ff5d334b4f6ab043bd5becda096b 100644 (file)
@@ -445,7 +445,7 @@ static int hb_qsv_filter_pre_work( hb_filter_object_t * filter,
     if(!in->qsv_details.filter_details)
         in->qsv_details.filter_details = pv;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
@@ -559,7 +559,7 @@ static int hb_qsv_filter_post_work( hb_filter_object_t * filter,
     hb_buffer_t * in = *buf_in;
     hb_buffer_t * out = *buf_out;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
index 3e1c0c48b2189775f85b776d7256a18684ecbe61..d730c1f09d1954dec34adf6ad2c8bdf1a4fc6ae3 100644 (file)
@@ -735,20 +735,20 @@ void ReadLoop( void * _w )
     // send empty buffers downstream to video & audio decoders to signal we're done.
     if( !*r->die && !r->job->done )
     {
-        push_buf( r, r->job->fifo_mpeg2, hb_buffer_init(0) );
+        push_buf(r, r->job->fifo_mpeg2, hb_buffer_eof_init());
 
         hb_audio_t *audio;
         for( n = 0; (audio = hb_list_item( r->job->list_audio, n)); ++n )
         {
             if ( audio->priv.fifo_in )
-                push_buf( r, audio->priv.fifo_in, hb_buffer_init(0) );
+                push_buf(r, audio->priv.fifo_in, hb_buffer_eof_init());
         }
 
         hb_subtitle_t *subtitle;
         for( n = 0; (subtitle = hb_list_item( r->job->list_subtitle, n)); ++n )
         {
             if ( subtitle->fifo_in && subtitle->source == VOBSUB)
-                push_buf( r, subtitle->fifo_in, hb_buffer_init(0) );
+                push_buf(r, subtitle->fifo_in, hb_buffer_eof_init());
         }
     }
 
index 21d039b20286285619d77cf0c462e4d1321f97f7..3c17c4a01c592c6c7bfa343701e709d1982da802 100644 (file)
@@ -336,7 +336,7 @@ static int vobsub_work( hb_filter_object_t * filter,
     hb_buffer_t * in = *buf_in;
     hb_buffer_t * sub;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_in = NULL;
         *buf_out = in;
@@ -563,7 +563,7 @@ static int ssa_work( hb_filter_object_t * filter,
                                   filter->subtitle->extradata_size);
         pv->script_initialized = 1;
     }
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_in = NULL;
         *buf_out = in;
@@ -659,7 +659,7 @@ static int textsub_work(hb_filter_object_t * filter,
         pv->script_initialized = 1;
     }
 
-    if (in->size <= 0)
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_in = NULL;
         *buf_out = in;
@@ -817,7 +817,7 @@ static int pgssub_work( hb_filter_object_t * filter,
     hb_buffer_t * in = *buf_in;
     hb_buffer_t * sub;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_in = NULL;
         *buf_out = in;
index 81bd661b72bb94cf475b544ba650d3f03fee09ac..f67759ea42d20d3dedd8232492c649eddf0d9271 100644 (file)
@@ -337,7 +337,7 @@ static int hb_rotate_work( hb_filter_object_t * filter,
     hb_filter_private_t * pv = filter->private_data;
     hb_buffer_t * in = *buf_in, * out;
 
-    if ( in->size <= 0 )
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = in;
         *buf_in = NULL;
index 5713f6deeed5cf4c141e18f7ec814329472c2c59..166830a5d2a268c91272b35533406b25aff6b38d 100644 (file)
@@ -5712,12 +5712,9 @@ hb_buffer_t * hb_ffmpeg_read( hb_stream_t *stream )
         // following them to preserve the timing (since the packing puts two
         // or more frames in what looks like one avi frame). The contents and
         // size of these null frames are ignored by the ff_h263_decode_frame
-        // as long as they're < 20 bytes. We need a positive size so we use
-        // one byte if we're given a zero or negative size. We don't know
-        // if the pkt data points anywhere reasonable so we just stick a
-        // byte of zero in our outbound buf.
-        buf = hb_buffer_init( 1 );
-        *buf->data = 0;
+        // as long as they're < 20 bytes. Zero length buffers are also
+        // use by theora to indicate duplicate frames.
+        buf = hb_buffer_init( 0 );
     }
     else
     {
index d11fbd228080f7c564de17d37b10c1b8d9ae5a2d..594251b0d5cfa9182d6c9e91001b86d44abda7f7 100644 (file)
@@ -600,7 +600,7 @@ static void flushSubtitles(hb_work_private_t *pv)
         }
         if (subtitle->config.dest == PASSTHRUSUB)
         {
-            hb_fifo_push(subtitle->fifo_out, hb_buffer_init(0));
+            hb_fifo_push(subtitle->fifo_out, hb_buffer_eof_init());
         }
     }
 }
@@ -624,7 +624,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     next = *buf_in;
     *buf_in = NULL;
 
-    if (next->size == 0)
+    if (next->s.flags & HB_BUF_FLAG_EOF)
     {
         if (sync->cur != NULL)
         {
@@ -738,7 +738,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
                pv->common->count_frames);
         hb_buffer_close(&sync->cur);
         hb_buffer_close(&next);
-        *buf_out = hb_buffer_init(0);
+        *buf_out = hb_buffer_eof_init();
         flushSubtitles(pv);
         // Unblock anybody waiting on this threads last PTS
         setSyncPTS(pv, INT64_MAX, 0);
@@ -754,7 +754,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
                sync->cur->s.start);
         hb_buffer_close(&sync->cur);
         hb_buffer_close( &next );
-        *buf_out = hb_buffer_init(0);
+        *buf_out = hb_buffer_eof_init();
         flushSubtitles(pv);
         // Unblock anybody waiting on this threads last PTS
         setSyncPTS(pv, INT64_MAX, 0);
@@ -874,7 +874,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
         // muxer or renderer filter.
         while ( ( sub = hb_fifo_get( subtitle->fifo_raw ) ) != NULL )
         {
-            if (sub->size > 0)
+            if (!(next->s.flags & HB_BUF_FLAG_EOF))
             {
                 out = sanitizeSubtitle(pv, i, sub);
                 if (out != NULL)
@@ -1013,7 +1013,7 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     *buf_in = NULL;
 
     /* if the next buffer is an eof send it downstream */
-    if ( buf->size <= 0 )
+    if (buf->s.flags & HB_BUF_FLAG_EOF)
     {
         *buf_out = buf;
         // Unblock anybody waiting on this threads last PTS
@@ -1064,7 +1064,7 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     if (job->frame_to_stop && pv->common->count_frames >= job->frame_to_stop)
     {
         hb_buffer_close( &buf );
-        *buf_out = hb_buffer_init(0);
+        *buf_out = hb_buffer_eof_init();
         // Unblock anybody waiting on this threads last PTS
         setSyncPTS(pv, INT64_MAX, sync->index+1);
         return HB_WORK_DONE;
@@ -1072,7 +1072,7 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     if (job->pts_to_stop && sync->next_start >= job->pts_to_stop)
     {
         hb_buffer_close( &buf );
-        *buf_out = hb_buffer_init(0);
+        *buf_out = hb_buffer_eof_init();
         // Unblock anybody waiting on this threads last PTS
         setSyncPTS(pv, INT64_MAX, sync->index+1);
         return HB_WORK_DONE;
index 499d850596c398eefe21e2276841a9d726c6dd22..8f62c92419dff7a4279edc6aa5d2684473fde544 100644 (file)
@@ -469,7 +469,8 @@ static int hb_vfr_work( hb_filter_object_t * filter,
 
     *buf_in = NULL;
     *buf_out = NULL;
-    if( in->size <= 0 )
+
+    if (in->s.flags & HB_BUF_FLAG_EOF)
     {
         hb_buffer_t *head = NULL, *tail = NULL, *next;
         int counter = 2;