Commit aad4b35c authored by François Cartegnie's avatar François Cartegnie 🤞
Browse files

demux: mkv: fix opus block truncation (fix #10176)

parent ff9af3f6
......@@ -1431,7 +1431,11 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
else if( MKV_IS_ID( el, KaxDiscardPadding ) )
{
KaxDiscardPadding &dp = *(KaxDiscardPadding*) el;
*pi_duration -= int64(dp);
dp.ReadData( es.I_O() );
if ( *pi_duration < int64(dp) )
*pi_duration = 0;
else
*pi_duration -= int64(dp);
}
#endif
break;
......
......@@ -601,20 +601,11 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
continue;
}
case VLC_CODEC_OPUS:
if( i_duration > 0 )
{
mtime_t i_length = i_duration * tk-> f_timecodescale *
mtime_t i_length = i_duration * tk-> f_timecodescale *
(double) p_segment->i_timescale / 1000.0;
p_block->i_nb_samples = i_length * tk->fmt.audio.i_rate
/ CLOCK_FREQ;
break;
}
else if( i_duration < 0 )
{
/* Opus uses p_block->i_length to handle discard padding */
p_block->i_length = -1 * i_duration * tk->fmt.audio.i_rate
if ( i_length < 0 ) i_length = 0;
p_block->i_nb_samples = i_length * tk->fmt.audio.i_rate
/ CLOCK_FREQ;
}
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment