[vlc-commits] [Git][videolan/vlc][master] 2 commits: packetizer: a52: fix recovery with dts set only
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Sun Dec 24 08:06:08 UTC 2023
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
d3d6132e by François Cartegnie at 2023-12-24T07:51:28+00:00
packetizer: a52: fix recovery with dts set only
- - - - -
a3bd36a5 by François Cartegnie at 2023-12-24T07:51:28+00:00
packetizer: a52: check and output truncated frame on desync
- - - - -
1 changed file:
- modules/packetizer/a52.c
Changes:
=====================================
modules/packetizer/a52.c
=====================================
@@ -51,6 +51,8 @@ vlc_module_begin ()
set_callbacks( Open, Close )
vlc_module_end ()
+static const uint8_t startcode[2] = { 0x0b, 0x77 };
+
typedef struct
{
/*
@@ -102,8 +104,12 @@ static block_t *GetOutBuffer( decoder_t *p_dec )
date_Init( &p_sys->end_date, p_sys->frame.i_rate, 1 );
}
- if( p_sys->bytestream.p_block->i_pts != date_Get( &p_sys->end_date ) &&
- p_sys->bytestream.p_block->i_pts != VLC_TICK_INVALID )
+ block_t *p_bshead = p_sys->bytestream.p_block;
+ /* Ensure we can recover if there's only dts set */
+ if( date_Get( &p_sys->end_date ) == VLC_TICK_INVALID && p_bshead->i_pts == VLC_TICK_INVALID )
+ p_bshead->i_pts = p_bshead->i_dts;
+
+ if( p_bshead->i_pts != VLC_TICK_INVALID && p_bshead->i_pts != date_Get( &p_sys->end_date ) )
{
/* Make sure we don't reuse the same pts twice
* as A/52 in PES sends multiple times the same pts */
@@ -173,14 +179,15 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
switch( p_sys->i_state )
{
case STATE_NOSYNC:
- while( block_PeekBytes( &p_sys->bytestream, p_header, 2 )
+ while( block_PeekBytes( &p_sys->bytestream, p_header, sizeof(startcode) )
== VLC_SUCCESS )
{
- if( p_header[0] == 0x0b && p_header[1] == 0x77 )
+ if( !memcmp(p_header, startcode, sizeof(startcode)) )
{
p_sys->i_state = STATE_SYNC;
break;
}
+
block_SkipByte( &p_sys->bytestream );
}
if( p_sys->i_state != STATE_SYNC )
@@ -251,13 +258,25 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
break;
}
- if( p_header[0] != 0x0b || p_header[1] != 0x77 )
+ if( memcmp(p_header, startcode, sizeof(startcode)) )
{
msg_Dbg( p_dec, "emulated sync word "
"(no sync on following frame)" );
- p_sys->i_state = STATE_NOSYNC;
- block_SkipByte( &p_sys->bytestream );
- break;
+ size_t offset = VLC_A52_MIN_HEADER_SIZE;
+ if( !block_FindStartcodeFromOffset( &p_sys->bytestream, &offset,
+ startcode, sizeof(startcode),
+ NULL, NULL ) )
+ {
+ if( offset < p_sys->i_input_size )
+ p_sys->i_input_size = offset;
+ /* else will resync after read */
+ }
+ else
+ {
+ p_sys->i_state = STATE_NOSYNC;
+ block_SkipByte( &p_sys->bytestream );
+ break;
+ }
}
vlc_a52_header_t a52;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9f076c3b237d40a61f2f09416bf763355b72695f...a3bd36a5f30a122ea6c8e194a131bc39af6ca959
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9f076c3b237d40a61f2f09416bf763355b72695f...a3bd36a5f30a122ea6c8e194a131bc39af6ca959
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list