#ifndef AVIF_INTERNAL_H
#define AVIF_INTERNAL_H
#include "avif/avif.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(AVIF_DLL) && defined(AVIF_USING_STATIC_LIBS)
#error "Your target is linking against avif and avif_internal: only one should be chosen"
#endif
#define AVIF_CLAMP(x, low, high) …
#define AVIF_MIN(a, b) …
#define AVIF_MAX(a, b) …
#if defined(AVIF_BREAK_ON_ERROR)
static inline void avifBreakOnError()
{
int * p = NULL;
*p = 0;
}
#else
#define avifBreakOnError() …
#endif
#define AVIF_CHECK(A) …
#define AVIF_CHECKERR(A, ERR) …
#define AVIF_CHECKRES(A) …
#ifdef NDEBUG
#define AVIF_ASSERT_OR_RETURN …
#else
#define AVIF_ASSERT_OR_RETURN(A) …
#endif
#define AVIF_URN_ALPHA0 …
#define AVIF_URN_ALPHA1 …
#define AVIF_CONTENT_TYPE_XMP …
float avifRoundf(float v);
uint16_t avifHTONS(uint16_t s);
uint16_t avifNTOHS(uint16_t s);
uint16_t avifCTOHS(uint16_t s);
uint32_t avifHTONL(uint32_t l);
uint32_t avifNTOHL(uint32_t l);
uint32_t avifCTOHL(uint32_t l);
uint64_t avifHTON64(uint64_t l);
uint64_t avifNTOH64(uint64_t l);
void avifCalcYUVCoefficients(const avifImage * image, float * outR, float * outG, float * outB);
avifTransferFunction;
avifTransferFunction avifTransferCharacteristicsGetGammaToLinearFunction(avifTransferCharacteristics atc);
avifTransferFunction avifTransferCharacteristicsGetLinearToGammaFunction(avifTransferCharacteristics atc);
void avifColorPrimariesComputeYCoeffs(avifColorPrimaries colorPrimaries, float coeffs[3]);
AVIF_NODISCARD avifBool avifColorPrimariesComputeRGBToXYZD50Matrix(avifColorPrimaries colorPrimaries, double coeffs[3][3]);
AVIF_NODISCARD avifBool avifColorPrimariesComputeXYZD50ToRGBMatrix(avifColorPrimaries colorPrimaries, double coeffs[3][3]);
AVIF_NODISCARD avifBool avifColorPrimariesComputeRGBToRGBMatrix(avifColorPrimaries srcColorPrimaries,
avifColorPrimaries dstColorPrimaries,
double coeffs[3][3]);
void avifLinearRGBConvertColorSpace(float rgb[4], double coeffs[3][3]);
#define AVIF_ARRAY_DECLARE(TYPENAME, ITEMSTYPE, ITEMSNAME) …
AVIF_NODISCARD avifBool avifArrayCreate(void * arrayStruct, uint32_t elementSize, uint32_t initialCapacity);
AVIF_NODISCARD void * avifArrayPush(void * arrayStruct);
void avifArrayPop(void * arrayStruct);
void avifArrayDestroy(void * arrayStruct);
void avifFractionSimplify(avifFraction * f);
AVIF_NODISCARD avifBool avifFractionCD(avifFraction * a, avifFraction * b);
AVIF_NODISCARD avifBool avifFractionAdd(avifFraction a, avifFraction b, avifFraction * result);
AVIF_NODISCARD avifBool avifFractionSub(avifFraction a, avifFraction b, avifFraction * result);
AVIF_NODISCARD avifBool avifDoubleToSignedFraction(double v, int32_t * numerator, uint32_t * denominator);
AVIF_NODISCARD avifBool avifDoubleToUnsignedFraction(double v, uint32_t * numerator, uint32_t * denominator);
void avifImageSetDefaults(avifImage * image);
void avifImageCopyNoAlloc(avifImage * dstImage, const avifImage * srcImage);
void avifImageCopySamples(avifImage * dstImage, const avifImage * srcImage, avifPlanesFlags planes);
#if defined(AVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM)
typedef enum avifSampleTransformBitDepth
{
AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_8 = 0,
AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_16 = 1,
AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_32 = 2,
AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_64 = 3
} avifSampleTransformBitDepth;
typedef enum avifSampleTransformTokenType
{
AVIF_SAMPLE_TRANSFORM_CONSTANT = 0,
AVIF_SAMPLE_TRANSFORM_INPUT_IMAGE_ITEM_INDEX = 1,
AVIF_SAMPLE_TRANSFORM_NEGATE = 2,
AVIF_SAMPLE_TRANSFORM_ABSOLUTE = 3,
AVIF_SAMPLE_TRANSFORM_SUM = 4,
AVIF_SAMPLE_TRANSFORM_DIFFERENCE = 5,
AVIF_SAMPLE_TRANSFORM_PRODUCT = 6,
AVIF_SAMPLE_TRANSFORM_DIVIDE = 7,
AVIF_SAMPLE_TRANSFORM_AND = 8,
AVIF_SAMPLE_TRANSFORM_OR = 9,
AVIF_SAMPLE_TRANSFORM_XOR = 10,
AVIF_SAMPLE_TRANSFORM_NOT = 11,
AVIF_SAMPLE_TRANSFORM_MSB = 12,
AVIF_SAMPLE_TRANSFORM_POW = 13,
AVIF_SAMPLE_TRANSFORM_MIN = 14,
AVIF_SAMPLE_TRANSFORM_MAX = 15,
AVIF_SAMPLE_TRANSFORM_RESERVED
} avifSampleTransformTokenType;
typedef struct avifSampleTransformToken
{
uint8_t type;
int32_t constant;
uint8_t inputImageItemIndex;
} avifSampleTransformToken;
AVIF_ARRAY_DECLARE(avifSampleTransformExpression, avifSampleTransformToken, tokens);
avifBool avifSampleTransformExpressionIsValid(const avifSampleTransformExpression * tokens, uint32_t numInputImageItems);
avifBool avifSampleTransformExpressionIsEquivalentTo(const avifSampleTransformExpression * a, const avifSampleTransformExpression * b);
avifResult avifSampleTransformRecipeToExpression(avifSampleTransformRecipe recipe, avifSampleTransformExpression * expression);
avifResult avifSampleTransformExpressionToRecipe(const avifSampleTransformExpression * expression, avifSampleTransformRecipe * recipe);
avifResult avifImageApplyExpression(avifImage * dstImage,
avifSampleTransformBitDepth bitDepth,
const avifSampleTransformExpression * expression,
uint8_t numInputImageItems,
const avifImage * inputImageItems[],
avifPlanesFlags planes);
avifResult avifImageApplyOperations(avifImage * dstImage,
avifSampleTransformBitDepth bitDepth,
uint32_t numTokens,
const avifSampleTransformToken tokens[],
uint8_t numInputImageItems,
const avifImage * inputImageItems[],
avifPlanesFlags planes);
#endif
avifAlphaParams;
void avifFillAlpha(const avifAlphaParams * params);
void avifReformatAlpha(const avifAlphaParams * params);
avifReformatMode;
avifAlphaMultiplyMode;
avifRGBColorSpaceInfo;
avifBool avifGetRGBColorSpaceInfo(const avifRGBImage * rgb, avifRGBColorSpaceInfo * info);
avifYUVColorSpaceInfo;
avifBool avifGetYUVColorSpaceInfo(const avifImage * image, avifYUVColorSpaceInfo * info);
avifReformatState;
void avifGetRGBAPixel(const avifRGBImage * src, uint32_t x, uint32_t y, const avifRGBColorSpaceInfo * info, float rgbaPixel[4]);
void avifSetRGBAPixel(const avifRGBImage * dst, uint32_t x, uint32_t y, const avifRGBColorSpaceInfo * info, const float rgbaPixel[4]);
avifResult avifImageRGBToYUVLibYUV(avifImage * image, const avifRGBImage * rgb);
avifResult avifImageYUVToRGBLibYUV(const avifImage * image, avifRGBImage * rgb, avifBool reformatAlpha, avifBool * alphaReformattedWithLibYUV);
avifResult avifImageRGBToYUVLibSharpYUV(avifImage * image, const avifRGBImage * rgb, const avifReformatState * state);
avifResult avifRGBImageToF16LibYUV(avifRGBImage * rgb);
avifResult avifRGBImagePremultiplyAlphaLibYUV(avifRGBImage * rgb);
avifResult avifRGBImageUnpremultiplyAlphaLibYUV(avifRGBImage * rgb);
AVIF_NODISCARD avifBool avifDimensionsTooLarge(uint32_t width, uint32_t height, uint32_t imageSizeLimit, uint32_t imageDimensionLimit);
void avifSetTileConfiguration(int threads, uint32_t width, uint32_t height, int * tileRowsLog2, int * tileColsLog2);
avifResult avifImageScaleWithLimit(avifImage * image,
uint32_t dstWidth,
uint32_t dstHeight,
uint32_t imageSizeLimit,
uint32_t imageDimensionLimit,
avifDiagnostics * diag);
avifItemCategory;
avifBool avifIsAlpha(avifItemCategory itemCategory);
#if defined(AVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM)
#define AVIF_SAMPLE_TRANSFORM_MAX_NUM_EXTRA_INPUT_IMAGE_ITEMS …
#define AVIF_SAMPLE_TRANSFORM_MAX_NUM_INPUT_IMAGE_ITEMS …
#define AVIF_SAMPLE_TRANSFORM_MIN_CATEGORY …
#define AVIF_SAMPLE_TRANSFORM_MAX_CATEGORY …
#endif
AVIF_NODISCARD avifBool avifAreGridDimensionsValid(avifPixelFormat yuvFormat,
uint32_t imageW,
uint32_t imageH,
uint32_t tileW,
uint32_t tileH,
avifDiagnostics * diag);
avifResult avifImageExtractExifOrientationToIrotImir(avifImage * image);
#if defined(AVIF_ENABLE_EXPERIMENTAL_MINI)
uint8_t avifImageIrotImirToExifOrientation(const avifImage * image);
#endif
#define AVIF_SPATIAL_ID_UNSET …
avifDecodeSample;
AVIF_ARRAY_DECLARE(avifDecodeSampleArray, avifDecodeSample, … } ;
avifCodecDecodeInput;
AVIF_NODISCARD avifCodecDecodeInput * avifCodecDecodeInputCreate(void);
void avifCodecDecodeInputDestroy(avifCodecDecodeInput * decodeInput);
avifEncodeSample;
AVIF_ARRAY_DECLARE(avifEncodeSampleArray, avifEncodeSample, … } ;
avifCodecEncodeOutput;
AVIF_NODISCARD avifCodecEncodeOutput * avifCodecEncodeOutputCreate(void);
avifResult avifCodecEncodeOutputAddSample(avifCodecEncodeOutput * encodeOutput, const uint8_t * data, size_t len, avifBool sync);
void avifCodecEncodeOutputDestroy(avifCodecEncodeOutput * encodeOutput);
avifCodecSpecificOption;
AVIF_ARRAY_DECLARE(avifCodecSpecificOptions, avifCodecSpecificOption, … } ;
AVIF_NODISCARD avifCodecSpecificOptions * avifCodecSpecificOptionsCreate(void);
void avifCodecSpecificOptionsClear(avifCodecSpecificOptions * csOptions);
void avifCodecSpecificOptionsDestroy(avifCodecSpecificOptions * csOptions);
avifResult avifCodecSpecificOptionsSet(avifCodecSpecificOptions * csOptions, const char * key, const char * value);
avifCodecType;
avifCodecType avifCodecTypeFromChoice(avifCodecChoice choice, avifCodecFlags requiredFlags);
struct avifCodec;
struct avifCodecInternal;
avifEncoderChange;
avifEncoderChanges;
avifCodecGetNextImageFunc;
avifCodecEncodeImageFunc;
avifCodecEncodeFinishFunc;
avifCodecDestroyInternalFunc;
avifCodec;
avifResult avifCodecCreate(avifCodecChoice choice, avifCodecFlags requiredFlags, avifCodec ** codec);
void avifCodecDestroy(avifCodec * codec);
AVIF_NODISCARD avifCodec * avifCodecCreateAOM(void);
const char * avifCodecVersionAOM(void);
AVIF_NODISCARD avifCodec * avifCodecCreateDav1d(void);
const char * avifCodecVersionDav1d(void);
AVIF_NODISCARD avifCodec * avifCodecCreateGav1(void);
const char * avifCodecVersionGav1(void);
AVIF_NODISCARD avifCodec * avifCodecCreateRav1e(void);
const char * avifCodecVersionRav1e(void);
AVIF_NODISCARD avifCodec * avifCodecCreateSvt(void);
const char * avifCodecVersionSvt(void);
AVIF_NODISCARD avifCodec * avifCodecCreateAVM(void);
const char * avifCodecVersionAVM(void);
#ifdef __clang__
__attribute__((__format__(__printf__, 2, 3)))
#endif
void avifDiagnosticsPrintf(avifDiagnostics * diag, const char * format, ...);
#if defined(AVIF_ENABLE_COMPLIANCE_WARDEN)
avifResult avifIsCompliant(const uint8_t * data, size_t size);
#endif
avifBoxMarker;
avifBoxHeader;
avifROStream;
const uint8_t * avifROStreamCurrent(avifROStream * stream);
void avifROStreamStart(avifROStream * stream, avifROData * raw, avifDiagnostics * diag, const char * diagContext);
size_t avifROStreamOffset(const avifROStream * stream);
void avifROStreamSetOffset(avifROStream * stream, size_t offset);
AVIF_NODISCARD avifBool avifROStreamHasBytesLeft(const avifROStream * stream, size_t byteCount);
size_t avifROStreamRemainingBytes(const avifROStream * stream);
AVIF_NODISCARD avifBool avifROStreamSkip(avifROStream * stream, size_t byteCount);
AVIF_NODISCARD avifBool avifROStreamRead(avifROStream * stream, uint8_t * data, size_t size);
AVIF_NODISCARD avifBool avifROStreamReadU16(avifROStream * stream, uint16_t * v);
AVIF_NODISCARD avifBool avifROStreamReadU16Endianness(avifROStream * stream, uint16_t * v, avifBool littleEndian);
AVIF_NODISCARD avifBool avifROStreamReadU32(avifROStream * stream, uint32_t * v);
AVIF_NODISCARD avifBool avifROStreamReadU32Endianness(avifROStream * stream, uint32_t * v, avifBool littleEndian);
AVIF_NODISCARD avifBool avifROStreamReadUX8(avifROStream * stream, uint64_t * v, uint64_t factor);
AVIF_NODISCARD avifBool avifROStreamReadU64(avifROStream * stream, uint64_t * v);
AVIF_NODISCARD avifBool avifROStreamReadString(avifROStream * stream, char * output, size_t outputSize);
AVIF_NODISCARD avifBool avifROStreamReadBoxHeader(avifROStream * stream, avifBoxHeader * header);
AVIF_NODISCARD avifBool avifROStreamReadBoxHeaderPartial(avifROStream * stream, avifBoxHeader * header, avifBool topLevel);
AVIF_NODISCARD avifBool avifROStreamReadVersionAndFlags(avifROStream * stream, uint8_t * version, uint32_t * flags);
AVIF_NODISCARD avifBool avifROStreamReadAndEnforceVersion(avifROStream * stream, uint8_t enforcedVersion);
AVIF_NODISCARD avifBool avifROStreamReadBits8(avifROStream * stream, uint8_t * v, size_t bitCount);
AVIF_NODISCARD avifBool avifROStreamReadBits(avifROStream * stream, uint32_t * v, size_t bitCount);
avifRWStream;
void avifRWStreamStart(avifRWStream * stream, avifRWData * raw);
size_t avifRWStreamOffset(const avifRWStream * stream);
void avifRWStreamSetOffset(avifRWStream * stream, size_t offset);
void avifRWStreamFinishWrite(avifRWStream * stream);
avifResult avifRWStreamWrite(avifRWStream * stream, const void * data, size_t size);
avifResult avifRWStreamWriteChars(avifRWStream * stream, const char * chars, size_t size);
avifResult avifRWStreamWriteBox(avifRWStream * stream, const char * type, size_t contentSize, avifBoxMarker * marker);
avifResult avifRWStreamWriteFullBox(avifRWStream * stream, const char * type, size_t contentSize, int version, uint32_t flags, avifBoxMarker * marker);
void avifRWStreamFinishBox(avifRWStream * stream, avifBoxMarker marker);
avifResult avifRWStreamWriteU8(avifRWStream * stream, uint8_t v);
avifResult avifRWStreamWriteU16(avifRWStream * stream, uint16_t v);
avifResult avifRWStreamWriteU32(avifRWStream * stream, uint32_t v);
avifResult avifRWStreamWriteU64(avifRWStream * stream, uint64_t v);
avifResult avifRWStreamWriteZeros(avifRWStream * stream, size_t byteCount);
avifResult avifRWStreamWriteBits(avifRWStream * stream, uint32_t v, size_t bitCount);
#define AVIF_BOX_SIZE_TBD …
avifCodecConfigurationBox;
avifSequenceHeader;
AVIF_NODISCARD avifBool avifSequenceHeaderParse(avifSequenceHeader * header, const avifROData * sample, avifCodecType codecType);
#if defined(AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP)
avifResult avifFindMinMaxWithoutOutliers(const float * gainMapF, int numPixels, float * rangeMin, float * rangeMax);
#endif
#define AVIF_INDEFINITE_DURATION64 …
#define AVIF_INDEFINITE_DURATION32 …
#ifdef __cplusplus
}
#endif
#endif