+/*****************************************************************************
+ * GetCc:
+ *****************************************************************************/
+static block_t *GetCc( decoder_t *p_dec, bool pb_present[4] )
+{
+ decoder_sys_t *p_sys = p_dec->p_sys;
+ block_t *p_cc;
+
+ for( int i = 0; i < 4; i++ )
+ pb_present[i] = p_sys->cc.pb_present[i];
+
+ if( p_sys->cc.i_data <= 0 )
+ return NULL;
+
+ p_cc = block_Alloc( p_sys->cc.i_data);
+ if( p_cc )
+ {
+ memcpy( p_cc->p_buffer, p_sys->cc.p_data, p_sys->cc.i_data );
+ p_cc->i_dts =
+ p_cc->i_pts = p_sys->cc.b_reorder ? p_sys->i_cc_pts : p_sys->i_cc_dts;
+ p_cc->i_flags = ( p_sys->cc.b_reorder ? p_sys->i_cc_flags : BLOCK_FLAG_TYPE_P ) & BLOCK_FLAG_TYPE_MASK;
+ }
+ cc_Flush( &p_sys->cc );
+ return p_cc;
+}
+
+/****************************************************************************
+ * Helpers
+ ****************************************************************************/
+static void PacketizeReset( void *p_private, bool b_broken )
+{
+ decoder_t *p_dec = p_private;
+ decoder_sys_t *p_sys = p_dec->p_sys;
+
+ if( b_broken )
+ {
+ if( p_sys->p_frame )
+ block_ChainRelease( p_sys->p_frame );
+ p_sys->p_frame = NULL;
+ p_sys->b_frame_sps = false;
+ p_sys->b_frame_pps = false;
+ p_sys->slice.i_frame_type = 0;
+ p_sys->b_slice = false;
+ }
+ p_sys->i_frame_pts = VLC_TS_INVALID;
+ p_sys->i_frame_dts = VLC_TS_INVALID;
+}
+static block_t *PacketizeParse( void *p_private, bool *pb_ts_used, block_t *p_block )
+{
+ decoder_t *p_dec = p_private;
+
+ /* Remove trailing 0 bytes */
+ while( p_block->i_buffer > 5 && p_block->p_buffer[p_block->i_buffer-1] == 0x00 )
+ p_block->i_buffer--;
+
+ return ParseNALBlock( p_dec, pb_ts_used, p_block );
+}
+static int PacketizeValidate( void *p_private, block_t *p_au )
+{
+ VLC_UNUSED(p_private);
+ VLC_UNUSED(p_au);
+ return VLC_SUCCESS;
+}
+
+static block_t *CreateAnnexbNAL( decoder_t *p_dec, const uint8_t *p, int i_size )