From 18ebc9ce8ec4eca857e4017535651b5939edcc072b21bfd1e163e41468186362 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 4 May 2020 15:17:25 +0000 Subject: [PATCH 1/4] Update to version 0.7.2 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/libavif?expand=0&rev=14 --- ...d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch | 279 ++++++++++++++++++ ...c74b5529da209266020852a72b554461e538.patch | 23 ++ ...9b37711c749681278f8b778f0e6c031c4ca2.patch | 150 ++++++++++ libavif-0.7.1.tar.gz | 3 - libavif-0.7.2.tar.gz | 3 + libavif.changes | 10 + libavif.spec | 6 +- 7 files changed, 470 insertions(+), 4 deletions(-) create mode 100644 e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch create mode 100644 e7dcc74b5529da209266020852a72b554461e538.patch create mode 100644 ebb29b37711c749681278f8b778f0e6c031c4ca2.patch delete mode 100644 libavif-0.7.1.tar.gz create mode 100644 libavif-0.7.2.tar.gz diff --git a/e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch b/e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch new file mode 100644 index 0000000..8be43eb --- /dev/null +++ b/e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch @@ -0,0 +1,279 @@ +From e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5 Mon Sep 17 00:00:00 2001 +From: Joe Drago +Date: Mon, 27 Apr 2020 14:27:31 -0700 +Subject: [PATCH] Added avifenc Lossless (--lossless, -l) mode, which sets new + defaults and warns when anything would cause the AVIF to not be lossless + +--- + CHANGELOG.md | 2 + + apps/avifenc.c | 119 ++++++++++++++++++++++++++++++++++++++--- + apps/shared/avifjpeg.c | 2 +- + apps/shared/avifjpeg.h | 2 +- + apps/shared/avifpng.c | 8 ++- + apps/shared/avifpng.h | 4 +- + 6 files changed, 123 insertions(+), 14 deletions(-) + +diff --git a/CHANGELOG.md b/CHANGELOG.md +index 19c8d08..8d05a5f 100644 +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), + and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + ## [Unreleased] ++### Added ++- avifenc: Lossless (--lossless, -l) mode, which sets new defaults and warns when anything would cause the AVIF to not be lossless + + ## [0.7.2] - 2020-04-24 + ### Added +diff --git a/apps/avifenc.c b/apps/avifenc.c +index 357596c..2d5a591 100644 +--- a/apps/avifenc.c ++++ b/apps/avifenc.c +@@ -25,6 +25,7 @@ static void syntax(void) + printf("Options:\n"); + printf(" -h,--help : Show syntax help\n"); + printf(" -j,--jobs J : Number of jobs (worker threads, default: 1)\n"); ++ 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, depth is retained)\n"); + printf(" -y,--yuv FORMAT : Output format [default=444, 422, 420]. (JPEG/PNG only; For y4m, format is retained)\n"); + printf(" -n,--nclx P/T/M : Set nclx colr box values (3 raw numbers, use -r to set range flag)\n"); +@@ -156,6 +157,7 @@ int main(int argc, char * argv[]) + avifRange requestedRange = AVIF_RANGE_FULL; + avifBool requestedRangeSet = AVIF_FALSE; + avifBool nclxSet = AVIF_FALSE; ++ avifBool lossless = AVIF_FALSE; + avifEncoder * encoder = NULL; + + avifNclxColorProfile nclx; +@@ -300,6 +302,19 @@ int main(int argc, char * argv[]) + fprintf(stderr, "ERROR: Invalid imir axis: %s\n", arg); + return 1; + } ++ } else if (!strcmp(arg, "-l") || !strcmp(arg, "--lossless")) { ++ lossless = AVIF_TRUE; ++ ++ // Set defaults, and warn later on if anything looks incorrect ++ requestedFormat = AVIF_PIXEL_FORMAT_YUV444; // don't subsample GBR ++ minQuantizer = AVIF_QUANTIZER_LOSSLESS; // lossless ++ maxQuantizer = AVIF_QUANTIZER_LOSSLESS; // lossless ++ minQuantizerAlpha = AVIF_QUANTIZER_LOSSLESS; // lossless ++ maxQuantizerAlpha = AVIF_QUANTIZER_LOSSLESS; // lossless ++ codecChoice = AVIF_CODEC_CHOICE_AOM; // rav1e doesn't support lossless transform yet: ++ // https://github.com/xiph/rav1e/issues/151 ++ requestedRange = AVIF_RANGE_FULL; // avoid limited range ++ requestedRangeSet = AVIF_TRUE; + } else { + // Positional argument + if (!inputFilename) { +@@ -325,6 +340,26 @@ int main(int argc, char * argv[]) + avifImage * avif = avifImageCreateEmpty(); + avifRWData raw = AVIF_DATA_EMPTY; + ++ uint32_t sourceDepth = 0; ++ avifBool sourceWasRGB = AVIF_TRUE; ++ avifAppFileFormat inputFormat = avifGuessFileFormat(inputFilename); ++ if (inputFormat == AVIF_APP_FILE_FORMAT_UNKNOWN) { ++ fprintf(stderr, "Cannot determine input file extension: %s\n", inputFilename); ++ returnCode = 1; ++ goto cleanup; ++ } ++ ++ if (lossless && (inputFormat != AVIF_APP_FILE_FORMAT_Y4M)) { ++ if (!nclxSet) { // don't stomp on the user's cmdline nclx values ++ // Assume SRGB unless they tell us otherwise via --nclx ++ nclx.colourPrimaries = AVIF_NCLX_TRANSFER_CHARACTERISTICS_BT709; ++ nclx.transferCharacteristics = AVIF_NCLX_TRANSFER_CHARACTERISTICS_SRGB; ++ nclx.matrixCoefficients = AVIF_NCLX_MATRIX_COEFFICIENTS_IDENTITY; // this is key for lossless ++ nclx.range = AVIF_RANGE_FULL; ++ nclxSet = AVIF_TRUE; ++ } ++ } ++ + // Set range and nclx in advance so any upcoming RGB -> YUV use the proper coefficients + if (requestedRangeSet) { + avif->yuvRange = requestedRange; +@@ -334,12 +369,6 @@ int main(int argc, char * argv[]) + avifImageSetProfileNCLX(avif, &nclx); + } + +- avifAppFileFormat inputFormat = avifGuessFileFormat(inputFilename); +- if (inputFormat == AVIF_APP_FILE_FORMAT_UNKNOWN) { +- fprintf(stderr, "Cannot determine input file extension: %s\n", inputFilename); +- returnCode = 1; +- goto cleanup; +- } + if (inputFormat == AVIF_APP_FILE_FORMAT_Y4M) { + if (requestedRangeSet) { + fprintf(stderr, "WARNING: Ignoring range (-r) value when encoding from y4m content.\n"); +@@ -353,13 +382,16 @@ int main(int argc, char * argv[]) + nclx.range = avif->yuvRange; + avifImageSetProfileNCLX(avif, &nclx); + } ++ sourceDepth = avif->depth; ++ sourceWasRGB = AVIF_FALSE; + } else if (inputFormat == AVIF_APP_FILE_FORMAT_JPEG) { + if (!avifJPEGRead(avif, inputFilename, requestedFormat, requestedDepth)) { + returnCode = 1; + goto cleanup; + } ++ sourceDepth = 8; + } else if (inputFormat == AVIF_APP_FILE_FORMAT_PNG) { +- if (!avifPNGRead(avif, inputFilename, requestedFormat, requestedDepth)) { ++ if (!avifPNGRead(avif, inputFilename, requestedFormat, requestedDepth, &sourceDepth)) { + returnCode = 1; + goto cleanup; + } +@@ -395,7 +427,78 @@ int main(int argc, char * argv[]) + avif->imir.axis = imirAxis; + } + +- printf("AVIF to be written:\n"); ++ avifBool usingAOM = AVIF_FALSE; ++ const char * codecName = avifCodecName(codecChoice, AVIF_CODEC_FLAG_CAN_ENCODE); ++ if (codecName && !strcmp(codecName, "aom")) { ++ usingAOM = AVIF_TRUE; ++ } ++ avifBool hasAlpha = (avif->alphaPlane && avif->alphaRowBytes); ++ avifBool losslessColorQP = (minQuantizer == AVIF_QUANTIZER_LOSSLESS) && (maxQuantizer == AVIF_QUANTIZER_LOSSLESS); ++ avifBool losslessAlphaQP = (minQuantizerAlpha == AVIF_QUANTIZER_LOSSLESS) && (maxQuantizerAlpha == AVIF_QUANTIZER_LOSSLESS); ++ avifBool depthMatches = (sourceDepth == avif->depth); ++ avifBool using444 = (avif->yuvFormat == AVIF_PIXEL_FORMAT_YUV444); ++ avifBool usingFullRange = (avif->yuvRange == AVIF_RANGE_FULL); ++ avifBool usingIdentityMatrix = (nclxSet && (nclx.matrixCoefficients == AVIF_NCLX_MATRIX_COEFFICIENTS_IDENTITY)); ++ ++ // Guess if the enduser is asking for lossless and enable it so that warnings can be emitted ++ if (losslessColorQP && (!hasAlpha || losslessAlphaQP)) { ++ // The enduser is probably expecting lossless. Turn it on and emit warnings ++ printf("Min/max QPs set to %d, assuming --lossless to enable warnings on potential lossless issues.\n", AVIF_QUANTIZER_LOSSLESS); ++ lossless = AVIF_TRUE; ++ } ++ ++ // Check for any reasons lossless will fail, and complain loudly ++ if (lossless) { ++ if (!usingAOM) { ++ fprintf(stderr, "WARNING: [--lossless] Only aom (-c) supports lossless transforms. Output might not be lossless.\n"); ++ lossless = AVIF_FALSE; ++ } ++ ++ if (!losslessColorQP) { ++ fprintf(stderr, ++ "WARNING: [--lossless] Color quantizer range (--min, --max) not set to %d. Color output might not be lossless.\n", ++ AVIF_QUANTIZER_LOSSLESS); ++ lossless = AVIF_FALSE; ++ } ++ ++ if (hasAlpha && !losslessAlphaQP) { ++ fprintf(stderr, ++ "WARNING: [--lossless] Alpha present and alpha quantizer range (--minalpha, --maxalpha) not set to %d. Alpha output might not be lossless.\n", ++ AVIF_QUANTIZER_LOSSLESS); ++ lossless = AVIF_FALSE; ++ } ++ ++ if (!depthMatches) { ++ fprintf(stderr, ++ "WARNING: [--lossless] Input depth (%d) does not match output depth (%d). Output might not be lossless.\n", ++ sourceDepth, ++ avif->depth); ++ lossless = AVIF_FALSE; ++ } ++ ++ if (sourceWasRGB) { ++ if (!using444) { ++ fprintf(stderr, "WARNING: [--lossless] Input data was RGB and YUV subsampling (-y) isn't YUV444. Output might not be lossless.\n"); ++ lossless = AVIF_FALSE; ++ } ++ ++ if (!usingFullRange) { ++ fprintf(stderr, "WARNING: [--lossless] Input data was RGB and output range (-r) isn't full. Output might not be lossless.\n"); ++ lossless = AVIF_FALSE; ++ } ++ ++ if (!usingIdentityMatrix) { ++ fprintf(stderr, "WARNING: [--lossless] Input data was RGB and nclx matrixCoefficients isn't set to identity (--nclx x/x/0); Output might not be lossless.\n"); ++ lossless = AVIF_FALSE; ++ } ++ } ++ } ++ ++ const char * lossyHint = " (Lossy)"; ++ if (lossless) { ++ lossyHint = " (Lossless)"; ++ } ++ printf("AVIF to be written:%s\n", lossyHint); + avifImageDump(avif); + + 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", +diff --git a/apps/shared/avifjpeg.c b/apps/shared/avifjpeg.c +index dcefb41..39bd0cd 100644 +--- a/apps/shared/avifjpeg.c ++++ b/apps/shared/avifjpeg.c +@@ -30,7 +30,7 @@ static void my_error_exit(j_common_ptr cinfo) + longjmp(myerr->setjmp_buffer, 1); + } + +-avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, int requestedDepth) ++avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth) + { + avifBool ret = AVIF_FALSE; + FILE * f = NULL; +diff --git a/apps/shared/avifjpeg.h b/apps/shared/avifjpeg.h +index 13c54dd..3824aea 100644 +--- a/apps/shared/avifjpeg.h ++++ b/apps/shared/avifjpeg.h +@@ -6,7 +6,7 @@ + + #include "avif/avif.h" + +-avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, int requestedDepth); ++avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth); + avifBool avifJPEGWrite(avifImage * avif, const char * outputFilename, int jpegQuality); + + #endif // ifndef LIBAVIF_APPS_SHARED_AVIFJPEG_H +diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c +index 843d6b0..3573a46 100644 +--- a/apps/shared/avifpng.c ++++ b/apps/shared/avifpng.c +@@ -14,7 +14,7 @@ + #pragma GCC diagnostic ignored "-Wclobbered" + #endif + +-avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, int requestedDepth) ++avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth, uint32_t * outPNGDepth) + { + avifBool readResult = AVIF_FALSE; + png_structp png = NULL; +@@ -104,6 +104,10 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm + imgBitDepth = 16; + } + ++ if (outPNGDepth) { ++ *outPNGDepth = imgBitDepth; ++ } ++ + png_read_update_info(png, info); + + avif->width = rawWidth; +@@ -143,7 +147,7 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm + return readResult; + } + +-avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int requestedDepth) ++avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, uint32_t requestedDepth) + { + avifBool writeResult = AVIF_FALSE; + png_structp png = NULL; +diff --git a/apps/shared/avifpng.h b/apps/shared/avifpng.h +index a10220e..12b68ad 100644 +--- a/apps/shared/avifpng.h ++++ b/apps/shared/avifpng.h +@@ -7,7 +7,7 @@ + #include "avif/avif.h" + + // if (requestedDepth == 0), do best-fit +-avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, int requestedDepth); +-avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int requestedDepth); ++avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth, uint32_t * outPNGDepth); ++avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, uint32_t requestedDepth); + + #endif // ifndef LIBAVIF_APPS_SHARED_AVIFPNG_H diff --git a/e7dcc74b5529da209266020852a72b554461e538.patch b/e7dcc74b5529da209266020852a72b554461e538.patch new file mode 100644 index 0000000..abd75dd --- /dev/null +++ b/e7dcc74b5529da209266020852a72b554461e538.patch @@ -0,0 +1,23 @@ +From e7dcc74b5529da209266020852a72b554461e538 Mon Sep 17 00:00:00 2001 +From: Andreas Schneider +Date: Wed, 29 Apr 2020 17:34:57 +0200 +Subject: [PATCH] apps: Use correct enum for colourPrimaries + +Signed-off-by: Andreas Schneider +--- + apps/avifenc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/apps/avifenc.c b/apps/avifenc.c +index 11595b7..e812670 100644 +--- a/apps/avifenc.c ++++ b/apps/avifenc.c +@@ -352,7 +352,7 @@ int main(int argc, char * argv[]) + if (lossless && (inputFormat != AVIF_APP_FILE_FORMAT_Y4M)) { + if (!nclxSet) { // don't stomp on the user's cmdline nclx values + // Assume SRGB unless they tell us otherwise via --nclx +- nclx.colourPrimaries = AVIF_NCLX_TRANSFER_CHARACTERISTICS_BT709; ++ nclx.colourPrimaries = AVIF_NCLX_COLOUR_PRIMARIES_BT709; + nclx.transferCharacteristics = AVIF_NCLX_TRANSFER_CHARACTERISTICS_SRGB; + nclx.matrixCoefficients = AVIF_NCLX_MATRIX_COEFFICIENTS_IDENTITY; // this is key for lossless + nclx.range = AVIF_RANGE_FULL; diff --git a/ebb29b37711c749681278f8b778f0e6c031c4ca2.patch b/ebb29b37711c749681278f8b778f0e6c031c4ca2.patch new file mode 100644 index 0000000..6eb0871 --- /dev/null +++ b/ebb29b37711c749681278f8b778f0e6c031c4ca2.patch @@ -0,0 +1,150 @@ +From ebb29b37711c749681278f8b778f0e6c031c4ca2 Mon Sep 17 00:00:00 2001 +From: Wan-Teh Chang +Date: Mon, 27 Apr 2020 18:43:51 -0700 +Subject: [PATCH] Do not ignore GCC's -Wclobbered warning + +The C Standard requires certain local variables in the function calling +setjmp be declared as volatile. I went through the code and declare +variables as volatile according to the C Standard, except for the 'rgb' +struct variable. Document my rationale. +--- + apps/shared/avifjpeg.c | 44 ++++++++++++++++++++++++++---------------- + apps/shared/avifpng.c | 25 ++++++++++++++++-------- + 2 files changed, 44 insertions(+), 25 deletions(-) + +diff --git a/apps/shared/avifjpeg.c b/apps/shared/avifjpeg.c +index 39bd0cd..5e68211 100644 +--- a/apps/shared/avifjpeg.c ++++ b/apps/shared/avifjpeg.c +@@ -12,11 +12,6 @@ + + #include "iccjpeg.h" + +-// This warning triggers false postives way too often in here. +-#if defined(__GNUC__) && !defined(__clang__) +-#pragma GCC diagnostic ignored "-Wclobbered" +-#endif +- + struct my_error_mgr + { + struct jpeg_error_mgr pub; +@@ -30,31 +25,44 @@ static void my_error_exit(j_common_ptr cinfo) + longjmp(myerr->setjmp_buffer, 1); + } + ++// Note on setjmp() and volatile variables: ++// ++// K & R, The C Programming Language 2nd Ed, p. 254 says: ++// ... Accessible objects have the values they had when longjmp was called, ++// except that non-volatile automatic variables in the function calling setjmp ++// become undefined if they were changed after the setjmp call. ++// ++// Therefore, 'iccData' is declared as volatile. 'rgb' should be declared as ++// volatile, but doing so would be inconvenient (try it) and since it is a ++// struct, the compiler is unlikely to put it in a register. 'ret' does not need ++// to be declared as volatile because it is not modified between setjmp and ++// longjmp. But GCC's -Wclobbered warning may have trouble figuring that out, so ++// we preemptively declare it as volatile. ++ + avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth) + { +- avifBool ret = AVIF_FALSE; +- FILE * f = NULL; +- uint8_t * iccData = NULL; ++ volatile avifBool ret = AVIF_FALSE; ++ uint8_t * volatile iccData = NULL; + + avifRGBImage rgb; + memset(&rgb, 0, sizeof(avifRGBImage)); + ++ FILE * f = fopen(inputFilename, "rb"); ++ if (!f) { ++ fprintf(stderr, "Can't open JPEG file for read: %s\n", inputFilename); ++ goto cleanup; ++ } ++ + struct my_error_mgr jerr; + struct jpeg_decompress_struct cinfo; + cinfo.err = jpeg_std_error(&jerr.pub); + jerr.pub.error_exit = my_error_exit; + if (setjmp(jerr.setjmp_buffer)) { +- return AVIF_FALSE; ++ goto cleanup; + } + + jpeg_create_decompress(&cinfo); + +- f = fopen(inputFilename, "rb"); +- if (!f) { +- fprintf(stderr, "Can't open JPEG file for read: %s\n", inputFilename); +- goto cleanup; +- } +- + setup_read_icc_profile(&cinfo); + jpeg_stdio_src(&cinfo, f); + jpeg_read_header(&cinfo, TRUE); +@@ -63,10 +71,12 @@ avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFor + int row_stride = cinfo.output_width * cinfo.output_components; + JSAMPARRAY buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, 1); + ++ uint8_t * iccDataTmp; + unsigned int iccDataLen; +- if (read_icc_profile(&cinfo, &iccData, &iccDataLen)) { ++ if (read_icc_profile(&cinfo, &iccDataTmp, &iccDataLen)) { ++ iccData = iccDataTmp; + if (avif->profileFormat == AVIF_PROFILE_FORMAT_NONE) { +- avifImageSetProfileICC(avif, iccData, (size_t)iccDataLen); ++ avifImageSetProfileICC(avif, iccDataTmp, (size_t)iccDataLen); + } else { + fprintf(stderr, "WARNING: JPEG contains ICC profile which is being overridden with --nclx\n"); + } +diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c +index 3573a46..934b5aa 100644 +--- a/apps/shared/avifpng.c ++++ b/apps/shared/avifpng.c +@@ -9,17 +9,26 @@ + #include + #include + +-// This warning triggers false postives way too often in here. +-#if defined(__GNUC__) && !defined(__clang__) +-#pragma GCC diagnostic ignored "-Wclobbered" +-#endif ++// Note on setjmp() and volatile variables: ++// ++// K & R, The C Programming Language 2nd Ed, p. 254 says: ++// ... Accessible objects have the values they had when longjmp was called, ++// except that non-volatile automatic variables in the function calling setjmp ++// become undefined if they were changed after the setjmp call. ++// ++// Therefore, 'rowPointers' is declared as volatile. 'rgb' should be declared as ++// volatile, but doing so would be inconvenient (try it) and since it is a ++// struct, the compiler is unlikely to put it in a register. 'readResult' and ++// 'writeResult' do not need to be declared as volatile because they are not ++// modified between setjmp and longjmp. But GCC's -Wclobbered warning may have ++// trouble figuring that out, so we preemptively declare them as volatile. + + avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth, uint32_t * outPNGDepth) + { +- avifBool readResult = AVIF_FALSE; ++ volatile avifBool readResult = AVIF_FALSE; + png_structp png = NULL; + png_infop info = NULL; +- png_bytep * rowPointers = NULL; ++ png_bytep * volatile rowPointers = NULL; + + avifRGBImage rgb; + memset(&rgb, 0, sizeof(avifRGBImage)); +@@ -149,10 +158,10 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm + + avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, uint32_t requestedDepth) + { +- avifBool writeResult = AVIF_FALSE; ++ volatile avifBool writeResult = AVIF_FALSE; + png_structp png = NULL; + png_infop info = NULL; +- png_bytep * rowPointers = NULL; ++ png_bytep * volatile rowPointers = NULL; + + avifRGBImage rgb; + memset(&rgb, 0, sizeof(avifRGBImage)); diff --git a/libavif-0.7.1.tar.gz b/libavif-0.7.1.tar.gz deleted file mode 100644 index 835bb2d..0000000 --- a/libavif-0.7.1.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bd48009aed6defc3a76c991612e1d2e3e255f6ec1840db0d562a9e84094da674 -size 2887666 diff --git a/libavif-0.7.2.tar.gz b/libavif-0.7.2.tar.gz new file mode 100644 index 0000000..2393c36 --- /dev/null +++ b/libavif-0.7.2.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9c1a33cc6a3bf579326241475bedc9f8076694c812243983d9b32962246eb75 +size 2892316 diff --git a/libavif.changes b/libavif.changes index cf9f6c8..90b8ca4 100644 --- a/libavif.changes +++ b/libavif.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Mon May 4 15:15:50 UTC 2020 - Andreas Schneider + +- Update to version 0.7.2 + * See https://github.com/AOMediaCodec/libavif/blob/master/CHANGELOG.md + for a complete changelog. + * Added e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch + * Added ebb29b37711c749681278f8b778f0e6c031c4ca2.patch + * Added e7dcc74b5529da209266020852a72b554461e538.patch + ------------------------------------------------------------------- Thu Apr 23 10:39:15 UTC 2020 - Ismail Dönmez diff --git a/libavif.spec b/libavif.spec index 5e9a11a..7a3d690 100644 --- a/libavif.spec +++ b/libavif.spec @@ -21,7 +21,7 @@ %define lib_name libavif3 Name: libavif -Version: 0.7.1 +Version: 0.7.2 Release: 0 Summary: Library for encoding and decoding .avif files License: BSD-2-Clause @@ -30,6 +30,10 @@ URL: https://github.com/AOMediaCodec/libavif # Source: https://github.com/AOMediaCodec/libavif/archive/v%{version}/%{name}-%{version}.tar.gz # +Patch0: https://github.com/AOMediaCodec/libavif/commit/e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch +Patch1: https://github.com/AOMediaCodec/libavif/commit/ebb29b37711c749681278f8b778f0e6c031c4ca2.patch +Patch2: https://github.com/AOMediaCodec/libavif/commit/e7dcc74b5529da209266020852a72b554461e538.patch +# BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: libjpeg8-devel From 3bdd5aa847d11f016b3abec428ae0c45a184c964dbe5d52cb52fddc7e6b31091 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 4 May 2020 15:19:41 +0000 Subject: [PATCH 2/4] Update for SO name bump OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/libavif?expand=0&rev=15 --- libavif.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavif.spec b/libavif.spec index 7a3d690..3a27193 100644 --- a/libavif.spec +++ b/libavif.spec @@ -18,7 +18,7 @@ %bcond_with aom -%define lib_name libavif3 +%define lib_name libavif4 Name: libavif Version: 0.7.2 From cdc1fdf8b04cf44d9cda6ca77ebc1716af7b238c93cb3491719a4603eb65d306 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 May 2020 12:59:11 +0000 Subject: [PATCH 3/4] Update to version 0.7.3 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/libavif?expand=0&rev=16 --- ...d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch | 279 ------------------ ...c74b5529da209266020852a72b554461e538.patch | 23 -- ...9b37711c749681278f8b778f0e6c031c4ca2.patch | 150 ---------- libavif-0.7.2.tar.gz | 3 - libavif-0.7.3.tar.gz | 3 + libavif.changes | 10 + libavif.spec | 2 +- 7 files changed, 14 insertions(+), 456 deletions(-) delete mode 100644 e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch delete mode 100644 e7dcc74b5529da209266020852a72b554461e538.patch delete mode 100644 ebb29b37711c749681278f8b778f0e6c031c4ca2.patch delete mode 100644 libavif-0.7.2.tar.gz create mode 100644 libavif-0.7.3.tar.gz diff --git a/e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch b/e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch deleted file mode 100644 index 8be43eb..0000000 --- a/e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch +++ /dev/null @@ -1,279 +0,0 @@ -From e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5 Mon Sep 17 00:00:00 2001 -From: Joe Drago -Date: Mon, 27 Apr 2020 14:27:31 -0700 -Subject: [PATCH] Added avifenc Lossless (--lossless, -l) mode, which sets new - defaults and warns when anything would cause the AVIF to not be lossless - ---- - CHANGELOG.md | 2 + - apps/avifenc.c | 119 ++++++++++++++++++++++++++++++++++++++--- - apps/shared/avifjpeg.c | 2 +- - apps/shared/avifjpeg.h | 2 +- - apps/shared/avifpng.c | 8 ++- - apps/shared/avifpng.h | 4 +- - 6 files changed, 123 insertions(+), 14 deletions(-) - -diff --git a/CHANGELOG.md b/CHANGELOG.md -index 19c8d08..8d05a5f 100644 ---- a/CHANGELOG.md -+++ b/CHANGELOG.md -@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - - ## [Unreleased] -+### Added -+- avifenc: Lossless (--lossless, -l) mode, which sets new defaults and warns when anything would cause the AVIF to not be lossless - - ## [0.7.2] - 2020-04-24 - ### Added -diff --git a/apps/avifenc.c b/apps/avifenc.c -index 357596c..2d5a591 100644 ---- a/apps/avifenc.c -+++ b/apps/avifenc.c -@@ -25,6 +25,7 @@ static void syntax(void) - printf("Options:\n"); - printf(" -h,--help : Show syntax help\n"); - printf(" -j,--jobs J : Number of jobs (worker threads, default: 1)\n"); -+ 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, depth is retained)\n"); - printf(" -y,--yuv FORMAT : Output format [default=444, 422, 420]. (JPEG/PNG only; For y4m, format is retained)\n"); - printf(" -n,--nclx P/T/M : Set nclx colr box values (3 raw numbers, use -r to set range flag)\n"); -@@ -156,6 +157,7 @@ int main(int argc, char * argv[]) - avifRange requestedRange = AVIF_RANGE_FULL; - avifBool requestedRangeSet = AVIF_FALSE; - avifBool nclxSet = AVIF_FALSE; -+ avifBool lossless = AVIF_FALSE; - avifEncoder * encoder = NULL; - - avifNclxColorProfile nclx; -@@ -300,6 +302,19 @@ int main(int argc, char * argv[]) - fprintf(stderr, "ERROR: Invalid imir axis: %s\n", arg); - return 1; - } -+ } else if (!strcmp(arg, "-l") || !strcmp(arg, "--lossless")) { -+ lossless = AVIF_TRUE; -+ -+ // Set defaults, and warn later on if anything looks incorrect -+ requestedFormat = AVIF_PIXEL_FORMAT_YUV444; // don't subsample GBR -+ minQuantizer = AVIF_QUANTIZER_LOSSLESS; // lossless -+ maxQuantizer = AVIF_QUANTIZER_LOSSLESS; // lossless -+ minQuantizerAlpha = AVIF_QUANTIZER_LOSSLESS; // lossless -+ maxQuantizerAlpha = AVIF_QUANTIZER_LOSSLESS; // lossless -+ codecChoice = AVIF_CODEC_CHOICE_AOM; // rav1e doesn't support lossless transform yet: -+ // https://github.com/xiph/rav1e/issues/151 -+ requestedRange = AVIF_RANGE_FULL; // avoid limited range -+ requestedRangeSet = AVIF_TRUE; - } else { - // Positional argument - if (!inputFilename) { -@@ -325,6 +340,26 @@ int main(int argc, char * argv[]) - avifImage * avif = avifImageCreateEmpty(); - avifRWData raw = AVIF_DATA_EMPTY; - -+ uint32_t sourceDepth = 0; -+ avifBool sourceWasRGB = AVIF_TRUE; -+ avifAppFileFormat inputFormat = avifGuessFileFormat(inputFilename); -+ if (inputFormat == AVIF_APP_FILE_FORMAT_UNKNOWN) { -+ fprintf(stderr, "Cannot determine input file extension: %s\n", inputFilename); -+ returnCode = 1; -+ goto cleanup; -+ } -+ -+ if (lossless && (inputFormat != AVIF_APP_FILE_FORMAT_Y4M)) { -+ if (!nclxSet) { // don't stomp on the user's cmdline nclx values -+ // Assume SRGB unless they tell us otherwise via --nclx -+ nclx.colourPrimaries = AVIF_NCLX_TRANSFER_CHARACTERISTICS_BT709; -+ nclx.transferCharacteristics = AVIF_NCLX_TRANSFER_CHARACTERISTICS_SRGB; -+ nclx.matrixCoefficients = AVIF_NCLX_MATRIX_COEFFICIENTS_IDENTITY; // this is key for lossless -+ nclx.range = AVIF_RANGE_FULL; -+ nclxSet = AVIF_TRUE; -+ } -+ } -+ - // Set range and nclx in advance so any upcoming RGB -> YUV use the proper coefficients - if (requestedRangeSet) { - avif->yuvRange = requestedRange; -@@ -334,12 +369,6 @@ int main(int argc, char * argv[]) - avifImageSetProfileNCLX(avif, &nclx); - } - -- avifAppFileFormat inputFormat = avifGuessFileFormat(inputFilename); -- if (inputFormat == AVIF_APP_FILE_FORMAT_UNKNOWN) { -- fprintf(stderr, "Cannot determine input file extension: %s\n", inputFilename); -- returnCode = 1; -- goto cleanup; -- } - if (inputFormat == AVIF_APP_FILE_FORMAT_Y4M) { - if (requestedRangeSet) { - fprintf(stderr, "WARNING: Ignoring range (-r) value when encoding from y4m content.\n"); -@@ -353,13 +382,16 @@ int main(int argc, char * argv[]) - nclx.range = avif->yuvRange; - avifImageSetProfileNCLX(avif, &nclx); - } -+ sourceDepth = avif->depth; -+ sourceWasRGB = AVIF_FALSE; - } else if (inputFormat == AVIF_APP_FILE_FORMAT_JPEG) { - if (!avifJPEGRead(avif, inputFilename, requestedFormat, requestedDepth)) { - returnCode = 1; - goto cleanup; - } -+ sourceDepth = 8; - } else if (inputFormat == AVIF_APP_FILE_FORMAT_PNG) { -- if (!avifPNGRead(avif, inputFilename, requestedFormat, requestedDepth)) { -+ if (!avifPNGRead(avif, inputFilename, requestedFormat, requestedDepth, &sourceDepth)) { - returnCode = 1; - goto cleanup; - } -@@ -395,7 +427,78 @@ int main(int argc, char * argv[]) - avif->imir.axis = imirAxis; - } - -- printf("AVIF to be written:\n"); -+ avifBool usingAOM = AVIF_FALSE; -+ const char * codecName = avifCodecName(codecChoice, AVIF_CODEC_FLAG_CAN_ENCODE); -+ if (codecName && !strcmp(codecName, "aom")) { -+ usingAOM = AVIF_TRUE; -+ } -+ avifBool hasAlpha = (avif->alphaPlane && avif->alphaRowBytes); -+ avifBool losslessColorQP = (minQuantizer == AVIF_QUANTIZER_LOSSLESS) && (maxQuantizer == AVIF_QUANTIZER_LOSSLESS); -+ avifBool losslessAlphaQP = (minQuantizerAlpha == AVIF_QUANTIZER_LOSSLESS) && (maxQuantizerAlpha == AVIF_QUANTIZER_LOSSLESS); -+ avifBool depthMatches = (sourceDepth == avif->depth); -+ avifBool using444 = (avif->yuvFormat == AVIF_PIXEL_FORMAT_YUV444); -+ avifBool usingFullRange = (avif->yuvRange == AVIF_RANGE_FULL); -+ avifBool usingIdentityMatrix = (nclxSet && (nclx.matrixCoefficients == AVIF_NCLX_MATRIX_COEFFICIENTS_IDENTITY)); -+ -+ // Guess if the enduser is asking for lossless and enable it so that warnings can be emitted -+ if (losslessColorQP && (!hasAlpha || losslessAlphaQP)) { -+ // The enduser is probably expecting lossless. Turn it on and emit warnings -+ printf("Min/max QPs set to %d, assuming --lossless to enable warnings on potential lossless issues.\n", AVIF_QUANTIZER_LOSSLESS); -+ lossless = AVIF_TRUE; -+ } -+ -+ // Check for any reasons lossless will fail, and complain loudly -+ if (lossless) { -+ if (!usingAOM) { -+ fprintf(stderr, "WARNING: [--lossless] Only aom (-c) supports lossless transforms. Output might not be lossless.\n"); -+ lossless = AVIF_FALSE; -+ } -+ -+ if (!losslessColorQP) { -+ fprintf(stderr, -+ "WARNING: [--lossless] Color quantizer range (--min, --max) not set to %d. Color output might not be lossless.\n", -+ AVIF_QUANTIZER_LOSSLESS); -+ lossless = AVIF_FALSE; -+ } -+ -+ if (hasAlpha && !losslessAlphaQP) { -+ fprintf(stderr, -+ "WARNING: [--lossless] Alpha present and alpha quantizer range (--minalpha, --maxalpha) not set to %d. Alpha output might not be lossless.\n", -+ AVIF_QUANTIZER_LOSSLESS); -+ lossless = AVIF_FALSE; -+ } -+ -+ if (!depthMatches) { -+ fprintf(stderr, -+ "WARNING: [--lossless] Input depth (%d) does not match output depth (%d). Output might not be lossless.\n", -+ sourceDepth, -+ avif->depth); -+ lossless = AVIF_FALSE; -+ } -+ -+ if (sourceWasRGB) { -+ if (!using444) { -+ fprintf(stderr, "WARNING: [--lossless] Input data was RGB and YUV subsampling (-y) isn't YUV444. Output might not be lossless.\n"); -+ lossless = AVIF_FALSE; -+ } -+ -+ if (!usingFullRange) { -+ fprintf(stderr, "WARNING: [--lossless] Input data was RGB and output range (-r) isn't full. Output might not be lossless.\n"); -+ lossless = AVIF_FALSE; -+ } -+ -+ if (!usingIdentityMatrix) { -+ fprintf(stderr, "WARNING: [--lossless] Input data was RGB and nclx matrixCoefficients isn't set to identity (--nclx x/x/0); Output might not be lossless.\n"); -+ lossless = AVIF_FALSE; -+ } -+ } -+ } -+ -+ const char * lossyHint = " (Lossy)"; -+ if (lossless) { -+ lossyHint = " (Lossless)"; -+ } -+ printf("AVIF to be written:%s\n", lossyHint); - avifImageDump(avif); - - 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", -diff --git a/apps/shared/avifjpeg.c b/apps/shared/avifjpeg.c -index dcefb41..39bd0cd 100644 ---- a/apps/shared/avifjpeg.c -+++ b/apps/shared/avifjpeg.c -@@ -30,7 +30,7 @@ static void my_error_exit(j_common_ptr cinfo) - longjmp(myerr->setjmp_buffer, 1); - } - --avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, int requestedDepth) -+avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth) - { - avifBool ret = AVIF_FALSE; - FILE * f = NULL; -diff --git a/apps/shared/avifjpeg.h b/apps/shared/avifjpeg.h -index 13c54dd..3824aea 100644 ---- a/apps/shared/avifjpeg.h -+++ b/apps/shared/avifjpeg.h -@@ -6,7 +6,7 @@ - - #include "avif/avif.h" - --avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, int requestedDepth); -+avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth); - avifBool avifJPEGWrite(avifImage * avif, const char * outputFilename, int jpegQuality); - - #endif // ifndef LIBAVIF_APPS_SHARED_AVIFJPEG_H -diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c -index 843d6b0..3573a46 100644 ---- a/apps/shared/avifpng.c -+++ b/apps/shared/avifpng.c -@@ -14,7 +14,7 @@ - #pragma GCC diagnostic ignored "-Wclobbered" - #endif - --avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, int requestedDepth) -+avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth, uint32_t * outPNGDepth) - { - avifBool readResult = AVIF_FALSE; - png_structp png = NULL; -@@ -104,6 +104,10 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm - imgBitDepth = 16; - } - -+ if (outPNGDepth) { -+ *outPNGDepth = imgBitDepth; -+ } -+ - png_read_update_info(png, info); - - avif->width = rawWidth; -@@ -143,7 +147,7 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm - return readResult; - } - --avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int requestedDepth) -+avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, uint32_t requestedDepth) - { - avifBool writeResult = AVIF_FALSE; - png_structp png = NULL; -diff --git a/apps/shared/avifpng.h b/apps/shared/avifpng.h -index a10220e..12b68ad 100644 ---- a/apps/shared/avifpng.h -+++ b/apps/shared/avifpng.h -@@ -7,7 +7,7 @@ - #include "avif/avif.h" - - // if (requestedDepth == 0), do best-fit --avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, int requestedDepth); --avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int requestedDepth); -+avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth, uint32_t * outPNGDepth); -+avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, uint32_t requestedDepth); - - #endif // ifndef LIBAVIF_APPS_SHARED_AVIFPNG_H diff --git a/e7dcc74b5529da209266020852a72b554461e538.patch b/e7dcc74b5529da209266020852a72b554461e538.patch deleted file mode 100644 index abd75dd..0000000 --- a/e7dcc74b5529da209266020852a72b554461e538.patch +++ /dev/null @@ -1,23 +0,0 @@ -From e7dcc74b5529da209266020852a72b554461e538 Mon Sep 17 00:00:00 2001 -From: Andreas Schneider -Date: Wed, 29 Apr 2020 17:34:57 +0200 -Subject: [PATCH] apps: Use correct enum for colourPrimaries - -Signed-off-by: Andreas Schneider ---- - apps/avifenc.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/apps/avifenc.c b/apps/avifenc.c -index 11595b7..e812670 100644 ---- a/apps/avifenc.c -+++ b/apps/avifenc.c -@@ -352,7 +352,7 @@ int main(int argc, char * argv[]) - if (lossless && (inputFormat != AVIF_APP_FILE_FORMAT_Y4M)) { - if (!nclxSet) { // don't stomp on the user's cmdline nclx values - // Assume SRGB unless they tell us otherwise via --nclx -- nclx.colourPrimaries = AVIF_NCLX_TRANSFER_CHARACTERISTICS_BT709; -+ nclx.colourPrimaries = AVIF_NCLX_COLOUR_PRIMARIES_BT709; - nclx.transferCharacteristics = AVIF_NCLX_TRANSFER_CHARACTERISTICS_SRGB; - nclx.matrixCoefficients = AVIF_NCLX_MATRIX_COEFFICIENTS_IDENTITY; // this is key for lossless - nclx.range = AVIF_RANGE_FULL; diff --git a/ebb29b37711c749681278f8b778f0e6c031c4ca2.patch b/ebb29b37711c749681278f8b778f0e6c031c4ca2.patch deleted file mode 100644 index 6eb0871..0000000 --- a/ebb29b37711c749681278f8b778f0e6c031c4ca2.patch +++ /dev/null @@ -1,150 +0,0 @@ -From ebb29b37711c749681278f8b778f0e6c031c4ca2 Mon Sep 17 00:00:00 2001 -From: Wan-Teh Chang -Date: Mon, 27 Apr 2020 18:43:51 -0700 -Subject: [PATCH] Do not ignore GCC's -Wclobbered warning - -The C Standard requires certain local variables in the function calling -setjmp be declared as volatile. I went through the code and declare -variables as volatile according to the C Standard, except for the 'rgb' -struct variable. Document my rationale. ---- - apps/shared/avifjpeg.c | 44 ++++++++++++++++++++++++++---------------- - apps/shared/avifpng.c | 25 ++++++++++++++++-------- - 2 files changed, 44 insertions(+), 25 deletions(-) - -diff --git a/apps/shared/avifjpeg.c b/apps/shared/avifjpeg.c -index 39bd0cd..5e68211 100644 ---- a/apps/shared/avifjpeg.c -+++ b/apps/shared/avifjpeg.c -@@ -12,11 +12,6 @@ - - #include "iccjpeg.h" - --// This warning triggers false postives way too often in here. --#if defined(__GNUC__) && !defined(__clang__) --#pragma GCC diagnostic ignored "-Wclobbered" --#endif -- - struct my_error_mgr - { - struct jpeg_error_mgr pub; -@@ -30,31 +25,44 @@ static void my_error_exit(j_common_ptr cinfo) - longjmp(myerr->setjmp_buffer, 1); - } - -+// Note on setjmp() and volatile variables: -+// -+// K & R, The C Programming Language 2nd Ed, p. 254 says: -+// ... Accessible objects have the values they had when longjmp was called, -+// except that non-volatile automatic variables in the function calling setjmp -+// become undefined if they were changed after the setjmp call. -+// -+// Therefore, 'iccData' is declared as volatile. 'rgb' should be declared as -+// volatile, but doing so would be inconvenient (try it) and since it is a -+// struct, the compiler is unlikely to put it in a register. 'ret' does not need -+// to be declared as volatile because it is not modified between setjmp and -+// longjmp. But GCC's -Wclobbered warning may have trouble figuring that out, so -+// we preemptively declare it as volatile. -+ - avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth) - { -- avifBool ret = AVIF_FALSE; -- FILE * f = NULL; -- uint8_t * iccData = NULL; -+ volatile avifBool ret = AVIF_FALSE; -+ uint8_t * volatile iccData = NULL; - - avifRGBImage rgb; - memset(&rgb, 0, sizeof(avifRGBImage)); - -+ FILE * f = fopen(inputFilename, "rb"); -+ if (!f) { -+ fprintf(stderr, "Can't open JPEG file for read: %s\n", inputFilename); -+ goto cleanup; -+ } -+ - struct my_error_mgr jerr; - struct jpeg_decompress_struct cinfo; - cinfo.err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = my_error_exit; - if (setjmp(jerr.setjmp_buffer)) { -- return AVIF_FALSE; -+ goto cleanup; - } - - jpeg_create_decompress(&cinfo); - -- f = fopen(inputFilename, "rb"); -- if (!f) { -- fprintf(stderr, "Can't open JPEG file for read: %s\n", inputFilename); -- goto cleanup; -- } -- - setup_read_icc_profile(&cinfo); - jpeg_stdio_src(&cinfo, f); - jpeg_read_header(&cinfo, TRUE); -@@ -63,10 +71,12 @@ avifBool avifJPEGRead(avifImage * avif, const char * inputFilename, avifPixelFor - int row_stride = cinfo.output_width * cinfo.output_components; - JSAMPARRAY buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, 1); - -+ uint8_t * iccDataTmp; - unsigned int iccDataLen; -- if (read_icc_profile(&cinfo, &iccData, &iccDataLen)) { -+ if (read_icc_profile(&cinfo, &iccDataTmp, &iccDataLen)) { -+ iccData = iccDataTmp; - if (avif->profileFormat == AVIF_PROFILE_FORMAT_NONE) { -- avifImageSetProfileICC(avif, iccData, (size_t)iccDataLen); -+ avifImageSetProfileICC(avif, iccDataTmp, (size_t)iccDataLen); - } else { - fprintf(stderr, "WARNING: JPEG contains ICC profile which is being overridden with --nclx\n"); - } -diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c -index 3573a46..934b5aa 100644 ---- a/apps/shared/avifpng.c -+++ b/apps/shared/avifpng.c -@@ -9,17 +9,26 @@ - #include - #include - --// This warning triggers false postives way too often in here. --#if defined(__GNUC__) && !defined(__clang__) --#pragma GCC diagnostic ignored "-Wclobbered" --#endif -+// Note on setjmp() and volatile variables: -+// -+// K & R, The C Programming Language 2nd Ed, p. 254 says: -+// ... Accessible objects have the values they had when longjmp was called, -+// except that non-volatile automatic variables in the function calling setjmp -+// become undefined if they were changed after the setjmp call. -+// -+// Therefore, 'rowPointers' is declared as volatile. 'rgb' should be declared as -+// volatile, but doing so would be inconvenient (try it) and since it is a -+// struct, the compiler is unlikely to put it in a register. 'readResult' and -+// 'writeResult' do not need to be declared as volatile because they are not -+// modified between setjmp and longjmp. But GCC's -Wclobbered warning may have -+// trouble figuring that out, so we preemptively declare them as volatile. - - avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelFormat requestedFormat, uint32_t requestedDepth, uint32_t * outPNGDepth) - { -- avifBool readResult = AVIF_FALSE; -+ volatile avifBool readResult = AVIF_FALSE; - png_structp png = NULL; - png_infop info = NULL; -- png_bytep * rowPointers = NULL; -+ png_bytep * volatile rowPointers = NULL; - - avifRGBImage rgb; - memset(&rgb, 0, sizeof(avifRGBImage)); -@@ -149,10 +158,10 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm - - avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, uint32_t requestedDepth) - { -- avifBool writeResult = AVIF_FALSE; -+ volatile avifBool writeResult = AVIF_FALSE; - png_structp png = NULL; - png_infop info = NULL; -- png_bytep * rowPointers = NULL; -+ png_bytep * volatile rowPointers = NULL; - - avifRGBImage rgb; - memset(&rgb, 0, sizeof(avifRGBImage)); diff --git a/libavif-0.7.2.tar.gz b/libavif-0.7.2.tar.gz deleted file mode 100644 index 2393c36..0000000 --- a/libavif-0.7.2.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b9c1a33cc6a3bf579326241475bedc9f8076694c812243983d9b32962246eb75 -size 2892316 diff --git a/libavif-0.7.3.tar.gz b/libavif-0.7.3.tar.gz new file mode 100644 index 0000000..a5f450d --- /dev/null +++ b/libavif-0.7.3.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4ce03649c58ec9f3dc6ab2b7cf7d58474b149acf1e4c563be4081bad60ed2dd +size 2893675 diff --git a/libavif.changes b/libavif.changes index 90b8ca4..b79fd2a 100644 --- a/libavif.changes +++ b/libavif.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Tue May 5 12:58:13 UTC 2020 - Andreas Schneider + +- Update to version 0.7.3 + * See https://github.com/AOMediaCodec/libavif/blob/master/CHANGELOG.md + for a complete changelog. + * Removed e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch + * Removed ebb29b37711c749681278f8b778f0e6c031c4ca2.patch + * Removed e7dcc74b5529da209266020852a72b554461e538.patch + ------------------------------------------------------------------- Mon May 4 15:15:50 UTC 2020 - Andreas Schneider diff --git a/libavif.spec b/libavif.spec index 3a27193..2d14dc8 100644 --- a/libavif.spec +++ b/libavif.spec @@ -21,7 +21,7 @@ %define lib_name libavif4 Name: libavif -Version: 0.7.2 +Version: 0.7.3 Release: 0 Summary: Library for encoding and decoding .avif files License: BSD-2-Clause From a6f3195052b06e50e95a8f58d9336b2cea5404dc23f32d555da02cfb39909c17 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 May 2020 13:17:28 +0000 Subject: [PATCH 4/4] Remove patches for spec OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/libavif?expand=0&rev=17 --- libavif.spec | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavif.spec b/libavif.spec index 2d14dc8..1a150ee 100644 --- a/libavif.spec +++ b/libavif.spec @@ -30,10 +30,6 @@ URL: https://github.com/AOMediaCodec/libavif # Source: https://github.com/AOMediaCodec/libavif/archive/v%{version}/%{name}-%{version}.tar.gz # -Patch0: https://github.com/AOMediaCodec/libavif/commit/e4e5d752ece581d6ef9fbb8bab0ab2edfde13fc5.patch -Patch1: https://github.com/AOMediaCodec/libavif/commit/ebb29b37711c749681278f8b778f0e6c031c4ca2.patch -Patch2: https://github.com/AOMediaCodec/libavif/commit/e7dcc74b5529da209266020852a72b554461e538.patch -# BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: libjpeg8-devel