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

Commit 258bb979 authored by Fyodor Kyslov's avatar Fyodor Kyslov Committed by Gerrit Code Review
Browse files

Merge "APV: Implement NV21 to P210 support" into main

parents 097d4746 e23f76ab
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1023,7 +1023,7 @@ c2_status_t C2SoftApvEnc::setEncodeArgs(oapv_frms_t* inputFrames, const C2Graphi
                    ALOGE("Not supported color format. %d", mColorFormat);
                    return C2_BAD_VALUE;
                }
            } else if (IsNV12(*input)) {
            } else if (IsNV12(*input) || IsNV21(*input)) {
                ALOGV("Convert from NV12 to P210");
                uint8_t  *srcY  = (uint8_t*)input->data()[0];
                uint8_t  *srcUV = (uint8_t*)input->data()[1];
@@ -1035,7 +1035,7 @@ c2_status_t C2SoftApvEnc::setEncodeArgs(oapv_frms_t* inputFrames, const C2Graphi
                                         layout.planes[layout.PLANE_Y].rowInc,
                                         layout.planes[layout.PLANE_U].rowInc,
                                         dstYStride, dstUVStride,
                                         width, height, CONV_FORMAT_I420);
                                         width, height, CONV_FORMAT_I420, IsNV12(*input));
            } else if (IsI420(*input)) {
                ALOGV("Convert from I420 to P210");
                uint8_t  *srcY  = (uint8_t*)input->data()[0];
+22 −7
Original line number Diff line number Diff line
@@ -749,7 +749,9 @@ void convertSemiPlanar8ToP210(uint16_t *dstY, uint16_t *dstUV,
                              size_t srcYStride, size_t srcUVStride,
                              size_t dstYStride, size_t dstUVStride,
                              uint32_t width, uint32_t height,
                              CONV_FORMAT_T format) {
                              CONV_FORMAT_T format, bool isNV12) {
  // This function assumes that dstStride/width are even.
  // The check for this is performed by the caller
  if (format != CONV_FORMAT_I420) {
    ALOGE("No support for semi-planar8 to P210. format is %d", format);
    return;
@@ -763,14 +765,27 @@ void convertSemiPlanar8ToP210(uint16_t *dstY, uint16_t *dstUV,
    srcY += srcYStride;
  }

  if (isNV12) {
    for (int32_t y = 0; y < (height + 1) / 2; ++y) {
    for (int32_t x = 0; x < width; ++x) {
        for (int32_t x = 0; x < width; x++) {
            dstUV[x] = dstUV[dstUVStride + x] =
                ((uint16_t)((double)srcUV[x] * 1023 / 255 + 0.5) << 6) & 0xFFC0;
        }
        srcUV += srcUVStride;
        dstUV += dstUVStride << 1;
    }
  } else { //NV21
    for (int32_t y = 0; y < (height + 1) / 2; ++y) {
        for (int32_t x = 0; x < width; x+=2) {
            dstUV[x+1] = dstUV[dstUVStride + x + 1] =
                ((uint16_t)((double)srcUV[x] * 1023 / 255 + 0.5) << 6) & 0xFFC0;
            dstUV[x] = dstUV[dstUVStride + x] =
                ((uint16_t)((double)srcUV[x + 1] * 1023 / 255 + 0.5) << 6) & 0xFFC0;
        }
        srcUV += srcUVStride;
        dstUV += dstUVStride << 1;
    }
  }
}

void convertPlanar8ToP210(uint16_t *dstY, uint16_t *dstUV,
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ void convertSemiPlanar8ToP210(uint16_t *dstY, uint16_t *dstUV,
                              size_t srcYStride, size_t srcUVStride,
                              size_t dstYStride, size_t dstUVStride,
                              uint32_t width, uint32_t height,
                              CONV_FORMAT_T format);
                              CONV_FORMAT_T format, bool isNV12);
void convertPlanar8ToP210(uint16_t *dstY, uint16_t *dstUV,
                              const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV,
                              size_t srcYStride, size_t srcUStride, size_t srcVStride,