Changeset 85b124f08d43c01f060abfb4d30ee24246ac4b97
- 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
| r6ee1e19 |
r85b124f |
|
| 47 | 47 | #include <vlc_codec.h> |
|---|
| 48 | 48 | #include <vlc_block_helper.h> |
|---|
| | 49 | #include "../codec/cc.h" |
|---|
| 49 | 50 | |
|---|
| 50 | 51 | #define SYNC_INTRAFRAME_TEXT N_("Sync on Intra Frame") |
|---|
| … | … | |
| 75 | 76 | static block_t *Packetize( decoder_t *, block_t ** ); |
|---|
| 76 | 77 | static block_t *ParseMPEGBlock( decoder_t *, block_t * ); |
|---|
| | 78 | static block_t *GetCc( decoder_t *p_dec, vlc_bool_t pb_present[4] ); |
|---|
| 77 | 79 | |
|---|
| 78 | 80 | struct decoder_sys_t |
|---|
| … | … | |
| 124 | 126 | vlc_bool_t b_sync_on_intra_frame; |
|---|
| 125 | 127 | 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; |
|---|
| 126 | 134 | }; |
|---|
| 127 | 135 | |
|---|
| … | … | |
| 148 | 156 | es_format_Init( &p_dec->fmt_out, VIDEO_ES, VLC_FOURCC('m','p','g','v') ); |
|---|
| 149 | 157 | p_dec->pf_packetize = Packetize; |
|---|
| | 158 | p_dec->pf_get_cc = GetCc; |
|---|
| 150 | 159 | |
|---|
| 151 | 160 | p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) ); |
|---|
| … | … | |
| 189 | 198 | if( p_sys->b_sync_on_intra_frame ) |
|---|
| 190 | 199 | 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 ); |
|---|
| 191 | 205 | |
|---|
| 192 | 206 | return VLC_SUCCESS; |
|---|
| … | … | |
| 369 | 383 | |
|---|
| 370 | 384 | /***************************************************************************** |
|---|
| | 385 | * GetCc: |
|---|
| | 386 | *****************************************************************************/ |
|---|
| | 387 | static 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 | /***************************************************************************** |
|---|
| 371 | 412 | * ParseMPEGBlock: Re-assemble fragments into a block containing a picture |
|---|
| 372 | 413 | *****************************************************************************/ |
|---|
| … | … | |
| 499 | 540 | p_sys->b_second_field = 0; |
|---|
| 500 | 541 | } |
|---|
| | 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 ); |
|---|
| 501 | 553 | } |
|---|
| 502 | 554 | |
|---|
| … | … | |
| 619 | 671 | } |
|---|
| 620 | 672 | } |
|---|
| | 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 | } |
|---|
| 621 | 677 | else if( p_frag->p_buffer[3] == 0x00 ) |
|---|
| 622 | 678 | { |
|---|