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

Commit 62267fc4 authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Remove libstagefright_filters.

The only caller was the command-line test tool removed last week. Since
this code contains yet more renderscript, we need to either rewrite it
or remove it, so let's remove it in the absence of callers.

Bug: http://b/256932140
Test: treehugger
Change-Id: Idb46f32d12f11ad8ab5e30572ee470d7491207e9
parent aca826f7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -318,7 +318,6 @@ cc_library {
        "libstagefright_esds",
        "libstagefright_color_conversion",
        "libyuv_static",
        "libstagefright_mediafilter",
        "libstagefright_webm",
        "libstagefright_timedtext",
        "libogg",
+0 −3
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@
#include <media/stagefright/MediaCodecConstants.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaFilter.h>
#include <media/stagefright/OMXClient.h>
#include <media/stagefright/PersistentSurface.h>
#include <media/stagefright/SurfaceUtils.h>
@@ -1457,8 +1456,6 @@ sp<CodecBase> MediaCodec::GetCodecBase(const AString &name, const char *owner) {
    } else if (name.startsWithIgnoreCase("omx.")) {
        // at this time only ACodec specifies a mime type.
        return new ACodec;
    } else if (name.startsWithIgnoreCase("android.filter.")) {
        return new MediaFilter;
    } else {
        return NULL;
    }
+0 −52
Original line number Diff line number Diff line
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_av_media_libstagefright_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_av_media_libstagefright_license"],
}

cc_library_static {
    name: "libstagefright_mediafilter",

    srcs: [
        "ColorConvert.cpp",
        "GraphicBufferListener.cpp",
        "IntrinsicBlurFilter.cpp",
        "MediaFilter.cpp",
        "RSFilter.cpp",
        "SaturationFilter.cpp",
        "saturationARGB.rscript",
        "SimpleFilter.cpp",
        "ZeroFilter.cpp",
    ],

    export_include_dirs: [
        "include",
    ],

    local_include_dirs: [
        "include/filters",
    ],

    cflags: [
        "-Wno-multichar",
        "-Werror",
        "-Wall",
    ],

    header_libs: [
        "libmediadrm_headers",
    ],

    shared_libs: [
        "libgui",
        "libmedia",
        "libhidlmemory",
    ],

    sanitize: {
        cfi: true,
    },
}
+0 −111
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.
 */

#include "ColorConvert.h"

#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif

namespace android {

void YUVToRGB(
        int32_t y, int32_t u, int32_t v,
        int32_t* r, int32_t* g, int32_t* b) {
    y -= 16;
    u -= 128;
    v -= 128;

    *b = 1192 * y + 2066 * u;
    *g = 1192 * y - 833 * v - 400 * u;
    *r = 1192 * y + 1634 * v;

    *r = min(262143, max(0, *r));
    *g = min(262143, max(0, *g));
    *b = min(262143, max(0, *b));

    *r >>= 10;
    *g >>= 10;
    *b >>= 10;
}

void convertYUV420spToARGB(
        uint8_t *pY, uint8_t *pUV, int32_t width, int32_t height,
        uint8_t *dest) {
    const int32_t bytes_per_pixel = 2;

    for (int32_t i = 0; i < height; i++) {
        for (int32_t j = 0; j < width; j++) {
            int32_t y = *(pY + i * width + j);
            int32_t u = *(pUV + (i/2) * width + bytes_per_pixel * (j/2));
            int32_t v = *(pUV + (i/2) * width + bytes_per_pixel * (j/2) + 1);

            int32_t r, g, b;
            YUVToRGB(y, u, v, &r, &g, &b);

            *dest++ = 0xFF;
            *dest++ = r;
            *dest++ = g;
            *dest++ = b;
        }
    }
}

void convertYUV420spToRGB888(
        uint8_t *pY, uint8_t *pUV, int32_t width, int32_t height,
        uint8_t *dest) {
    const int32_t bytes_per_pixel = 2;

    for (int32_t i = 0; i < height; i++) {
        for (int32_t j = 0; j < width; j++) {
            int32_t y = *(pY + i * width + j);
            int32_t u = *(pUV + (i/2) * width + bytes_per_pixel * (j/2));
            int32_t v = *(pUV + (i/2) * width + bytes_per_pixel * (j/2) + 1);

            int32_t r, g, b;
            YUVToRGB(y, u, v, &r, &g, &b);

            *dest++ = r;
            *dest++ = g;
            *dest++ = b;
        }
    }
}

// HACK - not even slightly optimized
// TODO: remove when RGBA support is added to SoftwareRenderer
void convertRGBAToARGB(
        uint8_t *src, int32_t width, int32_t height, uint32_t stride,
        uint8_t *dest) {
    for (int32_t i = 0; i < height; ++i) {
        for (int32_t j = 0; j < width; ++j) {
            uint8_t r = *src++;
            uint8_t g = *src++;
            uint8_t b = *src++;
            uint8_t a = *src++;
            *dest++ = a;
            *dest++ = r;
            *dest++ = g;
            *dest++ = b;
        }
        src += (stride - width) * 4;
    }
}

}   // namespace android
+0 −155
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "GraphicBufferListener"

#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/MediaErrors.h>

#include <gui/BufferItem.h>
#include <utils/String8.h>

#include "GraphicBufferListener.h"

namespace android {

status_t GraphicBufferListener::init(
        const sp<AMessage> &notify,
        size_t bufferWidth, size_t bufferHeight, size_t bufferCount) {
    mNotify = notify;

    String8 name("GraphicBufferListener");
    BufferQueue::createBufferQueue(&mProducer, &mConsumer);
    mConsumer->setConsumerName(name);
    mConsumer->setDefaultBufferSize(bufferWidth, bufferHeight);
    mConsumer->setConsumerUsageBits(GRALLOC_USAGE_SW_READ_OFTEN);

    status_t err = mConsumer->setMaxAcquiredBufferCount(bufferCount);
    if (err != NO_ERROR) {
        ALOGE("Unable to set BQ max acquired buffer count to %zu: %d",
                bufferCount, err);
        return err;
    }

    wp<BufferQueue::ConsumerListener> listener =
        static_cast<BufferQueue::ConsumerListener*>(this);
    sp<BufferQueue::ProxyConsumerListener> proxy =
        new BufferQueue::ProxyConsumerListener(listener);

    err = mConsumer->consumerConnect(proxy, false);
    if (err != NO_ERROR) {
        ALOGE("Error connecting to BufferQueue: %s (%d)",
                strerror(-err), err);
        return err;
    }

    ALOGV("init() successful.");

    return OK;
}

void GraphicBufferListener::onFrameAvailable(const BufferItem& /* item */) {
    ALOGV("onFrameAvailable() called");

    {
        Mutex::Autolock autoLock(mMutex);
        mNumFramesAvailable++;
    }

    sp<AMessage> notify = mNotify->dup();
    mNotify->setWhat(kWhatFrameAvailable);
    mNotify->post();
}

void GraphicBufferListener::onBuffersReleased() {
    ALOGV("onBuffersReleased() called");
    // nothing to do
}

void GraphicBufferListener::onSidebandStreamChanged() {
    ALOGW("GraphicBufferListener cannot consume sideband streams.");
    // nothing to do
}

BufferItem GraphicBufferListener::getBufferItem() {
    BufferItem item;

    {
        Mutex::Autolock autoLock(mMutex);
        if (mNumFramesAvailable <= 0) {
            ALOGE("getBuffer() called with no frames available");
            return item;
        }
        mNumFramesAvailable--;
    }

    status_t err = mConsumer->acquireBuffer(&item, 0);
    if (err == BufferQueue::NO_BUFFER_AVAILABLE) {
        // shouldn't happen, since we track num frames available
        ALOGE("frame was not available");
        item.mSlot = -1;
        return item;
    } else if (err != OK) {
        ALOGE("acquireBuffer returned err=%d", err);
        item.mSlot = -1;
        return item;
    }

    // Wait for it to become available.
    err = item.mFence->waitForever("GraphicBufferListener::getBufferItem");
    if (err != OK) {
        ALOGW("failed to wait for buffer fence: %d", err);
        // keep going
    }

    // If this is the first time we're seeing this buffer, add it to our
    // slot table.
    if (item.mGraphicBuffer != NULL) {
        ALOGV("setting mBufferSlot %d", item.mSlot);
        mBufferSlot[item.mSlot] = item.mGraphicBuffer;
    }

    return item;
}

sp<GraphicBuffer> GraphicBufferListener::getBuffer(BufferItem item) {
    sp<GraphicBuffer> buf;
    if (item.mSlot < 0 || item.mSlot >= BufferQueue::NUM_BUFFER_SLOTS) {
        ALOGE("getBuffer() received invalid BufferItem: mSlot==%d", item.mSlot);
        return buf;
    }

    buf = mBufferSlot[item.mSlot];
    CHECK(buf.get() != NULL);

    return buf;
}

status_t GraphicBufferListener::releaseBuffer(BufferItem item) {
    if (item.mSlot < 0 || item.mSlot >= BufferQueue::NUM_BUFFER_SLOTS) {
        ALOGE("getBuffer() received invalid BufferItem: mSlot==%d", item.mSlot);
        return ERROR_OUT_OF_RANGE;
    }

    mConsumer->releaseBuffer(item.mSlot, item.mFrameNumber,
            EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE);

    return OK;
}

}   // namespace android
Loading