Browse Source

demux: ogg: keep the map sizes when they are set

The p_old_map/p_new_map sizes should match their buffer size.

By default the channel counts are zero which considers the old/new maps match.
The channel count read may be updated but not the channel mapping.
We need to check the channel count match and the mapping matches.

Fixes https://code.videolan.org/videolan/vlc/-/issues/29314
cherry-pick-c5513cf9
Steve Lhomme 11 months ago
committed by Thomas Guillem
parent
commit
b3a03a2196
  1. 8
      modules/demux/ogg.c

8
modules/demux/ogg.c

@ -2424,9 +2424,11 @@ static bool Ogg_IsOpusFormatCompatible( const es_format_t *p_new,
int i_new_stream_count;
int i_old_coupled_count;
int i_new_coupled_count;
size_t i_old_map_size, i_new_map_size;
p_old_head = pp_old_data[0];
i_old_channel_count = i_old_stream_count = i_old_coupled_count = 0;
p_old_map = default_map;
i_old_map_size = ARRAY_SIZE(default_map);
if( pi_old_size[0] >= 19 && p_old_head[8] <= 15 )
{
i_old_channel_count = p_old_head[9];
@ -2442,6 +2444,7 @@ static bool Ogg_IsOpusFormatCompatible( const es_format_t *p_new,
i_old_stream_count = p_old_head[19];
i_old_coupled_count = p_old_head[20];
p_old_map = p_old_head + 21;
i_old_map_size = i_old_channel_count;
}
break;
}
@ -2449,6 +2452,7 @@ static bool Ogg_IsOpusFormatCompatible( const es_format_t *p_new,
p_new_head = (unsigned char *)pp_new_data[0];
i_new_channel_count = i_new_stream_count = i_new_coupled_count = 0;
p_new_map = default_map;
i_new_map_size = ARRAY_SIZE(default_map);
if( pi_new_size[0] >= 19 && p_new_head[8] <= 15 )
{
i_new_channel_count = p_new_head[9];
@ -2464,6 +2468,7 @@ static bool Ogg_IsOpusFormatCompatible( const es_format_t *p_new,
i_new_stream_count = p_new_head[19];
i_new_coupled_count = p_new_head[20];
p_new_map = p_new_head+21;
i_new_map_size = i_new_channel_count;
}
break;
}
@ -2471,8 +2476,9 @@ static bool Ogg_IsOpusFormatCompatible( const es_format_t *p_new,
b_match = i_old_channel_count == i_new_channel_count &&
i_old_stream_count == i_new_stream_count &&
i_old_coupled_count == i_new_coupled_count &&
i_old_map_size == i_new_map_size &&
memcmp(p_old_map, p_new_map,
i_new_channel_count*sizeof(*p_new_map)) == 0;
i_new_map_size*sizeof(*p_new_map)) == 0;
}
return b_match;

Loading…
Cancel
Save