Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental reduced HEIF header #1432

Merged
merged 23 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
561b143
Experimental reduced HEIF header
y-guyon Jun 12, 2023
1deb2cc
Add avifConiColorType
y-guyon Aug 17, 2023
7eb013a
Add TODO about NOT_IMPLEMENTED in ParseConi()
y-guyon Aug 17, 2023
68c6d77
Add hasExtendedMeta, hasExif and hasEXIF
y-guyon Aug 17, 2023
f301371
Add TODO in avifParse() about coni without avir
y-guyon Aug 17, 2023
feef5d3
Replace fallbacking by falling back
y-guyon Aug 17, 2023
ed76df2
Add assert(colorItem) in WriteFtypAndConi()
y-guyon Aug 17, 2023
cff7437
Propagate avifRWStreamWrite*() status
y-guyon Aug 19, 2023
c5294bf
Move headerStrategy to the end of avifEncoder
y-guyon Aug 22, 2023
600ae72
Rename AVIF_ENCODER_MINIMIZE_HEADER by REDUCE
y-guyon Aug 22, 2023
958574a
Add spec proposal ref to avifEncoderHeaderStrategy
y-guyon Aug 22, 2023
ff103e5
Add R to AVIF_ENCODER_REDUCE_HEADER
y-guyon Aug 23, 2023
a69d90e
Rename avifEncoderHeaderStrategy to Format
y-guyon Aug 23, 2023
9bc205d
Remove Encoder from avifEncoderHeaderFormat
y-guyon Aug 29, 2023
e56255f
Add avifDiagnostics to avifconitest
y-guyon Aug 29, 2023
89467bd
Check result of WriteExtendedColorProperties()
y-guyon Aug 30, 2023
d225f28
Call WriteHDRProperties() in WriteExtendedMeta()
y-guyon Aug 30, 2023
14043f2
Add CHANGELOG entry
y-guyon Aug 30, 2023
19a8982
Fix comments and literals
y-guyon Aug 31, 2023
b5f297d
Remove ABI changes from CHANGELOG.md
y-guyon Aug 31, 2023
fb4bce1
Guard needsConi and coniSeen by AVIF_ENABLE_AVIR
y-guyon Aug 31, 2023
c1cf4d4
Move headerFormat at the end of avifEncoderCreate
y-guyon Aug 31, 2023
d2776c3
Move code around
y-guyon Sep 1, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/ci-unix-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON
-DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON
-DAVIF_ENABLE_EXPERIMENTAL_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_AVIR=ON
- name: Build libavif (ninja)
working-directory: ./build
run: ninja
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON
-DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON
-DAVIF_ENABLE_EXPERIMENTAL_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_AVIR=ON
- name: Build libavif (ninja)
working-directory: ./build
run: ninja
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
in the future. Files created now might not decode in a future version.
This feature is off by default and must be enabled with the
AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP compilation flag.
* Add the headerFormat member of new type avifHeaderFormat to avifEncoder.
* Add experimental API for reading and writing "avir"-branded AVIF files
behind the compilation flag AVIF_ENABLE_EXPERIMENTAL_AVIR.

### Changed
* Update svt.cmd/svt.sh: v1.7.0
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ option(AVIF_ENABLE_EXPERIMENTAL_YCGCO_R "Enable experimental YCgCo-R matrix code
option(AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP
"Enable experimental gain map code (for HDR images that look good both on HDR and SDR displays)" OFF
)
option(AVIF_ENABLE_EXPERIMENTAL_AVIR "Enable experimental reduced header" OFF)
y-guyon marked this conversation as resolved.
Show resolved Hide resolved

option(AVIF_CODEC_AOM "Use the AOM codec for encoding/decoding (see AVIF_CODEC_AOM_DECODE/AVIF_CODEC_AOM_ENCODE)" OFF)
option(AVIF_CODEC_DAV1D "Use the dav1d codec for decoding" OFF)
Expand Down Expand Up @@ -269,6 +270,10 @@ if(AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP)
add_compile_definitions(AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP)
endif()

if(AVIF_ENABLE_EXPERIMENTAL_AVIR)
add_compile_definitions(AVIF_ENABLE_EXPERIMENTAL_AVIR)
endif()

set(AVIF_SRCS
src/alpha.c
src/avif.c
Expand Down
10 changes: 10 additions & 0 deletions apps/avifenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ static void syntaxLong(void)
printf(" -j,--jobs J : Number of jobs (worker threads, default: 1. Use \"all\" to use all available cores)\n");
printf(" --no-overwrite : Never overwrite existing output file\n");
printf(" -o,--output FILENAME : Instead of using the last filename given as output, use this filename\n");
#if defined(AVIF_ENABLE_EXPERIMENTAL_AVIR)
printf(" --avir : Use reduced header if possible\n");
#endif
printf(" -l,--lossless : Set all defaults to encode losslessly, and emit warnings when settings/input don't allow for it\n");
printf(" -d,--depth D : Output depth [8,10,12]. (JPEG/PNG only; For y4m or stdin, depth is retained)\n");
printf(" -y,--yuv FORMAT : Output format [default=auto, 444, 422, 420, 400]. Ignored for y4m or stdin (y4m format is retained)\n");
Expand Down Expand Up @@ -669,6 +672,7 @@ typedef struct
avifBool autoTiling;
avifBool progressive;
int speed;
avifHeaderFormat headerFormat;

int paspCount;
uint32_t paspValues[8]; // only the first two are used
Expand Down Expand Up @@ -888,6 +892,7 @@ static avifBool avifEncodeImagesFixedQuality(const avifSettings * settings,
encoder->autoTiling = settings->autoTiling;
encoder->codecChoice = settings->codecChoice;
encoder->speed = settings->speed;
encoder->headerFormat = settings->headerFormat;
encoder->timescale = settings->outputTiming.timescale;
encoder->keyframeInterval = settings->keyframeInterval;
encoder->repetitionCount = settings->repetitionCount;
Expand Down Expand Up @@ -1107,6 +1112,7 @@ int main(int argc, char * argv[])
settings.autoTiling = AVIF_FALSE;
settings.progressive = AVIF_FALSE;
settings.speed = 6;
settings.headerFormat = AVIF_HEADER_FULL;
settings.repetitionCount = AVIF_REPETITION_COUNT_INFINITE;
settings.keyframeInterval = 0;
settings.ignoreExif = AVIF_FALSE;
Expand Down Expand Up @@ -1177,6 +1183,10 @@ int main(int argc, char * argv[])
} else if (!strcmp(arg, "-o") || !strcmp(arg, "--output")) {
NEXTARG();
outputFilename = arg;
#if defined(AVIF_ENABLE_EXPERIMENTAL_AVIR)
} else if (!strcmp(arg, "--avir")) {
settings.headerFormat = AVIF_HEADER_REDUCED;
#endif // AVIF_ENABLE_EXPERIMENTAL_AVIR
} else if (!strcmp(arg, "-d") || !strcmp(arg, "--depth")) {
NEXTARG();
input.requestedDepth = atoi(arg);
Expand Down
18 changes: 18 additions & 0 deletions include/avif/avif.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,21 @@ typedef enum avifResult

AVIF_API const char * avifResultToString(avifResult result);

// ---------------------------------------------------------------------------
// avifHeaderFormat

typedef enum avifHeaderFormat
{
// AVIF file with an "avif" brand, a MetaBox and all its required boxes for maximum compatibility.
AVIF_HEADER_FULL,
#if defined(AVIF_ENABLE_EXPERIMENTAL_AVIR)
// AVIF file with an "avir" brand and a CondensedImageBox to reduce the encoded file size.
// This is based on the m64572 "Condensed image item" MPEG proposal for HEIF.
// WARNING: Experimental feature. Produces files that are incompatible with older decoders.
AVIF_HEADER_REDUCED,
#endif
} avifHeaderFormat;

// ---------------------------------------------------------------------------
// avifROData/avifRWData: Generic raw memory storage

Expand Down Expand Up @@ -1297,6 +1312,9 @@ typedef struct avifEncoder

// Version 1.0.0 ends here. Add any new members after this line.

// Defaults to AVIF_HEADER_FULL
avifHeaderFormat headerFormat;

#if defined(AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP)
int qualityGainMap; // changeable encoder setting
#endif
Expand Down
13 changes: 13 additions & 0 deletions include/avif/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ typedef enum avifItemCategory
#endif
} avifItemCategory;

// ---------------------------------------------------------------------------
y-guyon marked this conversation as resolved.
Show resolved Hide resolved

#if defined(AVIF_ENABLE_EXPERIMENTAL_AVIR)
// AVIF color_type field meaning in CondensedImageBox
typedef enum avifConiColorType
{
AVIF_CONI_COLOR_TYPE_SRGB = 0,
AVIF_CONI_COLOR_TYPE_NCLX_5BIT = 1,
AVIF_CONI_COLOR_TYPE_NCLX_8BIT = 2,
AVIF_CONI_COLOR_TYPE_ICC = 3
} avifConiColorType;
#endif // AVIF_ENABLE_EXPERIMENTAL_AVIR

// ---------------------------------------------------------------------------
// Grid AVIF images

Expand Down
Loading
Loading