| 68 | }; |
| 69 | |
| 70 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
| 71 | struct SwrContext * swr= NULL; |
| 72 | AVChannelLayout in_ch_layout = AV_CHANNEL_LAYOUT_MONO, out_ch_layout = AV_CHANNEL_LAYOUT_MONO; |
| 73 | enum AVSampleFormat in_sample_fmt = AV_SAMPLE_FMT_S16P; |
| 74 | enum AVSampleFormat out_sample_fmt = AV_SAMPLE_FMT_S16P; |
| 75 | int in_sample_rate = 44100; |
| 76 | int out_sample_rate = 44100; |
| 77 | int in_ch_count, out_ch_count; |
| 78 | char in_layout_string[256]; |
| 79 | char out_layout_string[256]; |
| 80 | uint8_t * ain[SWR_CH_MAX]; |
| 81 | uint8_t *aout[SWR_CH_MAX]; |
| 82 | uint8_t *out_data = NULL; |
| 83 | int in_sample_nb; |
| 84 | int out_sample_nb = size; |
| 85 | int count; |
| 86 | int ret; |
| 87 | |
| 88 | if (size > 128) { |
| 89 | GetByteContext gbc; |
| 90 | int64_t flags64; |
| 91 | |
| 92 | size -= 128; |
| 93 | bytestream2_init(&gbc, data + size, 128); |
| 94 | in_sample_rate = bytestream2_get_le16(&gbc) + 1; |
| 95 | out_sample_rate = bytestream2_get_le16(&gbc) + 1; |
| 96 | in_sample_fmt = formats[bytestream2_get_byte(&gbc) % FF_ARRAY_ELEMS(formats)]; |
| 97 | out_sample_fmt = formats[bytestream2_get_byte(&gbc) % FF_ARRAY_ELEMS(formats)]; |
| 98 | av_channel_layout_copy(& in_ch_layout, &layouts[bytestream2_get_byte(&gbc) % FF_ARRAY_ELEMS(layouts)]); |
| 99 | av_channel_layout_copy(&out_ch_layout, &layouts[bytestream2_get_byte(&gbc) % FF_ARRAY_ELEMS(layouts)]); |
| 100 | |
| 101 | out_sample_nb = bytestream2_get_le32(&gbc) & 0x7FFFFFFF; |
| 102 | |
| 103 | flags64 = bytestream2_get_le64(&gbc); |
| 104 | if (flags64 & 0x10) |
| 105 | av_force_cpu_flags(0); |
| 106 | } |
| 107 | |
| 108 | in_ch_count= in_ch_layout.nb_channels; |
| 109 | out_ch_count= out_ch_layout.nb_channels; |
| 110 | av_channel_layout_describe(& in_ch_layout, in_layout_string, sizeof( in_layout_string)); |
| 111 | av_channel_layout_describe(&out_ch_layout, out_layout_string, sizeof(out_layout_string)); |
| 112 | |
| 113 | // fprintf(stderr, "%s %d %s -> %s %d %s\n", |
| 114 | // av_get_sample_fmt_name( in_sample_fmt), in_sample_rate, in_layout_string, |
| 115 | // av_get_sample_fmt_name(out_sample_fmt), out_sample_rate, out_layout_string); |
| 116 | |
| 117 | if (swr_alloc_set_opts2(&swr, &out_ch_layout, out_sample_fmt, out_sample_rate, |
| 118 | &in_ch_layout, in_sample_fmt, in_sample_rate, |
| 119 | 0, 0) < 0) { |
| 120 | fprintf(stderr, "Failed swr_alloc_set_opts2()\n"); |
| 121 | goto end; |
| 122 | } |
| 123 | |
| 124 | if (swr_init(swr) < 0) { |
| 125 | fprintf(stderr, "Failed swr_init()\n"); |
| 126 | goto end; |
| 127 | } |
nothing calls this directly
no test coverage detected