Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba1f0ab5 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Remove 6 out of 8 RefBase references from mkv extractor

Bug: 67908544
Test: CTS DecoderTest
Change-Id: I04b6cda83861e70f1de70abc671dd791327be159
parent 9510d041
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
../../media/libmediaextractor/include/media/ExtractorUtils.h
 No newline at end of file
+7 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "MatroskaExtractor.h"

#include <media/DataSourceBase.h>
#include <media/ExtractorUtils.h>
#include <media/MediaTrack.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AUtils.h>
@@ -1108,7 +1109,7 @@ static status_t addFlacMetadata(
    meta.setData(kKeyFlacMetadata, 0, codecPrivate, codecPrivateSize);

    int32_t maxInputSize = 64 << 10;
    sp<FLACDecoder> flacDecoder = FLACDecoder::Create();
    FLACDecoder *flacDecoder = FLACDecoder::Create();
    if (flacDecoder != NULL
            && flacDecoder->parseMetadata((const uint8_t*)codecPrivate, codecPrivateSize) == OK) {
        FLAC__StreamMetadata_StreamInfo streamInfo = flacDecoder->getStreamInfo();
@@ -1120,6 +1121,7 @@ static status_t addFlacMetadata(
                    && streamInfo.channels != 0
                    && ((streamInfo.bits_per_sample + 7) / 8) >
                        INT32_MAX / streamInfo.max_blocksize / streamInfo.channels) {
                delete flacDecoder;
                return ERROR_MALFORMED;
            }
            maxInputSize = ((streamInfo.bits_per_sample + 7) / 8)
@@ -1128,6 +1130,7 @@ static status_t addFlacMetadata(
    }
    meta.setInt32(kKeyMaxInputSize, maxInputSize);

    delete flacDecoder;
    return OK;
}

@@ -1143,13 +1146,13 @@ status_t MatroskaExtractor::synthesizeAVCC(TrackInfo *trackInfo, size_t index) {
    }

    const mkvparser::Block::Frame &frame = block->GetFrame(0);
    sp<ABuffer> abuf = new ABuffer(frame.len);
    long n = frame.Read(mReader, abuf->data());
    auto tmpData = heapbuffer<unsigned char>(frame.len);
    long n = frame.Read(mReader, tmpData.get());
    if (n != 0) {
        return ERROR_MALFORMED;
    }

    if (!MakeAVCCodecSpecificData(trackInfo->mMeta, abuf)) {
    if (!MakeAVCCodecSpecificData(trackInfo->mMeta, tmpData.get(), frame.len)) {
        return ERROR_MALFORMED;
    }

+3 −12
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include <cutils/properties.h>
#include <media/DataSourceBase.h>
#include <media/ExtractorUtils.h>
#include <media/MediaTrack.h>
#include <media/VorbisComment.h>
#include <media/stagefright/foundation/ABuffer.h>
@@ -990,21 +991,11 @@ status_t MyOpusExtractor::verifyOpusHeader(MediaBufferBase *buffer) {
    return OK;
}

struct TmpData {
    uint8_t *data;
    TmpData(size_t size) {
        data = (uint8_t*) malloc(size);
    }
    ~TmpData() {
        free(data);
    }
};

status_t MyOpusExtractor::verifyOpusComments(MediaBufferBase *buffer) {
    // add artificial framing bit so we can reuse _vorbis_unpack_comment
    int32_t commentSize = buffer->range_length() + 1;
    TmpData commentDataHolder(commentSize);
    uint8_t *commentData = commentDataHolder.data;
    auto tmp = heapbuffer<uint8_t>(commentSize);
    uint8_t *commentData = tmp.get();
    if (commentData == nullptr) {
        return ERROR_MALFORMED;
    }
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * 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.
 */

#ifndef EXTRACTOR_UTILS_H_

#define EXTRACTOR_UTILS_H_

#include <memory>

namespace android {

template <class T>
std::unique_ptr<T[]> heapbuffer(size_t size) {
    return std::unique_ptr<T[]>(new (std::nothrow) T[size]);
}

}  // namespace android

#endif  // UTILS_H_
+2 −1
Original line number Diff line number Diff line
@@ -24,11 +24,12 @@

namespace android {

bool MakeAVCCodecSpecificData(MetaDataBase &meta, const sp<ABuffer> &accessUnit) {
bool MakeAVCCodecSpecificData(MetaDataBase &meta, const uint8_t *data, size_t size) {
    int32_t width;
    int32_t height;
    int32_t sarWidth;
    int32_t sarHeight;
    sp<ABuffer> accessUnit = new ABuffer((void*)data,  size);
    sp<ABuffer> csd = MakeAVCCodecSpecificData(accessUnit, &width, &height, &sarWidth, &sarHeight);
    if (csd == nullptr) {
        return false;
Loading