[libfdk-aac] adding libfdk-aac (#2480)

* [glossary] explain cross-pollination

* [glossary] explain cross-pollination

* add fdk-aac

* move fdk-aac to libfdk-aac

* [libfdk-aac] add  -fno-sanitize=shift

* [libfdk-aac] update the contact email, change the repository, disable ubsan's shift-base instead of shift

* [libfdk-aac] change the homepage link

* [libfdk-aac] add one CC entry
This commit is contained in:
Kostya Serebryany 2019-06-17 13:20:29 -07:00 committed by Max Moroz
parent 179d9732a2
commit 0cba0117f3
6 changed files with 181 additions and 0 deletions

View File

@ -0,0 +1,20 @@
# Copyright 2019 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
FROM gcr.io/oss-fuzz-base/base-builder
MAINTAINER kcc@google.com
RUN git clone --depth 1 https://android.googlesource.com/platform/external/aac/
COPY build.sh *.cpp $SRC/

View File

@ -0,0 +1,39 @@
// Copyright 2019 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "aacdecoder_lib.h"
#include <stdint.h>
#define FILEREAD_MAX_LAYERS 1
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
HANDLE_AACDECODER aacDecoderInfo = NULL;
UCHAR *conf[FILEREAD_MAX_LAYERS];
UINT confSize[FILEREAD_MAX_LAYERS];
if (Size > 255) return 0;
aacDecoderInfo = aacDecoder_Open(TT_MP4_ADIF, FILEREAD_MAX_LAYERS);
FDK_ASSERT(aacDecoderInfo != NULL);
for (UINT layer = 0; layer < FILEREAD_MAX_LAYERS; layer++) {
conf[layer] = const_cast<UCHAR *>(Data);
confSize[layer] = Size;
}
aacDecoder_ConfigRaw(aacDecoderInfo, conf, confSize);
aacDecoder_Close(aacDecoderInfo);
return 0;
}

View File

@ -0,0 +1,51 @@
// Copyright 2019 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "aacdecoder_lib.h"
#include <stdint.h>
#define FILEREAD_MAX_LAYERS 1
#define OUT_BUF_SIZE (8 * 2048 * 4)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
HANDLE_AACDECODER aacDecoderInfo = NULL;
INT_PCM TimeData[OUT_BUF_SIZE];
AAC_DECODER_ERROR err;
aacDecoderInfo = aacDecoder_Open(TT_MP4_LOAS, FILEREAD_MAX_LAYERS);
FDK_ASSERT(aacDecoderInfo != NULL);
const uint8_t *start = Data;
UINT valid, buffer_size;
do {
valid = buffer_size = Data + Size - start;
err = aacDecoder_Fill(aacDecoderInfo, const_cast<UCHAR **>(&start),
&buffer_size, &valid);
start += buffer_size - valid;
if (err == AAC_DEC_OK) {
do {
err = aacDecoder_DecodeFrame(aacDecoderInfo, TimeData, OUT_BUF_SIZE, 0);
if (err != AAC_DEC_OK && err != AAC_DEC_NOT_ENOUGH_BITS) {
aacDecoder_Close(aacDecoderInfo);
aacDecoderInfo = NULL;
return 0;
}
} while (err != AAC_DEC_NOT_ENOUGH_BITS);
}
} while (valid > 0);
aacDecoder_Close(aacDecoderInfo);
aacDecoderInfo = NULL;
return 0;
}

View File

@ -0,0 +1,36 @@
// Copyright 2019 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "aacdecoder_lib.h"
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
HANDLE_AACDECODER aacDecoderInfo = NULL;
TRANSPORT_TYPE transportType;
INT nrOfLayers;
if (Size != 8) return 0;
transportType = (TRANSPORT_TYPE)(Data[0] + (Data[1] << 8) + (Data[2] << 16) +
(Data[3] << 24));
nrOfLayers =
(UINT)(Data[4] + (Data[5] << 8) + (Data[6] << 16) + (Data[7] << 24));
aacDecoderInfo = aacDecoder_Open(transportType, nrOfLayers);
if (aacDecoderInfo != NULL) {
aacDecoder_Close(aacDecoderInfo);
}
return 0;
}

31
projects/libfdk-aac/build.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash -eu
# Copyright 2019 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
# Build the lib.
INCLUDES=$(for f in $(find aac -name include); do echo -I $f; done)
# exclude -fno-sanitize=shift-base as there are shallow errors.
EXTRA_FLAGS=-fno-sanitize=shift-base
for f in aac/*/src/*.cpp; do
$CXX $CXXFLAGS $INCLUDES $EXTRA_FLAGS -c $f &
done
wait
# Build the fuzz targets.
for target_cpp in *.cpp; do
target=$(basename $target_cpp .cpp)
$CXX $CXXFLAGS $EXTRA_FLAGS $target_cpp $INCLUDES *.o -lm $LIB_FUZZING_ENGINE -o $OUT/$target
done

View File

@ -0,0 +1,4 @@
homepage: https://android.googlesource.com/platform/external/aac/
primary_contact: audio-fdk@iis.fraunhofer.de
auto_ccs:
- "jmtrivi@google.com"