]> git.sesse.net Git - vlc/blobdiff - modules/packetizer/h264.c
Some more format strings
[vlc] / modules / packetizer / h264.c
index 4cd4d65f35ba82aca6cc119d4fdcbeb2b696923c..158bdea2f6619af8d5eeb76a9a156ced3960bca0 100644 (file)
@@ -84,6 +84,7 @@ struct decoder_sys_t
     int i_nal_ref_idc;
     int i_idr_pic_id;
     int i_frame_num;
+    int i_frame_type;
 };
 
 enum
@@ -133,6 +134,7 @@ static int Open( vlc_object_t *p_this )
         p_dec->fmt_in.i_codec != VLC_FOURCC( 'H', '2', '6', '4') &&
         p_dec->fmt_in.i_codec != VLC_FOURCC( 'V', 'S', 'S', 'H') &&
         p_dec->fmt_in.i_codec != VLC_FOURCC( 'v', 's', 's', 'h') &&
+        p_dec->fmt_in.i_codec != VLC_FOURCC( 'D', 'A', 'V', 'C') &&
         ( p_dec->fmt_in.i_codec != VLC_FOURCC( 'a', 'v', 'c', '1') ||
           p_dec->fmt_in.i_extra < 7 ) )
     {
@@ -163,6 +165,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_nal_ref_idc = -1;
     p_sys->i_idr_pic_id = -1;
     p_sys->i_frame_num = -1;
+    p_sys->i_frame_type = 0;
 
     /* Setup properties */
     es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
@@ -215,8 +218,8 @@ static int Open( vlc_object_t *p_this )
         /* Set the new extradata */
         p_dec->fmt_out.i_extra = p_sys->p_pps->i_buffer + p_sys->p_sps->i_buffer;
         p_dec->fmt_out.p_extra = (uint8_t*)malloc( p_dec->fmt_out.i_extra );
-        memcpy( p_dec->fmt_out.p_extra, p_sys->p_pps->p_buffer, p_sys->p_pps->i_buffer);
-        memcpy( p_dec->fmt_out.p_extra+p_sys->p_pps->i_buffer, p_sys->p_sps->p_buffer, p_sys->p_sps->i_buffer);
+        memcpy( p_dec->fmt_out.p_extra, p_sys->p_sps->p_buffer, p_sys->p_sps->i_buffer);
+        memcpy( p_dec->fmt_out.p_extra+p_sys->p_sps->i_buffer, p_sys->p_pps->p_buffer, p_sys->p_pps->i_buffer);
 
         /* Set callback */
         p_dec->pf_packetize = PacketizeAVC1;
@@ -477,7 +480,9 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
     do {                                                      \
         p_pic = block_ChainGather( p_sys->p_frame );          \
         p_pic->i_length = 0;    /* FIXME */                   \
+        p_pic->i_flags |= p_sys->i_frame_type;                \
                                                               \
+        p_sys->i_frame_type = 0;                              \
         p_sys->p_frame = NULL;                                \
         p_sys->b_slice = VLC_FALSE;                           \
                                                               \
@@ -514,7 +519,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
     else if( i_nal_type >= NAL_SLICE && i_nal_type <= NAL_SLICE_IDR )
     {
         uint8_t *dec;
-        int i_dec, i_first_mb, i_slice_type, i_frame_num, i_pic_flags = 0;
+        int i_dec, i_first_mb, i_slice_type, i_frame_num;
         vlc_bool_t b_pic = VLC_FALSE;
         bs_t s;
 
@@ -529,23 +534,22 @@ static block_t *ParseNALBlock( decoder_t *p_dec, block_t *p_frag )
         /* slice_type */
         switch( (i_slice_type = bs_read_ue( &s )) )
         {
-            case 0: case 5:
-                i_pic_flags = BLOCK_FLAG_TYPE_P;
-                break;
-            case 1: case 6:
-                i_pic_flags = BLOCK_FLAG_TYPE_B;
-                break;
-            case 2: case 7:
-                i_pic_flags = BLOCK_FLAG_TYPE_I;
-                break;
-            case 3: case 8: /* SP */
-                i_pic_flags = BLOCK_FLAG_TYPE_P;
-                break;
-            case 4: case 9:
-                i_pic_flags = BLOCK_FLAG_TYPE_I;
-                break;
+        case 0: case 5:
+            p_sys->i_frame_type = BLOCK_FLAG_TYPE_P;
+            break;
+        case 1: case 6:
+            p_sys->i_frame_type = BLOCK_FLAG_TYPE_B;
+            break;
+        case 2: case 7:
+            p_sys->i_frame_type = BLOCK_FLAG_TYPE_I;
+            break;
+        case 3: case 8: /* SP */
+            p_sys->i_frame_type = BLOCK_FLAG_TYPE_P;
+            break;
+        case 4: case 9:
+            p_sys->i_frame_type = BLOCK_FLAG_TYPE_I;
+            break;
         }
-        p_frag->i_flags |= i_pic_flags;
 
         /* pic_parameter_set_id */
         bs_read_ue( &s );