History

avcodec/alsdec: Allow the user to set a maximum prediction order

The only offical profile i could find (ALS simple profile) has a max of 15 while the bitstream allows 1023 which is very slow. We do have a fate sample with 1023 Fixes: Timeout Fixes: 429645375/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5377900448907264

Michael Niedermayer committed 1 year ago

Commit 0887d2e1 parent 0a108a31 file · +20 −0Browse files

Unified · Split

libavcodec/alsdec.c+20−0
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838 #include "internal.h"
3939 #include "mlz.h"
4040 #include "libavutil/mem.h"
41+#include "libavutil/opt.h"
4142 #include "libavutil/samplefmt.h"
4243 #include "libavutil/crc.h"
4344 #include "libavutil/softfloat_ieee754.h"
@@ -194,6 +195,7 @@ typedef struct ALSChannelData { · 150 unmodified lines
194195
195196
196197 typedef struct ALSDecContext {
198+ AVClass *av_class;
197199 AVCodecContext *avctx;
198200 ALSSpecificConfig sconf;
199201 GetBitContext gb;
@@ -239,6 +241,7 @@ typedef struct ALSDecContext { · 39 unmodified lines
239241 unsigned char *larray; ///< buffer to store the output of masked lz decompression
240242 int *nbits; ///< contains the number of bits to read for masked lz decompression for all samples
241243 int highest_decoded_channel;
244+ int user_max_order; ///< user specified maximum prediction order
242245 } ALSDecContext;
243246
244247
@@ -352,6 +355,11 @@ static av_cold int read_specific_config(ALSDecContext *ctx) · 107 unmodified lines
352355 skip_bits(&gb, 5); // skip 5 reserved bits
353356 skip_bits1(&gb); // skip aux_data_enabled
354357
358+ if (sconf->max_order > ctx->user_max_order) {
359+ av_log(avctx, AV_LOG_ERROR, "order %d exceeds specified max %d\n", sconf->max_order, ctx->user_max_order);
360+ return AVERROR_INVALIDDATA;
361+ }
362+
355363
356364 // check for ALSSpecificConfig struct
357365 if (als_id != MKBETAG('A','L','S','\0'))
@@ -2183,6 +2191,17 @@ static av_cold void flush(AVCodecContext *avctx) · 1825 unmodified lines
21832191 ctx->frame_id = 0;
21842192 }
21852193
2194+static const AVOption options[] = {
2195+ { "max_order", "Sets the maximum order (ALS simple profile allows max 15)", offsetof(ALSDecContext, user_max_order), AV_OPT_TYPE_INT, { .i64 = 1023 }, 0, 1023, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM },
2196+ { NULL }
2197+};
2198+
2199+static const AVClass als_class = {
2200+ .class_name = "als",
2201+ .item_name = av_default_item_name,
2202+ .option = options,
2203+ .version = LIBAVUTIL_VERSION_INT,
2204+};
21862205
21872206 const FFCodec ff_als_decoder = {
21882207 .p.name = "als",
@@ -2193,6 +2212,7 @@ const FFCodec ff_als_decoder = { · 4 unmodified lines
21932212 .init = decode_init,
21942213 .close = decode_end,
21952214 FF_CODEC_DECODE_CB(decode_frame),
2215+ .p.priv_class = &als_class,
21962216 .flush = flush,
21972217 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
21982218 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t