Commit aad4b35c authored by Francois Cartegnie's avatar Francois Cartegnie

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

parent ff9af3f6
...@@ -1431,6 +1431,10 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s ...@@ -1431,6 +1431,10 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
else if( MKV_IS_ID( el, KaxDiscardPadding ) ) else if( MKV_IS_ID( el, KaxDiscardPadding ) )
{ {
KaxDiscardPadding &dp = *(KaxDiscardPadding*) el; KaxDiscardPadding &dp = *(KaxDiscardPadding*) el;
dp.ReadData( es.I_O() );
if ( *pi_duration < int64(dp) )
*pi_duration = 0;
else
*pi_duration -= int64(dp); *pi_duration -= int64(dp);
} }
#endif #endif
......
...@@ -601,22 +601,13 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock ...@@ -601,22 +601,13 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
continue; continue;
} }
case VLC_CODEC_OPUS: 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; (double) p_segment->i_timescale / 1000.0;
if ( i_length < 0 ) i_length = 0;
p_block->i_nb_samples = i_length * tk->fmt.audio.i_rate p_block->i_nb_samples = i_length * tk->fmt.audio.i_rate
/ CLOCK_FREQ; / CLOCK_FREQ;
break; 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
/ CLOCK_FREQ;
}
break;
}
if( tk->fmt.i_cat != VIDEO_ES ) if( tk->fmt.i_cat != VIDEO_ES )
......
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