Changeset 396d77133092ff6a127824ac3a669192e8a8b07d
- Timestamp:
- 08/10/05 22:07:20
(3 years ago)
- Author:
- Jean-Paul Saman <jpsaman@videolan.org>
- git-committer:
- Jean-Paul Saman <jpsaman@videolan.org> 1123704440 +0000
- git-parent:
[af44196ee69a672807560c64b3a3359e8101ff17]
- git-author:
- Jean-Paul Saman <jpsaman@videolan.org> 1123704440 +0000
- Message:
Flagging BLOCK_FLAG_DISCONTINUITY for every PID in the input when the slider is moved on the GUI or a jump in the stream is made. It is also propagated to the mpegvideo packetizer. The packetizer has a new mode to sync on I-frame boundary after such a jump. It avoids sending some broken frames to the client. (Forward port of branches/0.8.1-jpsaman-thedj revision 11067 and 11842.)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rfafb8f9 |
r396d771 |
|
| 2 | 2 | * ts.c: Transport Stream input module for VLC. |
|---|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | | * Copyright (C) 2004-2005 the VideoLAN team |
|---|
| | 4 | * Copyright (C) 2004-2005 VideoLAN (Centrale Réseaux) and its contributors |
|---|
| 5 | 5 | * $Id$ |
|---|
| 6 | 6 | * |
|---|
| … | … | |
| 1614 | 1614 | const vlc_bool_t b_payload = p[3]&0x10; |
|---|
| 1615 | 1615 | const int i_cc = p[3]&0x0f; /* continuity counter */ |
|---|
| | 1616 | vlc_bool_t b_discontinuity = VLC_FALSE;/* discontinuity */ |
|---|
| 1616 | 1617 | |
|---|
| 1617 | 1618 | /* transport_scrambling_control is ignored */ |
|---|
| 1618 | | |
|---|
| 1619 | 1619 | int i_skip = 0; |
|---|
| 1620 | 1620 | vlc_bool_t i_ret = VLC_FALSE; |
|---|
| … | … | |
| 1661 | 1661 | "ignored", pid->i_pid ); |
|---|
| 1662 | 1662 | } |
|---|
| | 1663 | /* discontinuity indicator found in stream */ |
|---|
| | 1664 | b_discontinuity = p[5]&0x80 ? VLC_TRUE : VLC_FALSE; |
|---|
| | 1665 | if( p[5]&0x40 ) |
|---|
| | 1666 | msg_Dbg( p_demux, "random access indicator (pid=%d) ", pid->i_pid ); |
|---|
| 1663 | 1667 | } |
|---|
| 1664 | 1668 | } |
|---|
| … | … | |
| 1671 | 1675 | * test the content ? |
|---|
| 1672 | 1676 | */ |
|---|
| 1673 | | |
|---|
| 1674 | 1677 | i_diff = ( i_cc - pid->i_cc )&0x0f; |
|---|
| 1675 | 1678 | if( b_payload && i_diff == 1 ) |
|---|
| … | … | |
| 1685 | 1688 | pid->i_cc = i_cc; |
|---|
| 1686 | 1689 | } |
|---|
| 1687 | | else if( i_diff != 0 ) |
|---|
| | 1690 | else if( i_diff != 0 && !b_discontinuity ) |
|---|
| 1688 | 1691 | { |
|---|
| 1689 | 1692 | /* FIXME what to do when discontinuity_indicator is set ? */ |
|---|
| … | … | |
| 1692 | 1695 | |
|---|
| 1693 | 1696 | pid->i_cc = i_cc; |
|---|
| 1694 | | |
|---|
| 1695 | 1697 | if( pid->es->p_pes && pid->es->fmt.i_cat != VIDEO_ES ) |
|---|
| 1696 | 1698 | { |
|---|
| … | … | |
| 1758 | 1760 | } |
|---|
| 1759 | 1761 | } |
|---|
| 1760 | | |
|---|
| | 1762 | |
|---|
| | 1763 | if( b_discontinuity && pid->es->p_pes ) |
|---|
| | 1764 | { |
|---|
| | 1765 | msg_Warn( p_demux, "discontinuity indicator (pid=%d) ", |
|---|
| | 1766 | pid->i_pid ); |
|---|
| | 1767 | pid->es->p_pes->i_flags |= BLOCK_FLAG_DISCONTINUITY; |
|---|
| | 1768 | } |
|---|
| 1761 | 1769 | return i_ret; |
|---|
| 1762 | 1770 | } |
|---|
| … | … | |
| 1950 | 1958 | if( i_iod_tag != 0x02 ) |
|---|
| 1951 | 1959 | { |
|---|
| | 1960 | #ifdef DEBUG |
|---|
| 1952 | 1961 | fprintf( stderr, "\n ERR: tag %02x != 0x02", i_iod_tag ); |
|---|
| | 1962 | #endif |
|---|
| 1953 | 1963 | return p_iod; |
|---|
| 1954 | 1964 | } |
|---|
| r32b36df |
r396d771 |
|
| 2 | 2 | * ts.c: MPEG-II TS Muxer |
|---|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | | * Copyright (C) 2001, 2002 the VideoLAN team |
|---|
| | 4 | * Copyright (C) 2001-2005 VideoLAN (Centrale Réseaux) and its contributors |
|---|
| 5 | 5 | * $Id$ |
|---|
| 6 | 6 | * |
|---|
| … | … | |
| 271 | 271 | int i_stream_id; |
|---|
| 272 | 272 | int i_continuity_counter; |
|---|
| | 273 | vlc_bool_t b_discontinuity; |
|---|
| 273 | 274 | |
|---|
| 274 | 275 | /* to be used for carriege of DIV3 */ |
|---|
| … | … | |
| 654 | 655 | p_stream->i_codec = p_input->p_fmt->i_codec; |
|---|
| 655 | 656 | p_stream->i_continuity_counter = 0; |
|---|
| | 657 | p_stream->b_discontinuity = VLC_FALSE; |
|---|
| 656 | 658 | p_stream->i_decoder_specific_info = 0; |
|---|
| 657 | 659 | p_stream->p_decoder_specific_info = NULL; |
|---|
| … | … | |
| 1569 | 1571 | |
|---|
| 1570 | 1572 | p_stream->i_continuity_counter = (p_stream->i_continuity_counter+1)%16; |
|---|
| | 1573 | p_stream->b_discontinuity = (p_pes->i_flags & BLOCK_FLAG_DISCONTINUITY); |
|---|
| 1571 | 1574 | |
|---|
| 1572 | 1575 | if( b_adaptation_field ) |
|---|
| … | … | |
| 1582 | 1585 | p_ts->p_buffer[4] = 7 + i_stuffing; |
|---|
| 1583 | 1586 | p_ts->p_buffer[5] = 0x10; /* flags */ |
|---|
| | 1587 | if( p_stream->b_discontinuity ) |
|---|
| | 1588 | { |
|---|
| | 1589 | p_ts->p_buffer[5] |= 0x80; /* flag TS dicontinuity */ |
|---|
| | 1590 | p_stream->b_discontinuity = VLC_FALSE; |
|---|
| | 1591 | } |
|---|
| 1584 | 1592 | p_ts->p_buffer[6] = ( 0 )&0xff; |
|---|
| 1585 | 1593 | p_ts->p_buffer[7] = ( 0 )&0xff; |
|---|
| … | … | |
| 1646 | 1654 | return p_ts; |
|---|
| 1647 | 1655 | } |
|---|
| 1648 | | |
|---|
| 1649 | 1656 | |
|---|
| 1650 | 1657 | static void TSSetPCR( block_t *p_ts, mtime_t i_dts ) |
|---|
| … | … | |
| 1801 | 1808 | { |
|---|
| 1802 | 1809 | p_ts->p_buffer[5] = 0x00; |
|---|
| | 1810 | if( p_stream->b_discontinuity ) |
|---|
| | 1811 | { |
|---|
| | 1812 | p_ts->p_buffer[5] |= 0x80; |
|---|
| | 1813 | p_stream->b_discontinuity = VLC_FALSE; |
|---|
| | 1814 | } |
|---|
| 1803 | 1815 | for( i = 6; i < 6 + i_stuffing - 2; i++ ) |
|---|
| 1804 | 1816 | { |
|---|
| r130e829 |
r396d771 |
|
| 2 | 2 | * mpegvideo.c: parse and packetize an MPEG1/2 video stream |
|---|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | | * Copyright (C) 2001, 2002 the VideoLAN team |
|---|
| | 4 | * Copyright (C) 2001-2005 VideoLAN (Centrale Réseaux) and its contributors |
|---|
| 5 | 5 | * $Id$ |
|---|
| 6 | 6 | * |
|---|
| … | … | |
| 8 | 8 | * Eric Petit <titer@videolan.org> |
|---|
| 9 | 9 | * Gildas Bazin <gbazin@videolan.org> |
|---|
| | 10 | * Jean-Paul Saman <jpsaman #_at_# m2x dot nl> |
|---|
| 10 | 11 | * |
|---|
| 11 | 12 | * This program is free software; you can redistribute it and/or modify |
|---|
| … | … | |
| 49 | 50 | #include "vlc_block_helper.h" |
|---|
| 50 | 51 | |
|---|
| | 52 | #define SYNC_INTRAFRAME_TEXT N_("Sync on intraframe") |
|---|
| | 53 | #define SYNC_INTRAFRAME_LONGTEXT N_("Normally the packetizer would " \ |
|---|
| | 54 | "sync on the next full frame. This flags instructs the packetizer " \ |
|---|
| | 55 | "to sync on the first intraframe found.") |
|---|
| | 56 | |
|---|
| 51 | 57 | /***************************************************************************** |
|---|
| 52 | 58 | * Module descriptor |
|---|
| … | … | |
| 61 | 67 | set_capability( "packetizer", 50 ); |
|---|
| 62 | 68 | set_callbacks( Open, Close ); |
|---|
| | 69 | |
|---|
| | 70 | add_bool( "packetizer-mpegvideo-sync-iframe", 1, NULL, SYNC_INTRAFRAME_TEXT, |
|---|
| | 71 | SYNC_INTRAFRAME_LONGTEXT, VLC_TRUE ); |
|---|
| 63 | 72 | vlc_module_end(); |
|---|
| 64 | 73 | |
|---|
| … | … | |
| 113 | 122 | /* Number of pictures since last sequence header */ |
|---|
| 114 | 123 | int i_seq_old; |
|---|
| 115 | | |
|---|
| | 124 | |
|---|
| | 125 | /* Sync behaviour */ |
|---|
| | 126 | vlc_bool_t b_sync_on_intra_frame; |
|---|
| | 127 | vlc_bool_t b_discontinuity; |
|---|
| 116 | 128 | }; |
|---|
| 117 | 129 | |
|---|
| … | … | |
| 175 | 187 | p_sys->i_last_ref_pts = 0; |
|---|
| 176 | 188 | |
|---|
| | 189 | p_sys->b_discontinuity = VLC_FALSE; |
|---|
| | 190 | p_sys->b_sync_on_intra_frame = var_CreateGetBool( p_dec, "packetizer-mpegvideo-sync-iframe" ); |
|---|
| | 191 | if( p_sys->b_sync_on_intra_frame ) |
|---|
| | 192 | msg_Dbg( p_dec, "syncing happens on intraframe now." ); |
|---|
| | 193 | |
|---|
| 177 | 194 | return VLC_SUCCESS; |
|---|
| 178 | 195 | } |
|---|
| … | … | |
| 200 | 217 | block_ChainRelease( p_sys->p_frame ); |
|---|
| 201 | 218 | } |
|---|
| | 219 | |
|---|
| | 220 | var_Destroy( p_dec, "packetizer-mpegvideo-sync-iframe" ); |
|---|
| 202 | 221 | |
|---|
| 203 | 222 | free( p_sys ); |
|---|
| … | … | |
| 220 | 239 | { |
|---|
| 221 | 240 | p_sys->i_state = STATE_NOSYNC; |
|---|
| 222 | | if( p_sys->p_frame ) block_ChainRelease( p_sys->p_frame ); |
|---|
| | 241 | p_sys->b_discontinuity = VLC_TRUE; |
|---|
| | 242 | if( p_sys->p_frame ) |
|---|
| | 243 | block_ChainRelease( p_sys->p_frame ); |
|---|
| 223 | 244 | p_sys->p_frame = NULL; |
|---|
| 224 | 245 | p_sys->pp_last = &p_sys->p_frame; |
|---|
| … | … | |
| 295 | 316 | } |
|---|
| 296 | 317 | |
|---|
| | 318 | /* If a discontinuity has been encountered, then wait till |
|---|
| | 319 | * the next Intra frame before continuing with packetizing */ |
|---|
| | 320 | if( p_sys->b_discontinuity && |
|---|
| | 321 | p_sys->b_sync_on_intra_frame ) |
|---|
| | 322 | { |
|---|
| | 323 | if( p_pic->i_flags & BLOCK_FLAG_TYPE_I ) |
|---|
| | 324 | { |
|---|
| | 325 | msg_Dbg( p_dec, "synced on Intra frame" ); |
|---|
| | 326 | p_sys->b_discontinuity = VLC_FALSE; |
|---|
| | 327 | p_pic->i_flags |= BLOCK_FLAG_DISCONTINUITY; |
|---|
| | 328 | } |
|---|
| | 329 | else |
|---|
| | 330 | { |
|---|
| | 331 | p_sys->i_state = STATE_NOSYNC; |
|---|
| | 332 | break; |
|---|
| | 333 | } |
|---|
| | 334 | } |
|---|
| | 335 | |
|---|
| 297 | 336 | /* We've just started the stream, wait for the first PTS. |
|---|
| 298 | 337 | * We discard here so we can still get the sequence header. */ |
|---|
| rc6a7622 |
r396d771 |
|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
|---|
| | 8 | * Jean-Paul Saman <jpsaman #_at_# m2x dot nl> |
|---|
| 8 | 9 | * |
|---|
| 9 | 10 | * This program is free software; you can redistribute it and/or modify |
|---|
| … | … | |
| 64 | 65 | es_out_pgrm_t *p_pgrm; |
|---|
| 65 | 66 | |
|---|
| 66 | | /* */ |
|---|
| | 67 | /* Signal a discontinuity in the timeline for every PID */ |
|---|
| | 68 | vlc_bool_t b_discontinuity; |
|---|
| | 69 | |
|---|
| | 70 | /* Misc. */ |
|---|
| 67 | 71 | int64_t i_preroll_end; |
|---|
| 68 | 72 | |
|---|
| … | … | |
| 277 | 281 | { |
|---|
| 278 | 282 | es_out_id_t *es = p_sys->es[i]; |
|---|
| 279 | | |
|---|
| | 283 | es->b_discontinuity = VLC_TRUE; /* signal discontinuity */ |
|---|
| | 284 | |
|---|
| 280 | 285 | /* Send a dummy block to let decoder know that |
|---|
| 281 | 286 | * there is a discontinuity */ |
|---|
| … | … | |
| 670 | 675 | es_format_Copy( &es->fmt, fmt ); |
|---|
| 671 | 676 | es->i_preroll_end = -1; |
|---|
| | 677 | es->b_discontinuity = VLC_FALSE; |
|---|
| 672 | 678 | |
|---|
| 673 | 679 | switch( fmt->i_cat ) |
|---|
| … | … | |
| 1032 | 1038 | |
|---|
| 1033 | 1039 | p_block->i_rate = p_input->i_rate; |
|---|
| | 1040 | if( es->b_discontinuity ) |
|---|
| | 1041 | { |
|---|
| | 1042 | p_block->i_flags |= BLOCK_FLAG_DISCONTINUITY; |
|---|
| | 1043 | es->b_discontinuity = VLC_FALSE; |
|---|
| | 1044 | } |
|---|
| 1034 | 1045 | |
|---|
| 1035 | 1046 | /* TODO handle mute */ |
|---|