MCPcopy Create free account
hub / github.com/AOMediaCodec/libavif / avifSampleTransformExpressionIsValid

Function avifSampleTransformExpressionIsValid

src/sampletransform.c:13–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11// Convenience functions
12
13avifBool avifSampleTransformExpressionIsValid(const avifSampleTransformExpression * tokens, uint32_t numInputImageItems)
14{
15 uint32_t stackSize = 0;
16 for (uint32_t t = 0; t < tokens->count; ++t) {
17 const avifSampleTransformToken * token = &tokens->tokens[t];
18 AVIF_CHECK(token->type < AVIF_SAMPLE_TRANSFORM_RESERVED);
19 if (token->type == AVIF_SAMPLE_TRANSFORM_INPUT_IMAGE_ITEM_INDEX) {
20 // inputImageItemIndex is 1-based.
21 AVIF_CHECK(token->inputImageItemIndex != 0);
22 AVIF_CHECK(token->inputImageItemIndex <= numInputImageItems);
23 }
24 if (token->type < AVIF_SAMPLE_TRANSFORM_FIRST_UNARY_OPERATOR) {
25 // Likely an operand.
26 ++stackSize;
27 } else if (token->type < AVIF_SAMPLE_TRANSFORM_FIRST_BINARY_OPERATOR) {
28 // Likely a unary operator.
29 AVIF_CHECK(stackSize >= 1);
30 // Pop one and push one.
31 } else {
32 // Likely a binary operator.
33 AVIF_CHECK(stackSize >= 2);
34 --stackSize; // Pop two and push one.
35 }
36 }
37 AVIF_CHECK(stackSize == 1);
38 return AVIF_TRUE;
39}
40
41avifBool avifSampleTransformExpressionIsEquivalentTo(const avifSampleTransformExpression * a, const avifSampleTransformExpression * b)
42{

Callers 3

avifImageApplyExpressionFunction · 0.85
TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68