Adding linear interpolation to rgb->yuv conversion
When the UV planes are smaller than the Y plane, doing the upscaling in nearest mode was creating artefacts, so I changed it to use linear interpolation to fix the issue. BUG=460380 Committed: https://skia.googlesource.com/skia/+/cd9d42c5167a50f1bf20e969343556d61354171b Review URL: https://codereview.chromium.org/973563002
This commit is contained in:
parent
55f0b18ee0
commit
4ab3dbb636
@ -365,8 +365,12 @@ static GrTexture* load_yuv_texture(GrContext* ctx, const GrUniqueKey& optionalKe
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
yuvDesc.fWidth = yuvInfo.fSize[i].fWidth;
|
||||
yuvDesc.fHeight = yuvInfo.fSize[i].fHeight;
|
||||
yuvTextures[i].reset(
|
||||
ctx->refScratchTexture(yuvDesc, GrContext::kApprox_ScratchTexMatch));
|
||||
bool needsExactTexture =
|
||||
(yuvDesc.fWidth != yuvInfo.fSize[0].fWidth) ||
|
||||
(yuvDesc.fHeight != yuvInfo.fSize[0].fHeight);
|
||||
yuvTextures[i].reset(ctx->refScratchTexture(yuvDesc,
|
||||
needsExactTexture ? GrContext::kExact_ScratchTexMatch :
|
||||
GrContext::kApprox_ScratchTexMatch));
|
||||
if (!yuvTextures[i] ||
|
||||
!yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight,
|
||||
yuvDesc.fConfig, planes[i], yuvInfo.fRowBytes[i])) {
|
||||
|
@ -33,7 +33,15 @@ public:
|
||||
yuvMatrix[1].preScale(w[1] / w[0], h[1] / h[0]);
|
||||
yuvMatrix[2] = yuvMatrix[0];
|
||||
yuvMatrix[2].preScale(w[2] / w[0], h[2] / h[0]);
|
||||
return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, yuvMatrix, colorSpace));
|
||||
GrTextureParams::FilterMode uvFilterMode =
|
||||
((sizes[1].fWidth != sizes[0].fWidth) ||
|
||||
(sizes[1].fHeight != sizes[0].fHeight) ||
|
||||
(sizes[2].fWidth != sizes[0].fWidth) ||
|
||||
(sizes[2].fHeight != sizes[0].fHeight)) ?
|
||||
GrTextureParams::kBilerp_FilterMode :
|
||||
GrTextureParams::kNone_FilterMode;
|
||||
return SkNEW_ARGS(YUVtoRGBEffect, (yTexture, uTexture, vTexture, yuvMatrix,
|
||||
uvFilterMode, colorSpace));
|
||||
}
|
||||
|
||||
const char* name() const SK_OVERRIDE { return "YUV to RGB"; }
|
||||
@ -103,13 +111,14 @@ public:
|
||||
|
||||
private:
|
||||
YUVtoRGBEffect(GrTexture* yTexture, GrTexture* uTexture, GrTexture* vTexture,
|
||||
SkMatrix yuvMatrix[3], SkYUVColorSpace colorSpace)
|
||||
SkMatrix yuvMatrix[3], GrTextureParams::FilterMode uvFilterMode,
|
||||
SkYUVColorSpace colorSpace)
|
||||
: fYTransform(kLocal_GrCoordSet, yuvMatrix[0], yTexture, GrTextureParams::kNone_FilterMode)
|
||||
, fYAccess(yTexture)
|
||||
, fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, GrTextureParams::kNone_FilterMode)
|
||||
, fUAccess(uTexture)
|
||||
, fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, GrTextureParams::kNone_FilterMode)
|
||||
, fVAccess(vTexture)
|
||||
, fUTransform(kLocal_GrCoordSet, yuvMatrix[1], uTexture, uvFilterMode)
|
||||
, fUAccess(uTexture, uvFilterMode)
|
||||
, fVTransform(kLocal_GrCoordSet, yuvMatrix[2], vTexture, uvFilterMode)
|
||||
, fVAccess(vTexture, uvFilterMode)
|
||||
, fColorSpace(colorSpace) {
|
||||
this->initClassID<YUVtoRGBEffect>();
|
||||
this->addCoordTransform(&fYTransform);
|
||||
|
Loading…
Reference in New Issue
Block a user