Hello community, here is the log from the commit of package libavif for openSUSE:Factory checked in at 2020-08-18 12:00:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libavif (Old) and /work/SRC/openSUSE:Factory/.libavif.new.3399 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libavif" Tue Aug 18 12:00:21 2020 rev:7 rq:827354 version:0.8.1 Changes: -------- --- /work/SRC/openSUSE:Factory/libavif/libavif.changes 2020-07-24 10:01:42.189740628 +0200 +++ /work/SRC/openSUSE:Factory/.libavif.new.3399/libavif.changes 2020-08-18 12:02:46.719421303 +0200 @@ -1,0 +2,8 @@ +Mon Aug 17 13:35:27 UTC 2020 - Andreas Schneider <[email protected]> + +- Update to version 0.8.1 + * See https://github.com/AOMediaCodec/libavif/blob/master/CHANGELOG.md + for a complete changelog. +- Enabled AOM support (default) + +------------------------------------------------------------------- Old: ---- libavif-0.8.0.tar.gz New: ---- libavif-0.8.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libavif.spec ++++++ --- /var/tmp/diff_new_pack.Kh78lY/_old 2020-08-18 12:02:50.867421870 +0200 +++ /var/tmp/diff_new_pack.Kh78lY/_new 2020-08-18 12:02:50.871421870 +0200 @@ -16,12 +16,12 @@ # -%bcond_with aom +%bcond_without aom -%define lib_name libavif5 +%define lib_name libavif6 Name: libavif -Version: 0.8.0 +Version: 0.8.1 Release: 0 Summary: Library for encoding and decoding .avif files License: BSD-2-Clause @@ -39,7 +39,7 @@ BuildRequires: pkgconfig(rav1e) %if %{with aom} -BuildRequires: pkgconfig(aom) >= 1.1.0 +BuildRequires: pkgconfig(aom) >= 2.0.0 %endif %description ++++++ libavif-0.8.0.tar.gz -> libavif-0.8.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libavif-0.8.0/.github/workflows/ci.yml new/libavif-0.8.1/.github/workflows/ci.yml --- old/libavif-0.8.0/.github/workflows/ci.yml 2020-07-14 21:50:45.000000000 +0200 +++ new/libavif-0.8.1/.github/workflows/ci.yml 2020-08-05 21:57:33.000000000 +0200 @@ -34,13 +34,10 @@ - name: Setup rav1e working-directory: ./ext run: bash rav1e.cmd - - name: Setup libgav1 - working-directory: ./ext - run: bash libgav1.cmd - name: Prepare libavif (cmake) run: | mkdir build && cd build - cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON -DAVIF_CODEC_DAV1D=ON -DAVIF_LOCAL_DAV1D=ON -DAVIF_CODEC_RAV1E=ON -DAVIF_LOCAL_RAV1E=ON -DAVIF_CODEC_LIBGAV1=ON -DAVIF_LOCAL_LIBGAV1=ON -DAVIF_BUILD_TESTS=1 + cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON -DAVIF_CODEC_DAV1D=ON -DAVIF_LOCAL_DAV1D=ON -DAVIF_CODEC_RAV1E=ON -DAVIF_LOCAL_RAV1E=ON -DAVIF_BUILD_TESTS=1 - name: Build libavif (make) working-directory: ./build run: make -j $(($(nproc) + 1)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libavif-0.8.0/.travis.yml new/libavif-0.8.1/.travis.yml --- old/libavif-0.8.0/.travis.yml 2020-07-14 21:50:45.000000000 +0200 +++ new/libavif-0.8.1/.travis.yml 2020-08-05 21:57:33.000000000 +0200 @@ -22,12 +22,11 @@ - export MAKEFLAGS=-j$(nproc) - bash aom.cmd - bash dav1d.cmd - - bash libgav1.cmd - bash rav1e.cmd - cd .. - mkdir build - cd build - - cmake -G Ninja -DCMAKE_BUILD_TYPE=$config -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON -DAVIF_CODEC_DAV1D=ON -DAVIF_LOCAL_DAV1D=ON -DAVIF_CODEC_RAV1E=ON -DAVIF_LOCAL_RAV1E=ON -DAVIF_CODEC_LIBGAV1=ON -DAVIF_LOCAL_LIBGAV1=ON -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON -DAVIF_BUILD_TESTS=ON .. + - cmake -G Ninja -DCMAKE_BUILD_TYPE=$config -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON -DAVIF_CODEC_DAV1D=ON -DAVIF_LOCAL_DAV1D=ON -DAVIF_CODEC_RAV1E=ON -DAVIF_LOCAL_RAV1E=ON -DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON -DAVIF_BUILD_TESTS=ON .. script: - ninja diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libavif-0.8.0/CHANGELOG.md new/libavif-0.8.1/CHANGELOG.md --- old/libavif-0.8.0/CHANGELOG.md 2020-07-14 21:50:45.000000000 +0200 +++ new/libavif-0.8.1/CHANGELOG.md 2020-08-05 21:57:33.000000000 +0200 @@ -6,6 +6,21 @@ ## [Unreleased] +## [0.8.1] - 2020-08-05 + +### Added +* Add `ignoreAlpha` field to avifRGBImage (linkmauve) +* Save support in gdk-pixbuf component (novomesk) + +### Changed +* Only ever create one iref box, filled with multiple cdsc boxes (#247) +* Fix incorrect 16-to-8 monochrome YUV conversion +* Make decoding optional in CMake, like encoding is +* Include avif INTERFACE_INCLUDE_DIRECTORIES first (cryptomilk) +* Set C standard to C99, adjust flags for dav1d (1480c1) +* Minor cleanup/fixes in reformat.c (wantehchang) +* Fix a crash in the gdk-pixbuf loader, removed unnecessary asserts (novomesk) + ## [0.8.0] - 2020-07-14 ### Added @@ -453,7 +468,8 @@ - Constants `AVIF_VERSION`, `AVIF_VERSION_MAJOR`, `AVIF_VERSION_MINOR`, `AVIF_VERSION_PATCH` - `avifVersion()` function -[Unreleased]: https://github.com/AOMediaCodec/libavif/compare/v0.8.0...HEAD +[Unreleased]: https://github.com/AOMediaCodec/libavif/compare/v0.8.1...HEAD +[0.8.1]: https://github.com/AOMediaCodec/libavif/compare/v0.8.0...v0.8.1 [0.8.0]: https://github.com/AOMediaCodec/libavif/compare/v0.7.3...v0.8.0 [0.7.3]: https://github.com/AOMediaCodec/libavif/compare/v0.7.2...v0.7.3 [0.7.2]: https://github.com/AOMediaCodec/libavif/compare/v0.7.1...v0.7.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libavif-0.8.0/CMakeLists.txt new/libavif-0.8.1/CMakeLists.txt --- old/libavif-0.8.0/CMakeLists.txt 2020-07-14 21:50:45.000000000 +0200 +++ new/libavif-0.8.1/CMakeLists.txt 2020-08-05 21:57:33.000000000 +0200 @@ -7,7 +7,10 @@ # and find_package() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") -project(libavif LANGUAGES C CXX VERSION 0.8.0) +project(libavif LANGUAGES C VERSION 0.8.1) + +# Set C99 as the default +set(CMAKE_C_STANDARD 99) # SOVERSION scheme: MAJOR.MINOR.PATCH # If there was an incompatible interface change: @@ -16,7 +19,7 @@ # Increment MINOR. Set PATCH to 0 # If the source code was changed, but there were no interface changes: # Increment PATCH. -set(LIBRARY_VERSION_MAJOR 5) +set(LIBRARY_VERSION_MAJOR 6) set(LIBRARY_VERSION_MINOR 0) set(LIBRARY_VERSION_PATCH 0) set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}") @@ -34,6 +37,10 @@ option(AVIF_LOCAL_LIBGAV1 "Build the libgav1 codec by providing your own copy of the repo in ext/libgav1 (see Local Builds in README)" OFF) option(AVIF_LOCAL_RAV1E "Build the rav1e codec by providing your own copy of the repo in ext/rav1e (see Local Builds in README)" OFF) +if(AVIF_LOCAL_LIBGAV1) + enable_language(CXX) +endif() + # --------------------------------------------------------------------------------------- # This insanity is for people embedding libavif or making fully static or Windows builds. # Any proper unix environment should ignore these entire following blocks. @@ -89,9 +96,9 @@ -Wno-missing-noreturn -Wno-padded -Wno-sign-conversion + -Wno-error=c11-extensions ) elseif(CMAKE_C_COMPILER_ID MATCHES "GNU") - add_definitions(-std=gnu99) # Enforce C99 for gcc MESSAGE(STATUS "libavif: Enabling warnings for GCC") add_definitions(-Werror -Wall -Wextra) elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") @@ -264,7 +271,7 @@ endif() if(NOT AVIF_CODEC_AOM AND NOT AVIF_CODEC_DAV1D AND NOT AVIF_CODEC_LIBGAV1) - message(FATAL_ERROR "libavif: No decoding library is enabled, bailing out.") + message(WARNING "libavif: No decoding library is enabled.") endif() add_library(avif ${AVIF_SRCS}) @@ -317,7 +324,13 @@ set_target_properties(avifenc PROPERTIES LINKER_LANGUAGE "CXX") endif() target_link_libraries(avifenc avif ${AVIF_PLATFORM_LIBRARIES} ${ZLIB_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY}) - target_include_directories(avifenc PRIVATE apps/shared ${ZLIB_INCLUDE_DIR} ${PNG_PNG_INCLUDE_DIR} ${JPEG_INCLUDE_DIR}) + target_include_directories(avifenc + PRIVATE + $<TARGET_PROPERTY:avif,INTERFACE_INCLUDE_DIRECTORIES> + ${CMAKE_CURRENT_SOURCE_DIR}/apps/shared + ${ZLIB_INCLUDE_DIR} + ${PNG_PNG_INCLUDE_DIR} + ${JPEG_INCLUDE_DIR}) add_executable(avifdec apps/avifdec.c @@ -331,7 +344,13 @@ set_target_properties(avifdec PROPERTIES LINKER_LANGUAGE "CXX") endif() target_link_libraries(avifdec avif ${AVIF_PLATFORM_LIBRARIES} ${ZLIB_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY}) - target_include_directories(avifdec PRIVATE apps/shared ${ZLIB_INCLUDE_DIR} ${PNG_PNG_INCLUDE_DIR} ${JPEG_INCLUDE_DIR}) + target_include_directories(avifdec + PRIVATE + $<TARGET_PROPERTY:avif,INTERFACE_INCLUDE_DIRECTORIES> + ${CMAKE_CURRENT_SOURCE_DIR}/apps/shared + ${ZLIB_INCLUDE_DIR} + ${PNG_PNG_INCLUDE_DIR} + ${JPEG_INCLUDE_DIR}) if(NOT SKIP_INSTALL_APPS AND NOT SKIP_INSTALL_ALL) install(TARGETS avifenc avifdec diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libavif-0.8.0/contrib/gdk-pixbuf/loader.c new/libavif-0.8.1/contrib/gdk-pixbuf/loader.c --- old/libavif-0.8.0/contrib/gdk-pixbuf/loader.c 2020-07-14 21:50:45.000000000 +0200 +++ new/libavif-0.8.1/contrib/gdk-pixbuf/loader.c 2020-08-05 21:57:33.000000000 +0200 @@ -1,5 +1,6 @@ -// Copyright 2020 Emmanuel Gil Peyrot. All rights reserved. -// SPDX-License-Identifier: BSD-2-Clause +/* Copyright 2020 Emmanuel Gil Peyrot. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause +*/ #include <avif/avif.h> @@ -76,7 +77,7 @@ ret = avifDecoderNextImage(decoder); if (ret == AVIF_RESULT_NO_IMAGES_REMAINING) { - // No more images, bail out. Verify that you got the expected amount of images decoded. + /* No more images, bail out. Verify that you got the expected amount of images decoded. */ return TRUE; } else if (ret != AVIF_RESULT_OK) { g_set_error(error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_FAILED, @@ -88,7 +89,9 @@ width = image->width; height = image->height; - (*context->size_func)(&width, &height, context->user_data); + if (context->size_func) { + (*context->size_func)(&width, &height, context->user_data); + } if (width == 0 || height == 0) { g_set_error_literal(error, @@ -103,7 +106,7 @@ context->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, !!image->alphaPlane, bits_per_sample, - width, height); + image->width, image->height); if (context->pixbuf == NULL) { g_set_error_literal(error, GDK_PIXBUF_ERROR, @@ -138,9 +141,7 @@ struct avif_context * context; avifDecoder * decoder; - g_assert(size_func != NULL); g_assert(prepared_func != NULL); - g_assert(updated_func != NULL); decoder = avifDecoderCreate(); if (!decoder) { @@ -182,15 +183,189 @@ { struct avif_context * context = (struct avif_context *) data; g_byte_array_append(context->data, buf, size); - *error = NULL; + if (error) + *error = NULL; return TRUE; } +static gboolean avif_is_save_option_supported (const gchar *option_key) +{ + if (g_strcmp0(option_key, "quality") == 0) { + return TRUE; + } + + return FALSE; +} + +static gboolean avif_image_saver(FILE *f, + GdkPixbuf *pixbuf, + gchar **keys, + gchar **values, + GError **error) +{ + int width, height, min_quantizer, max_quantizer, alpha_quantizer; + long quality = 52; /* default; must be between 0 and 100 */ + gboolean save_alpha; + avifImage *avif; + avifRGBImage rgb; + avifResult res; + avifRWData raw = AVIF_DATA_EMPTY; + avifEncoder *encoder; + guint maxThreads; + + if (f == NULL || pixbuf == NULL) { + return FALSE; + } + + if (keys && *keys) { + gchar **kiter = keys; + gchar **viter = values; + + while (*kiter) { + if (strcmp(*kiter, "quality") == 0) { + char *endptr = NULL; + quality = strtol(*viter, &endptr, 10); + + if (endptr == *viter) { + g_set_error(error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_BAD_OPTION, + "AVIF quality must be a value between 0 and 100; value ā%sā could not be parsed.", + *viter); + + return FALSE; + } + + if (quality < 0 || quality > 100) { + + g_set_error(error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_BAD_OPTION, + "AVIF quality must be a value between 0 and 100; value ā%dā is not allowed.", + (int)quality); + + return FALSE; + } + } else { + g_warning("Unrecognized parameter (%s) passed to AVIF saver.", *kiter); + } + + ++kiter; + ++viter; + } + } + + if (gdk_pixbuf_get_bits_per_sample(pixbuf) != 8) { + g_set_error(error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_UNKNOWN_TYPE, + "Sorry, only 8bit images are supported by this AVIF saver"); + return FALSE; + } + + width = gdk_pixbuf_get_width(pixbuf); + height = gdk_pixbuf_get_height(pixbuf); + + if ( width == 0 || height == 0) { + g_set_error(error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_CORRUPT_IMAGE, + "Empty image, nothing to save"); + return FALSE; + } + + save_alpha = gdk_pixbuf_get_has_alpha(pixbuf); + + if (save_alpha) { + if ( gdk_pixbuf_get_n_channels(pixbuf) != 4) { + g_set_error(error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_UNKNOWN_TYPE, + "Unsupported number of channels"); + return FALSE; + } + } + else { + if ( gdk_pixbuf_get_n_channels(pixbuf) != 3) { + g_set_error(error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_UNKNOWN_TYPE, + "Unsupported number of channels"); + return FALSE; + } + } + + max_quantizer = AVIF_QUANTIZER_WORST_QUALITY * ( 100 - CLAMP(quality, 0, 100)) / 100; + min_quantizer = 0; + alpha_quantizer = 0; + + if ( max_quantizer > 20 ) { + min_quantizer = max_quantizer - 20; + + if (max_quantizer > 40) { + alpha_quantizer = max_quantizer - 40; + } + } + + avif = avifImageCreate(width, height, 8, AVIF_PIXEL_FORMAT_YUV420); + avif->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT601; + avifRGBImageSetDefaults( &rgb, avif); + + rgb.depth = 8; + rgb.pixels = (uint8_t*) gdk_pixbuf_read_pixels(pixbuf); + rgb.rowBytes = gdk_pixbuf_get_rowstride(pixbuf); + + if (save_alpha) { + rgb.format = AVIF_RGB_FORMAT_RGBA; + } else { + rgb.format = AVIF_RGB_FORMAT_RGB; + } + + res = avifImageRGBToYUV(avif, &rgb); + if ( res != AVIF_RESULT_OK ) { + g_set_error(error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_FAILED, + "Problem in RGB->YUV conversion: %s", avifResultToString(res)); + avifImageDestroy(avif); + return FALSE; + } + + maxThreads = g_get_num_processors(); + encoder = avifEncoderCreate(); + + encoder->maxThreads = CLAMP(maxThreads, 1, 64); + encoder->minQuantizer = min_quantizer; + encoder->maxQuantizer = max_quantizer; + encoder->minQuantizerAlpha = 0; + encoder->maxQuantizerAlpha = alpha_quantizer; + encoder->speed = 8; + + res = avifEncoderWrite(encoder, avif, &raw); + avifEncoderDestroy(encoder); + avifImageDestroy(avif); + + if ( res == AVIF_RESULT_OK ) { + fwrite(raw.data, 1, raw.size, f); + avifRWDataFree(&raw); + return TRUE; + } + + g_set_error(error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_FAILED, + "AVIF encoder problem: %s", avifResultToString(res)); + return FALSE; +} + + G_MODULE_EXPORT void fill_vtable(GdkPixbufModule * module) { module->begin_load = begin_load; module->stop_load = stop_load; module->load_increment = load_increment; + module->is_save_option_supported = avif_is_save_option_supported; + module->save = avif_image_saver; } G_MODULE_EXPORT void fill_info(GdkPixbufFormat * info) @@ -213,7 +388,7 @@ info->description = "AV1 Image File Format"; info->mime_types = (gchar **)mime_types; info->extensions = (gchar **)extensions; - info->flags = GDK_PIXBUF_FORMAT_THREADSAFE; + info->flags = GDK_PIXBUF_FORMAT_WRITABLE | GDK_PIXBUF_FORMAT_THREADSAFE; info->license = "BSD"; info->disabled = FALSE; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libavif-0.8.0/include/avif/avif.h new/libavif-0.8.1/include/avif/avif.h --- old/libavif-0.8.0/include/avif/avif.h 2020-07-14 21:50:45.000000000 +0200 +++ new/libavif-0.8.1/include/avif/avif.h 2020-08-05 21:57:33.000000000 +0200 @@ -16,7 +16,7 @@ #define AVIF_VERSION_MAJOR 0 #define AVIF_VERSION_MINOR 8 -#define AVIF_VERSION_PATCH 0 +#define AVIF_VERSION_PATCH 1 #define AVIF_VERSION (AVIF_VERSION_MAJOR * 10000) + (AVIF_VERSION_MINOR * 100) + AVIF_VERSION_PATCH typedef int avifBool; @@ -399,6 +399,8 @@ avifRGBFormat format; // all channels are always full range avifChromaUpsampling chromaUpsampling; // How to upsample non-4:4:4 UV (ignored for 444) when converting to RGB. // Unused when converting to YUV. avifRGBImageSetDefaults() prefers quality over speed. + avifBool ignoreAlpha; // Used for XRGB formats, treats formats containing alpha (such as ARGB) as if they were + // RGB, treating the alpha bits as if they were all 1. uint8_t * pixels; uint32_t rowBytes; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libavif-0.8.0/src/avif.c new/libavif-0.8.1/src/avif.c --- old/libavif-0.8.0/src/avif.c 2020-07-14 21:50:45.000000000 +0200 +++ new/libavif-0.8.1/src/avif.c 2020-08-05 21:57:33.000000000 +0200 @@ -353,6 +353,7 @@ rgb->depth = image->depth; rgb->format = AVIF_RGB_FORMAT_RGBA; rgb->chromaUpsampling = AVIF_CHROMA_UPSAMPLING_BILINEAR; + rgb->ignoreAlpha = AVIF_FALSE; rgb->pixels = NULL; rgb->rowBytes = 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libavif-0.8.0/src/reformat.c new/libavif-0.8.1/src/reformat.c --- old/libavif-0.8.0/src/reformat.c 2020-07-14 21:50:45.000000000 +0200 +++ new/libavif-0.8.1/src/reformat.c 2020-08-05 21:57:33.000000000 +0200 @@ -134,7 +134,7 @@ } avifImageAllocatePlanes(image, AVIF_PLANES_YUV); - if (avifRGBFormatHasAlpha(rgb->format)) { + if (avifRGBFormatHasAlpha(rgb->format) && !rgb->ignoreAlpha) { avifImageAllocatePlanes(image, AVIF_PLANES_A); } @@ -297,7 +297,7 @@ params.dstOffsetBytes = 0; params.dstPixelBytes = state.yuvChannelBytes; - if (avifRGBFormatHasAlpha(rgb->format)) { + if (avifRGBFormatHasAlpha(rgb->format) && !rgb->ignoreAlpha) { params.srcDepth = rgb->depth; params.srcRange = AVIF_RANGE_FULL; params.srcPlane = rgb->pixels; @@ -340,7 +340,11 @@ for (uint32_t j = 0; j < image->height; ++j) { const uint32_t uvJ = j >> state->formatInfo.chromaShiftY; const uint8_t * ptrY8 = &yPlane[j * yRowBytes]; + const uint8_t * ptrU8 = &uPlane[(uvJ * uRowBytes)]; + const uint8_t * ptrV8 = &vPlane[(uvJ * vRowBytes)]; const uint16_t * ptrY16 = (const uint16_t *)ptrY8; + const uint16_t * ptrU16 = (const uint16_t *)ptrU8; + const uint16_t * ptrV16 = (const uint16_t *)ptrV8; uint8_t * ptrR = &rgb->pixels[state->rgbOffsetBytesR + (j * rgb->rowBytes)]; uint8_t * ptrG = &rgb->pixels[state->rgbOffsetBytesG + (j * rgb->rowBytes)]; @@ -365,15 +369,11 @@ if (image->yuvFormat == AVIF_PIXEL_FORMAT_YUV444) { uint16_t unormU, unormV; - const uint8_t * ptrU8 = &uPlane[(uvJ * uRowBytes)]; - const uint8_t * ptrV8 = &vPlane[(uvJ * vRowBytes)]; if (image->depth == 8) { unormU = ptrU8[uvI]; unormV = ptrV8[uvI]; } else { // clamp incoming data to protect against bad LUT lookups - const uint16_t * ptrU16 = (const uint16_t *)ptrU8; - const uint16_t * ptrV16 = (const uint16_t *)ptrV8; unormU = AVIF_MIN(ptrU16[uvI], yuvMaxChannel); unormV = AVIF_MIN(ptrV16[uvI], yuvMaxChannel); } @@ -706,9 +706,9 @@ const float Gc = AVIF_CLAMP(G, 0.0f, 1.0f); const float Bc = AVIF_CLAMP(B, 0.0f, 1.0f); - *((uint16_t *)ptrR) = (uint16_t)(0.5f + (Rc * rgbMaxChannel)); - *((uint16_t *)ptrG) = (uint16_t)(0.5f + (Gc * rgbMaxChannel)); - *((uint16_t *)ptrB) = (uint16_t)(0.5f + (Bc * rgbMaxChannel)); + *ptrR = (uint8_t)(0.5f + (Rc * rgbMaxChannel)); + *ptrG = (uint8_t)(0.5f + (Gc * rgbMaxChannel)); + *ptrB = (uint8_t)(0.5f + (Bc * rgbMaxChannel)); ptrR += rgbPixelBytes; ptrG += rgbPixelBytes; @@ -925,7 +925,7 @@ return AVIF_RESULT_REFORMAT_FAILED; } - if (avifRGBFormatHasAlpha(rgb->format)) { + if (avifRGBFormatHasAlpha(rgb->format) && !rgb->ignoreAlpha) { avifAlphaParams params; params.width = rgb->width; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libavif-0.8.0/src/write.c new/libavif-0.8.1/src/write.c --- old/libavif-0.8.0/src/write.c 2020-07-14 21:50:45.000000000 +0200 +++ new/libavif-0.8.1/src/write.c 2020-08-05 21:57:33.000000000 +0200 @@ -633,18 +633,23 @@ // ----------------------------------------------------------------------- // Write iref boxes + avifBoxMarker iref = 0; for (uint32_t itemIndex = 0; itemIndex < encoder->data->items.count; ++itemIndex) { avifEncoderItem * item = &encoder->data->items.item[itemIndex]; if (item->irefToID != 0) { - avifBoxMarker iref = avifRWStreamWriteFullBox(&s, "iref", AVIF_BOX_SIZE_TBD, 0, 0); + if (!iref) { + iref = avifRWStreamWriteFullBox(&s, "iref", AVIF_BOX_SIZE_TBD, 0, 0); + } avifBoxMarker refType = avifRWStreamWriteBox(&s, item->irefType, AVIF_BOX_SIZE_TBD); avifRWStreamWriteU16(&s, item->id); // unsigned int(16) from_item_ID; avifRWStreamWriteU16(&s, 1); // unsigned int(16) reference_count; avifRWStreamWriteU16(&s, item->irefToID); // unsigned int(16) to_item_ID; avifRWStreamFinishBox(&s, refType); - avifRWStreamFinishBox(&s, iref); } } + if (iref) { + avifRWStreamFinishBox(&s, iref); + } // ----------------------------------------------------------------------- // Write iprp -> ipco/ipma
