From: Loren Merritt Date: Sat, 5 Mar 2005 09:34:53 +0000 (+0000) Subject: avc2avi: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d0bd44f769543e81280a5a97bbe985c6dfd86cf1;p=libx264 avc2avi: Use POC to determine frame boundaries (frame_num couldn't distinguish consecutive B-frames). Fix keyframe flag to mark IDR only, not all I slices. git-svn-id: svn://svn.videolan.org/x264/trunk@153 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/tools/avc2avi.c b/tools/avc2avi.c index 36f11c44..7f868094 100644 --- a/tools/avc2avi.c +++ b/tools/avc2avi.c @@ -130,9 +130,12 @@ typedef struct int i_ref_idc; int i_idr_pic_id; int i_frame_num; + int i_poc; int b_key; int i_log2_max_frame_num; + int i_poc_type; + int i_log2_max_poc_lsb; } h264_t; void h264_parser_init( h264_t * ); @@ -432,6 +435,8 @@ void h264_parser_init( h264_t *h ) h->i_idr_pic_id = -1; h->i_frame_num = -1; h->i_log2_max_frame_num = 0; + h->i_poc = -1; + h->i_poc_type = -1; } void h264_parser_parse( h264_t *h, nal_t *nal, int *pb_nal_start ) { @@ -452,13 +457,12 @@ void h264_parser_parse( h264_t *h, nal_t *nal, int *pb_nal_start ) /* Skip i_log2_max_frame_num */ h->i_log2_max_frame_num = bs_read_ue( &s ) + 4; /* Read poc_type */ - i_tmp = bs_read_ue( &s ); - if( i_tmp == 0 ) + h->i_poc_type = bs_read_ue( &s ); + if( h->i_poc_type == 0 ) { - /* skip i_log2_max_poc_lsb */ - bs_read_ue( &s ); + h->i_log2_max_poc_lsb = bs_read_ue( &s ) + 4; } - else if( i_tmp == 1 ) + else if( h->i_poc_type == 1 ) { int i_cycle; /* skip b_delta_pic_order_always_zero */ @@ -525,10 +529,8 @@ void h264_parser_parse( h264_t *h, nal_t *nal, int *pb_nal_start ) h->b_key = 0; break; case 2: case 7: /* I */ - h->b_key = 1; - break; - case 4: case 9: /* ? */ - h->b_key = 1; + case 4: case 9: /* SI */ + h->b_key = (nal->i_type == NAL_SLICE_IDR); break; } /* pps id */ @@ -550,6 +552,14 @@ void h264_parser_parse( h264_t *h, nal_t *nal, int *pb_nal_start ) h->i_idr_pic_id = i_tmp; } + + if( h->i_poc_type == 0 ) + { + i_tmp = bs_read( &s, h->i_log2_max_poc_lsb ); + if( i_tmp != h->i_poc ) + *pb_nal_start = 1; + h->i_poc = i_tmp; + } } h->i_nal_type = nal->i_type; h->i_ref_idc = nal->i_ref_idc;