MCPcopy Create free account
hub / github.com/AOMediaCodec/libavif / avifImageDownshiftTo8bpc

Function avifImageDownshiftTo8bpc

src/reformat_libyuv.c:906–930  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

904}
905
906static avifResult avifImageDownshiftTo8bpc(const avifImage * image, avifImage * image8, avifBool downshiftAlpha)
907{
908 avifImageSetDefaults(image8);
909 avifImageCopyNoAlloc(image8, image);
910 image8->depth = 8;
911 // downshiftAlpha will be true only if the image has an alpha plane. So it is safe to pass AVIF_PLANES_ALL here in that case.
912 assert(!downshiftAlpha || image->alphaPlane);
913 AVIF_CHECKRES(avifImageAllocatePlanes(image8, downshiftAlpha ? AVIF_PLANES_ALL : AVIF_PLANES_YUV));
914 // 16384 for 10-bit and 4096 for 12-bit.
915 const int scale = 1 << (24 - image->depth);
916 for (int plane = AVIF_CHAN_Y; plane <= (downshiftAlpha ? AVIF_CHAN_A : AVIF_CHAN_V); ++plane) {
917 const uint32_t planeWidth = avifImagePlaneWidth(image, plane);
918 if (planeWidth == 0) {
919 continue;
920 }
921 Convert16To8Plane((const uint16_t *)avifImagePlane(image, plane),
922 avifImagePlaneRowBytes(image, plane) / 2,
923 avifImagePlane(image8, plane),
924 avifImagePlaneRowBytes(image8, plane),
925 scale,
926 planeWidth,
927 avifImagePlaneHeight(image, plane));
928 }
929 return AVIF_RESULT_OK;
930}
931
932IGNORE_CFI_ICALL avifResult avifImageYUVToRGBLibYUV(const avifImage * image, avifRGBImage * rgb, avifBool reformatAlpha, avifBool * alphaReformattedWithLibYUV)
933{

Callers 1

avifImageYUVToRGBLibYUVFunction · 0.85

Calls 7

avifImageSetDefaultsFunction · 0.85
avifImageCopyNoAllocFunction · 0.85
avifImageAllocatePlanesFunction · 0.85
avifImagePlaneWidthFunction · 0.85
avifImagePlaneFunction · 0.85
avifImagePlaneRowBytesFunction · 0.85
avifImagePlaneHeightFunction · 0.85

Tested by

no test coverage detected