Issue #2357 - VPXDecoder does not decode alpha frames.

Another requirement to have transparency in videos. Straight port of Firefox 53 implementation, save for some oddities relating to needing to put uint8_t instead of uint8 in yuv_convert to get this to compile.

Ref: BZ 1321076, 1329104
This commit is contained in:
Jeremy Andrews 2023-10-23 22:20:36 -05:00 committed by roytam1
commit c0ba3a8d2e
9 changed files with 315 additions and 65 deletions

View file

@ -155,5 +155,26 @@ ConvertYCbCrToRGB(const layers::PlanarYCbCrData& aData,
}
}
void
ConvertYCbCrAToARGB(const uint8_t* aSrcY,
const uint8_t* aSrcU,
const uint8_t* aSrcV,
const uint8_t* aSrcA,
int aSrcStrideYA, int aSrcStrideUV,
uint8_t* aDstARGB, int aDstStrideARGB,
int aWidth, int aHeight) {
ConvertYCbCrAToARGB32(aSrcY,
aSrcU,
aSrcV,
aSrcA,
aDstARGB,
aWidth,
aHeight,
aSrcStrideYA,
aSrcStrideUV,
aDstStrideARGB);
}
} // namespace gfx
} // namespace mozilla

View file

@ -24,6 +24,17 @@ ConvertYCbCrToRGB(const layers::PlanarYCbCrData& aData,
unsigned char* aDestBuffer,
int32_t aStride);
// Currently this function only has support for I420 type.
void
ConvertYCbCrAToARGB(const uint8_t* aSrcY,
const uint8_t* aSrcU,
const uint8_t* aSrcV,
const uint8_t* aSrcA,
int aSrcStrideYA, int aSrcStrideUV,
uint8_t* aDstARGB, int aDstStrideARGB,
int aWidth, int aHeight);
} // namespace gfx
} // namespace mozilla

View file

@ -550,6 +550,27 @@ void ScaleYCbCrToRGB32_deprecated(const uint8_t* y_buf,
if (has_mmx)
EMMS();
}
void ConvertYCbCrAToARGB32(const uint8_t* y_buf,
const uint8_t* u_buf,
const uint8_t* v_buf,
const uint8_t* a_buf,
uint8_t* argb_buf,
int pic_width,
int pic_height,
int ya_pitch,
int uv_pitch,
int argb_pitch) {
// The downstream graphics stack expects an attenuated input, hence why the
// attenuation parameter is set.
DebugOnly<int> err = libyuv::I420AlphaToARGB(y_buf, ya_pitch,
u_buf, uv_pitch,
v_buf, uv_pitch,
a_buf, ya_pitch,
argb_buf, argb_pitch,
pic_width, pic_height, 1);
MOZ_ASSERT(!err);
}
} // namespace gfx
} // namespace mozilla

View file

@ -106,6 +106,18 @@ void ScaleYCbCrToRGB32_deprecated(const uint8_t* yplane,
Rotate view_rotate,
ScaleFilter filter);
void ConvertYCbCrAToARGB32(const uint8_t* yplane,
const uint8_t* uplane,
const uint8_t* vplane,
const uint8_t* aplane,
uint8_t* argbframe,
int pic_width,
int pic_height,
int yastride,
int uvstride,
int argbstride);
} // namespace gfx
} // namespace mozilla