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

Commit 5a043534 authored by James Dong's avatar James Dong
Browse files

Remove the restriction that the width must be a multiple of 4 or 2 for thumbnail generation

o simply applying the change in commit a161af9d to other formats
o related-to-bug: 5947196

Change-Id: I95de10263b8ad9ec941f1d6b907fca6aeff0a90f
parent 3a29869d
Loading
Loading
Loading
Loading
+35 −22
Original line number Diff line number Diff line
@@ -144,8 +144,8 @@ status_t ColorConverter::convertCbYCrY(
        return ERROR_UNSUPPORTED;
    }

    uint32_t *dst_ptr = (uint32_t *)dst.mBits
        + (dst.mCropTop * dst.mWidth + dst.mCropLeft) / 2;
    uint16_t *dst_ptr = (uint16_t *)dst.mBits
        + dst.mCropTop * dst.mWidth + dst.mCropLeft;

    const uint8_t *src_ptr = (const uint8_t *)src.mBits
        + (src.mCropTop * dst.mWidth + src.mCropLeft) * 2;
@@ -182,11 +182,15 @@ status_t ColorConverter::convertCbYCrY(
                | ((kAdjustedClip[g2] >> 2) << 5)
                | (kAdjustedClip[b2] >> 3);

            dst_ptr[x / 2] = (rgb2 << 16) | rgb1;
            if (x + 1 < src.cropWidth()) {
                *(uint32_t *)(&dst_ptr[x]) = (rgb2 << 16) | rgb1;
            } else {
                dst_ptr[x] = rgb1;
            }
        }

        src_ptr += src.mWidth * 2;
        dst_ptr += dst.mWidth / 2;
        dst_ptr += dst.mWidth;
    }

    return OK;
@@ -290,15 +294,14 @@ status_t ColorConverter::convertQCOMYUV420SemiPlanar(
        const BitmapParams &src, const BitmapParams &dst) {
    uint8_t *kAdjustedClip = initClip();

    if (!((dst.mWidth & 3) == 0
            && (src.mCropLeft & 1) == 0
    if (!((src.mCropLeft & 1) == 0
            && src.cropWidth() == dst.cropWidth()
            && src.cropHeight() == dst.cropHeight())) {
        return ERROR_UNSUPPORTED;
    }

    uint32_t *dst_ptr = (uint32_t *)dst.mBits
        + (dst.mCropTop * dst.mWidth + dst.mCropLeft) / 2;
    uint16_t *dst_ptr = (uint16_t *)dst.mBits
        + dst.mCropTop * dst.mWidth + dst.mCropLeft;

    const uint8_t *src_y =
        (const uint8_t *)src.mBits + src.mCropTop * src.mWidth + src.mCropLeft;
@@ -340,7 +343,11 @@ status_t ColorConverter::convertQCOMYUV420SemiPlanar(
                | ((kAdjustedClip[g2] >> 2) << 5)
                | (kAdjustedClip[r2] >> 3);

            dst_ptr[x / 2] = (rgb2 << 16) | rgb1;
            if (x + 1 < src.cropWidth()) {
                *(uint32_t *)(&dst_ptr[x]) = (rgb2 << 16) | rgb1;
            } else {
                dst_ptr[x] = rgb1;
            }
        }

        src_y += src.mWidth;
@@ -349,7 +356,7 @@ status_t ColorConverter::convertQCOMYUV420SemiPlanar(
            src_u += src.mWidth;
        }

        dst_ptr += dst.mWidth / 2;
        dst_ptr += dst.mWidth;
    }

    return OK;
@@ -361,15 +368,14 @@ status_t ColorConverter::convertYUV420SemiPlanar(

    uint8_t *kAdjustedClip = initClip();

    if (!((dst.mWidth & 3) == 0
            && (src.mCropLeft & 1) == 0
    if (!((src.mCropLeft & 1) == 0
            && src.cropWidth() == dst.cropWidth()
            && src.cropHeight() == dst.cropHeight())) {
        return ERROR_UNSUPPORTED;
    }

    uint32_t *dst_ptr = (uint32_t *)dst.mBits
        + (dst.mCropTop * dst.mWidth + dst.mCropLeft) / 2;
    uint16_t *dst_ptr = (uint16_t *)dst.mBits
        + dst.mCropTop * dst.mWidth + dst.mCropLeft;

    const uint8_t *src_y =
        (const uint8_t *)src.mBits + src.mCropTop * src.mWidth + src.mCropLeft;
@@ -411,7 +417,11 @@ status_t ColorConverter::convertYUV420SemiPlanar(
                | ((kAdjustedClip[g2] >> 2) << 5)
                | (kAdjustedClip[r2] >> 3);

            dst_ptr[x / 2] = (rgb2 << 16) | rgb1;
            if (x + 1 < src.cropWidth()) {
                *(uint32_t *)(&dst_ptr[x]) = (rgb2 << 16) | rgb1;
            } else {
                dst_ptr[x] = rgb1;
            }
        }

        src_y += src.mWidth;
@@ -420,7 +430,7 @@ status_t ColorConverter::convertYUV420SemiPlanar(
            src_u += src.mWidth;
        }

        dst_ptr += dst.mWidth / 2;
        dst_ptr += dst.mWidth;
    }

    return OK;
@@ -430,15 +440,14 @@ status_t ColorConverter::convertTIYUV420PackedSemiPlanar(
        const BitmapParams &src, const BitmapParams &dst) {
    uint8_t *kAdjustedClip = initClip();

    if (!((dst.mWidth & 3) == 0
            && (src.mCropLeft & 1) == 0
    if (!((src.mCropLeft & 1) == 0
            && src.cropWidth() == dst.cropWidth()
            && src.cropHeight() == dst.cropHeight())) {
        return ERROR_UNSUPPORTED;
    }

    uint32_t *dst_ptr = (uint32_t *)dst.mBits
        + (dst.mCropTop * dst.mWidth + dst.mCropLeft) / 2;
    uint16_t *dst_ptr = (uint16_t *)dst.mBits
        + dst.mCropTop * dst.mWidth + dst.mCropLeft;

    const uint8_t *src_y = (const uint8_t *)src.mBits;

@@ -478,7 +487,11 @@ status_t ColorConverter::convertTIYUV420PackedSemiPlanar(
                | ((kAdjustedClip[g2] >> 2) << 5)
                | (kAdjustedClip[b2] >> 3);

            dst_ptr[x / 2] = (rgb2 << 16) | rgb1;
            if (x + 1 < src.cropWidth()) {
                *(uint32_t *)(&dst_ptr[x]) = (rgb2 << 16) | rgb1;
            } else {
                dst_ptr[x] = rgb1;
            }
        }

        src_y += src.mWidth;
@@ -487,7 +500,7 @@ status_t ColorConverter::convertTIYUV420PackedSemiPlanar(
            src_u += src.mWidth;
        }

        dst_ptr += dst.mWidth / 2;
        dst_ptr += dst.mWidth;
    }

    return OK;