Commit Graph

1325 Commits

Author SHA1 Message Date
Martin Storsjo a52114dd69 Merge remote-tracking branch 'aosp/master' 2021-01-14 15:38:20 +02:00
Martin Storsjo d75500444a Don't use enums for values read directly from the bitstream
The enums don't cover all possible values read from the bitstream.

This fixes undefined behaviour sanitizer errors.

Fixes: 27647/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBFDK_AAC_fuzzer-5654559200116736
Fixes: 28193/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBFDK_AAC_fuzzer-4901213455515648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2021-01-14 15:36:03 +02:00
Rosen Penev d284d42e71 fix compilation with mips16
Some users wrongly pass both -mips16 and -mdsp when compiling on MIPS
platforms. Handle such a case.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-01-14 14:56:46 +02:00
Kris Alder 093573a634 Merge "Added aac_enc_fuzzer" 2021-01-13 01:03:20 +00:00
Cindy Zhou 5690f9c39f Merge "Enable cfi for aac" 2021-01-08 17:47:26 +00:00
Treehugger Robot 5d8224586c Merge "Adjust VBR mode depending on given peak bitrate and fix crash recovery usage." 2021-01-08 15:47:48 +00:00
Fraunhofer IIS FDK e499f9485e Adjust VBR mode depending on given peak bitrate and fix crash recovery usage.
Operating the FDK encoder in A2DP with variable bitrate mode
configuration resulted in unexpected encoder return value AACENC_ENCODE_ERROR.

Due to peak bitrate restriction the encoder quite often runs into requantization.
In case the bitrate constraint is not fulfilled, the so-called crash recovery is
used as final emergency step. The crash recovery reduces the overall bit
consumption considering the given number of bits to be saved. The bit difference
is extracted from audio element structures. In VBR mode the element wise bit
consumption state was not updated since there is typically no bitrate limitation
required.

The patch solves the choppy audio problems and increases audio quality for
AAC VBR encoding.

The changes in FDKaacEnc_QCMain() ensure that audio element bit info is always
updated. This is achieved by always calling FDKaacEnc_BitResRedistribution()
and FDKaacEnc_prepareBitDistribution() with maxBitsPerFrame variable as total
bits parameter.
Furthermore, VBR assumes a certain target bitrate which is used for internal
configuration and limitations. In case the peak bitrate parameter is less than
the VBR mode target bitrate the maximum of both bitrate configurations was used.

The function FDKaacEnc_AdjustVBRBitrateMode() is added to adjust the encoder
internal VBR mode to a desired target bitrate less than given peak bitrate.
It is possible that the peak bitrate is very close to the desired target bitrate.
The virtual available bitreservoir is quite low and the encoder would run quite
often into requantization with needless audio quality reduction. In such a
configuration, it is a better choice to use the CBR targeted threshold adaption
to avoid audio quality reduction.

In FDKaacEnc_Initialize(), there was already a bitResMode selection depending
on available bitreservoir for CBR. This selection will now also be used for VBR.
In case the bitResMode is AACENC_BR_MODE_FULL and VBR mode is selected, the VBR
threshold adaption is used. Otherwise, CBR threshold adaption strategy is used
and therefore, no unnecessary fill bits are written.

Bug: 161400526
Test: see bug
Change-Id: I1865f817180150da6add2623a64f1a102622784a
2021-01-08 10:52:53 +08:00
Anuj Joshi ec3d6d9f0e Added aac_enc_fuzzer
Test: ./aac_enc_fuzzer
Bug: 172429950

Change-Id: Ia84f85425f6df10b13a3d045472f7f684f27eb8a
2020-12-28 10:33:12 +05:30
Cindy Zhou c93fff6784 Enable cfi for aac
Bug: 158010610
Bug: 173497308
Test: ran atest DecoderConformanceTest, ImageReaderDecoderTest,
VideoDecoderPerfTest, VideoEncoderTest.  Compare the
before and after enabling CFI results since there was a number of tests
that were initially failing.

Change-Id: I0d0d2a76512dc909a67f34adacff9ffbf536dbe7
2020-12-17 07:45:11 -08:00
Martin Storsjo 2e64f76d2e Don't use an enum for a value read directly from the bitstream
The enum doesn't cover all possible values read from the bitstream.

This fixes undefined behaviour sanitizer errors.

Fixes: 27624/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBFDK_AAC_fuzzer-6049277318791168

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2020-11-30 12:55:07 +02:00
Xin Li b831187d3a Mark ab/6881855 as merged
Bug: 172690556
Change-Id: I4edc064b9a87da525672e61919ec8fb59a70202e
2020-11-23 11:29:57 -08:00
Martin Storsjo a0411159e8 Revert "Avoid a failed assert on invalid channel indices"
This reverts commit 9b0f848911.

This local fix doesn't seem to be needed any more after the latest
upstream update.
2020-11-17 12:58:59 +02:00
Martin Storsjo 2b3e9ddc81 Revert "Don't use an enum for a value read directly from the bitstream"
This reverts commit 28fcbe9fae.

This local fix doesn't seem to be needed any more after the latest
upstream update.
2020-11-17 12:58:30 +02:00
Martin Storsjo d9a9f3b793 Revert "Don't use an enum for a value read directly from the bitstream"
This reverts commit e7d8591ff2.

This local fix doesn't seem to be needed any more after the latest
upstream update.
2020-11-17 12:58:00 +02:00
Martin Storsjo 60a11ea3ef Revert "Don't use an enum for a value read directly from the bitstream"
This reverts commit 8439b745f6.

This local fix doesn't seem to be needed any more after the latest
upstream update.
2020-11-17 12:57:21 +02:00
Martin Storsjo ea21799a7b Revert "Avoid undefined shifts in SATURATE_SHIFT"
This reverts commit 3a831a5fbc.

This local fix doesn't seem to be needed any more after the latest
upstream update.
2020-11-17 12:56:58 +02:00
Martin Storsjo 559379e08b Update the version numbers in the public installed headers 2020-11-17 12:41:48 +02:00
Martin Storsjo dc29bf5457 Remove references to sbr_crc.cpp that was removed upstream 2020-11-17 12:40:36 +02:00
Martin Storsjo c7a3808a2f Merge remote-tracking branch 'aosp/master' 2020-11-17 12:38:51 +02:00
Martin Storsjo d23a21ab42 Avoid undefined shifts in calculateSbrEnvelope
Fixes: 26845/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBFDK_AAC_fuzzer-5670674796118016

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2020-11-17 12:26:19 +02:00
Martin Storsjo 4e944af756 Avoid undefined shifts in SBR calcCRC
Fixes: 25404/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBFDK_AAC_fuzzer-5397024709804032

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2020-11-17 12:26:19 +02:00
Bill Yi 0834f1a0b8 Merge "Merge rvc-release RP1A.201105.002 to aosp-master - DO NOT MERGE" am: f4adff7fbb
Original change: https://android-review.googlesource.com/c/platform/external/aac/+/1486978

Change-Id: Ied811f647e67defe1286b9a8e4a0bdc2c89da3c2
2020-11-05 03:01:21 +00:00
Bill Yi 8b4e287ff6 Merge rvc-release RP1A.201105.002 to aosp-master - DO NOT MERGE am: 5b4265a02a
Original change: https://android-review.googlesource.com/c/platform/external/aac/+/1486978

Change-Id: Ifc71d75171dfbc250f59774aea3ddb950e70d356
2020-11-05 03:01:13 +00:00
Bill Yi f4adff7fbb Merge "Merge rvc-release RP1A.201105.002 to aosp-master - DO NOT MERGE" 2020-11-05 01:06:54 +00:00
Bill Yi 5b4265a02a Merge rvc-release RP1A.201105.002 to aosp-master - DO NOT MERGE
Merged-In: I44e842648acbceb02bbc28cf2ad729a0caddf60d
Change-Id: Iead5cf2ca1c993da0844a11d1e64bf3cc86ed5dd
2020-11-04 13:57:54 -08:00
Bill Yi 4c3407e563 Merge rvc-release RP1A.201105.002 to stage-aosp-master - DO NOT MERGE
Merged-In: I31fe9fe1e8dd7e919848be94dd73dfb779e7065d
Change-Id: I462d697908f9803317f038c916d5942967efa28a
2020-11-03 22:27:17 -08:00
Xin Li f473247482 Skip ab/6749736 in stage.
Merged-In: Icfe1613791fb53502d99e3030dd9e9baa3fa5c33
Change-Id: I7d1c753bfa3343d5931058143dc016c3a0861700
2020-10-08 16:52:22 -07:00
android-build-team Robot 0e9a1509b5 Merge cherrypicks of [12620612, 12620613, 12620936, 12620457, 12616684, 12621005, 12620883, 12620884, 12620846, 12620847, 12620869, 12620848, 12620849, 12620961, 12620962, 12620827, 12620614, 12620197, 12620885, 12620198, 12621039, 12621040, 12621041, 12620937, 12620615, 12620886] into rvc-release
Change-Id: If3dab82f5ef50b669aa488a49aebe27bb6070079
2020-09-16 23:30:07 +00:00
Fraunhofer IIS FDK ffff95538e Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels().
In the bug the SBR decoder has already set up 9 channels and tries to
allocate one more channel. The assignment of the QMF channels to SBR
channels fails since the QMF domain manages only 8+1 channels instead
of 10 channels as reqeusted by SBR.
Here we have added a check in sbrDecoder_InitElement() which will
return with a parse error in case additional SBR channels would exceed
the maximum number of SBR channels. This solves the potential heap
buffer overflow.

Bug: 158762825
Test: atest DecoderTestAacDrc DecoderTestAacFormat DecoderTestXheAac
Change-Id: I0150ac6d5a47ffce883010f531928656eebc619e
Merged-In: I0150ac6d5a47ffce883010f531928656eebc619e
(cherry picked from commit bb8f983bf3)
2020-09-16 23:28:22 +00:00
Xin Li a222880e9b [automerger skipped] Merge "Merge Android R" am: 89b6626d5d -s ours am: 26a0396347 -s ours am: c0dbde6b33 -s ours am: ec717def34 -s ours
am skip reason: Change-Id Idcdb13a8c37b0b4b5446169c3e80dfe55586bc77 with SHA-1 7a0dde5d5d is in history

Original change: https://android-review.googlesource.com/c/platform/external/aac/+/1421866

Change-Id: I33abaa1c2d16e2b0b93b33e942c1e315fd1f29aa
2020-09-11 03:59:15 +00:00
Xin Li ec717def34 [automerger skipped] Merge "Merge Android R" am: 89b6626d5d -s ours am: 26a0396347 -s ours am: c0dbde6b33 -s ours
am skip reason: Change-Id Idcdb13a8c37b0b4b5446169c3e80dfe55586bc77 with SHA-1 7a0dde5d5d is in history

Original change: https://android-review.googlesource.com/c/platform/external/aac/+/1421866

Change-Id: I5b8161f44651f40c168a81ba535e8c26ad5b533e
2020-09-11 03:33:44 +00:00
Xin Li c0dbde6b33 [automerger skipped] Merge "Merge Android R" am: 89b6626d5d -s ours am: 26a0396347 -s ours
am skip reason: Change-Id Idcdb13a8c37b0b4b5446169c3e80dfe55586bc77 with SHA-1 7a0dde5d5d is in history

Original change: https://android-review.googlesource.com/c/platform/external/aac/+/1421866

Change-Id: I1713993ae0e8fb75c4e27fdad6c8e263b7391a03
2020-09-11 02:02:53 +00:00
Xin Li 26a0396347 [automerger skipped] Merge "Merge Android R" am: 89b6626d5d -s ours
am skip reason: Change-Id Idcdb13a8c37b0b4b5446169c3e80dfe55586bc77 with SHA-1 7a0dde5d5d is in history

Original change: https://android-review.googlesource.com/c/platform/external/aac/+/1421866

Change-Id: I6d537ca8862ea4f0409b2f173ab9d7e9cafc70ae
2020-09-11 00:40:34 +00:00
Xin Li 89b6626d5d Merge "Merge Android R" 2020-09-10 17:22:12 +00:00
Fraunhofer IIS FDK 543db9d0bd [automerger skipped] [DO NOT MERGE] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: 50aa5be388 am: 0468e02e5b am: d20df7ee14 -s ours am: 80ebc985fb -s ours am: 035cf671b8 am: ce38f54339 -s ours am: a3d45a6804 am: aa6329fb90 am: 8ad12f29d8
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12088847

Change-Id: Iefa0bc6d2f856953743b58518ce85ecc9d268428
2020-09-10 00:00:19 +00:00
Fraunhofer IIS FDK 098059f5bb [automerger skipped] [DO NOT MERGE] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: 50aa5be388 am: 0468e02e5b am: d20df7ee14 -s ours am: 80ebc985fb -s ours am: 035cf671b8 am: ce38f54339 -s ours am: a3d45a6804 am: 846f899a2f am: 7b0e1e7056
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12088847

Change-Id: I6c6b66c316ec178db6d1e17712c07fe7819c9a10
2020-09-09 23:58:02 +00:00
Fraunhofer IIS FDK fd762222af [automerger skipped] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: c516539a20 am: 17dd8dfad9 am: 8336b89345 -s ours am: 971b630c47 -s ours am: e82257ae36 -s ours am: 1935ab0459 -s ours
am skip reason: Change-Id I0150ac6d5a47ffce883010f531928656eebc619e with SHA-1 bb8f983bf3 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12091300

Change-Id: I040218276ea001057c4caf0174917b6d4019a77b
2020-09-09 23:57:55 +00:00
Fraunhofer IIS FDK 7b0e1e7056 [automerger skipped] [DO NOT MERGE] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: 50aa5be388 am: 0468e02e5b am: d20df7ee14 -s ours am: 80ebc985fb -s ours am: 035cf671b8 am: ce38f54339 -s ours am: a3d45a6804 am: 846f899a2f
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12088847

Change-Id: I26b07435bd9342cc5d03ab1b592a9c2327e200c2
2020-09-09 23:57:28 +00:00
Fraunhofer IIS FDK 52ee4c21d8 [automerger skipped] [DO NOT MERGE] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: 50aa5be388 am: 0468e02e5b am: d20df7ee14 -s ours am: 80ebc985fb -s ours am: 035cf671b8 am: ce38f54339 -s ours am: a3d45a6804 am: aa6329fb90 am: 421e4c1cdf
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12088847

Change-Id: I1bc389e9d78adac54555747734eb944ce4252e02
2020-09-09 23:57:27 +00:00
Fraunhofer IIS FDK 1935ab0459 [automerger skipped] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: c516539a20 am: 17dd8dfad9 am: 8336b89345 -s ours am: 971b630c47 -s ours am: e82257ae36 -s ours
am skip reason: Change-Id I0150ac6d5a47ffce883010f531928656eebc619e with SHA-1 bb8f983bf3 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12091300

Change-Id: If77ba60c209bf8f0eab292b75cd5c6d5ec82ac3b
2020-09-09 23:57:15 +00:00
Fraunhofer IIS FDK 8e26f8d6b3 [automerger skipped] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: c516539a20 am: 17dd8dfad9 am: 8336b89345 -s ours am: 971b630c47 -s ours am: 4ee75655ab -s ours am: eb737fb95b -s ours
am skip reason: Change-Id I0150ac6d5a47ffce883010f531928656eebc619e with SHA-1 bb8f983bf3 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12091300

Change-Id: I11fbcafea541a3a8cea729f0b6e76b905998ccfb
2020-09-09 23:57:01 +00:00
Fraunhofer IIS FDK 8a856643ac [automerger skipped] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: c516539a20 am: 17dd8dfad9 am: 8336b89345 -s ours am: 971b630c47 -s ours am: 4ee75655ab -s ours am: 9474f4eb44 -s ours
am skip reason: Change-Id I0150ac6d5a47ffce883010f531928656eebc619e with SHA-1 bb8f983bf3 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12091300

Change-Id: I6089f72bd3a957d4ba782a933d9f28802d5d2978
2020-09-09 23:56:13 +00:00
Fraunhofer IIS FDK 8ad12f29d8 [automerger skipped] [DO NOT MERGE] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: 50aa5be388 am: 0468e02e5b am: d20df7ee14 -s ours am: 80ebc985fb -s ours am: 035cf671b8 am: ce38f54339 -s ours am: a3d45a6804 am: aa6329fb90
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12088847

Change-Id: I8235c710a39639720ca3a52f6a0c84f3cbc6fe5f
2020-09-09 23:25:20 +00:00
Fraunhofer IIS FDK 421e4c1cdf [automerger skipped] [DO NOT MERGE] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: 50aa5be388 am: 0468e02e5b am: d20df7ee14 -s ours am: 80ebc985fb -s ours am: 035cf671b8 am: ce38f54339 -s ours am: a3d45a6804 am: aa6329fb90
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12088847

Change-Id: I2466f0be7926e6f135d774f0289198af18753804
2020-09-09 23:25:20 +00:00
Fraunhofer IIS FDK eb737fb95b [automerger skipped] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: c516539a20 am: 17dd8dfad9 am: 8336b89345 -s ours am: 971b630c47 -s ours am: 4ee75655ab -s ours
am skip reason: Change-Id I0150ac6d5a47ffce883010f531928656eebc619e with SHA-1 bb8f983bf3 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12091300

Change-Id: I92f87237ef6f4a0b9a21801e738378d550e98465
2020-09-09 23:25:12 +00:00
Fraunhofer IIS FDK 9474f4eb44 [automerger skipped] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: c516539a20 am: 17dd8dfad9 am: 8336b89345 -s ours am: 971b630c47 -s ours am: 4ee75655ab -s ours
am skip reason: Change-Id I0150ac6d5a47ffce883010f531928656eebc619e with SHA-1 bb8f983bf3 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12091300

Change-Id: Ie76449e6f28f51989ed628d4f996992147e72621
2020-09-09 23:25:11 +00:00
Fraunhofer IIS FDK 846f899a2f [automerger skipped] [DO NOT MERGE] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: 50aa5be388 am: 0468e02e5b am: d20df7ee14 -s ours am: 80ebc985fb -s ours am: 035cf671b8 am: ce38f54339 -s ours am: a3d45a6804
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12088847

Change-Id: Icfcbfe06d528323ba83366db8bae197082329037
2020-09-09 23:17:24 +00:00
Fraunhofer IIS FDK e82257ae36 [automerger skipped] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: c516539a20 am: 17dd8dfad9 am: 8336b89345 -s ours am: 971b630c47 -s ours
am skip reason: Change-Id I0150ac6d5a47ffce883010f531928656eebc619e with SHA-1 bb8f983bf3 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12091300

Change-Id: I26b8dd96bf69eadd2fbee7487516667598ba546a
2020-09-09 23:17:18 +00:00
Fraunhofer IIS FDK aa6329fb90 [automerger skipped] [DO NOT MERGE] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: 50aa5be388 am: 0468e02e5b am: d20df7ee14 -s ours am: 80ebc985fb -s ours am: 035cf671b8 am: ce38f54339 -s ours am: a3d45a6804
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12088847

Change-Id: Idd4c6d188cc413f82b83b02ceee852d432a1e827
2020-09-09 23:16:47 +00:00
Fraunhofer IIS FDK 4ee75655ab [automerger skipped] Fix heap buffer overflow in sbrDecoder_AssignQmfChannels2SbrChannels(). am: c516539a20 am: 17dd8dfad9 am: 8336b89345 -s ours am: 971b630c47 -s ours
am skip reason: Change-Id I0150ac6d5a47ffce883010f531928656eebc619e with SHA-1 bb8f983bf3 is in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/aac/+/12091300

Change-Id: I8b35930cca12c2c5e2eb2614af497119b479b51a
2020-09-09 23:16:39 +00:00