* +libavif

Closes #210

* wip
This commit is contained in:
Max Howell 2023-03-12 17:09:12 -04:00 committed by GitHub
parent c92d3ef609
commit abe6aa98eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 108 additions and 6 deletions

View file

@ -18,15 +18,16 @@ build:
make
make install
env:
CC: clang
ARGS:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX="{{prefix}}"
test:
script: |
aomenc --help
aomdec --help
linux:
CFLAGS: -fPIC
CXXFLAGS: -fPIC
LDFLAGS: -pie
test: |
aomenc --help
aomdec --help
provides:
- bin/aomenc

View file

@ -0,0 +1,58 @@
#include "avif/avif.h"
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char * argv[])
{
if (argc != 2) {
fprintf(stderr, "avif_example_decode_file [filename.avif]\n");
return 1;
}
const char * inputFilename = argv[1];
int returnCode = 1;
avifRGBImage rgb;
memset(&rgb, 0, sizeof(rgb));
avifDecoder * decoder = avifDecoderCreate();
avifResult result = avifDecoderSetIOFile(decoder, inputFilename);
if (result != AVIF_RESULT_OK) {
fprintf(stderr, "Cannot open file for read: %s\n", inputFilename);
goto cleanup;
}
result = avifDecoderParse(decoder);
if (result != AVIF_RESULT_OK) {
fprintf(stderr, "Failed to decode image: %s\n", avifResultToString(result));
goto cleanup;
}
printf("Parsed AVIF: %ux%u (%ubpc)\n", decoder->image->width, decoder->image->height, decoder->image->depth);
while (avifDecoderNextImage(decoder) == AVIF_RESULT_OK) {
avifRGBImageSetDefaults(&rgb, decoder->image);
avifRGBImageAllocatePixels(&rgb);
if (avifImageYUVToRGB(decoder->image, &rgb) != AVIF_RESULT_OK) {
fprintf(stderr, "Conversion from YUV failed: %s\n", inputFilename);
goto cleanup;
}
if (rgb.depth > 8) {
uint16_t * firstPixel = (uint16_t *)rgb.pixels;
printf(" * First pixel: RGBA(%u,%u,%u,%u)\n", firstPixel[0], firstPixel[1], firstPixel[2], firstPixel[3]);
} else {
uint8_t * firstPixel = rgb.pixels;
printf(" * First pixel: RGBA(%u,%u,%u,%u)\n", firstPixel[0], firstPixel[1], firstPixel[2], firstPixel[3]);
}
}
returnCode = 0;
cleanup:
avifRGBImageFreePixels(&rgb);
avifDecoderDestroy(decoder);
return returnCode;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

View file

@ -0,0 +1,43 @@
distributable:
url: https://github.com/AOMediaCodec/libavif/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: AOMediaCodec/libavif
dependencies:
aomedia.googlesource.com/aom: ^3
libpng.org: ^1
libjpeg-turbo.org: ^2
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
cmake.org: ^3
working-directory: build
script: |
cmake .. $ARGS
make --jobs {{ hw.concurrency }} install
env:
ARGS:
- -DCMAKE_INSTALL_PREFIX={{prefix}}
- -DCMAKE_BUILD_TYPE=Release
- -DAVIF_CODEC_AOM=ON
- -DAVIF_BUILD_APPS=ON
- -DAVIF_BUILD_EXAMPLES=OFF
- -DAVIF_BUILD_TESTS=OFF
provides:
- bin/avifenc
- bin/avifdec
test: |
avifenc fixture.png test.avif
test -f test.avif
avifdec test.avif test.jpg
test -f test.jpg
cc example.c -lavif
./a.out test.avif