vlc/vlc-2.0 | branch: master | Timothy B. Terriberry <[email protected]> | Sun Sep 2 15:24:03 2012 -0700| [94d204fb190d0495c6382581cb40712e32548a24] | committer: Jean-Baptiste Kempf
Fix 0-byte Ogg packet handling. This stops rejecting 0-byte packets, adds checks everywhere we access the first byte of a packet, updates the th_decode_packetin() return value checking so that duplicate frames aren't thrown away, and updates video pts generation so the resulting frames are displayed correctly, Fixes bug #3416. Signed-off-by: Rafaël Carré <[email protected]> (cherry picked from commit 9c7198eaeda34f791fd007287e4089099ed70e22) Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=94d204fb190d0495c6382581cb40712e32548a24 --- modules/codec/theora.c | 4 +++- modules/demux/ogg.c | 31 +++++++++++++++---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/modules/codec/theora.c b/modules/codec/theora.c index 7413da0..b3c7b74 100644 --- a/modules/codec/theora.c +++ b/modules/codec/theora.c @@ -454,7 +454,9 @@ static picture_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket ) /* TODO: Implement _granpos (3rd parameter here) and add the * call to TH_DECCTL_SET_GRANDPOS after seek */ - if (th_decode_packetin( p_sys->tcx, p_oggpacket, NULL )) /* 0 on success */ + /* TODO: If the return is TH_DUPFRAME, we don't need to display a new + * frame, but we do need to keep displaying the previous one. */ + if (th_decode_packetin( p_sys->tcx, p_oggpacket, NULL ) < 0) return NULL; /* bad packet */ /* Check for keyframe */ diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c index 1c9321c..9b15998 100644 --- a/modules/demux/ogg.c +++ b/modules/demux/ogg.c @@ -644,13 +644,6 @@ static void Ogg_DecodePacket( demux_t *p_demux, mtime_t i_pts = -1, i_interpolated_pts; demux_sys_t *p_ogg = p_demux->p_sys; - /* Sanity check */ - if( !p_oggpacket->bytes ) - { - msg_Dbg( p_demux, "discarding 0 sized packet" ); - return; - } - if( p_oggpacket->bytes >= 7 && ! memcmp ( p_oggpacket->packet, "Annodex", 7 ) ) { @@ -664,7 +657,7 @@ static void Ogg_DecodePacket( demux_t *p_demux, return; } - if( p_stream->fmt.i_codec == VLC_CODEC_SUBT && + if( p_stream->fmt.i_codec == VLC_CODEC_SUBT && p_oggpacket->bytes > 0 && p_oggpacket->packet[0] & PACKET_TYPE_BITS ) return; /* Check the ES is selected */ @@ -840,9 +833,6 @@ static void Ogg_DecodePacket( demux_t *p_demux, return; } - if( p_oggpacket->bytes <= 0 ) - return; - if( !( p_block = block_New( p_demux, p_oggpacket->bytes ) ) ) return; @@ -883,8 +873,11 @@ static void Ogg_DecodePacket( demux_t *p_demux, /* Normalize PTS */ - if( i_pts == 0 ) i_pts = VLC_TS_0; - else if( i_pts == -1 && i_interpolated_pts == 0 ) i_pts = VLC_TS_0; + if( i_pts == VLC_TS_INVALID ) i_pts = VLC_TS_0; + else if( i_pts == -1 && i_interpolated_pts == VLC_TS_INVALID ) + i_pts = VLC_TS_0; + else if( i_pts == -1 && p_stream->fmt.i_cat == VIDEO_ES ) + i_pts = i_interpolated_pts; else if( i_pts == -1 ) i_pts = VLC_TS_INVALID; if( p_stream->fmt.i_cat == AUDIO_ES ) @@ -937,6 +930,12 @@ static void Ogg_DecodePacket( demux_t *p_demux, p_stream->fmt.i_codec != VLC_CODEC_DIRAC && p_stream->fmt.i_codec != VLC_CODEC_KATE ) { + if( p_oggpacket->bytes <= 0 ) + { + msg_Dbg( p_demux, "discarding 0 sized packet" ); + block_Release( p_block ); + return; + } /* We remove the header from the packet */ i_header_len = (*p_oggpacket->packet & PACKET_LEN_BITS01) >> 6; i_header_len |= (*p_oggpacket->packet & PACKET_LEN_BITS2) << 1; @@ -1325,8 +1324,8 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux ) p_ogg->i_streams--; } } - else if( (*oggpacket.packet & PACKET_TYPE_BITS ) == PACKET_TYPE_HEADER && - oggpacket.bytes >= 44+1 ) + else if( oggpacket.bytes >= 44+1 && + (*oggpacket.packet & PACKET_TYPE_BITS ) == PACKET_TYPE_HEADER ) { stream_header_t tmp; stream_header_t *st = &tmp; @@ -1993,7 +1992,7 @@ static void Ogg_ReadFlacHeader( demux_t *p_demux, logical_stream_t *p_stream, bs_init( &s, p_oggpacket->packet, p_oggpacket->bytes ); bs_read( &s, 1 ); - if( bs_read( &s, 7 ) == 0 ) + if( p_oggpacket->bytes > 0 && bs_read( &s, 7 ) == 0 ) { if( bs_read( &s, 24 ) >= 34 /*size STREAMINFO*/ ) { _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
