| 52 | } |
| 53 | |
| 54 | static avifResult svtCodecEncodeImage(avifCodec * codec, |
| 55 | avifEncoder * encoder, |
| 56 | const avifImage * image, |
| 57 | avifBool alpha, |
| 58 | int tileRowsLog2, |
| 59 | int tileColsLog2, |
| 60 | int quality, |
| 61 | avifEncoderChanges encoderChanges, |
| 62 | avifBool disableLaggedOutput, |
| 63 | uint32_t addImageFlags, |
| 64 | avifCodecEncodeOutput * output) |
| 65 | { |
| 66 | // SVT-AV1 does not support changing encoder settings. |
| 67 | if (encoderChanges) { |
| 68 | return AVIF_RESULT_NOT_IMPLEMENTED; |
| 69 | } |
| 70 | |
| 71 | // SVT-AV1 does not support changing image dimensions. |
| 72 | if (codec->internal->svt_encoder != NULL) { |
| 73 | if ((codec->internal->svt_config.source_width != image->width) || (codec->internal->svt_config.source_height != image->height)) { |
| 74 | return AVIF_RESULT_NOT_IMPLEMENTED; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // SVT-AV1 does not support encoding layered image. |
| 79 | if (encoder->extraLayerCount > 0) { |
| 80 | return AVIF_RESULT_NOT_IMPLEMENTED; |
| 81 | } |
| 82 | |
| 83 | // SVT-AV1 does not support disabling lagged output. Ignore this setting. |
| 84 | (void)disableLaggedOutput; |
| 85 | |
| 86 | avifResult result = AVIF_RESULT_UNKNOWN_ERROR; |
| 87 | EbColorFormat color_format = EB_YUV420; |
| 88 | uint8_t * uvPlanes = NULL; // 4:2:0 U and V placeholder for alpha because SVT-AV1 does not support 4:0:0. |
| 89 | EbBufferHeaderType * input_buffer = NULL; |
| 90 | EbErrorType res = EB_ErrorNone; |
| 91 | |
| 92 | int y_shift = 0; |
| 93 | EbColorRange svt_range; |
| 94 | if (alpha) { |
| 95 | // AV1-AVIF specification, Section 4 "Auxiliary Image Items and Sequences": |
| 96 | // The color_range field in the Sequence Header OBU shall be set to 1. |
| 97 | svt_range = EB_CR_FULL_RANGE; |
| 98 | |
| 99 | // AV1-AVIF specification, Section 4 "Auxiliary Image Items and Sequences": |
| 100 | // The mono_chrome field in the Sequence Header OBU shall be set to 1. |
| 101 | // Some encoders do not support 4:0:0 and encode alpha as 4:2:0 so it is not always respected. |
| 102 | y_shift = 1; |
| 103 | |
| 104 | // CICP (CP/TC/MC) does not apply to the alpha auxiliary image. |
| 105 | // Use Unspecified (2) colour primaries, transfer characteristics, and matrix coefficients below. |
| 106 | } else { |
| 107 | // AV1-ISOBMFF specification, Section 2.3.4: |
| 108 | // The value of full_range_flag in the 'colr' box SHALL match the color_range |
| 109 | // flag in the Sequence Header OBU. |
| 110 | svt_range = (image->yuvRange == AVIF_RANGE_FULL) ? EB_CR_FULL_RANGE : EB_CR_STUDIO_RANGE; |
| 111 |
nothing calls this directly
no test coverage detected