| 904 | } |
| 905 | |
| 906 | static 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 | |
| 932 | IGNORE_CFI_ICALL avifResult avifImageYUVToRGBLibYUV(const avifImage * image, avifRGBImage * rgb, avifBool reformatAlpha, avifBool * alphaReformattedWithLibYUV) |
| 933 | { |
no test coverage detected