mirror of
https://github.com/ivabus/pantry
synced 2024-11-22 08:25:07 +03:00
parent
c92d3ef609
commit
abe6aa98eb
4 changed files with 108 additions and 6 deletions
|
@ -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
|
||||
|
|
58
projects/github.com/AOMediaCodec/libavif/example.c
Normal file
58
projects/github.com/AOMediaCodec/libavif/example.c
Normal 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;
|
||||
}
|
BIN
projects/github.com/AOMediaCodec/libavif/fixture.png
Normal file
BIN
projects/github.com/AOMediaCodec/libavif/fixture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 82 B |
43
projects/github.com/AOMediaCodec/libavif/package.yml
Normal file
43
projects/github.com/AOMediaCodec/libavif/package.yml
Normal 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
|
Loading…
Reference in a new issue