Skip to content

Commit

Permalink
Apply comments
Browse files Browse the repository at this point in the history
  • Loading branch information
y-guyon committed Feb 4, 2025
1 parent 275d085 commit dbb4ee5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions include/avif/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,24 @@ typedef enum avifSampleTransformTokenType
AVIF_SAMPLE_TRANSFORM_FIRST_INPUT_IMAGE_ITEM_INDEX = 1,
AVIF_SAMPLE_TRANSFORM_LAST_INPUT_IMAGE_ITEM_INDEX = 32,

// Unary operators. L is the left operand.
// Unary operators. L is the operand.
AVIF_SAMPLE_TRANSFORM_FIRST_UNARY_OPERATOR = 64,
AVIF_SAMPLE_TRANSFORM_NEGATION = 64, // S = -L
AVIF_SAMPLE_TRANSFORM_ABSOLUTE = 65, // S = |L|
AVIF_SAMPLE_TRANSFORM_NOT = 66, // S = ~L
AVIF_SAMPLE_TRANSFORM_BSR = 67, // S = L<=0 ? 0 : floor(log2(L))
AVIF_SAMPLE_TRANSFORM_BSR = 67, // S = L<=0 ? 0 : truncate(log2(L))
AVIF_SAMPLE_TRANSFORM_LAST_UNARY_OPERATOR = 67,

// Binary operators. L is the left operand. R is the right operand.
AVIF_SAMPLE_TRANSFORM_FIRST_BINARY_OPERATOR = 128,
AVIF_SAMPLE_TRANSFORM_SUM = 128, // S = L + R
AVIF_SAMPLE_TRANSFORM_DIFFERENCE = 129, // S = L - R
AVIF_SAMPLE_TRANSFORM_PRODUCT = 130, // S = L * R
AVIF_SAMPLE_TRANSFORM_QUOTIENT = 131, // S = R==0 ? L : floor(L / R)
AVIF_SAMPLE_TRANSFORM_QUOTIENT = 131, // S = R==0 ? L : truncate(L / R)
AVIF_SAMPLE_TRANSFORM_AND = 132, // S = L & R
AVIF_SAMPLE_TRANSFORM_OR = 133, // S = L | R
AVIF_SAMPLE_TRANSFORM_XOR = 134, // S = L ^ R
AVIF_SAMPLE_TRANSFORM_POW = 135, // S = L==0 ? 0 : pow(L, R)
AVIF_SAMPLE_TRANSFORM_POW = 135, // S = L==0 ? 0 : truncate(pow(L, R))
AVIF_SAMPLE_TRANSFORM_MIN = 136, // S = L<=R ? L : R
AVIF_SAMPLE_TRANSFORM_MAX = 137, // S = L<=R ? R : L
AVIF_SAMPLE_TRANSFORM_LAST_BINARY_OPERATOR = 137,
Expand Down
2 changes: 1 addition & 1 deletion src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -2115,7 +2115,7 @@ static avifResult avifParseSampleTransformTokens(avifROStream * s, avifSampleTra
avifSampleTransformToken * token = (avifSampleTransformToken *)avifArrayPush(expression);
AVIF_CHECKERR(token != NULL, AVIF_RESULT_OUT_OF_MEMORY);

uint8_t tokenValue = AVIF_SAMPLE_TRANSFORM_RESERVED;
uint8_t tokenValue;
AVIF_CHECKERR(avifROStreamRead(s, &tokenValue, /*size=*/1), AVIF_RESULT_BMFF_PARSE_FAILED); // unsigned int(8) token;
if (tokenValue == AVIF_SAMPLE_TRANSFORM_CONSTANT) {
token->type = AVIF_SAMPLE_TRANSFORM_CONSTANT;
Expand Down
1 change: 0 additions & 1 deletion src/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,6 @@ static avifResult avifEncoderWriteSampleTransformTokens(avifRWStream * s, const

if (token->type == AVIF_SAMPLE_TRANSFORM_CONSTANT) {
AVIF_CHECKRES(avifRWStreamWriteU8(s, token->type)); // unsigned int(8) token;
// TODO(yguyon): Verify two's complement representation is guaranteed here.
const uint32_t constant = (uint32_t)token->constant;
AVIF_CHECKRES(avifRWStreamWriteU32(s, constant)); // signed int(1<<(bit_depth+3)) constant;
} else if (token->type == AVIF_SAMPLE_TRANSFORM_INPUT_IMAGE_ITEM_INDEX) {
Expand Down

0 comments on commit dbb4ee5

Please sign in to comment.