[vlc-commits] demux: caf: handle Opus (fix #19544)
Francois Cartegnie
git at videolan.org
Thu Feb 1 19:00:51 CET 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Feb 1 18:56:25 2018 +0100| [24bbba20f8e9aba09c26055632c48ef396270942] | committer: Francois Cartegnie
demux: caf: handle Opus (fix #19544)
Apple's undocumented framing.
There's no external framing to figure limits. The opus
decoder will never read the full packet, containing
up to CLOCK_FREQ/20 of samples/frames.
We must enforce sending single frames.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=24bbba20f8e9aba09c26055632c48ef396270942
---
modules/demux/caf.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/modules/demux/caf.c b/modules/demux/caf.c
index 6477452adc..c422826247 100644
--- a/modules/demux/caf.c
+++ b/modules/demux/caf.c
@@ -83,6 +83,7 @@ struct demux_sys_t
{
es_format_t fmt;
es_out_id_t *es;
+ unsigned i_max_frames;
uint64_t i_data_offset;
uint64_t i_data_size;
@@ -512,6 +513,11 @@ static int ReadDescChunk( demux_t *p_demux )
p_sys->fmt.audio.i_blockalign = i_bytes_per_packet;
p_sys->fmt.i_bitrate = i_bits_per_channel * p_sys->fmt.audio.i_rate * i_channels_per_frame;
+ if( p_sys->fmt.i_codec == VLC_CODEC_OPUS )
+ {
+ p_sys->i_max_frames = 1;
+ }
+
return VLC_SUCCESS;
}
@@ -951,12 +957,21 @@ static int Demux( demux_t *p_demux )
}
else /* use packet table */
{
+ uint64_t i_max_frames;
+ if( p_sys->packet_table.i_num_packets > p_sys->position.i_frames )
+ i_max_frames = p_sys->packet_table.i_num_packets - p_sys->position.i_frames;
+ else
+ i_max_frames = 1; /* will be rejected on FrameSpanAddDescription below */
+
+ if( i_max_frames > p_sys->i_max_frames )
+ i_max_frames = p_sys->i_max_frames;
+
do
{
if( FrameSpanAddDescription( p_demux, p_sys->position.i_desc_bytes + advance.i_desc_bytes, &advance ))
break;
}
- while (( i_req_samples > advance.i_samples ) && ( p_sys->position.i_frames + advance.i_frames ) < p_sys->packet_table.i_num_packets );
+ while ( i_req_samples > advance.i_samples && advance.i_frames < i_max_frames );
}
if( !advance.i_frames )
More information about the vlc-commits
mailing list