%global git_date  20241213
%global git_hash  03d5e38
%global git_ver  1.1.1

%global rel  1
%global src_name %{name}-%{git_date}-%{git_hash}.tar.xz

# Building without aom, dav1d, rav1e, svt-av1

Name:           libavif
Version:    %{git_ver}^%{git_date}g%{git_hash}
Release:    %{rel}%{?dist}
Summary:        Library for encoding and decoding .avif files

License:        BSD
URL:            https://github.com/AOMediaCodec/libavif
Source0:        %{url}/%{src_name}
#Patch1:		gdk-pixbuf-mode-to-axis.patch
# No longer need - DT
# Patch0:		gdk-pixbuf-avifRGBToYUVFlag-refactor.patch
#

BuildRequires:  cmake make
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig(libjpeg)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(zlib)
BuildRequires:  pkgconfig(libyuv)

%description
This library aims to be a friendly, portable C implementation of the AV1 Image
File Format, as described here:

https://aomediacodec.github.io/av1-avif/

%package devel
Summary:        Development files for libavif
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description devel
This package holds the development files for libavif.

%package tools
Summary:        Tools to encode and decode AVIF files

%description tools
This library aims to be a friendly, portable C implementation of the AV1 Image
File Format, as described here:

https://aomediacodec.github.io/av1-avif/

This package holds the commandline tools to encode and decode AVIF files.

%package     -n avif-pixbuf-loader
Summary:        AVIF image loader for GTK+ applications
BuildRequires:  pkgconfig(gdk-pixbuf-2.0)
Requires:       gdk-pixbuf2

%description -n avif-pixbuf-loader
Avif-pixbuf-loader contains a plugin to load AVIF images in GTK+ applications.

%prep
%autosetup -n %{name} -p1

%build
%cmake \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DAVIF_BUILD_APPS=1 \
    -DAVIF_BUILD_GDK_PIXBUF=1 \
    -DAVIF_ENABLE_WERROR=OFF

%cmake_build

%install
%cmake_install

%files
%license LICENSE
%{_libdir}/libavif.so.*
%{_datadir}/thumbnailers/avif.thumbnailer

%files devel
%{_libdir}/libavif.so
%{_includedir}/avif/
%{_libdir}/cmake/libavif/
%{_libdir}/pkgconfig/libavif.pc

%files tools
%doc CHANGELOG.md README.md
%{_bindir}/avifdec
%{_bindir}/avifenc

%files -n avif-pixbuf-loader
%{_libdir}/gdk-pixbuf-2.0/*/loaders/libpixbufloader-avif.so

%changelog
%autochangelog