aboutsummaryrefslogtreecommitdiffstats
path: root/tools/target_dec_fuzzer.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2022-02-23 23:58:34 -0300
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:47 -0300
commit2f8ccca2fa94ce256ff77baa18f462c1abd8d2cc (patch)
tree142bd136706bface5b680c6f815aa4ba68e99bac /tools/target_dec_fuzzer.c
parentf5ef91e02080316f50d606f5b0b03333bb627ed7 (diff)
downloadffmpeg-2f8ccca2fa94ce256ff77baa18f462c1abd8d2cc.tar.gz
tools/target_{bsf,dec}_fuzzer: convert to new channel layout-API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'tools/target_dec_fuzzer.c')
-rw-r--r--tools/target_dec_fuzzer.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 23b0184059..eaa26b0e62 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -242,6 +242,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
GetByteContext gbc;
int extradata_size;
int flags;
+ uint64_t request_channel_layout;
int64_t flags64;
size -= 1024;
@@ -272,7 +273,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
extradata_size = bytestream2_get_le32(&gbc);
ctx->sample_rate = bytestream2_get_le32(&gbc) & 0x7FFFFFFF;
- ctx->channels = (unsigned)bytestream2_get_le32(&gbc) % FF_SANE_NB_CHANNELS;
+ ctx->ch_layout.channels = (unsigned)bytestream2_get_le32(&gbc) % FF_SANE_NB_CHANNELS;
ctx->block_align = bytestream2_get_le32(&gbc) & 0x7FFFFFFF;
ctx->codec_tag = bytestream2_get_le32(&gbc);
if (c->codec_tags) {
@@ -281,7 +282,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
ctx->codec_tag = c->codec_tags[ctx->codec_tag % n];
}
keyframes = bytestream2_get_le64(&gbc);
- ctx->request_channel_layout = bytestream2_get_le64(&gbc);
+ request_channel_layout = bytestream2_get_le64(&gbc);
ctx->idct_algo = bytestream2_get_byte(&gbc) % 25;
flushpattern = bytestream2_get_le64(&gbc);
@@ -300,6 +301,31 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
}
+ // Keep the deprecated request_channel_layout behavior to ensure old fuzzing failures
+ // remain reproducible.
+ if (request_channel_layout) {
+ switch (ctx->codec_id) {
+ case AV_CODEC_ID_AC3:
+ case AV_CODEC_ID_EAC3:
+ case AV_CODEC_ID_MLP:
+ case AV_CODEC_ID_TRUEHD:
+ case AV_CODEC_ID_DTS:
+ if (request_channel_layout & ~INT64_MIN) {
+ char *downmix_layout = av_mallocz(19);
+ if (!downmix_layout)
+ error("Failed memory allocation");
+ av_strlcatf(downmix_layout, 19, "0x%"PRIx64, request_channel_layout & ~INT64_MIN);
+ av_dict_set(&opts, "downmix", downmix_layout, AV_DICT_DONT_STRDUP_VAL);
+ }
+ if (ctx->codec_id != AV_CODEC_ID_DTS)
+ break;
+ // fall-through
+ case AV_CODEC_ID_DOLBY_E:
+ av_dict_set_int(&opts, "channel_order", !!(request_channel_layout & INT64_MIN), 0);
+ break;
+ }
+ }
+
flags64 = bytestream2_get_le64(&gbc);
if (flags64 &1)
ctx->debug |= FF_DEBUG_SKIP;