| 58 | } |
| 59 | |
| 60 | static avifResult rav1eCodecEncodeImage(avifCodec * codec, |
| 61 | avifEncoder * encoder, |
| 62 | const avifImage * image, |
| 63 | avifBool alpha, |
| 64 | int tileRowsLog2, |
| 65 | int tileColsLog2, |
| 66 | int quality, |
| 67 | avifEncoderChanges encoderChanges, |
| 68 | avifBool disableLaggedOutput, |
| 69 | uint32_t addImageFlags, |
| 70 | avifCodecEncodeOutput * output) |
| 71 | { |
| 72 | // rav1e does not support changing encoder settings. |
| 73 | if (encoderChanges) { |
| 74 | return AVIF_RESULT_NOT_IMPLEMENTED; |
| 75 | } |
| 76 | |
| 77 | // rav1e does not support changing image dimensions. |
| 78 | if (!codec->internal->rav1eContext) { |
| 79 | codec->internal->encodeWidth = image->width; |
| 80 | codec->internal->encodeHeight = image->height; |
| 81 | } else if ((codec->internal->encodeWidth != image->width) || (codec->internal->encodeHeight != image->height)) { |
| 82 | return AVIF_RESULT_NOT_IMPLEMENTED; |
| 83 | } |
| 84 | |
| 85 | // rav1e does not support encoding layered image. |
| 86 | if (encoder->extraLayerCount > 0) { |
| 87 | return AVIF_RESULT_NOT_IMPLEMENTED; |
| 88 | } |
| 89 | |
| 90 | // rav1e does not support disabling lagged output. See https://github.com/xiph/rav1e/issues/2267. Ignore this setting. |
| 91 | (void)disableLaggedOutput; |
| 92 | |
| 93 | avifResult result = AVIF_RESULT_UNKNOWN_ERROR; |
| 94 | |
| 95 | RaConfig * rav1eConfig = NULL; |
| 96 | RaFrame * rav1eFrame = NULL; |
| 97 | |
| 98 | if (!codec->internal->rav1eContext) { |
| 99 | const avifBool supports400 = rav1eSupports400(); |
| 100 | RaPixelRange rav1eRange; |
| 101 | if (alpha) { |
| 102 | // AV1-AVIF specification, Section 4 "Auxiliary Image Items and Sequences": |
| 103 | // The color_range field in the Sequence Header OBU shall be set to 1. |
| 104 | rav1eRange = RA_PIXEL_RANGE_FULL; |
| 105 | |
| 106 | // AV1-AVIF specification, Section 4 "Auxiliary Image Items and Sequences": |
| 107 | // The mono_chrome field in the Sequence Header OBU shall be set to 1. |
| 108 | // Some encoders do not support 4:0:0 and encode alpha as 4:2:0 so it is not always respected. |
| 109 | codec->internal->chromaSampling = supports400 ? RA_CHROMA_SAMPLING_CS400 : RA_CHROMA_SAMPLING_CS420; |
| 110 | codec->internal->yShift = 1; |
| 111 | |
| 112 | // CICP (CP/TC/MC) does not apply to the alpha auxiliary image. |
| 113 | // Use Unspecified (2) colour primaries, transfer characteristics, and matrix coefficients below. |
| 114 | } else { |
| 115 | // AV1-ISOBMFF specification, Section 2.3.4: |
| 116 | // The value of full_range_flag in the 'colr' box SHALL match the color_range |
| 117 | // flag in the Sequence Header OBU. |
nothing calls this directly
no test coverage detected