| 1097 | } |
| 1098 | |
| 1099 | static avifBool avifEncodeImagesFixedQuality(const avifSettings * settings, |
| 1100 | avifInput * input, |
| 1101 | const avifInputFile * firstFile, |
| 1102 | const avifImage * firstImage, |
| 1103 | const avifImage * const * gridCells, |
| 1104 | avifRWData * encoded, |
| 1105 | avifEncodedByteSizes * byteSizes) |
| 1106 | { |
| 1107 | avifBool success = AVIF_FALSE; |
| 1108 | avifRWDataFree(encoded); |
| 1109 | avifEncoder * encoder = avifEncoderCreate(); |
| 1110 | if (!encoder) { |
| 1111 | fprintf(stderr, "ERROR: Out of memory\n"); |
| 1112 | goto cleanup; |
| 1113 | } |
| 1114 | |
| 1115 | encoder->maxThreads = settings->jobs; |
| 1116 | encoder->codecChoice = settings->codecChoice; |
| 1117 | encoder->speed = settings->speed; |
| 1118 | encoder->timescale = settings->outputTiming.timescale; |
| 1119 | encoder->keyframeInterval = settings->keyframeInterval; |
| 1120 | encoder->repetitionCount = settings->repetitionCount; |
| 1121 | encoder->headerFormat = settings->headerFormat; |
| 1122 | encoder->creationTime = settings->creationTime; |
| 1123 | encoder->modificationTime = settings->modificationTime; |
| 1124 | encoder->extraLayerCount = settings->layers - 1; |
| 1125 | if (!avifEncodeUpdateEncoderSettings(encoder, &firstFile->settings)) { |
| 1126 | goto cleanup; |
| 1127 | } |
| 1128 | |
| 1129 | if (settings->overrideQuality != INVALID_QUALITY) { |
| 1130 | encoder->quality = settings->overrideQuality; |
| 1131 | } |
| 1132 | if (settings->overrideQualityAlpha != INVALID_QUALITY) { |
| 1133 | encoder->qualityAlpha = settings->overrideQualityAlpha; |
| 1134 | } |
| 1135 | #if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION) |
| 1136 | if (settings->qualityGainMap != INVALID_QUALITY) { |
| 1137 | encoder->qualityGainMap = settings->qualityGainMap; |
| 1138 | } |
| 1139 | #endif |
| 1140 | |
| 1141 | if (input->requestedDepth == 8 && input->requestedDepthExtension == 8) { |
| 1142 | encoder->sampleTransformRecipe = AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_EXTENSION_8B_8B; |
| 1143 | } else if (input->requestedDepth == 12 && input->requestedDepthExtension == 4) { |
| 1144 | encoder->sampleTransformRecipe = AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_EXTENSION_12B_4B; |
| 1145 | } else if (input->requestedDepth == 12 && input->requestedDepthExtension == 8) { |
| 1146 | encoder->sampleTransformRecipe = AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_EXTENSION_12B_8B_OVERLAP_4B; |
| 1147 | } else if (input->requestedDepthExtension != 0) { |
| 1148 | fprintf(stderr, "ERROR: Unsupported bit depth extension scheme: %d + %d\n", input->requestedDepth, input->requestedDepthExtension); |
| 1149 | goto cleanup; |
| 1150 | } |
| 1151 | |
| 1152 | const char * const codecName = avifCodecName(settings->codecChoice, AVIF_CODEC_FLAG_CAN_ENCODE); |
| 1153 | char speedStr[16]; |
| 1154 | if (settings->speed == AVIF_SPEED_DEFAULT) { |
| 1155 | strcpy(speedStr, "default"); |
| 1156 | } else { |
no test coverage detected