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
38#include "internal.h"38#include "internal.h"
39#include "mlz.h"39#include "mlz.h"
40#include "libavutil/mem.h"40#include "libavutil/mem.h"
41#include "libavutil/opt.h"
41#include "libavutil/samplefmt.h"42#include "libavutil/samplefmt.h"
42#include "libavutil/crc.h"43#include "libavutil/crc.h"
43#include "libavutil/softfloat_ieee754.h"44#include "libavutil/softfloat_ieee754.h"
@@ -194,6 +195,7 @@ typedef struct ALSChannelData { · 150 unmodified lines
194 195
195 196
196typedef struct ALSDecContext {197typedef struct ALSDecContext {
198 AVClass *av_class;
197 AVCodecContext *avctx;199 AVCodecContext *avctx;
198 ALSSpecificConfig sconf;200 ALSSpecificConfig sconf;
199 GetBitContext gb;201 GetBitContext gb;
@@ -239,6 +241,7 @@ typedef struct ALSDecContext { · 39 unmodified lines
239 unsigned char *larray; ///< buffer to store the output of masked lz decompression241 unsigned char *larray; ///< buffer to store the output of masked lz decompression
240 int *nbits; ///< contains the number of bits to read for masked lz decompression for all samples242 int *nbits; ///< contains the number of bits to read for masked lz decompression for all samples
241 int highest_decoded_channel;243 int highest_decoded_channel;
244 int user_max_order; ///< user specified maximum prediction order
242} ALSDecContext;245} ALSDecContext;
243 246
244 247
@@ -352,6 +355,11 @@ static av_cold int read_specific_config(ALSDecContext *ctx) · 107 unmodified lines
352 skip_bits(&gb, 5); // skip 5 reserved bits355 skip_bits(&gb, 5); // skip 5 reserved bits
353 skip_bits1(&gb); // skip aux_data_enabled356 skip_bits1(&gb); // skip aux_data_enabled
354 357
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
355 363
356 // check for ALSSpecificConfig struct364 // check for ALSSpecificConfig struct
357 if (als_id != MKBETAG('A','L','S','\0'))365 if (als_id != MKBETAG('A','L','S','\0'))
@@ -2183,6 +2191,17 @@ static av_cold void flush(AVCodecContext *avctx) · 1825 unmodified lines
2183 ctx->frame_id = 0;2191 ctx->frame_id = 0;
2184}2192}
2185 2193
2194static 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
2199static const AVClass als_class = {
2200 .class_name = "als",
2201 .item_name = av_default_item_name,
2202 .option = options,
2203 .version = LIBAVUTIL_VERSION_INT,
2204};
2186 2205
2187const FFCodec ff_als_decoder = {2206const FFCodec ff_als_decoder = {
2188 .p.name = "als",2207 .p.name = "als",
@@ -2193,6 +2212,7 @@ const FFCodec ff_als_decoder = { · 4 unmodified lines
2193 .init = decode_init,2212 .init = decode_init,
2194 .close = decode_end,2213 .close = decode_end,
2195 FF_CODEC_DECODE_CB(decode_frame),2214 FF_CODEC_DECODE_CB(decode_frame),
2215 .p.priv_class = &als_class,
2196 .flush = flush,2216 .flush = flush,
2197 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,2217 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
2198 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,2218 .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