Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/audio/ffmpeg_dec/ffmpeg_dec-convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ int ffmpeg_dec_convert_frame(const AVFrame *frame, uint8_t *out, size_t out_size

if (channels <= 0 || frame->nb_samples <= 0)
return -EINVAL;

/*
* The frame's channel count comes from the bitstream, @channels from the
* sink. Every path below indexes the frame planes with @channels, so a
* stream with fewer channels than the sink would be read past its end.
*/
if (frame->ch_layout.nb_channels != channels)
return -EINVAL;
if (need > out_size)
return -ENOSPC;

Expand Down
3 changes: 2 additions & 1 deletion src/audio/ffmpeg_dec/ffmpeg_dec-convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
* Dispatches to specialized HiFi/SIMD and unrolled scalar conversion routines
* based on the source AVFrame format and the destination SOF sink format.
*
* Returns number of bytes written, or a negative errno on error.
* Returns number of bytes written, -ENOSPC if @out is too small, or -EINVAL for
* an empty frame or one whose channel count does not match @channels.
*/
int ffmpeg_dec_convert_frame(const AVFrame *frame, uint8_t *out, size_t out_size,
int sink_fmt, int channels);
Expand Down
Loading