#include <limits.h>
+#include "libavutil/audioconvert.h"
#include "libavutil/crc.h"
#include "avcodec.h"
#include "internal.h"
int32_t *decoded[FLAC_MAX_CHANNELS]; ///< decoded samples
} FLACContext;
+static const int64_t flac_channel_layouts[6] = {
+ AV_CH_LAYOUT_MONO,
+ AV_CH_LAYOUT_STEREO,
+ AV_CH_LAYOUT_SURROUND,
+ AV_CH_LAYOUT_QUAD,
+ AV_CH_LAYOUT_5POINT0,
+ AV_CH_LAYOUT_5POINT1
+};
+
static void allocate_buffers(FLACContext *s);
int avpriv_flac_is_extradata_valid(AVCodecContext *avctx,
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
+ if (avctx->channels <= FF_ARRAY_ELEMS(flac_channel_layouts))
+ avctx->channel_layout = flac_channel_layouts[avctx->channels - 1];
+
return 0;
}
type = get_bits(&s->gb, 6);
if (get_bits1(&s->gb)) {
+ int left = get_bits_left(&s->gb);
wasted = 1;
+ if ( left < 0 ||
+ (left < s->curr_bps && !show_bits_long(&s->gb, left)) ||
+ !show_bits_long(&s->gb, s->curr_bps)) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Invalid number of wasted bits > available bits (%d) - left=%d\n",
+ s->curr_bps, left);
+ return AVERROR_INVALIDDATA;
+ }
while (!get_bits1(&s->gb))
wasted++;
s->curr_bps -= wasted;