Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
318 changes: 317 additions & 1 deletion apps/avifenc.c

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions include/avif/avif.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ typedef int avifBool;
#define AVIF_SPEED_SLOWEST 0
#define AVIF_SPEED_FASTEST 10

#define MAX_AV1_LAYER_COUNT 4

typedef enum avifPlanesFlag
{
AVIF_PLANES_YUV = (1 << 0),
Expand Down Expand Up @@ -778,9 +780,11 @@ typedef enum avifProgressiveState
// for an image sequence.
AVIF_PROGRESSIVE_STATE_UNAVAILABLE = 0,

// The current AVIF/Source offers a progressive image, but avifDecoder.allowProgressive is not
// enabled, so it will behave as if the image was not progressive and will simply decode the
// best version of this item.
// For decoder, this means the current AVIF/Source offers a progressive image, but
// avifDecoder.allowProgressive is not enabled, so it will behave as if the image was not
// progressive and will simply decode the best version of this item.
// For encoder, this means at least one of color and alpha image has multiple layers and
// indicates this is a progressive image.
AVIF_PROGRESSIVE_STATE_AVAILABLE,

// The current AVIF/Source offers a progressive image, and avifDecoder.allowProgressive is true.
Expand Down Expand Up @@ -971,6 +975,18 @@ AVIF_API avifResult avifDecoderNthImageMaxExtent(const avifDecoder * decoder, ui
struct avifEncoderData;
struct avifCodecSpecificOptions;

typedef struct avifScalingMode {
uint64_t numerator;
uint64_t denominator;
} avifScalingMode;

typedef struct avifLayerConfig {
int minQuantizer;
int maxQuantizer;
avifScalingMode horizontalMode;
avifScalingMode verticalMode;
} avifLayerConfig;

// Notes:
// * If avifEncoderWrite() returns AVIF_RESULT_OK, output must be freed with avifRWDataFree()
// * If (maxThreads < 2), multithreading is disabled
Expand Down Expand Up @@ -999,6 +1015,11 @@ typedef struct avifEncoder
int keyframeInterval; // How many frames between automatic forced keyframes; 0 to disable (default).
uint64_t timescale; // timescale of the media (Hz)

uint8_t layerCount; // Image layers for color sub image; 0 to disable layer image (default).
uint8_t layerCountAlpha; // Image layers for alpha sub image; 0 to disable layer image (default).
avifLayerConfig layers[MAX_AV1_LAYER_COUNT];
avifLayerConfig layersAlpha[MAX_AV1_LAYER_COUNT];

// stats from the most recent write
avifIOStats ioStats;

Expand Down
1 change: 1 addition & 0 deletions include/avif/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ typedef avifResult (*avifCodecEncodeImageFunc)(struct avifCodec * codec,
avifEncoder * encoder,
const avifImage * image,
avifBool alpha,
int layerIndex,
avifAddImageFlags addImageFlags,
avifCodecEncodeOutput * output);
typedef avifBool (*avifCodecEncodeFinishFunc)(struct avifCodec * codec, avifCodecEncodeOutput * output);
Expand Down
Loading