Update to libavif 0.7.1.

- Enable the encoding/decoding apps.
- Add support for JPEG and PNG to the encoding/decoding apps.

from Brad (maintainer)
This commit is contained in:
ajacoutot 2020-04-23 06:42:08 +00:00
parent efc2e498c6
commit e776536313
7 changed files with 147 additions and 60 deletions

View File

@ -1,13 +1,13 @@
# $OpenBSD: Makefile,v 1.6 2020/04/04 08:35:17 ajacoutot Exp $ # $OpenBSD: Makefile,v 1.7 2020/04/23 06:42:08 ajacoutot Exp $
COMMENT= library for encoding and decoding .avif files COMMENT= library for encoding and decoding .avif files
GH_ACCOUNT= AOMediaCodec GH_ACCOUNT= AOMediaCodec
GH_PROJECT= libavif GH_PROJECT= libavif
GH_TAGNAME= v0.6.3 GH_TAGNAME= v0.7.1
CATEGORIES= graphics CATEGORIES= graphics
SHARED_LIBS= avif 1.0 SHARED_LIBS= avif 1.1
HOMEPAGE= https://github.com/AOMediaCodec/libavif HOMEPAGE= https://github.com/AOMediaCodec/libavif
@ -16,16 +16,19 @@ MAINTAINER= Brad Smith <brad@comstyle.com>
# BSD # BSD
PERMIT_PACKAGE= Yes PERMIT_PACKAGE= Yes
WANTLIB= aom dav1d m pthread WANTLIB= aom c dav1d jpeg m png pthread z
COMPILER= base-clang ports-gcc COMPILER= base-clang ports-gcc
MODULES= devel/cmake MODULES= devel/cmake
LIB_DEPENDS= multimedia/aom \ LIB_DEPENDS= graphics/jpeg \
graphics/png \
multimedia/aom \
multimedia/dav1d multimedia/dav1d
CONFIGURE_ARGS+=-DAVIF_BUILD_TESTS=ON \ CONFIGURE_ARGS+=-DAVIF_BUILD_APPS=ON \
-DAVIF_BUILD_TESTS=ON \
-DAVIF_CODEC_AOM=ON \ -DAVIF_CODEC_AOM=ON \
-DAVIF_CODEC_DAV1D=ON -DAVIF_CODEC_DAV1D=ON

View File

@ -1,2 +1,2 @@
SHA256 (libavif-0.6.3.tar.gz) = X7CliZMcti2GGBLtdRD1BmT0FCIi5cxQsqhxwohfVC4= SHA256 (libavif-0.7.1.tar.gz) = vUgAmu1t78OnbJkWEuHS4+JV9uwYQNsNViqehAlNpnQ=
SIZE (libavif-0.6.3.tar.gz) = 2878362 SIZE (libavif-0.7.1.tar.gz) = 2887666

View File

@ -0,0 +1,33 @@
$OpenBSD: patch-apps_avifdump_c,v 1.1 2020/04/23 06:42:08 ajacoutot Exp $
avifdump - Fix format specifiers for 32bit.
Index: apps/avifdump.c
--- apps/avifdump.c.orig
+++ apps/avifdump.c
@@ -5,6 +5,7 @@
#include "avifutil.h"
+#include <inttypes.h>
#include <stdio.h>
#include <string.h>
@@ -62,7 +63,7 @@ int main(int argc, char * argv[])
firstImage = AVIF_FALSE;
avifImageDump(decoder->image);
- printf(" * %zu timescales per second, %2.2f seconds (%zu timescales), %d frame%s\n",
+ printf(" * %" PRIu64 " timescales per second, %2.2f seconds (%" PRIu64 " timescales), %d frame%s\n",
decoder->timescale,
decoder->duration,
decoder->durationInTimescales,
@@ -71,7 +72,7 @@ int main(int argc, char * argv[])
printf(" * Frames:\n");
}
- printf(" * Decoded frame [%d] [pts %2.2f (%zu timescales)] [duration %2.2f (%zu timescales)]\n",
+ printf(" * Decoded frame [%d] [pts %2.2f (%" PRIu64 " timescales)] [duration %2.2f (%" PRIu64 " timescales)]\n",
frameIndex,
decoder->imageTiming.pts,
decoder->imageTiming.ptsInTimescales,

View File

@ -0,0 +1,67 @@
$OpenBSD: patch-apps_avifenc_c,v 1.1 2020/04/23 06:42:08 ajacoutot Exp $
- Choose high-quality-but-lossy QP defaults for avifenc.
- Move opinions about default speeds for avifenc out of the codec layer and into avifenc.
Index: apps/avifenc.c
--- apps/avifenc.c.orig
+++ apps/avifenc.c
@@ -48,7 +48,9 @@ static void syntax(void)
AVIF_QUANTIZER_BEST_QUALITY,
AVIF_QUANTIZER_WORST_QUALITY,
AVIF_QUANTIZER_LOSSLESS);
- printf(" -s,--speed S : Encoder speed (%d-%d, slowest to fastest)\n", AVIF_SPEED_SLOWEST, AVIF_SPEED_FASTEST);
+ printf(" -s,--speed S : Encoder speed (%d-%d, slowest-fastest, 'default' for codec internal defaults. default speed: 8)\n",
+ AVIF_SPEED_SLOWEST,
+ AVIF_SPEED_FASTEST);
printf(" -c,--codec C : AV1 codec to use (choose from versions list below)\n");
printf(" --pasp H,V : Add pasp property (aspect ratio). H=horizontal spacing, V=vertical spacing\n");
printf(" --clap WN,WD,HN,HD,HON,HOD,VON,VOD: Add clap property (clean aperture). Width, Height, HOffset, VOffset (in num/denom pairs)\n");
@@ -140,10 +142,10 @@ int main(int argc, char * argv[])
avifPixelFormat requestedFormat = AVIF_PIXEL_FORMAT_YUV444;
int requestedDepth = 0;
int minQuantizer = AVIF_QUANTIZER_BEST_QUALITY;
- int maxQuantizer = AVIF_QUANTIZER_BEST_QUALITY;
+ int maxQuantizer = 10; // "High Quality", but not lossless
int minQuantizerAlpha = AVIF_QUANTIZER_LOSSLESS;
int maxQuantizerAlpha = AVIF_QUANTIZER_LOSSLESS;
- int speed = AVIF_SPEED_DEFAULT;
+ int speed = 8;
int paspCount = 0;
uint32_t paspValues[8]; // only the first two are used
int clapCount = 0;
@@ -246,13 +248,17 @@ int main(int argc, char * argv[])
requestedRangeSet = AVIF_TRUE;
} else if (!strcmp(arg, "-s") || !strcmp(arg, "--speed")) {
NEXTARG();
- speed = atoi(arg);
- if (speed > AVIF_SPEED_FASTEST) {
- speed = AVIF_SPEED_FASTEST;
+ if (!strcmp(arg, "default") || !strcmp(arg, "d")) {
+ speed = AVIF_SPEED_DEFAULT;
+ } else {
+ speed = atoi(arg);
+ if (speed > AVIF_SPEED_FASTEST) {
+ speed = AVIF_SPEED_FASTEST;
+ }
+ if (speed < AVIF_SPEED_SLOWEST) {
+ speed = AVIF_SPEED_SLOWEST;
+ }
}
- if (speed < AVIF_SPEED_SLOWEST) {
- speed = AVIF_SPEED_SLOWEST;
- }
} else if (!strcmp(arg, "-c") || !strcmp(arg, "--codec")) {
NEXTARG();
codecChoice = avifCodecChoiceFromName(arg);
@@ -390,8 +396,9 @@ int main(int argc, char * argv[])
printf("AVIF to be written:\n");
avifImageDump(avif);
- printf("Encoding with AV1 codec '%s', color QP [%d (%s) <-> %d (%s)], alpha QP [%d (%s) <-> %d (%s)], %d worker thread(s), please wait...\n",
+ printf("Encoding with AV1 codec '%s' speed [%d], color QP [%d (%s) <-> %d (%s)], alpha QP [%d (%s) <-> %d (%s)], %d worker thread(s), please wait...\n",
avifCodecName(codecChoice, AVIF_CODEC_FLAG_CAN_ENCODE),
+ speed,
minQuantizer,
quantizerString(minQuantizer),
maxQuantizer,

View File

@ -0,0 +1,33 @@
$OpenBSD: patch-src_codec_aom_c,v 1.1 2020/04/23 06:42:08 ajacoutot Exp $
- Changed default libaom encode speed to 8.
- Move opinions about default speeds for avifenc out of the codec layer and into avifenc.
Index: src/codec_aom.c
--- src/codec_aom.c.orig
+++ src/codec_aom.c
@@ -244,14 +244,16 @@ static avifBool aomCodecEncodeImage(avifCodec * codec,
// Speed 10: RealTime CpuUsed 8
unsigned int aomUsage = AOM_USAGE_GOOD_QUALITY;
int aomCpuUsed = -1;
- if (encoder->speed != AVIF_SPEED_DEFAULT) {
- if (encoder->speed < 8) {
- aomUsage = AOM_USAGE_GOOD_QUALITY;
- aomCpuUsed = AVIF_CLAMP(encoder->speed, 0, 5);
- } else {
- aomUsage = AOM_USAGE_REALTIME;
- aomCpuUsed = AVIF_CLAMP(encoder->speed - 2, 6, 8);
- }
+ int speed = encoder->speed;
+ if (speed == AVIF_SPEED_DEFAULT) {
+ speed = 8; // Semi-arbitrary; chosen as a good balance of speed and output for a cmdline default
+ }
+ if (speed < 8) {
+ aomUsage = AOM_USAGE_GOOD_QUALITY;
+ aomCpuUsed = AVIF_CLAMP(speed, 0, 5);
+ } else {
+ aomUsage = AOM_USAGE_REALTIME;
+ aomCpuUsed = AVIF_CLAMP(speed - 2, 6, 8);
}
if (image->depth > 8) {

View File

@ -1,51 +0,0 @@
$OpenBSD: patch-src_reformat_c,v 1.1 2020/04/04 08:35:17 ajacoutot Exp $
Fix clang warning (switch clamp to min).
Index: src/reformat.c
--- src/reformat.c.orig
+++ src/reformat.c
@@ -311,9 +311,9 @@ static avifResult avifImageYUV16ToRGB16Color(avifImage
uint32_t uvI = AVIF_MIN(i >> state->formatInfo.chromaShiftX, maxUVI);
// clamp incoming data to protect against bad LUT lookups
- const uint16_t unormY = AVIF_CLAMP(ptrY[i], 0, yuvMaxChannel);
- const uint16_t unormU = AVIF_CLAMP(ptrU[uvI], 0, yuvMaxChannel);
- const uint16_t unormV = AVIF_CLAMP(ptrV[uvI], 0, yuvMaxChannel);
+ const uint16_t unormY = AVIF_MIN(ptrY[i], yuvMaxChannel);
+ const uint16_t unormU = AVIF_MIN(ptrU[uvI], yuvMaxChannel);
+ const uint16_t unormV = AVIF_MIN(ptrV[uvI], yuvMaxChannel);
// Convert unorm to float
const float Y = unormFloatTableY[unormY];
@@ -357,7 +357,7 @@ static avifResult avifImageYUV16ToRGB16Mono(avifImage
for (uint32_t i = 0; i < image->width; ++i) {
// clamp incoming data to protect against bad LUT lookups
- const uint16_t unormY = AVIF_CLAMP(ptrY[i], 0, yuvMaxChannel);
+ const uint16_t unormY = AVIF_MIN(ptrY[i], yuvMaxChannel);
// Convert unorm to float
const float Y = unormFloatTableY[unormY];
@@ -408,9 +408,9 @@ static avifResult avifImageYUV16ToRGB8Color(avifImage
uint32_t uvI = AVIF_MIN(i >> state->formatInfo.chromaShiftX, maxUVI);
// clamp incoming data to protect against bad LUT lookups
- const uint16_t unormY = AVIF_CLAMP(ptrY[i], 0, yuvMaxChannel);
- const uint16_t unormU = AVIF_CLAMP(ptrU[uvI], 0, yuvMaxChannel);
- const uint16_t unormV = AVIF_CLAMP(ptrV[uvI], 0, yuvMaxChannel);
+ const uint16_t unormY = AVIF_MIN(ptrY[i], yuvMaxChannel);
+ const uint16_t unormU = AVIF_MIN(ptrU[uvI], yuvMaxChannel);
+ const uint16_t unormV = AVIF_MIN(ptrV[uvI], yuvMaxChannel);
// Convert unorm to float
const float Y = unormFloatTableY[unormY];
@@ -454,7 +454,7 @@ static avifResult avifImageYUV16ToRGB8Mono(avifImage *
for (uint32_t i = 0; i < image->width; ++i) {
// clamp incoming data to protect against bad LUT lookups
- const uint16_t unormY = AVIF_CLAMP(ptrY[i], 0, yuvMaxChannel);
+ const uint16_t unormY = AVIF_MIN(ptrY[i], yuvMaxChannel);
// Convert unorm to float
const float Y = unormFloatTableY[unormY];

View File

@ -1,4 +1,6 @@
@comment $OpenBSD: PLIST,v 1.2 2020/03/04 07:28:28 ajacoutot Exp $ @comment $OpenBSD: PLIST,v 1.3 2020/04/23 06:42:08 ajacoutot Exp $
@bin bin/avifdec
@bin bin/avifenc
include/avif/ include/avif/
include/avif/avif.h include/avif/avif.h
lib/cmake/ lib/cmake/