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

Commit 5a28b0ea authored by Luis GarciaCalderon's avatar Luis GarciaCalderon Committed by Ricardo Cerqueira
Browse files

libstagefright: Add NV12 Tile to RGB color conversion

- Adds support of NV12 Tile to RGB565 color conversion
using the qcom color convertor library.

Patchset 1: Add QCOM_HARDWARE ifdefs

Change-Id: I8f6fa92651b666376af514b46a5027f56492dd43
parent 79b0b331
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@
#include <media/stagefright/MediaErrors.h>

#ifdef QCOM_HARDWARE
#include <dlfcn.h>
#include <OMX_QCOMExtns.h>
#include <QOMX_AudioExtensions.h>
#endif
@@ -52,6 +54,9 @@ bool ColorConverter::isValid() const {
        case OMX_QCOM_COLOR_FormatYVU420SemiPlanar:
        case OMX_COLOR_FormatYUV420SemiPlanar:
        case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar:
#ifdef QCOM_HARDWARE
        case QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka:
#endif
            return true;

        default:
@@ -127,6 +132,46 @@ status_t ColorConverter::convert(
            err = convertTIYUV420PackedSemiPlanar(src, dst);
            break;

#ifdef QCOM_HARDWARE
        case QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka:
            {
                void * lib = dlopen("libmm-color-convertor.so", RTLD_NOW);
                typedef int (*convertFn)(ColorConvertParams src, ColorConvertParams dst, uint8_t *adjustedClip);

                convertFn convertNV12Tile = (convertFn)dlsym(lib, "_Z7convertN7android18ColorConvertParamsES0_Ph");

                struct ColorConvertParams srcTemp;
                srcTemp.width = srcWidth;
                srcTemp.height = srcHeight;
                srcTemp.cropWidth = src.cropWidth();
                srcTemp.cropHeight = src.cropHeight();
                srcTemp.cropLeft = src.mCropLeft;
                srcTemp.cropRight = src.mCropRight;
                srcTemp.cropTop = src.mCropTop;
                srcTemp.cropBottom = src.mCropBottom;
                srcTemp.data = src.mBits;
                srcTemp.colorFormat = YCbCr420Tile;
                srcTemp.flags = 0;

                struct ColorConvertParams dstTemp;
                dstTemp.width = dstWidth;
                dstTemp.height = dstHeight;
                dstTemp.cropWidth = dst.cropWidth();
                dstTemp.cropHeight = dst.cropHeight();
                dstTemp.cropLeft = dst.mCropLeft;
                dstTemp.cropRight = dst.mCropRight;
                dstTemp.cropTop = dst.mCropTop;
                dstTemp.cropBottom = dst.mCropBottom;
                dstTemp.data = dst.mBits;
                dstTemp.colorFormat = RGB565;
                dstTemp.flags = 0;

                uint8_t * adjustedClip = initClip();
                err = convertNV12Tile(srcTemp, dstTemp, adjustedClip);
                dlclose(lib);
            }
            break;
#endif
        default:
        {
            CHECK(!"Should not be here. Unknown color conversion.");