diff --git a/README.suse-maint b/README.suse-maint
new file mode 100644
index 0000000..80abe77
--- /dev/null
+++ b/README.suse-maint
@@ -0,0 +1,25 @@
+# How to update the rav1e package
+
+## Prerequisites:
+You need the download_files and cargo_vendor obs services installed:
+ zypper in obs-service-download_files obs-service-cargo_vendor
+
+## Updating to a new version from upstream
+
+Edit the spec file and update the version variable.
+
+Download the new source file by running:
+ osc service ra download_files
+
+Uncompress the rav1e-%{version}.tar.gz file:
+ tar xf rav1e-*.tar.gz
+
+This will create a rav1e-%{version} directory
+
+Edit the _service file and set the srcdir param
+to the extracted directory.
+
+Run the cargo_vendor service with:
+ osc service disabledrun
+
+Update the changelog file with the upstream release notes.
diff --git a/_service b/_service
index 7a6861f..c444f09 100644
--- a/_service
+++ b/_service
@@ -1,5 +1,5 @@
- rav1e
+ rav1e-0.4.1
diff --git a/cargo_config b/cargo_config
new file mode 100644
index 0000000..6fb4ff4
--- /dev/null
+++ b/cargo_config
@@ -0,0 +1,5 @@
+[source.crates-io]
+replace-with = "vendored-sources"
+
+[source.vendored-sources]
+directory = "vendor"
\ No newline at end of file
diff --git a/f553646d70fba8e265d436103a73520eb7adec8c.patch b/f553646d70fba8e265d436103a73520eb7adec8c.patch
new file mode 100644
index 0000000..06c5479
--- /dev/null
+++ b/f553646d70fba8e265d436103a73520eb7adec8c.patch
@@ -0,0 +1,42 @@
+From f553646d70fba8e265d436103a73520eb7adec8c Mon Sep 17 00:00:00 2001
+From: David Michael Barr
+Date: Thu, 8 Jul 2021 13:39:59 +0900
+Subject: [PATCH] Initialise residual when less than the transform width is
+ visible
+
+The input stride for forward transforms did not match the output
+stride of residual computation in this case. Extend the residual
+stride to the transform width and zero the non-visible portion.
+Fixes #2662. Fixes #2757.
+---
+ src/encoder.rs | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/src/encoder.rs b/src/encoder.rs
+index 564d78d7e..1ccf8c831 100644
+--- a/src/encoder.rs
++++ b/src/encoder.rs
+@@ -1209,12 +1209,20 @@ pub fn encode_tx_block(
+ residual,
+ &ts.input_tile.planes[p].subregion(area),
+ &rec.subregion(area),
+- visible_tx_w,
++ tx_size.width(),
+ visible_tx_h,
+ );
++ if visible_tx_w < tx_size.width() {
++ for row in residual.chunks_mut(tx_size.width()).take(visible_tx_h) {
++ for a in &mut row[visible_tx_w..] {
++ *a = 0;
++ }
++ }
++ }
+ }
+- let visible_area = visible_tx_w * visible_tx_h;
+- for a in residual[visible_area..].iter_mut() {
++ let initialized_area =
++ if visible_tx_w == 0 { 0 } else { tx_size.width() * visible_tx_h };
++ for a in residual[initialized_area..].iter_mut() {
+ *a = 0;
+ }
+
diff --git a/rav1e.changes b/rav1e.changes
index 6d7e920..0d4c481 100644
--- a/rav1e.changes
+++ b/rav1e.changes
@@ -1,3 +1,14 @@
+-------------------------------------------------------------------
+Fri Jul 9 06:11:11 UTC 2021 - Andreas Schneider
+
+- Fixed squared artefacts on image when converting to AVIF
+ * Added f553646d70fba8e265d436103a73520eb7adec8c.patch
+
+-------------------------------------------------------------------
+Wed Jun 2 07:19:00 UTC 2021 - Andreas Schneider
+
+- Fix service for cargo vendor creation
+
-------------------------------------------------------------------
Wed Apr 7 21:40:52 UTC 2021 - Dirk Müller
diff --git a/rav1e.spec b/rav1e.spec
index 1cc4b54..d9dc71c 100644
--- a/rav1e.spec
+++ b/rav1e.spec
@@ -28,8 +28,14 @@ URL: https://github.com/xiph/rav1e
#
Source0: https://github.com/xiph/rav1e/archive/v%{version}/%{name}-%{version}.tar.gz
Source1: vendor.tar.xz
+Source2: cargo_config
+Source98: README.suse-maint
Source99: baselibs.conf
#
+# Fix squared artefacts on image when converting to AVIF
+Patch0: https://github.com/xiph/rav1e/commit/f553646d70fba8e265d436103a73520eb7adec8c.patch
+#
+BuildRequires: cargo
BuildRequires: cargo-c
BuildRequires: nasm
BuildRequires: rust-packaging
@@ -89,8 +95,6 @@ directory = './vendor'
rustc = "%{__rustc}"
rustdoc = "%{__rustdoc}"
rustflags = %{__global_rustflags_toml}
-[install]
-root = '%{buildroot}%{_prefix}'
[term]
verbose = true
EOF
@@ -101,21 +105,22 @@ sed -i 's/"rav1e_js", //' Cargo.toml
%build
export RUSTFLAGS=%{rustflags}
-%{cargo_build}
-CFLAGS="%{optflags}" %{__cargo} cbuild
+cargo build --offline --release
+CFLAGS="%{optflags}" cargo cbuild
%install
export RUSTFLAGS=%{rustflags}
-%{cargo_install}
+cargo install --offline --root=%{buildroot}%{_prefix} --path .
rm -rf %{buildroot}%{_datadir}/cargo
-%{__cargo} cinstall \
+cargo cinstall \
--destdir=%{buildroot} \
--prefix=%{_prefix} \
--libdir=%{_libdir} \
--includedir=%{_includedir} \
--pkgconfigdir=%{_libdir}/pkgconfig
rm -f %{buildroot}%{_libdir}/librav1e.a
+rm -f %{buildroot}%{_prefix}/.crates*
%post -n librav1e0 -p /sbin/ldconfig
%postun -n librav1e0 -p /sbin/ldconfig
diff --git a/vendor.tar.xz b/vendor.tar.xz
index 883577d..2f0b7e6 100644
--- a/vendor.tar.xz
+++ b/vendor.tar.xz
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:b5ffd22b5b37f8e89ae1c1a6d295de86265f671fd7955b8994b0a1bf30f05665
-size 15054112
+oid sha256:cc962cdae054eea09f102ecae6d34e8a14e4daac5dc76a0923bc1024c2fce1ff
+size 15053860