Changeset ca42fbe0b485eac3a0990f1aba3b660253cdaf98

Show
Ignore:
Timestamp:
01/18/08 09:00:26 (7 months ago)
Author:
Jean-Paul Saman <jpsaman@videolan.org>
git-committer:
Jean-Paul Saman <jpsaman@videolan.org> 1200643226 +0000
git-parent:

[db4506a7ce6cd2c2c33131b1fad725d16807bcdc]

git-author:
Jean-Paul Saman <jpsaman@videolan.org> 1200643226 +0000
Message:

Check malloc return values and fix a few compiler warnings.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/packetizer/h264.c

    r2bf327d rca42fbe  
    246246        if( p_dec->fmt_out.i_extra ) free( p_dec->fmt_out.p_extra ); 
    247247        p_dec->fmt_out.i_extra = 0; p_dec->fmt_out.p_extra = NULL; 
    248   
     248 
    249249        /* Set the new extradata */ 
    250         p_dec->fmt_out.i_extra = p_sys->p_pps->i_buffer + p_sys->p_sps->i_buffer; 
    251250        p_dec->fmt_out.p_extra = (uint8_t*)malloc( p_dec->fmt_out.i_extra ); 
    252         memcpy( (uint8_t*)p_dec->fmt_out.p_extra, p_sys->p_sps->p_buffer, p_sys->p_sps->i_buffer); 
    253         memcpy( (uint8_t*)p_dec->fmt_out.p_extra+p_sys->p_sps->i_buffer, p_sys->p_pps->p_buffer, p_sys->p_pps->i_buffer); 
    254         p_sys->b_header = VLC_TRUE; 
    255  
     251        if( p_dec->fmt_out.p_extra ) 
     252        { 
     253            p_dec->fmt_out.i_extra = p_sys->p_pps->i_buffer + p_sys->p_sps->i_buffer; 
     254            memcpy( (uint8_t*)p_dec->fmt_out.p_extra, p_sys->p_sps->p_buffer, p_sys->p_sps->i_buffer); 
     255            memcpy( (uint8_t*)p_dec->fmt_out.p_extra+p_sys->p_sps->i_buffer, p_sys->p_pps->p_buffer, p_sys->p_pps->i_buffer); 
     256            p_sys->b_header = VLC_TRUE; 
     257        } 
    256258        /* Set callback */ 
    257259        p_dec->pf_packetize = PacketizeAVC1; 
     
    484486    uint8_t *dst = malloc( i_src ); 
    485487 
    486     *pp_ret = dst; 
    487  
    488     while( src < end ) 
    489     { 
    490         if( src < end - 3 && src[0] == 0x00 && src[1] == 0x00 && 
    491             src[2] == 0x03 ) 
    492         { 
    493             *dst++ = 0x00; 
    494             *dst++ = 0x00; 
    495  
    496             src += 3; 
    497             continue; 
    498         } 
    499         *dst++ = *src++; 
    500     } 
    501  
     488    if( dst ) 
     489    { 
     490        *pp_ret = dst; 
     491 
     492        while( src < end ) 
     493        { 
     494            if( src < end - 3 && src[0] == 0x00 && src[1] == 0x00 && 
     495                src[2] == 0x03 ) 
     496            { 
     497                *dst++ = 0x00; 
     498                *dst++ = 0x00; 
     499 
     500                src += 3; 
     501                continue; 
     502            } 
     503            *dst++ = *src++; 
     504        } 
     505    } 
    502506    *pi_ret = dst - *pp_ret; 
    503507} 
     
    520524    return val&0x01 ? (val+1)/2 : -(val/2); 
    521525} 
    522  
    523526 
    524527/***************************************************************************** 
     
    579582    else if( i_nal_type >= NAL_SLICE && i_nal_type <= NAL_SLICE_IDR ) 
    580583    { 
    581         uint8_t *dec
    582         int i_dec, i_first_mb, i_slice_type; 
     584        uint8_t *dec = NULL
     585        int i_dec = 0, i_first_mb, i_slice_type; 
    583586        slice_t slice; 
    584587        vlc_bool_t b_pic; 
     
    647650                slice.i_delta_pic_order_cnt_bottom = bs_read_se( &s ); 
    648651        } 
    649         else if( p_sys->i_pic_order_cnt_type == 1 && !p_sys->i_delta_pic_order_always_zero_flag ) 
     652        else if( (p_sys->i_pic_order_cnt_type == 1) && 
     653                 (!p_sys->i_delta_pic_order_always_zero_flag) ) 
    650654        { 
    651655            slice.i_delta_pic_order_cnt0 = bs_read_se( &s ); 
     
    662666            slice.i_nal_ref_idc != p_sys->slice.i_nal_ref_idc ) 
    663667            b_pic = VLC_TRUE; 
    664         if( slice.i_bottom_field_flag != -1 && p_sys->slice.i_bottom_field_flag != -1 && slice.i_bottom_field_flag != p_sys->slice.i_bottom_field_flag ) 
     668        if( (slice.i_bottom_field_flag != -1) && 
     669            (p_sys->slice.i_bottom_field_flag != -1) && 
     670            (slice.i_bottom_field_flag != p_sys->slice.i_bottom_field_flag) ) 
    665671            b_pic = VLC_TRUE; 
    666672        if( p_sys->i_pic_order_cnt_type == 0 && 
     
    688694    else if( i_nal_type == NAL_SPS ) 
    689695    { 
    690         uint8_t *dec
    691         int     i_dec
     696        uint8_t *dec = NULL
     697        int     i_dec = 0
    692698        bs_t s; 
    693699        int i_tmp;