Changeset 4598f227ca9f8cb35d6a834577db17aaef1a608d

Show
Ignore:
Timestamp:
15/08/06 00:16:07 (2 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1155593767 +0000
git-parent:

[c72c4815bb525a54ecaae23a29e506e9af8b506c]

git-author:
Gildas Bazin <gbazin@videolan.org> 1155593767 +0000
Message:

* modules/packetizer/h264.c: insert an SPS and PPS before each keyframe.

Files:

Legend:

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

    r94431db r4598f22  
    285285        { 
    286286            case STATE_NOSYNC: 
    287                 /* Skip untill 3 byte startcode 0 0 1 */ 
     287                /* Skip until 3 byte startcode 0 0 1 */ 
    288288                if( block_FindStartcodeFromOffset( &p_sys->bytestream, 
    289289                      &p_sys->i_offset, p_sys->startcode+1, 3 ) == VLC_SUCCESS) 
     
    355355 * PacketizeAVC1: Takes VCL blocks of data and creates annexe B type NAL stream 
    356356 * Will always use 4 byte 0 0 0 1 startcodes 
    357  * Should prepend the SPS and PPS to the front of the stream  
     357 * Will prepend a SPS and PPS before each keyframe 
    358358 ****************************************************************************/ 
    359359static block_t *PacketizeAVC1( decoder_t *p_dec, block_t **pp_block ) 
     
    368368    p_block = *pp_block; 
    369369    *pp_block = NULL; 
    370  
    371 #if 0 
    372     if( //(p_block->i_flags & BLOCK_FLAG_TYPE_I) && 
    373         p_sys->p_sps && p_sys->p_pps ) 
    374     { 
    375         block_t *p_pic; 
    376         block_t *p_sps = block_Duplicate( p_sys->p_sps ); 
    377         block_t *p_pps = block_Duplicate( p_sys->p_pps ); 
    378         p_sps->i_dts = p_pps->i_dts = p_block->i_dts; 
    379         p_sps->i_pts = p_pps->i_pts = p_block->i_pts; 
    380         p_pic = ParseNALBlock( p_dec, p_sps ); 
    381         if( p_pic ) block_ChainAppend( &p_ret, p_pic ); 
    382         p_pic = ParseNALBlock( p_dec, p_pps ); 
    383         if( p_pic ) block_ChainAppend( &p_ret, p_pic ); 
    384     } 
    385 #endif 
    386370 
    387371    for( p = p_block->p_buffer; p < &p_block->p_buffer[p_block->i_buffer]; ) 
     
    491475 
    492476#define OUTPUT \ 
    493     do {                                                \ 
    494         p_pic = block_ChainGather( p_sys->p_frame );    \ 
    495         p_pic->i_length = 0;    /* FIXME */             \ 
    496                                                         \ 
    497         p_sys->p_frame = NULL;                          \ 
    498         p_sys->b_slice = VLC_FALSE;                     \ 
     477    do {                                                      \ 
     478        p_pic = block_ChainGather( p_sys->p_frame );          \ 
     479        p_pic->i_length = 0;    /* FIXME */                   \ 
     480                                                              \ 
     481        p_sys->p_frame = NULL;                                \ 
     482        p_sys->b_slice = VLC_FALSE;                           \ 
     483                                                              \ 
     484        if( ( p_pic->i_flags & BLOCK_FLAG_TYPE_I ) &&         \ 
     485              p_sys->p_sps && p_sys->p_pps )                  \ 
     486        {                                                     \ 
     487            block_t *p_sps = block_Duplicate( p_sys->p_sps ); \ 
     488            block_t *p_pps = block_Duplicate( p_sys->p_pps ); \ 
     489            p_sps->i_dts = p_pps->i_dts = p_pic->i_dts;       \ 
     490            p_sps->i_pts = p_pps->i_pts = p_pic->i_pts;       \ 
     491            block_ChainAppend( &p_sps, p_pps );               \ 
     492            block_ChainAppend( &p_sps, p_pic );               \ 
     493            p_pic = block_ChainGather( p_sps );               \ 
     494        }                                                     \ 
    499495    } while(0) 
    500496 
     
    550546                break; 
    551547        } 
     548        p_frag->i_flags |= i_pic_flags; 
    552549 
    553550        /* pic_parameter_set_id */ 
     
    710707        free( dec ); 
    711708 
    712  
    713709        if( p_sys->b_slice ) OUTPUT; 
     710 
     711        /* We have a new SPS */ 
     712        if( p_sys->p_sps ) block_Release( p_sys->p_sps ); 
     713        p_sys->p_sps = p_frag; 
     714 
     715        /* Do not append the SPS because we will insert it on keyframes */ 
     716        return p_pic; 
    714717    } 
    715718    else if( i_nal_type == NAL_PPS ) 
     
    724727 
    725728        if( p_sys->b_slice ) OUTPUT; 
     729 
     730        /* We have a new PPS */ 
     731        if( p_sys->p_pps ) block_Release( p_sys->p_pps ); 
     732        p_sys->p_pps = p_frag; 
     733 
     734        /* Do not append the PPS because we will insert it on keyframes */ 
     735        return p_pic; 
    726736    } 
    727737    else if( i_nal_type == NAL_AU_DELIMITER ||