| 170 | } |
| 171 | |
| 172 | avifResult avifSampleTransformExpressionToRecipe(const avifSampleTransformExpression * expression, avifSampleTransformRecipe * recipe) |
| 173 | { |
| 174 | *recipe = AVIF_SAMPLE_TRANSFORM_NONE; |
| 175 | const avifSampleTransformRecipe kAllRecipes[] = { AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_EXTENSION_8B_8B, |
| 176 | AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_EXTENSION_12B_4B, |
| 177 | AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_EXTENSION_12B_8B_OVERLAP_4B }; |
| 178 | for (size_t i = 0; i < sizeof(kAllRecipes) / sizeof(kAllRecipes[0]); ++i) { |
| 179 | avifSampleTransformRecipe candidateRecipe = kAllRecipes[i]; |
| 180 | avifSampleTransformExpression candidateExpression = { 0 }; |
| 181 | AVIF_CHECKRES(avifSampleTransformRecipeToExpression(candidateRecipe, &candidateExpression)); |
| 182 | const avifBool equivalence = avifSampleTransformExpressionIsEquivalentTo(expression, &candidateExpression); |
| 183 | avifArrayDestroy(&candidateExpression); |
| 184 | if (equivalence) { |
| 185 | *recipe = candidateRecipe; |
| 186 | return AVIF_RESULT_OK; |
| 187 | } |
| 188 | } |
| 189 | return AVIF_RESULT_OK; |
| 190 | } |
| 191 | |
| 192 | //------------------------------------------------------------------------------ |
| 193 | // Operators |