[vlc-commits] packetizer: hxxx: allow early stop in SEI parsing

Francois Cartegnie git at videolan.org
Fri Oct 7 16:33:30 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Oct  6 14:38:05 2016 +0200| [fb57b0dbc349db23823961f746e6fc425d1490b2] | committer: Francois Cartegnie

packetizer: hxxx: allow early stop in SEI parsing

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

 modules/packetizer/h264.c     | 5 +++--
 modules/packetizer/hxxx_sei.c | 9 +++++----
 modules/packetizer/hxxx_sei.h | 2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index f011a93..169888e 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -167,7 +167,7 @@ static void PutSPS( decoder_t *p_dec, block_t *p_frag );
 static void PutPPS( decoder_t *p_dec, block_t *p_frag );
 static bool ParseSlice( decoder_t *p_dec, bool *pb_new_picture, slice_t *p_slice,
                         int i_nal_ref_idc, int i_nal_type, const block_t *p_frag );
-static void ParseSeiCallback( const hxxx_sei_data_t *, void * );
+static bool ParseSeiCallback( const hxxx_sei_data_t *, void * );
 
 
 static const uint8_t p_h264_startcode[3] = { 0x00, 0x00, 0x01 };
@@ -950,7 +950,7 @@ static bool ParseSlice( decoder_t *p_dec, bool *pb_new_picture, slice_t *p_slice
     return true;
 }
 
-static void ParseSeiCallback( const hxxx_sei_data_t *p_sei_data, void *cbdata )
+static bool ParseSeiCallback( const hxxx_sei_data_t *p_sei_data, void *cbdata )
 {
     decoder_t *p_dec = (decoder_t *) cbdata;
     decoder_sys_t *p_sys = p_dec->p_sys;
@@ -993,5 +993,6 @@ static void ParseSeiCallback( const hxxx_sei_data_t *p_sei_data, void *cbdata )
             break;
     }
 
+    return true;
 }
 
diff --git a/modules/packetizer/hxxx_sei.c b/modules/packetizer/hxxx_sei.c
index c0238ce..85a59ed 100644
--- a/modules/packetizer/hxxx_sei.c
+++ b/modules/packetizer/hxxx_sei.c
@@ -40,6 +40,7 @@ void HxxxParseSEI(const uint8_t *p_buf, size_t i_buf,
 {
     bs_t s;
     unsigned i_bitflow = 0;
+    bool b_continue = true;
 
     if( i_buf <= i_header )
         return;
@@ -48,7 +49,7 @@ void HxxxParseSEI(const uint8_t *p_buf, size_t i_buf,
     s.p_fwpriv = &i_bitflow;
     s.pf_forward = hxxx_bsfw_ep3b_to_rbsp;  /* Does the emulated 3bytes conversion to rbsp */
 
-    while( bs_remain( &s ) >= 8 && bs_aligned( &s ) )
+    while( bs_remain( &s ) >= 8 && bs_aligned( &s ) && b_continue )
     {
         /* Read type */
         unsigned i_type = 0;
@@ -85,7 +86,7 @@ void HxxxParseSEI(const uint8_t *p_buf, size_t i_buf,
             case HXXX_SEI_PIC_TIMING:
             {
                 sei_data.p_bs = &s;
-                pf_callback( &sei_data, cbdata );
+                b_continue = pf_callback( &sei_data, cbdata );
             } break;
 
             /* Look for user_data_registered_itu_t_t35 */
@@ -120,7 +121,7 @@ void HxxxParseSEI(const uint8_t *p_buf, size_t i_buf,
                 {
                     sei_data.itu_t35.i_cc = i_t35 - 3;
                     sei_data.itu_t35.p_cc = &p_t35[3];
-                    pf_callback( &sei_data, cbdata );
+                    b_continue = pf_callback( &sei_data, cbdata );
                 }
 
                 free( p_t35 );
@@ -133,7 +134,7 @@ void HxxxParseSEI(const uint8_t *p_buf, size_t i_buf,
                 //bool b_exact_match = bs_read( &s, 1 );
                 //bool b_broken_link = bs_read( &s, 1 );
                 //int i_changing_slice_group = bs_read( &s, 2 );
-                pf_callback( &sei_data, cbdata );
+                b_continue = pf_callback( &sei_data, cbdata );
             } break;
 
             default:
diff --git a/modules/packetizer/hxxx_sei.h b/modules/packetizer/hxxx_sei.h
index a51d6e2..6189c17 100644
--- a/modules/packetizer/hxxx_sei.h
+++ b/modules/packetizer/hxxx_sei.h
@@ -46,7 +46,7 @@ typedef struct
     };
 } hxxx_sei_data_t;
 
-typedef void (*pf_hxxx_sei_callback)(const hxxx_sei_data_t *, void *);
+typedef bool (*pf_hxxx_sei_callback)(const hxxx_sei_data_t *, void *);
 void HxxxParseSEI(const uint8_t *, size_t, uint8_t, pf_hxxx_sei_callback, void *);
 void HxxxParse_AnnexB_SEI(const uint8_t *, size_t, uint8_t, pf_hxxx_sei_callback, void *);
 



More information about the vlc-commits mailing list