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

Commit f6b3e5e9 authored by Harish Mahendrakar's avatar Harish Mahendrakar
Browse files

C2: Update graphic buffer allocation calls to allow odd dimensions

Use width and height aligned to multiples of two while allocating
graphic buffers in the encode path.

Also allow width and height to be odd while converting from RGB
to YUV.

This is necessary to allow encoders to support odd dimensions.

Bug: 329378524
Bug: 325679394
Test: atest CtsMediaEncoderTestCases:VideoEncoderTest
Change-Id: I30533df402603a83874408a49b2f15747f8e972d
parent 75b19fc6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include <media/openmax/OMX_Core.h>
#include <media/openmax/OMX_IndexExt.h>
#include <media/stagefright/foundation/avc_utils.h>
#include <media/stagefright/foundation/AUtils.h>
#include <media/stagefright/omx/1.0/WGraphicBufferSource.h>
#include <media/stagefright/omx/OmxGraphicBufferSource.h>
#include <media/stagefright/CCodec.h>
@@ -1458,7 +1459,8 @@ void CCodec::configure(const sp<AMessage> &msg) {
                int64_t blockUsage =
                    usage.value | C2MemoryUsage::CPU_READ | C2MemoryUsage::CPU_WRITE;
                std::shared_ptr<C2GraphicBlock> block = FetchGraphicBlock(
                        width, height, componentColorFormat, blockUsage, {comp->getName()});
                        align(width, 2), align(height, 2), componentColorFormat, blockUsage,
                        {comp->getName()});
                sp<GraphicBlockBuffer> buffer;
                if (block) {
                    buffer = GraphicBlockBuffer::Allocate(
+2 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <C2PlatformSupport.h>

#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AUtils.h>
#include <media/stagefright/foundation/MediaDefs.h>
#include <media/stagefright/CodecBase.h>
#include <media/stagefright/MediaCodecConstants.h>
@@ -57,7 +58,7 @@ sp<GraphicBlockBuffer> AllocateInputGraphicBuffer(

    std::shared_ptr<C2GraphicBlock> block;
    c2_status_t err = pool->fetchGraphicBlock(
            width, height, pixelFormat, fullUsage, &block);
            align(width, 2), align(height, 2), pixelFormat, fullUsage, &block);
    if (err != C2_OK) {
        ALOGD("fetch graphic block failed: %d", err);
        return nullptr;
+0 −2
Original line number Diff line number Diff line
@@ -593,8 +593,6 @@ status_t ConvertRGBToPlanarYUV(
        uint8_t *dstY, size_t dstStride, size_t dstVStride, size_t bufferSize,
        const C2GraphicView &src, C2Color::matrix_t colorMatrix, C2Color::range_t colorRange) {
    CHECK(dstY != nullptr);
    CHECK((src.width() & 1) == 0);
    CHECK((src.height() & 1) == 0);

    if (dstStride * dstVStride * 3 / 2 > bufferSize) {
        ALOGD("conversion buffer is too small for converting from RGB to YUV");