[vlc-commits] [Git][videolan/vlc][master] 9 commits: vlc_block_helper: pass the bytestream as const
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu May 28 09:39:28 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
50c0481d by Steve Lhomme at 2026-05-28T09:23:21+00:00
vlc_block_helper: pass the bytestream as const
We do not modify it, we're only peeking.
- - - - -
25350e50 by Steve Lhomme at 2026-05-28T09:23:21+00:00
vlc_block_helper: pass the startcode length as size_t
- - - - -
860eb408 by Steve Lhomme at 2026-05-28T09:23:21+00:00
vlc_block_helper: avoid subtracting from i_startcode_length
There is no check if it's 0.
- - - - -
e23a7b6d by Steve Lhomme at 2026-05-28T09:23:21+00:00
vlc_block_helper: remove useless initialization
- - - - -
e0c64d70 by Steve Lhomme at 2026-05-28T09:23:21+00:00
vlc_block_helper: initialize pointers with NULL
- - - - -
90d52e6d by Steve Lhomme at 2026-05-28T09:23:21+00:00
vlc_block_helper: use same type for pi_offset and i_caller_offset_backup
- - - - -
e7602609 by Steve Lhomme at 2026-05-28T09:23:21+00:00
demux: adaptive: call block_SkipBytes() explicitly
It may be optimized someday and it's more readable.
- - - - -
acfcd493 by Steve Lhomme at 2026-05-28T09:23:21+00:00
packetizer: mpeg4: ignore block_XXXBytes after checking bytes remaining
- - - - -
e2722d5f by Steve Lhomme at 2026-05-28T09:23:21+00:00
packetizer: ignore block_SkipByte() after a successful block_PeekBytes()
This is usually used to find a syncpoint.
- - - - -
7 changed files:
- include/vlc_block_helper.h
- modules/demux/adaptive/plumbing/SourceStream.cpp
- modules/packetizer/a52.c
- modules/packetizer/dts.c
- modules/packetizer/mlp.c
- modules/packetizer/mpeg4audio.c
- modules/packetizer/mpegaudio.c
Changes:
=====================================
include/vlc_block_helper.h
=====================================
@@ -277,15 +277,16 @@ typedef const uint8_t * (*block_startcode_helper_t)( const uint8_t *, const uint
typedef bool (*block_startcode_matcher_t)( uint8_t, size_t, const uint8_t * );
static inline int block_FindStartcodeFromOffset(
- block_bytestream_t *p_bytestream, size_t *pi_offset,
- const uint8_t *p_startcode, int i_startcode_length,
+ const block_bytestream_t *p_bytestream, size_t *pi_offset,
+ const uint8_t *p_startcode, size_t i_startcode_length,
block_startcode_helper_t p_startcode_helper,
block_startcode_matcher_t p_startcode_matcher )
{
- block_t *p_block, *p_block_backup = 0;
- ssize_t i_size = 0;
+ block_t *p_block, *p_block_backup = NULL;
+ ssize_t i_size;
size_t i_offset, i_offset_backup = 0;
- int i_caller_offset_backup = 0, i_match;
+ size_t i_caller_offset_backup = 0;
+ size_t i_match;
/* Find the right place */
i_size = *pi_offset + p_bytestream->i_block_offset;
@@ -314,7 +315,7 @@ static inline int block_FindStartcodeFromOffset(
{
/* Use optimized helper when possible */
if( p_startcode_helper && !i_match &&
- (p_block->i_buffer - i_offset) > ((size_t)i_startcode_length - 1) )
+ (p_block->i_buffer - i_offset + 1) > i_startcode_length )
{
const uint8_t *p_res = p_startcode_helper( &p_block->p_buffer[i_offset],
&p_block->p_buffer[p_block->i_buffer] );
@@ -324,7 +325,7 @@ static inline int block_FindStartcodeFromOffset(
return VLC_SUCCESS;
}
/* Then parsing boundary with legacy code */
- i_offset = p_block->i_buffer - (i_startcode_length - 1);
+ i_offset = p_block->i_buffer + 1 - i_startcode_length;
}
bool b_matched = ( p_startcode_matcher )
@@ -348,7 +349,7 @@ static inline int block_FindStartcodeFromOffset(
i_match++;
}
- else if ( i_match > 0 )
+ else if ( i_match != 0 )
{
/* False positive */
p_block = p_block_backup;
=====================================
modules/demux/adaptive/plumbing/SourceStream.cpp
=====================================
@@ -235,7 +235,7 @@ ssize_t BufferedChunksSourceStream::Read(uint8_t *buf, size_t i_toread)
const size_t i_drop = i_bytestream_offset - MAX_BACKEND;
if(i_drop >= MIN_BACKEND_CLEANUP) /* Dont flush for few bytes */
{
- block_GetBytes(&bs, nullptr, i_drop);
+ block_SkipBytes(&bs, i_drop);
block_BytestreamFlush(&bs);
i_bytestream_offset -= i_drop;
i_global_offset += i_drop;
=====================================
modules/packetizer/a52.c
=====================================
@@ -188,7 +188,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
break;
}
- block_SkipByte( &p_sys->bytestream );
+ (void) block_SkipByte( &p_sys->bytestream );
}
if( p_sys->i_state != STATE_SYNC )
{
=====================================
modules/packetizer/dts.c
=====================================
@@ -176,7 +176,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
p_sys->i_state = STATE_SYNC;
break;
}
- block_SkipByte( &p_sys->bytestream );
+ (void) block_SkipByte( &p_sys->bytestream );
}
if( p_sys->i_state != STATE_SYNC )
{
=====================================
modules/packetizer/mlp.c
=====================================
@@ -316,7 +316,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
p_sys->i_state = STATE_SYNC;
break;
}
- block_SkipByte( &p_sys->bytestream );
+ (void) block_SkipByte( &p_sys->bytestream );
}
if( p_sys->i_state != STATE_SYNC )
{
=====================================
modules/packetizer/mpeg4audio.c
=====================================
@@ -703,7 +703,7 @@ static block_t *PacketizeStreamBlock(decoder_t *p_dec, block_t **pp_block)
p_sys->i_type = TYPE_LOAS;
break;
}
- block_SkipByte(&p_sys->bytestream);
+ (void) block_SkipByte(&p_sys->bytestream);
}
if (p_sys->i_state != STATE_SYNC) {
block_BytestreamFlush(&p_sys->bytestream);
@@ -827,10 +827,10 @@ static block_t *PacketizeStreamBlock(decoder_t *p_dec, block_t **pp_block)
p_buf = p_out_buffer->p_buffer;
/* Skip the ADTS/LOAS header */
- block_SkipBytes(&p_sys->bytestream, p_sys->i_header_size);
+ (void) block_SkipBytes(&p_sys->bytestream, p_sys->i_header_size);
/* Copy the whole frame into the buffer */
- block_GetBytes(&p_sys->bytestream, p_buf, p_sys->i_frame_size);
+ (void) block_GetBytes(&p_sys->bytestream, p_buf, p_sys->i_frame_size);
if (p_sys->i_type != TYPE_ADTS) { /* parse/extract the whole frame */
assert(p_sys->i_type == TYPE_LOAS);
p_out_buffer->i_buffer = LOASParse(p_dec, p_buf, p_sys->i_frame_size);
=====================================
modules/packetizer/mpegaudio.c
=====================================
@@ -204,7 +204,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
p_sys->i_state = STATE_SYNC;
break;
}
- block_SkipByte( &p_sys->bytestream );
+ (void) block_SkipByte( &p_sys->bytestream );
}
if( p_sys->i_state != STATE_SYNC )
{
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ab2369b5f56fb0a60eab75f25b637da7b1bf2fff...e2722d5f711a35b4d05eb72d314237ba9a53fe39
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ab2369b5f56fb0a60eab75f25b637da7b1bf2fff...e2722d5f711a35b4d05eb72d314237ba9a53fe39
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list