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

Commit c77e12ff authored by Gopalakrishnan Nallasamy's avatar Gopalakrishnan Nallasamy Committed by Lajos Molnar
Browse files

FrameDecoder:Add format details for RGBA1010102

Skia library requires the output in RGBA1010102, codec outputs in
YCbCr_P010. Define MediaCodec constants for RGBA1010102.

Bug: 206456921

Test: atest android.media.cts.ImageReaderDecoderTest
Change-Id: Iaaed14ac3d278185d1c6dde8b6586e98cf7f0599
parent e36588e4
Loading
Loading
Loading
Loading
+30 −4
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <media/stagefright/FrameCaptureProcessor.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaCodec.h>
#include <media/stagefright/MediaCodecConstants.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/Utils.h>
@@ -192,6 +193,13 @@ bool getDstColorFormat(
            *dstBpp = 4;
            return true;
        }
        case HAL_PIXEL_FORMAT_RGBA_1010102:
        {
            *dstFormat = (OMX_COLOR_FORMATTYPE)COLOR_Format32bitABGR2101010;
            *captureFormat = ui::PixelFormat::RGBA_1010102;
            *dstBpp = 4;
            return true;
        }
        default:
        {
            ALOGE("Unsupported color format: %d", colorFormat);
@@ -523,8 +531,12 @@ sp<AMessage> VideoFrameDecoder::onGetFormatAndSeekOptions(
        return NULL;
    }

    if (dstFormat() == COLOR_Format32bitABGR2101010) {
        videoFormat->setInt32("color-format", COLOR_FormatYUVP010);
    } else {
        // TODO: Use Flexible color instead
        videoFormat->setInt32("color-format", OMX_COLOR_FormatYUV420Planar);
    }

    // For the thumbnail extraction case, try to allocate single buffer in both
    // input and output ports, if seeking to a sync frame. NOTE: This request may
@@ -632,6 +644,11 @@ status_t VideoFrameDecoder::onOutputReceived(
        crop_bottom = height - 1;
    }

    int32_t slice_height;
    if (outputFormat->findInt32("slice-height", &slice_height) && slice_height > 0) {
        height = slice_height;
    }

    if (mFrame == NULL) {
        sp<IMemory> frameMem = allocVideoFrame(
                trackMeta(),
@@ -823,8 +840,12 @@ sp<AMessage> MediaImageDecoder::onGetFormatAndSeekOptions(
        return NULL;
    }

    if (dstFormat() == COLOR_Format32bitABGR2101010) {
        videoFormat->setInt32("color-format", COLOR_FormatYUVP010);
    } else {
        // TODO: Use Flexible color instead
        videoFormat->setInt32("color-format", OMX_COLOR_FormatYUV420Planar);
    }

    if ((mGridRows == 1) && (mGridCols == 1)) {
        videoFormat->setInt32("android._num-input-buffers", 1);
@@ -930,6 +951,11 @@ status_t MediaImageDecoder::onOutputReceived(
        crop_bottom = height - 1;
    }

    int32_t slice_height;
    if (outputFormat->findInt32("slice-height", &slice_height) && slice_height > 0) {
        height = slice_height;
    }

    int32_t crop_width, crop_height;
    crop_width = crop_right - crop_left + 1;
    crop_height = crop_bottom - crop_top + 1;
+3 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <media/stagefright/foundation/ALooper.h>
#include <media/stagefright/foundation/ColorUtils.h>
#include <media/stagefright/ColorConverter.h>
#include <media/stagefright/MediaCodecConstants.h>
#include <media/stagefright/MediaErrors.h>

#include "libyuv/convert_from.h"
@@ -51,7 +52,8 @@ namespace android {
static bool isRGB(OMX_COLOR_FORMATTYPE colorFormat) {
    return colorFormat == OMX_COLOR_Format16bitRGB565
            || colorFormat == OMX_COLOR_Format32BitRGBA8888
            || colorFormat == OMX_COLOR_Format32bitBGRA8888;
            || colorFormat == OMX_COLOR_Format32bitBGRA8888
            || colorFormat == COLOR_Format32bitABGR2101010;
}

bool ColorConverter::ColorSpace::isBt709() {
@@ -102,7 +104,6 @@ bool ColorConverter::isValid() const {
#else
            return mDstFormat == OMX_COLOR_Format16bitRGB565;
#endif

        default:
            return false;
    }