Changeset 595

Show
Ignore:
Timestamp:
06/20/07 22:11:21 (1 year ago)
Author:
gbooker
Message:

Fixes for H.264 streams. Apparently, B slices don't always depend on future frames.

Also, I don't seem to have any h.264 files with out of order frames where each frame's data is stored by itself. So, I can't fully test this. Basically, I need:
1, 3, 2
instead of
132, -, -,

Anyone?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/FFusionCodec.c

    r594 r595  
    948948                 
    949949                drp->frameType = qtTypeForFrameInfo(drp->frameType, type, skippable); 
    950                 myDrp->frameData->frameNumber = p->frameNumber; 
    951                 myDrp->frameData->skippabble = skippable; 
     950                if(myDrp->frameData != NULL) 
     951                { 
     952                        myDrp->frameData->frameNumber = p->frameNumber; 
     953                        myDrp->frameData->skippabble = skippable; 
     954                } 
    952955                Codecprintf(glob->fileLog, "began frame %d as %d:%d\n", p->frameNumber, type, skippable); 
    953956        } 
  • trunk/bitstream_info.c

    r588 r595  
    138138                acl->mChannelLayoutTag = ac3_layout_no_lfe[acmod]; 
    139139         
     140        return 1; 
     141} 
     142 
     143static int parse_mpeg4_extra(FFusionParserContext *parser, const uint8_t *buf, int buf_size) 
     144{ 
     145        ParseContext1 *pc1 = (ParseContext1 *)parser->pc->priv_data; 
     146        pc1->pc.frame_start_found = 0; 
     147         
     148        MpegEncContext *s = pc1->enc; 
     149        GetBitContext gb1, *gb = &gb1; 
     150         
     151        s->avctx = parser->avctx; 
     152        s->current_picture_ptr = &s->current_picture; 
     153         
     154        init_get_bits(gb, buf, 8 * buf_size); 
     155        ff_mpeg4_decode_picture_header(s, gb); 
    140156        return 1; 
    141157} 
     
    208224        sizeof(uint64_t), 
    209225        NULL, 
    210         NULL
     226        parse_mpeg4_extra
    211227        parse_mpeg4_stream, 
    212228}; 
     
    216232        int is_avc; 
    217233        int nal_length_size; 
    218 #if 0 /*this was an attempt to figure out the PTS information and detect an out of order P frame before we hit its B frame */ 
    219234        int prevPts; 
    220 #endif 
    221235         
    222236        int poc_type; 
     
    226240 
    227241        int log2_max_poc_lsb; 
    228 #if 0 /*this was an attempt to figure out the PTS information and detect an out of order P frame before we hit its B frame */ 
    229242        int poc_msb; 
    230243        int prev_poc_lsb; 
    231 #endif 
    232244 
    233245        int delta_pic_order_always_zero_flag; 
     
    362374        GetBitContext getbit, *gb = &getbit; 
    363375        int slice_type; 
    364 #if 0 /*this was an attempt to figure out the PTS information and detect an out of order P frame before we hit its B frame */ 
    365376        int field_pic_flag = 0; 
    366377        int bottom_field_flag = 0; 
    367378        int frame_number; 
    368 #endif 
    369         static const uint8_t slice_type_map[5] = {FF_P_TYPE, FF_B_TYPE, FF_I_TYPE, FF_SP_TYPE, FF_SI_TYPE}; 
     379//      static const uint8_t slice_type_map[5] = {FF_P_TYPE, FF_B_TYPE, FF_I_TYPE, FF_SP_TYPE, FF_SI_TYPE}; 
     380        static const uint8_t slice_type_map[5] = {FF_P_TYPE, FF_P_TYPE, FF_I_TYPE, FF_SP_TYPE, FF_SI_TYPE}; 
    370381         
    371382        init_get_bits(gb, buf, 8 * buf_size); 
     
    382393        if(just_type) 
    383394                return 1; 
    384 #if 0 /*this was an attempt to figure out the PTS information and detect an out of order P frame before we hit its B frame */ 
    385395         
    386396        get_ue_golomb(gb); //pic_parameter_set_id 
     
    449459                *pts = expectedpoc + delta_pic_order_cnt[0]; 
    450460        } 
    451 #endif 
    452461         
    453462        return 1; 
     
    461470        int buf_index = 0; 
    462471        int ret = 0; 
    463         int pts_decoded = 1
     472        int pts_decoded = 0
    464473        int lowestType = 20; 
    465474         
     
    557566                                        if(nal_ref_idc) 
    558567                                                *skippable = 0; 
    559 #if 0 /*this was an attempt to figure out the PTS information and detect an out of order P frame before we hit its B frame */ 
    560568                                        if(pts_decoded == 0) 
    561569                                        { 
     
    563571                                                if(pts > context->prevPts) 
    564572                                                { 
    565                                                         if(pts > context->prevPts + 1) 
    566                                                                 *precedesAPastFrame = 1; 
    567                                                         else 
    568                                                                 *precedesAPastFrame = 0; 
     573                                                        if(pts < context->prevPts) 
     574                                                                lowestType = FF_B_TYPE; 
    569575                                                        context->prevPts = pts; 
    570576                                                } 
    571                                                 else 
    572                                                         *precedesAPastFrame = 0; 
    573577                                        } 
    574 #endif 
    575578                                } 
    576579                        }