Changeset 85b124f08d43c01f060abfb4d30ee24246ac4b97

Show
Ignore:
Timestamp:
10/17/07 21:56:26 (11 months ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1192650986 +0000
git-parent:

[f75f9b5b367bf1b491f49e52b57d54a529e78839]

git-author:
Laurent Aimar <fenrir@videolan.org> 1192650986 +0000
Message:

Added cc data extraction support for mpeg 1/2 when the mpeg packetizer

is used. (Only dvb/atsc CC support is working)

Files:

Legend:

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

    r6ee1e19 r85b124f  
    4747#include <vlc_codec.h> 
    4848#include <vlc_block_helper.h> 
     49#include "../codec/cc.h" 
    4950 
    5051#define SYNC_INTRAFRAME_TEXT N_("Sync on Intra Frame") 
     
    7576static block_t *Packetize( decoder_t *, block_t ** ); 
    7677static block_t *ParseMPEGBlock( decoder_t *, block_t * ); 
     78static block_t *GetCc( decoder_t *p_dec, vlc_bool_t pb_present[4] ); 
    7779 
    7880struct decoder_sys_t 
     
    124126    vlc_bool_t  b_sync_on_intra_frame; 
    125127    vlc_bool_t  b_discontinuity; 
     128 
     129    /* */ 
     130    vlc_bool_t b_cc_reset; 
     131    uint32_t i_cc_flags; 
     132    mtime_t i_cc_pts; 
     133    cc_data_t cc; 
    126134}; 
    127135 
     
    148156    es_format_Init( &p_dec->fmt_out, VIDEO_ES, VLC_FOURCC('m','p','g','v') ); 
    149157    p_dec->pf_packetize = Packetize; 
     158    p_dec->pf_get_cc = GetCc; 
    150159 
    151160    p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) ); 
     
    189198    if( p_sys->b_sync_on_intra_frame ) 
    190199        msg_Dbg( p_dec, "syncing on intra frame now" ); 
     200 
     201    p_sys->b_cc_reset = VLC_FALSE; 
     202    p_sys->i_cc_pts = 0; 
     203    p_sys->i_cc_flags = 0; 
     204    cc_Init( &p_sys->cc ); 
    191205 
    192206    return VLC_SUCCESS; 
     
    369383 
    370384/***************************************************************************** 
     385 * GetCc: 
     386 *****************************************************************************/ 
     387static block_t *GetCc( decoder_t *p_dec, vlc_bool_t pb_present[4] ) 
     388{ 
     389    decoder_sys_t *p_sys = p_dec->p_sys; 
     390    block_t *p_cc; 
     391    int i; 
     392 
     393    for( i = 0; i < 4; i++ ) 
     394        pb_present[i] = p_sys->cc.pb_present[i]; 
     395 
     396    if( p_sys->cc.i_data <= 0 ) 
     397        return NULL; 
     398 
     399    p_cc = block_New( p_dec, p_sys->cc.i_data); 
     400    if( p_cc ) 
     401    { 
     402        memcpy( p_cc->p_buffer, p_sys->cc.p_data, p_sys->cc.i_data ); 
     403        p_cc->i_dts =  
     404        p_cc->i_pts = p_sys->i_cc_pts; 
     405        p_cc->i_flags = p_sys->i_cc_flags & ( BLOCK_FLAG_TYPE_I|BLOCK_FLAG_TYPE_P|BLOCK_FLAG_TYPE_B); 
     406    } 
     407    cc_Flush( &p_sys->cc ); 
     408    return p_cc; 
     409} 
     410 
     411/***************************************************************************** 
    371412 * ParseMPEGBlock: Re-assemble fragments into a block containing a picture 
    372413 *****************************************************************************/ 
     
    499540            p_sys->b_second_field = 0; 
    500541        } 
     542 
     543        /* CC */ 
     544        p_sys->b_cc_reset = VLC_TRUE; 
     545        p_sys->i_cc_pts = p_pic->i_pts; 
     546        p_sys->i_cc_flags = p_pic->i_flags; 
     547    } 
     548 
     549    if( !p_pic && p_sys->b_cc_reset ) 
     550    { 
     551        p_sys->b_cc_reset = VLC_FALSE; 
     552        cc_Flush( &p_sys->cc ); 
    501553    } 
    502554 
     
    619671        } 
    620672    } 
     673    else if( p_frag->p_buffer[3] == 0xb2 && p_frag->i_buffer > 4 ) 
     674    { 
     675        cc_Extract( &p_sys->cc, &p_frag->p_buffer[4], p_frag->i_buffer - 4 ); 
     676    } 
    621677    else if( p_frag->p_buffer[3] == 0x00 ) 
    622678    {