Index: media/libvpx/config/generic/vpx_config.c =================================================================== --- media/libvpx/config/generic/vpx_config.c +++ media/libvpx/config/generic/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=generic-gnu --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --log=/home/cm/Work/firefox/media/libvpx/config/generic/config.log"; +static const char* const cfg = "--target=generic-gnu --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --log=/builds/worker/checkouts/gecko/media/libvpx/config/generic/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/linux/arm/vpx_config.c =================================================================== --- media/libvpx/config/linux/arm/vpx_config.c +++ media/libvpx/config/linux/arm/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=armv7-linux-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-runtime-cpu-detect --enable-realtime-only --log=/home/cm/Work/firefox/media/libvpx/config/linux/arm/config.log"; +static const char* const cfg = "--target=armv7-linux-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-runtime-cpu-detect --enable-realtime-only --log=/builds/worker/checkouts/gecko/media/libvpx/config/linux/arm/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/linux/arm64/vpx_config.c =================================================================== --- media/libvpx/config/linux/arm64/vpx_config.c +++ media/libvpx/config/linux/arm64/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=arm64-linux-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-realtime-only --disable-sve --log=/home/cm/Work/firefox/media/libvpx/config/linux/arm64/config.log"; +static const char* const cfg = "--target=arm64-linux-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-realtime-only --disable-sve --log=/builds/worker/checkouts/gecko/media/libvpx/config/linux/arm64/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/linux/ia32/vpx_config.c =================================================================== --- media/libvpx/config/linux/ia32/vpx_config.c +++ media/libvpx/config/linux/ia32/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=x86-linux-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/home/cm/Work/firefox/media/libvpx/config/linux/ia32/config.log"; +static const char* const cfg = "--target=x86-linux-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/builds/worker/checkouts/gecko/media/libvpx/config/linux/ia32/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/linux/loongarch64/vpx_config.c =================================================================== --- media/libvpx/config/linux/loongarch64/vpx_config.c +++ media/libvpx/config/linux/loongarch64/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=loongarch64-linux-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-runtime-cpu-detect --enable-realtime-only --log=/home/cm/Work/firefox/media/libvpx/config/linux/loongarch64/config.log"; +static const char* const cfg = "--target=loongarch64-linux-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-runtime-cpu-detect --enable-realtime-only --log=/builds/worker/checkouts/gecko/media/libvpx/config/linux/loongarch64/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/linux/x64/vpx_config.c =================================================================== --- media/libvpx/config/linux/x64/vpx_config.c +++ media/libvpx/config/linux/x64/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=x86_64-linux-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/home/cm/Work/firefox/media/libvpx/config/linux/x64/config.log"; +static const char* const cfg = "--target=x86_64-linux-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/builds/worker/checkouts/gecko/media/libvpx/config/linux/x64/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/mac/arm64/vpx_config.c =================================================================== --- media/libvpx/config/mac/arm64/vpx_config.c +++ media/libvpx/config/mac/arm64/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=arm64-darwin-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --log=/home/cm/Work/firefox/media/libvpx/config/mac/arm64/config.log"; +static const char* const cfg = "--target=arm64-darwin-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --log=/builds/worker/checkouts/gecko/media/libvpx/config/mac/arm64/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/mac/ia32/vpx_config.c =================================================================== --- media/libvpx/config/mac/ia32/vpx_config.c +++ media/libvpx/config/mac/ia32/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=x86-darwin9-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/home/cm/Work/firefox/media/libvpx/config/mac/ia32/config.log"; +static const char* const cfg = "--target=x86-darwin9-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/builds/worker/checkouts/gecko/media/libvpx/config/mac/ia32/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/mac/x64/vpx_config.c =================================================================== --- media/libvpx/config/mac/x64/vpx_config.c +++ media/libvpx/config/mac/x64/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=x86_64-darwin9-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/home/cm/Work/firefox/media/libvpx/config/mac/x64/config.log"; +static const char* const cfg = "--target=x86_64-darwin9-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/builds/worker/checkouts/gecko/media/libvpx/config/mac/x64/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/win/aarch64/vpx_config.c =================================================================== --- media/libvpx/config/win/aarch64/vpx_config.c +++ media/libvpx/config/win/aarch64/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=arm64-win64-vs15 --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-realtime-only --disable-sve --log=/home/cm/Work/firefox/media/libvpx/config/win/aarch64/config.log"; +static const char* const cfg = "--target=arm64-win64-vs15 --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-realtime-only --disable-sve --log=/builds/worker/checkouts/gecko/media/libvpx/config/win/aarch64/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/win/ia32/vpx_config.c =================================================================== --- media/libvpx/config/win/ia32/vpx_config.c +++ media/libvpx/config/win/ia32/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=x86-win32-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/home/cm/Work/firefox/media/libvpx/config/win/ia32/config.log"; +static const char* const cfg = "--target=x86-win32-gcc --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/builds/worker/checkouts/gecko/media/libvpx/config/win/ia32/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/config/win/x64/vpx_config.c =================================================================== --- media/libvpx/config/win/x64/vpx_config.c +++ media/libvpx/config/win/x64/vpx_config.c @@ -4,7 +4,7 @@ /* that can be found in the LICENSE file in the root of the source */ /* tree. An additional intellectual property rights grant can be found */ /* in the file PATENTS. All contributing project authors may */ /* be found in the AUTHORS file in the root of the source tree. */ #include "vpx/vpx_codec.h" -static const char* const cfg = "--target=x86_64-win64-vs15 --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/home/cm/Work/firefox/media/libvpx/config/win/x64/config.log"; +static const char* const cfg = "--target=x86_64-win64-vs15 --enable-external-build --disable-examples --disable-install-docs --disable-unit-tests --enable-multi-res-encoding --size-limit=8192x4608 --enable-pic --disable-avx512 --enable-postproc --enable-vp9-postproc --as=yasm --log=/builds/worker/checkouts/gecko/media/libvpx/config/win/x64/config.log"; const char *vpx_codec_build_config(void) {return cfg;} Index: media/libvpx/libvpx/examples/vpx_enc_fuzzer.cc =================================================================== --- media/libvpx/libvpx/examples/vpx_enc_fuzzer.cc +++ media/libvpx/libvpx/examples/vpx_enc_fuzzer.cc @@ -113,12 +113,13 @@ const int h = vpx_img_plane_height(img, plane); int y; // Assuming that for nv12 we read all chroma data at once if (img->fmt == VPX_IMG_FMT_NV12 && plane > 1) break; - // Fixing NV12 chroma width if it is odd - if (img->fmt == VPX_IMG_FMT_NV12 && plane == 1) w = (w + 1) & ~1; + // NV12 UV plane is interleaved, so it has twice the width of a subsampled + // plane. + if (img->fmt == VPX_IMG_FMT_NV12 && plane == 1) w = w * 2; for (y = 0; y < h; ++y) { size_t nb = bytespp * w; if (nb > size - used) { nb = size - used; Index: media/libvpx/libvpx/test/encode_api_test.cc =================================================================== --- media/libvpx/libvpx/test/encode_api_test.cc +++ media/libvpx/libvpx/test/encode_api_test.cc @@ -218,13 +218,11 @@ } ASSERT_EQ(vpx_img_wrap(&img, img_fmt, kWidth, kHeight, /*stride_align=*/1, buf.get()), &img) << "Unable to wrap vpx_image for format: " << img_fmt; - const bool is_420 = - (img.x_chroma_shift == 1 && img.y_chroma_shift == 1) || - img_fmt == VPX_IMG_FMT_NV12; + const bool is_420 = img.x_chroma_shift == 1 && img.y_chroma_shift == 1; // In profiles 0 and 2, only 4:2:0 format is allowed. In profiles 1 and 3, // all other subsampling formats are allowed. In profiles 0 and 1, only // bit depth 8 is allowed. In profiles 2 and 3, only bit depths 10 and 12 // are allowed. cfg.g_profile = 2 * high_bit_depth + !is_420; @@ -3367,8 +3365,31 @@ VPX_CODEC_OK); vpx_img_free(img); ASSERT_EQ(vpx_codec_destroy(&enc), VPX_CODEC_OK); } + +// Reproduces a VP9 encoder assertion failure / SEGV crash caused by +// superblock search failure under specific scaling and rate control scenarios. +// Bug: 479149056 +TEST(EncodeAPI, VP9OssFuzz479149056) { + VP9Encoder encoder(3, 1, VPX_BITS_8, VPX_IMG_FMT_I422); + encoder.Configure(/*threads=*/2, /*width=*/33, /*height=*/341, VPX_CBR, + VPX_DL_GOOD_QUALITY); + encoder.Encode(/*key_frame=*/true); + encoder.Encode(/*key_frame=*/false); + encoder.Encode(/*key_frame=*/false); + encoder.Configure(/*threads=*/14, /*width=*/29, /*height=*/177, VPX_VBR, + VPX_DL_GOOD_QUALITY); + encoder.Encode(/*key_frame=*/false); + encoder.Configure(/*threads=*/0, /*width=*/33, /*height=*/337, VPX_CBR, + VPX_DL_REALTIME); + encoder.Configure(/*threads=*/0, /*width=*/33, /*height=*/341, VPX_VBR, + VPX_DL_GOOD_QUALITY); + encoder.Encode(/*key_frame=*/false); + encoder.Encode(/*key_frame=*/false); + encoder.Encode(/*key_frame=*/false); + encoder.Encode(/*key_frame=*/false); +} #endif // CONFIG_VP9_ENCODER } // namespace Index: media/libvpx/libvpx/test/ivf_video_source.h =================================================================== --- media/libvpx/libvpx/test/ivf_video_source.h +++ media/libvpx/libvpx/test/ivf_video_source.h @@ -52,10 +52,19 @@ // Read file header uint8_t file_hdr[kIvfFileHdrSize]; ASSERT_EQ(kIvfFileHdrSize, fread(file_hdr, 1, kIvfFileHdrSize, input_file_)) << "File header read failed."; + // The following two conditions are not asserted directly as some static + // analyzers (observed with clang-19) do not properly terminate execution + // when an eof or error is assumed after the previous fread(). + if (ferror(input_file_)) { + FAIL() << "File header read failed."; + } + if (feof(input_file_)) { + FAIL() << "Unexpected eof."; + } // Check file header ASSERT_TRUE(file_hdr[0] == 'D' && file_hdr[1] == 'K' && file_hdr[2] == 'I' && file_hdr[3] == 'F') << "Input is not an IVF file."; Index: media/libvpx/libvpx/test/test_vector_test.cc =================================================================== --- media/libvpx/libvpx/test/test_vector_test.cc +++ media/libvpx/libvpx/test/test_vector_test.cc @@ -38,17 +38,11 @@ using DecodeParam = std::tuple; class TestVectorTest : public ::libvpx_test::DecoderTest, public ::libvpx_test::CodecTestWithParam { protected: - TestVectorTest() : DecoderTest(GET_PARAM(0)), md5_file_(nullptr) { -#if CONFIG_VP9_DECODER - resize_clips_.insert(::libvpx_test::kVP9TestVectorsResize, - ::libvpx_test::kVP9TestVectorsResize + - ::libvpx_test::kNumVP9TestVectorsResize); -#endif - } + TestVectorTest() : DecoderTest(GET_PARAM(0)), md5_file_(nullptr) {} ~TestVectorTest() override { if (md5_file_) fclose(md5_file_); } @@ -94,13 +88,10 @@ // Check md5 match. ASSERT_STREQ(expected_md5, actual_md5) << "Md5 checksums don't match: frame number = " << frame_number; } -#if CONFIG_VP9_DECODER - std::set resize_clips_; -#endif int mt_mode_; private: FILE *md5_file_; }; Index: media/libvpx/libvpx/test/vpx_image_test.cc =================================================================== --- media/libvpx/libvpx/test/vpx_image_test.cc +++ media/libvpx/libvpx/test/vpx_image_test.cc @@ -66,10 +66,11 @@ vpx_image_t img; vpx_img_fmt_t format = VPX_IMG_FMT_NV12; unsigned int align = 32; EXPECT_EQ(vpx_img_alloc(&img, format, kWidth, kHeight, align), &img); + EXPECT_EQ(img.x_chroma_shift, 1u); EXPECT_EQ(img.stride[VPX_PLANE_U], img.stride[VPX_PLANE_Y]); EXPECT_EQ(img.stride[VPX_PLANE_V], img.stride[VPX_PLANE_U]); EXPECT_EQ(img.planes[VPX_PLANE_V], img.planes[VPX_PLANE_U] + 1); vpx_img_free(&img); } Index: media/libvpx/libvpx/tools_common.c =================================================================== --- media/libvpx/libvpx/tools_common.c +++ media/libvpx/libvpx/tools_common.c @@ -90,12 +90,13 @@ int w = vpx_img_plane_width(yuv_frame, plane); const int h = vpx_img_plane_height(yuv_frame, plane); int r; // Assuming that for nv12 we read all chroma data at once if (yuv_frame->fmt == VPX_IMG_FMT_NV12 && plane > 1) break; - // Fixing NV12 chroma width if it is odd - if (yuv_frame->fmt == VPX_IMG_FMT_NV12 && plane == 1) w = (w + 1) & ~1; + // NV12 UV plane is interleaved, so it has twice the width of a subsampled + // plane. + if (yuv_frame->fmt == VPX_IMG_FMT_NV12 && plane == 1) w = w * 2; /* Determine the correct plane based on the image format. The for-loop * always counts in Y,U,V order, but this may not match the order of * the data on disk. */ switch (plane) { @@ -232,12 +233,13 @@ const int h = vpx_img_plane_height(img, plane); int y; // Assuming that for nv12 we write all chroma data at once if (img->fmt == VPX_IMG_FMT_NV12 && plane > 1) break; - // Fixing NV12 chroma width if it is odd - if (img->fmt == VPX_IMG_FMT_NV12 && plane == 1) w = (w + 1) & ~1; + // NV12 UV plane is interleaved, so it has twice the width of a subsampled + // plane. + if (img->fmt == VPX_IMG_FMT_NV12 && plane == 1) w = w * 2; for (y = 0; y < h; ++y) { fwrite(buf, bytespp, w, file); buf += stride; } @@ -255,12 +257,13 @@ const int h = vpx_img_plane_height(img, plane); int y; // Assuming that for nv12 we read all chroma data at once if (img->fmt == VPX_IMG_FMT_NV12 && plane > 1) break; - // Fixing NV12 chroma width if it is odd - if (img->fmt == VPX_IMG_FMT_NV12 && plane == 1) w = (w + 1) & ~1; + // NV12 UV plane is interleaved, so it has twice the width of a subsampled + // plane. + if (img->fmt == VPX_IMG_FMT_NV12 && plane == 1) w = w * 2; for (y = 0; y < h; ++y) { if (fread(buf, bytespp, w, file) != (size_t)w) return 0; buf += stride; } Index: media/libvpx/libvpx/video_reader.c =================================================================== --- media/libvpx/libvpx/video_reader.c +++ media/libvpx/libvpx/video_reader.c @@ -36,31 +36,32 @@ } if (fread(header, 1, 32, file) != 32) { fprintf(stderr, "File header on %s can't be read.\n", filename); // Can't read file header + fclose(file); return NULL; } if (memcmp(kIVFSignature, header, 4) != 0) { fprintf(stderr, "The IVF signature on %s is wrong.\n", filename); // Wrong IVF signature - + fclose(file); return NULL; } if (mem_get_le16(header + 4) != 0) { fprintf(stderr, "%s uses the wrong IVF version.\n", filename); // Wrong IVF version - + fclose(file); return NULL; } reader = calloc(1, sizeof(*reader)); if (!reader) { fprintf( stderr, "Can't allocate VpxVideoReader\n"); // Can't allocate VpxVideoReader - + fclose(file); return NULL; } reader->file = file; reader->info.codec_fourcc = mem_get_le32(header + 8); Index: media/libvpx/libvpx/video_writer.c =================================================================== --- media/libvpx/libvpx/video_writer.c +++ media/libvpx/libvpx/video_writer.c @@ -42,10 +42,11 @@ return NULL; } writer = malloc(sizeof(*writer)); if (!writer) { fprintf(stderr, "Can't allocate VpxVideoWriter.\n"); + fclose(file); return NULL; } writer->frame_count = 0; writer->info = *info; writer->file = file; Index: media/libvpx/libvpx/vp8/common/alloccommon.c =================================================================== --- media/libvpx/libvpx/vp8/common/alloccommon.c +++ media/libvpx/libvpx/vp8/common/alloccommon.c @@ -36,22 +36,26 @@ vpx_free(oci->pp_limits_buffer); oci->pp_limits_buffer = NULL; vpx_free(oci->postproc_state.generated_noise); - oci->postproc_state.generated_noise = NULL; + memset(&oci->postproc_state, 0, sizeof(oci->postproc_state)); #endif vpx_free(oci->above_context); vpx_free(oci->mip); #if CONFIG_ERROR_CONCEALMENT vpx_free(oci->prev_mip); oci->prev_mip = NULL; + oci->prev_mi = NULL; #endif oci->above_context = NULL; oci->mip = NULL; + oci->mi = NULL; + oci->show_frame_mi = NULL; + oci->frame_to_show = NULL; } int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) { int i; Index: media/libvpx/libvpx/vp8/vp8_cx_iface.c =================================================================== --- media/libvpx/libvpx/vp8/vp8_cx_iface.c +++ media/libvpx/libvpx/vp8/vp8_cx_iface.c @@ -98,13 +98,14 @@ vpx_codec_pkt_list_decl(64) pkt_list; unsigned int fixed_kf_cntr; vpx_enc_frame_flags_t control_frame_flags; }; -// Called by vp8e_set_config() and vp8e_encode() only. Must not be called -// by vp8e_init() because the `error` paramerer (cpi->common.error) will be -// destroyed by vpx_codec_enc_init_ver() after vp8e_init() returns an error. +// Called by update_extracfg(), vp8e_set_config() and vp8e_encode() only. Must +// not be called by vp8e_init() because the `error` paramerer +// (cpi->common.error) will be destroyed by vpx_codec_enc_init_ver() after +// vp8e_init() returns an error. // See the "IMPORTANT" comment in vpx_codec_enc_init_ver(). static vpx_codec_err_t update_error_state( vpx_codec_alg_priv_t *ctx, const struct vpx_internal_error_info *error) { const vpx_codec_err_t res = error->error_code; @@ -530,16 +531,26 @@ } static vpx_codec_err_t update_extracfg(vpx_codec_alg_priv_t *ctx, const struct vp8_extracfg *extra_cfg) { const vpx_codec_err_t res = validate_config(ctx, &ctx->cfg, extra_cfg, 0); - if (res == VPX_CODEC_OK) { - ctx->vp8_cfg = *extra_cfg; - set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg, NULL); - vp8_change_config(ctx->cpi, &ctx->oxcf); + if (res != VPX_CODEC_OK) return res; + + if (setjmp(ctx->cpi->common.error.jmp)) { + const vpx_codec_err_t codec_err = + update_error_state(ctx, &ctx->cpi->common.error); + ctx->cpi->common.error.setjmp = 0; + vpx_clear_system_state(); + assert(codec_err != VPX_CODEC_OK); + return codec_err; } - return res; + ctx->cpi->common.error.setjmp = 1; + ctx->vp8_cfg = *extra_cfg; + set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg, NULL); + vp8_change_config(ctx->cpi, &ctx->oxcf); + ctx->cpi->common.error.setjmp = 0; + return VPX_CODEC_OK; } static vpx_codec_err_t set_cpu_used(vpx_codec_alg_priv_t *ctx, va_list args) { struct vp8_extracfg extra_cfg = ctx->vp8_cfg; extra_cfg.cpu_used = CAST(VP8E_SET_CPUUSED, args); @@ -791,10 +802,14 @@ vpx_codec_err_t res = VPX_CODEC_OK; yv12->y_buffer = img->planes[VPX_PLANE_Y]; yv12->u_buffer = img->planes[VPX_PLANE_U]; yv12->v_buffer = img->planes[VPX_PLANE_V]; + // TODO(issue 520751602): this should use img->w/h to set y_width/y_height + // and that should be used to calculate uv_width/height after the code is + // updated to correctly use uv_crop_width/height to avoid using uninitialized + // data from the border. yv12->y_crop_width = y_w; yv12->y_crop_height = y_h; yv12->y_width = y_w; yv12->y_height = y_h; yv12->uv_crop_width = uv_w; @@ -1028,23 +1043,14 @@ dst_end_time_stamp = pts_end * ctx->timestamp_ratio.num / ctx->timestamp_ratio.den; res = image2yuvconfig(img, &sd); - if (sd.y_width != ctx->cfg.g_w || sd.y_height != ctx->cfg.g_h) { - /* from vpx_encoder.h for g_w/g_h: - "Note that the frames passed as input to the encoder must have this - resolution" - */ - ctx->base.err_detail = "Invalid input frame resolution"; - res = VPX_CODEC_INVALID_PARAM; - } else { - if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags, - &sd, dst_time_stamp, dst_end_time_stamp)) { - VP8_COMP *cpi = (VP8_COMP *)ctx->cpi; - res = update_error_state(ctx, &cpi->common.error); - } + if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags, &sd, + dst_time_stamp, dst_end_time_stamp)) { + VP8_COMP *cpi = (VP8_COMP *)ctx->cpi; + res = update_error_state(ctx, &cpi->common.error); } /* reset for next frame */ ctx->next_frame_flag = 0; } Index: media/libvpx/libvpx/vp9/encoder/vp9_encodeframe.c =================================================================== --- media/libvpx/libvpx/vp9/encoder/vp9_encodeframe.c +++ media/libvpx/libvpx/vp9/encoder/vp9_encodeframe.c @@ -2875,11 +2875,12 @@ max_size = BLOCK_4X4; // NOTE: each call to get_sb_partition_size_range() uses the previous // passed in values for min and max as a starting point. // Find the min and max partition used in previous frame at this location - if (cm->frame_type != KEY_FRAME) { + if (cm->frame_type != KEY_FRAME && + (cm->width == cm->last_width && cm->height == cm->last_height)) { MODE_INFO **prev_mi = &cm->prev_mi_grid_visible[mi_row * xd->mi_stride + mi_col]; get_sb_partition_size_range(xd, prev_mi, &min_size, &max_size, bs_hist); } // Find the min and max partition sizes used in the left SB64 @@ -2932,18 +2933,24 @@ int mi_col, BLOCK_SIZE bsize, BLOCK_SIZE *min_bs, BLOCK_SIZE *max_bs) { int mi_width = num_8x8_blocks_wide_lookup[bsize]; int mi_height = num_8x8_blocks_high_lookup[bsize]; int idx, idy; + BLOCK_SIZE bs, min_size, max_size; + + min_size = BLOCK_64X64; + max_size = BLOCK_4X4; + + if (cm->width != cm->last_width || cm->height != cm->last_height) { + *min_bs = min_size; + *max_bs = max_size; + return; + } MODE_INFO *mi; const int idx_str = cm->mi_stride * mi_row + mi_col; MODE_INFO **prev_mi = &cm->prev_mi_grid_visible[idx_str]; - BLOCK_SIZE bs, min_size, max_size; - - min_size = BLOCK_64X64; - max_size = BLOCK_4X4; for (idy = 0; idy < mi_height; ++idy) { for (idx = 0; idx < mi_width; ++idx) { mi = prev_mi[idy * cm->mi_stride + idx]; bs = mi ? mi->sb_type : bsize; @@ -3044,12 +3051,10 @@ BLOCK_SIZE bsize) { const int mag_mv = abs(ctx->mic.mv[0].as_mv.col) + abs(ctx->mic.mv[0].as_mv.row); const int left_in_image = !!xd->left_mi; const int above_in_image = !!xd->above_mi; - MODE_INFO **prev_mi = - &cm->prev_mi_grid_visible[mi_col + cm->mi_stride * mi_row]; int above_par = 0; // above_partitioning int left_par = 0; // left_partitioning int last_par = 0; // last_partitioning int offset = 0; int i; @@ -3092,16 +3097,20 @@ left_par = 2; else if (context_size == bsize) left_par = 1; } - if (prev_mi[0]) { - context_size = prev_mi[0]->sb_type; - if (context_size < bsize) - last_par = 2; - else if (context_size == bsize) - last_par = 1; + if (cm->width == cm->last_width && cm->height == cm->last_height) { + MODE_INFO **prev_mi = + &cm->prev_mi_grid_visible[mi_col + cm->mi_stride * mi_row]; + if (prev_mi[0]) { + context_size = prev_mi[0]->sb_type; + if (context_size < bsize) + last_par = 2; + else if (context_size == bsize) + last_par = 1; + } } mean = &vp9_partition_feature_mean[offset]; sd = &vp9_partition_feature_std[offset]; features[0] = ((float)ctx->rate - mean[0]) / sd[0]; Index: media/libvpx/libvpx/vp9/encoder/vp9_encoder.c =================================================================== --- media/libvpx/libvpx/vp9/encoder/vp9_encoder.c +++ media/libvpx/libvpx/vp9/encoder/vp9_encoder.c @@ -5145,12 +5145,12 @@ (void)xd; } // Process the wiener variance in 16x16 block basis. static int qsort_comp(const void *elem1, const void *elem2) { - int a = *((const int *)elem1); - int b = *((const int *)elem2); + int a = *((const tran_low_t *)elem1); + int b = *((const tran_low_t *)elem2); if (a > b) return 1; if (a < b) return -1; return 0; } @@ -5254,11 +5254,11 @@ #endif // CONFIG_VP9_HIGHBITDEPTH coeff[0] = 0; for (idx = 1; idx < coeff_count; ++idx) coeff[idx] = abs(coeff[idx]); - qsort(coeff, coeff_count - 1, sizeof(*coeff), qsort_comp); + qsort(coeff, coeff_count, sizeof(*coeff), qsort_comp); // Noise level estimation median_val = coeff[coeff_count / 2]; // Wiener filter Index: media/libvpx/libvpx/vp9/encoder/vp9_pickmode.c =================================================================== --- media/libvpx/libvpx/vp9/encoder/vp9_pickmode.c +++ media/libvpx/libvpx/vp9/encoder/vp9_pickmode.c @@ -2209,21 +2209,24 @@ ref_frame == LAST_FRAME)) { if (usable_ref_frame < ALTREF_FRAME) { if (!force_skip_low_temp_var && usable_ref_frame > LAST_FRAME) { i = (ref_frame == LAST_FRAME) ? GOLDEN_FRAME : LAST_FRAME; if ((cpi->ref_frame_flags & ref_frame_to_flag(i))) - if (x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[i] << 1)) - ref_frame_skip_mask |= (1 << ref_frame); + if (x->pred_mv_sad[i] < INT_MAX) + if (x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[i] << 1)) + ref_frame_skip_mask |= (1 << ref_frame); } } else if (!cpi->rc.is_src_frame_alt_ref && !(frame_mv[this_mode][ref_frame].as_int == 0 && ref_frame == ALTREF_FRAME)) { int ref1 = (ref_frame == GOLDEN_FRAME) ? LAST_FRAME : GOLDEN_FRAME; int ref2 = (ref_frame == ALTREF_FRAME) ? LAST_FRAME : ALTREF_FRAME; if (((cpi->ref_frame_flags & ref_frame_to_flag(ref1)) && + x->pred_mv_sad[ref1] < INT_MAX && (x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[ref1] << 1))) || ((cpi->ref_frame_flags & ref_frame_to_flag(ref2)) && + x->pred_mv_sad[ref2] < INT_MAX && (x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[ref2] << 1)))) ref_frame_skip_mask |= (1 << ref_frame); } } if (ref_frame_skip_mask & (1 << ref_frame)) continue; Index: media/libvpx/libvpx/vp9/encoder/vp9_rdopt.c =================================================================== --- media/libvpx/libvpx/vp9/encoder/vp9_rdopt.c +++ media/libvpx/libvpx/vp9/encoder/vp9_rdopt.c @@ -3608,11 +3608,12 @@ if (x->pred_mv_sad[ALTREF_FRAME] > (x->pred_mv_sad[GOLDEN_FRAME] << 1)) mode_skip_mask[ALTREF_FRAME] |= INTER_ALL; if (sf->adaptive_mode_search) { if (cm->show_frame && !cpi->rc.is_src_frame_alt_ref && - cpi->rc.frames_since_golden >= 3) + cpi->rc.frames_since_golden >= 3 && + x->pred_mv_sad[LAST_FRAME] < INT_MAX) if (x->pred_mv_sad[GOLDEN_FRAME] > (x->pred_mv_sad[LAST_FRAME] << 1)) mode_skip_mask[GOLDEN_FRAME] |= INTER_ALL; } if (bsize > sf->max_intra_bsize && cpi->ref_frame_flags != 0) { Index: media/libvpx/libvpx/vp9/vp9_cx_iface.c =================================================================== --- media/libvpx/libvpx/vp9/vp9_cx_iface.c +++ media/libvpx/libvpx/vp9/vp9_cx_iface.c @@ -1551,26 +1551,17 @@ } const int64_t dst_end_time_stamp = timebase_units_to_ticks(timebase_in_ts, pts_end); res = image2yuvconfig(img, &sd); - if (sd.y_width != ctx->cfg.g_w || sd.y_height != ctx->cfg.g_h) { - /* from vpx_encoder.h for g_w/g_h: - "Note that the frames passed as input to the encoder must have this - resolution" - */ - ctx->base.err_detail = "Invalid input frame resolution"; - res = VPX_CODEC_INVALID_PARAM; - } else { - // Store the original flags in to the frame buffer. Will extract the - // key frame flag when we actually encode this frame. - if (vp9_receive_raw_frame(cpi, flags | ctx->next_frame_flags, &sd, - dst_time_stamp, dst_end_time_stamp)) { - res = update_error_state(ctx, &cpi->common.error); - } - ctx->next_frame_flags = 0; + // Store the original flags in to the frame buffer. Will extract the + // key frame flag when we actually encode this frame. + if (vp9_receive_raw_frame(cpi, flags | ctx->next_frame_flags, &sd, + dst_time_stamp, dst_end_time_stamp)) { + res = update_error_state(ctx, &cpi->common.error); } + ctx->next_frame_flags = 0; } cx_data = ctx->cx_data; cx_data_sz = ctx->cx_data_sz; Index: media/libvpx/libvpx/vp9/vp9_iface_common.c =================================================================== --- media/libvpx/libvpx/vp9/vp9_iface_common.c +++ media/libvpx/libvpx/vp9/vp9_iface_common.c @@ -35,12 +35,12 @@ } } img->cs = yv12->color_space; img->range = yv12->color_range; img->bit_depth = 8; - img->w = yv12->y_stride; - img->h = ALIGN_POWER_OF_TWO(yv12->y_height + 2 * VP9_ENC_BORDER_IN_PIXELS, 3); + img->w = yv12->y_width; + img->h = yv12->y_height; img->d_w = yv12->y_crop_width; img->d_h = yv12->y_crop_height; img->r_w = yv12->render_width; img->r_h = yv12->render_height; img->x_chroma_shift = yv12->subsampling_x; @@ -84,20 +84,20 @@ yv12->y_crop_width = img->d_w; yv12->y_crop_height = img->d_h; yv12->render_width = img->r_w; yv12->render_height = img->r_h; - yv12->y_width = img->d_w; - yv12->y_height = img->d_h; + yv12->y_width = img->w; + yv12->y_height = img->h; - yv12->uv_width = img->x_chroma_shift == 1 || img->fmt == VPX_IMG_FMT_NV12 - ? (1 + yv12->y_width) / 2 - : yv12->y_width; + yv12->uv_width = (yv12->y_width + img->x_chroma_shift) >> img->x_chroma_shift; yv12->uv_height = - img->y_chroma_shift == 1 ? (1 + yv12->y_height) / 2 : yv12->y_height; - yv12->uv_crop_width = yv12->uv_width; - yv12->uv_crop_height = yv12->uv_height; + (yv12->y_height + img->y_chroma_shift) >> img->y_chroma_shift; + yv12->uv_crop_width = + (yv12->y_crop_width + img->x_chroma_shift) >> img->x_chroma_shift; + yv12->uv_crop_height = + (yv12->y_crop_height + img->y_chroma_shift) >> img->y_chroma_shift; yv12->y_stride = img->stride[VPX_PLANE_Y]; assert(img->stride[VPX_PLANE_U] == img->stride[VPX_PLANE_V]); yv12->uv_stride = img->stride[VPX_PLANE_U]; yv12->color_space = img->cs; @@ -128,11 +128,7 @@ #else yv12->border = (img->stride[VPX_PLANE_Y] - img->w) / 2; #endif // CONFIG_VP9_HIGHBITDEPTH yv12->subsampling_x = img->x_chroma_shift; yv12->subsampling_y = img->y_chroma_shift; - // When reading the data, UV are in one plane for NV12 format, thus - // x_chroma_shift is 0. After converting, UV are in separate planes, and - // subsampling_x should be set to 1. - if (img->fmt == VPX_IMG_FMT_NV12) yv12->subsampling_x = 1; return VPX_CODEC_OK; } Index: media/libvpx/libvpx/vpx/src/vpx_image.c =================================================================== --- media/libvpx/libvpx/vpx/src/vpx_image.c +++ media/libvpx/libvpx/vpx/src/vpx_image.c @@ -81,15 +81,14 @@ case VPX_IMG_FMT_I44416: bps = 48; break; default: bps = 16; break; } /* Get chroma shift values for this format */ - // For VPX_IMG_FMT_NV12, xcs needs to be 0 such that UV data is all read at - // once. switch (fmt) { case VPX_IMG_FMT_I420: case VPX_IMG_FMT_YV12: + case VPX_IMG_FMT_NV12: case VPX_IMG_FMT_I422: case VPX_IMG_FMT_I42016: case VPX_IMG_FMT_I42216: xcs = 1; break; default: xcs = 0; break; } @@ -161,10 +160,14 @@ /* Calculate strides */ img->stride[VPX_PLANE_Y] = img->stride[VPX_PLANE_ALPHA] = stride_in_bytes; img->stride[VPX_PLANE_U] = img->stride[VPX_PLANE_V] = stride_in_bytes >> xcs; + if (fmt == VPX_IMG_FMT_NV12) { + img->stride[VPX_PLANE_U] = img->stride[VPX_PLANE_V] = stride_in_bytes; + } + /* Default viewport to entire image. (This vpx_img_set_rect call always * succeeds.) */ int ret = vpx_img_set_rect(img, 0, 0, d_w, d_h); assert(ret == 0); (void)ret; @@ -216,13 +219,13 @@ data += (size_t)img->h * img->stride[VPX_PLANE_Y]; unsigned int uv_x = x >> img->x_chroma_shift; unsigned int uv_y = y >> img->y_chroma_shift; if (img->fmt == VPX_IMG_FMT_NV12) { - img->planes[VPX_PLANE_U] = - data + uv_x + uv_y * img->stride[VPX_PLANE_U]; - img->planes[VPX_PLANE_V] = img->planes[VPX_PLANE_U] + 1; + img->planes[VPX_PLANE_U] = data + uv_x * bytes_per_sample * 2 + + uv_y * img->stride[VPX_PLANE_U]; + img->planes[VPX_PLANE_V] = img->planes[VPX_PLANE_U] + bytes_per_sample; } else if (!(img->fmt & VPX_IMG_FMT_UV_FLIP)) { img->planes[VPX_PLANE_U] = data + uv_x * bytes_per_sample + uv_y * img->stride[VPX_PLANE_U]; data += (size_t)(img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_U]; Index: media/libvpx/libvpx/vpx_dsp/arm/sad_neon.c =================================================================== --- media/libvpx/libvpx/vpx_dsp/arm/sad_neon.c +++ media/libvpx/libvpx/vpx_dsp/arm/sad_neon.c @@ -106,10 +106,11 @@ } while (--i != 0); return horizontal_add_uint16x8(sum); } +#if CONFIG_ENCODERS static INLINE unsigned int sad8xh_neon(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, int h) { uint16x8_t sum = vdupq_n_u16(0); @@ -143,17 +144,19 @@ ref_ptr += 2 * ref_stride; } while (--i != 0); return horizontal_add_uint16x8(sum); } +#endif // CONFIG_ENCODERS #define SAD_WXH_NEON(w, h) \ unsigned int vpx_sad##w##x##h##_neon(const uint8_t *src, int src_stride, \ const uint8_t *ref, int ref_stride) { \ return sad##w##xh_neon(src, src_stride, ref, ref_stride, (h)); \ } +#if CONFIG_ENCODERS SAD_WXH_NEON(4, 4) SAD_WXH_NEON(4, 8) SAD_WXH_NEON(8, 4) SAD_WXH_NEON(8, 8) @@ -167,13 +170,19 @@ SAD_WXH_NEON(32, 32) SAD_WXH_NEON(32, 64) SAD_WXH_NEON(64, 32) SAD_WXH_NEON(64, 64) +#else // !CONFIG_ENCODERS +SAD_WXH_NEON(16, 16) +SAD_WXH_NEON(32, 32) +SAD_WXH_NEON(64, 64) +#endif // CONFIG_ENCODERS #undef SAD_WXH_NEON +#if CONFIG_ENCODERS #define SAD_SKIP_WXH_NEON(w, h) \ unsigned int vpx_sad_skip_##w##x##h##_neon( \ const uint8_t *src, int src_stride, const uint8_t *ref, \ int ref_stride) { \ return 2 * \ @@ -387,5 +396,6 @@ SAD_WXH_AVG_NEON(64, 32) SAD_WXH_AVG_NEON(64, 64) #undef SAD_WXH_AVG_NEON +#endif // CONFIG_ENCODERS Index: media/libvpx/libvpx/vpx_dsp/arm/sad_neon_dotprod.c =================================================================== --- media/libvpx/libvpx/vpx_dsp/arm/sad_neon_dotprod.c +++ media/libvpx/libvpx/vpx_dsp/arm/sad_neon_dotprod.c @@ -100,23 +100,30 @@ const uint8_t *src, int src_stride, const uint8_t *ref, \ int ref_stride) { \ return sad##w##xh_neon_dotprod(src, src_stride, ref, ref_stride, (h)); \ } +#if CONFIG_ENCODERS SAD_WXH_NEON_DOTPROD(16, 8) SAD_WXH_NEON_DOTPROD(16, 16) SAD_WXH_NEON_DOTPROD(16, 32) SAD_WXH_NEON_DOTPROD(32, 16) SAD_WXH_NEON_DOTPROD(32, 32) SAD_WXH_NEON_DOTPROD(32, 64) SAD_WXH_NEON_DOTPROD(64, 32) SAD_WXH_NEON_DOTPROD(64, 64) +#else // !CONFIG_ENCODERS +SAD_WXH_NEON_DOTPROD(16, 16) +SAD_WXH_NEON_DOTPROD(32, 32) +SAD_WXH_NEON_DOTPROD(64, 64) +#endif // CONFIG_ENCODERS #undef SAD_WXH_NEON_DOTPROD +#if CONFIG_ENCODERS #define SAD_SKIP_WXH_NEON_DOTPROD(w, h) \ unsigned int vpx_sad_skip_##w##x##h##_neon_dotprod( \ const uint8_t *src, int src_stride, const uint8_t *ref, \ int ref_stride) { \ return 2 * sad##w##xh_neon_dotprod(src, 2 * src_stride, ref, \ @@ -243,5 +250,6 @@ SAD_WXH_AVG_NEON_DOTPROD(64, 32) SAD_WXH_AVG_NEON_DOTPROD(64, 64) #undef SAD_WXH_AVG_NEON_DOTPROD +#endif // CONFIG_ENCODERS Index: media/libvpx/libvpx/vpx_dsp/mips/sad_mmi.c =================================================================== --- media/libvpx/libvpx/vpx_dsp/mips/sad_mmi.c +++ media/libvpx/libvpx/vpx_dsp/mips/sad_mmi.c @@ -381,10 +381,11 @@ const uint8_t *ref, int ref_stride) { \ return vpx_sad64x(src, src_stride, ref, ref_stride, H); \ } vpx_sad64xN(64); +#if CONFIG_ENCODERS vpx_sad64xN(32); sadMxNx4D_mmi(64, 64); sadMxNx4D_mmi(64, 32); static inline unsigned int vpx_sad_avg64x(const uint8_t *src, int src_stride, @@ -432,10 +433,11 @@ return vpx_sad_avg64x(src, src_stride, ref, ref_stride, second_pred, H); \ } vpx_sad_avg64xN(64); vpx_sad_avg64xN(32); +#endif // CONFIG_ENCODERS static inline unsigned int vpx_sad32x(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, int counter) { unsigned int sad; @@ -471,12 +473,13 @@ unsigned int vpx_sad32x##H##_mmi(const uint8_t *src, int src_stride, \ const uint8_t *ref, int ref_stride) { \ return vpx_sad32x(src, src_stride, ref, ref_stride, H); \ } +vpx_sad32xN(32); +#if CONFIG_ENCODERS vpx_sad32xN(64); -vpx_sad32xN(32); vpx_sad32xN(16); sadMxNx4D_mmi(32, 64); sadMxNx4D_mmi(32, 32); sadMxNx4D_mmi(32, 16); @@ -526,10 +529,11 @@ } vpx_sad_avg32xN(64); vpx_sad_avg32xN(32); vpx_sad_avg32xN(16); +#endif // CONFIG_ENCODERS static inline unsigned int vpx_sad16x(const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, int counter) { unsigned int sad; @@ -565,12 +569,13 @@ unsigned int vpx_sad16x##H##_mmi(const uint8_t *src, int src_stride, \ const uint8_t *ref, int ref_stride) { \ return vpx_sad16x(src, src_stride, ref, ref_stride, H); \ } +vpx_sad16xN(16); +#if CONFIG_ENCODERS vpx_sad16xN(32); -vpx_sad16xN(16); vpx_sad16xN(8); sadMxNx4D_mmi(16, 32); sadMxNx4D_mmi(16, 16); sadMxNx4D_mmi(16, 8); @@ -803,5 +808,6 @@ return vpx_sad_avg4x(src, src_stride, ref, ref_stride, second_pred, H); \ } vpx_sad_avg4xN(8); vpx_sad_avg4xN(4); +#endif // CONFIG_ENCODERS Index: media/libvpx/libvpx/vpx_dsp/mips/sad_msa.c =================================================================== --- media/libvpx/libvpx/vpx_dsp/mips/sad_msa.c +++ media/libvpx/libvpx/vpx_dsp/mips/sad_msa.c @@ -18,10 +18,11 @@ out = (RTYPE)__msa_insve_w((v4i32)out, 2, (v4i32)in2); \ out = (RTYPE)__msa_insve_w((v4i32)out, 3, (v4i32)in3); \ } #define SAD_INSVE_W4_UB(...) SAD_INSVE_W4(v16u8, __VA_ARGS__) +#if CONFIG_ENCODERS static uint32_t sad_4width_msa(const uint8_t *src_ptr, int32_t src_stride, const uint8_t *ref_ptr, int32_t ref_stride, int32_t height) { int32_t ht_cnt; uint32_t src0, src1, src2, src3, ref0, ref1, ref2, ref3; @@ -64,10 +65,11 @@ sad += SAD_UB2_UH(src0, src1, ref0, ref1); } return HADD_UH_U32(sad); } +#endif // CONFIG_ENCODERS static uint32_t sad_16width_msa(const uint8_t *src, int32_t src_stride, const uint8_t *ref, int32_t ref_stride, int32_t height) { int32_t ht_cnt; @@ -157,10 +159,11 @@ sad += HADD_UH_U32(sad1); return sad; } +#if CONFIG_ENCODERS static void sad_4width_x4d_msa(const uint8_t *src_ptr, int32_t src_stride, const uint8_t *const aref_ptr[], int32_t ref_stride, int32_t height, uint32_t *sad_array) { const uint8_t *ref0_ptr, *ref1_ptr, *ref2_ptr, *ref3_ptr; @@ -630,10 +633,11 @@ sad = __msa_hadd_u_w(sad0, sad0); sad += __msa_hadd_u_w(sad1, sad1); return HADD_SW_S32(sad); } +#endif // CONFIG_ENCODERS #define VPX_SAD_4xHEIGHT_MSA(height) \ uint32_t vpx_sad4x##height##_msa(const uint8_t *src, int32_t src_stride, \ const uint8_t *ref, int32_t ref_stride) { \ return sad_4width_msa(src, src_stride, ref, ref_stride, height); \ @@ -736,10 +740,11 @@ int32_t ref_stride, const uint8_t *second_pred) { \ return avgsad_64width_msa(src, src_stride, ref, ref_stride, height, \ second_pred); \ } +#if CONFIG_ENCODERS // 64x64 VPX_SAD_64xHEIGHT_MSA(64); VPX_SAD_64xHEIGHTx4D_MSA(64); VPX_AVGSAD_64xHEIGHT_MSA(64); @@ -800,5 +805,15 @@ // 4x4 VPX_SAD_4xHEIGHT_MSA(4); VPX_SAD_4xHEIGHTx4D_MSA(4); VPX_AVGSAD_4xHEIGHT_MSA(4); +#else // !CONFIG_ENCODERS +// 64x64 +VPX_SAD_64xHEIGHT_MSA(64); + +// 32x32 +VPX_SAD_32xHEIGHT_MSA(32); + +// 16x16 +VPX_SAD_16xHEIGHT_MSA(16); +#endif // CONFIG_ENCODERS Index: media/libvpx/libvpx/vpx_dsp/sad.c =================================================================== --- media/libvpx/libvpx/vpx_dsp/sad.c +++ media/libvpx/libvpx/vpx_dsp/sad.c @@ -30,10 +30,12 @@ ref_ptr += ref_stride; } return sad; } +#if CONFIG_ENCODERS + #define sadMxN(m, n) \ unsigned int vpx_sad##m##x##n##_c(const uint8_t *src_ptr, int src_stride, \ const uint8_t *ref_ptr, int ref_stride) { \ return sad(src_ptr, src_stride, ref_ptr, ref_stride, m, n); \ } \ @@ -68,40 +70,50 @@ for (i = 0; i < 4; ++i) { \ sad_array[i] = 2 * sad(src_ptr, 2 * src_stride, ref_array[i], \ 2 * ref_stride, (m), (n / 2)); \ } \ } +#else // !CONFIG_ENCODERS +#define sadMxN(m, n) \ + unsigned int vpx_sad##m##x##n##_c(const uint8_t *src_ptr, int src_stride, \ + const uint8_t *ref_ptr, int ref_stride) { \ + return sad(src_ptr, src_stride, ref_ptr, ref_stride, m, n); \ + } + +#define sadMxNx4D(m, n) +#endif // CONFIG_ENCODERS /* clang-format off */ // 64x64 sadMxN(64, 64) sadMxNx4D(64, 64) +// 32x32 +sadMxN(32, 32) +sadMxNx4D(32, 32) + +// 16x16 +sadMxN(16, 16) +sadMxNx4D(16, 16) + +#if CONFIG_ENCODERS // 64x32 sadMxN(64, 32) sadMxNx4D(64, 32) // 32x64 sadMxN(32, 64) sadMxNx4D(32, 64) -// 32x32 -sadMxN(32, 32) -sadMxNx4D(32, 32) - // 32x16 sadMxN(32, 16) sadMxNx4D(32, 16) // 16x32 sadMxN(16, 32) sadMxNx4D(16, 32) -// 16x16 -sadMxN(16, 16) -sadMxNx4D(16, 16) - // 16x8 sadMxN(16, 8) sadMxNx4D(16, 8) // 8x16 @@ -121,13 +133,14 @@ sadMxNx4D(4, 8) // 4x4 sadMxN(4, 4) sadMxNx4D(4, 4) +#endif // CONFIG_ENCODERS /* clang-format on */ -#if CONFIG_VP9_HIGHBITDEPTH +#if CONFIG_VP9_HIGHBITDEPTH && CONFIG_ENCODERS static INLINE unsigned int highbd_sad(const uint8_t *src8_ptr, int src_stride, const uint8_t *ref8_ptr, int ref_stride, int width, int height) { int y, x; @@ -251,6 +264,6 @@ // 4x4 highbd_sadMxN(4, 4) highbd_sadMxNx4D(4, 4) /* clang-format on */ -#endif // CONFIG_VP9_HIGHBITDEPTH +#endif // CONFIG_VP9_HIGHBITDEPTH && CONFIG_ENCODERS Index: media/libvpx/libvpx/vpx_dsp/vpx_dsp.mk =================================================================== --- media/libvpx/libvpx/vpx_dsp/vpx_dsp.mk +++ media/libvpx/libvpx/vpx_dsp/vpx_dsp.mk @@ -381,37 +381,30 @@ # skin detection DSP_SRCS-yes += skin_detection.h DSP_SRCS-yes += skin_detection.c ifeq ($(CONFIG_ENCODERS),yes) -DSP_SRCS-yes += sad.c DSP_SRCS-yes += subtract.c DSP_SRCS-yes += sum_squares.c DSP_SRCS-$(HAVE_NEON) += arm/sum_squares_neon.c DSP_SRCS-$(HAVE_SVE) += arm/sum_squares_sve.c DSP_SRCS-$(HAVE_SSE2) += x86/sum_squares_sse2.c DSP_SRCS-$(HAVE_MSA) += mips/sum_squares_msa.c DSP_SRCS-$(HAVE_NEON) += arm/sad4d_neon.c DSP_SRCS-$(HAVE_NEON_DOTPROD) += arm/sad4d_neon_dotprod.c -DSP_SRCS-$(HAVE_NEON) += arm/sad_neon.c -DSP_SRCS-$(HAVE_NEON_DOTPROD) += arm/sad_neon_dotprod.c DSP_SRCS-$(HAVE_NEON) += arm/subtract_neon.c -DSP_SRCS-$(HAVE_MSA) += mips/sad_msa.c DSP_SRCS-$(HAVE_MSA) += mips/subtract_msa.c DSP_SRCS-$(HAVE_LSX) += loongarch/sad_lsx.c -DSP_SRCS-$(HAVE_MMI) += mips/sad_mmi.c DSP_SRCS-$(HAVE_MMI) += mips/subtract_mmi.c DSP_SRCS-$(HAVE_AVX2) += x86/sad4d_avx2.c -DSP_SRCS-$(HAVE_AVX2) += x86/sad_avx2.c DSP_SRCS-$(HAVE_AVX2) += x86/subtract_avx2.c DSP_SRCS-$(HAVE_AVX512) += x86/sad4d_avx512.c -DSP_SRCS-$(HAVE_AVX512) += x86/sad_avx512.c ifeq ($(HAVE_X86_ASM),yes) DSP_SRCS-$(HAVE_SSE2) += x86/sad4d_sse2.asm DSP_SRCS-$(HAVE_SSE2) += x86/sad_sse2.asm DSP_SRCS-$(HAVE_SSE2) += x86/subtract_sse2.asm @@ -434,51 +427,61 @@ endif # CONFIG_VP9_HIGHBITDEPTH endif # CONFIG_ENCODERS ifneq ($(filter yes,$(CONFIG_ENCODERS) $(CONFIG_POSTPROC) $(CONFIG_VP9_POSTPROC)),) +DSP_SRCS-yes += sad.c DSP_SRCS-yes += variance.c DSP_SRCS-yes += variance.h DSP_SRCS-$(HAVE_NEON) += arm/avg_pred_neon.c +DSP_SRCS-$(HAVE_NEON) += arm/sad_neon.c +DSP_SRCS-$(HAVE_NEON_DOTPROD) += arm/sad_neon_dotprod.c DSP_SRCS-$(HAVE_NEON) += arm/subpel_variance_neon.c DSP_SRCS-$(HAVE_NEON_DOTPROD) += arm/subpel_variance_neon_dotprod.c DSP_SRCS-$(HAVE_NEON) += arm/variance_neon.c DSP_SRCS-$(HAVE_NEON_DOTPROD) += arm/variance_neon_dotprod.c +DSP_SRCS-$(HAVE_MSA) += mips/sad_msa.c DSP_SRCS-$(HAVE_MSA) += mips/variance_msa.c DSP_SRCS-$(HAVE_MSA) += mips/sub_pixel_variance_msa.c DSP_SRCS-$(HAVE_LSX) += loongarch/variance_lsx.h DSP_SRCS-$(HAVE_LSX) += loongarch/variance_lsx.c DSP_SRCS-$(HAVE_LSX) += loongarch/sub_pixel_variance_lsx.c DSP_SRCS-$(HAVE_LSX) += loongarch/avg_pred_lsx.c +DSP_SRCS-$(HAVE_MMI) += mips/sad_mmi.c DSP_SRCS-$(HAVE_MMI) += mips/variance_mmi.c DSP_SRCS-$(HAVE_SSE2) += x86/avg_pred_sse2.c DSP_SRCS-$(HAVE_AVX2) += x86/avg_pred_avx2.c +DSP_SRCS-$(HAVE_AVX2) += x86/sad_avx2.c +DSP_SRCS-$(HAVE_AVX512) += x86/sad_avx512.c DSP_SRCS-$(HAVE_SSE2) += x86/variance_sse2.c # Contains SSE2 and SSSE3 DSP_SRCS-$(HAVE_AVX2) += x86/variance_avx2.c DSP_SRCS-$(HAVE_VSX) += ppc/variance_vsx.c ifeq ($(VPX_ARCH_X86_64)$(HAVE_X86_ASM),yesyes) DSP_SRCS-$(HAVE_SSE2) += x86/ssim_opt_x86_64.asm endif # VPX_ARCH_X86_64 ifeq ($(HAVE_X86_ASM),yes) +DSP_SRCS-$(HAVE_SSE2) += x86/sad_sse2.asm DSP_SRCS-$(HAVE_SSE2) += x86/subpel_variance_sse2.asm # Contains SSE2 and SSSE3 endif ifeq ($(CONFIG_VP9_HIGHBITDEPTH),yes) DSP_SRCS-$(HAVE_SSE2) += x86/highbd_variance_sse2.c ifeq ($(HAVE_X86_ASM),yes) DSP_SRCS-$(HAVE_SSE2) += x86/highbd_variance_impl_sse2.asm DSP_SRCS-$(HAVE_SSE2) += x86/highbd_subpel_variance_impl_sse2.asm endif DSP_SRCS-$(HAVE_NEON) += arm/highbd_avg_pred_neon.c +ifeq ($(CONFIG_ENCODERS),yes) DSP_SRCS-$(HAVE_NEON) += arm/highbd_sse_neon.c +endif DSP_SRCS-$(HAVE_NEON) += arm/highbd_variance_neon.c DSP_SRCS-$(HAVE_NEON_DOTPROD) += arm/highbd_variance_neon_dotprod.c DSP_SRCS-$(HAVE_SVE) += arm/highbd_variance_sve.c DSP_SRCS-$(HAVE_NEON) += arm/highbd_subpel_variance_neon.c endif # CONFIG_VP9_HIGHBITDEPTH Index: media/libvpx/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl =================================================================== --- media/libvpx/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl +++ media/libvpx/libvpx/vpx_dsp/vpx_dsp_rtcd_defs.pl @@ -764,31 +764,22 @@ specialize qw/vpx_sse sse4_1 avx2 neon neon_dotprod/; # # Single block SAD # -add_proto qw/unsigned int vpx_sad64x64/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; -specialize qw/vpx_sad64x64 neon neon_dotprod avx512 avx2 msa vsx mmi lsx/, "$sse2_asm"; - add_proto qw/unsigned int vpx_sad64x32/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vpx_sad64x32 neon neon_dotprod avx512 avx2 msa vsx mmi/, "$sse2_asm"; add_proto qw/unsigned int vpx_sad32x64/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vpx_sad32x64 neon neon_dotprod avx2 msa vsx mmi/, "$sse2_asm"; -add_proto qw/unsigned int vpx_sad32x32/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; -specialize qw/vpx_sad32x32 neon neon_dotprod avx2 msa vsx mmi lsx/, "$sse2_asm"; - add_proto qw/unsigned int vpx_sad32x16/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vpx_sad32x16 neon neon_dotprod avx2 msa vsx mmi/, "$sse2_asm"; add_proto qw/unsigned int vpx_sad16x32/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vpx_sad16x32 neon neon_dotprod msa vsx mmi/, "$sse2_asm"; -add_proto qw/unsigned int vpx_sad16x16/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; -specialize qw/vpx_sad16x16 neon neon_dotprod msa vsx mmi lsx/, "$sse2_asm"; - add_proto qw/unsigned int vpx_sad16x8/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vpx_sad16x8 neon neon_dotprod msa vsx mmi/, "$sse2_asm"; add_proto qw/unsigned int vpx_sad8x16/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; specialize qw/vpx_sad8x16 neon msa vsx mmi/, "$sse2_asm"; @@ -1268,10 +1259,22 @@ } # CONFIG_ENCODERS if (vpx_config("CONFIG_ENCODERS") eq "yes" || vpx_config("CONFIG_POSTPROC") eq "yes" || vpx_config("CONFIG_VP9_POSTPROC") eq "yes") { # +# Single block SAD +# +add_proto qw/unsigned int vpx_sad16x16/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; +specialize qw/vpx_sad16x16 neon neon_dotprod msa vsx mmi lsx/, "$sse2_asm"; + +add_proto qw/unsigned int vpx_sad32x32/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; +specialize qw/vpx_sad32x32 neon neon_dotprod avx2 msa vsx mmi lsx/, "$sse2_asm"; + +add_proto qw/unsigned int vpx_sad64x64/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride"; +specialize qw/vpx_sad64x64 neon neon_dotprod avx512 avx2 msa vsx mmi lsx/, "$sse2_asm"; + +# # Variance # add_proto qw/unsigned int vpx_variance64x64/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vpx_variance64x64 sse2 avx2 neon neon_dotprod msa mmi vsx lsx/; Index: media/libvpx/libvpx/vpx_dsp/x86/sad_avx2.c =================================================================== --- media/libvpx/libvpx/vpx_dsp/x86/sad_avx2.c +++ media/libvpx/libvpx/vpx_dsp/x86/sad_avx2.c @@ -94,10 +94,11 @@ int ref_stride) { \ return 2 * sad32xh_avx2(src_ptr, src_stride * 2, ref_ptr, ref_stride * 2, \ h / 2); \ } +#if CONFIG_ENCODERS #define FSAD64 \ FSAD64_H(64) \ FSAD64_H(32) \ FSADS64_H(64) \ FSADS64_H(32) @@ -107,10 +108,14 @@ FSAD32_H(32) \ FSAD32_H(16) \ FSADS32_H(64) \ FSADS32_H(32) \ FSADS32_H(16) +#else // !CONFIG_ENCODERS +#define FSAD64 FSAD64_H(64) +#define FSAD32 FSAD32_H(32) +#endif // CONFIG_ENCODERS FSAD64 FSAD32 #undef FSAD64 @@ -118,10 +123,11 @@ #undef FSAD64_H #undef FSAD32_H #undef FSADS64_H #undef FSADS32_H +#if CONFIG_ENCODERS #define FSADAVG64_H(h) \ unsigned int vpx_sad64x##h##_avg_avx2( \ const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, \ int ref_stride, const uint8_t *second_pred) { \ int i; \ @@ -204,5 +210,7 @@ #undef FSADAVG64 #undef FSADAVG32 #undef FSADAVG64_H #undef FSADAVG32_H + +#endif // CONFIG_ENCODERS Index: media/libvpx/libvpx/vpx_dsp/x86/sad_avx512.c =================================================================== --- media/libvpx/libvpx/vpx_dsp/x86/sad_avx512.c +++ media/libvpx/libvpx/vpx_dsp/x86/sad_avx512.c @@ -43,22 +43,28 @@ int ref_stride) { \ return 2 * sad64xh_avx512(src_ptr, src_stride * 2, ref_ptr, \ ref_stride * 2, h / 2); \ } +#if CONFIG_ENCODERS #define FSAD64 \ FSAD64_H(64) \ FSAD64_H(32) \ FSADS64_H(64) \ FSADS64_H(32) +#else +#define FSAD64 FSAD64_H(64) +#endif // CONFIG_ENCODERS FSAD64 #undef FSAD64 #undef FSAD64_H #undef FSADS64_H +#if CONFIG_ENCODERS + #define FSADAVG64_H(h) \ unsigned int vpx_sad64x##h##_avg_avx512( \ const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, \ int ref_stride, const uint8_t *second_pred) { \ int i; \ @@ -84,5 +90,7 @@ FSADAVG64 #undef FSADAVG64 #undef FSADAVG64_H + +#endif // CONFIG_ENCODERS Index: media/libvpx/libvpx/vpx_dsp/x86/sad_sse2.asm =================================================================== --- media/libvpx/libvpx/vpx_dsp/x86/sad_sse2.asm +++ media/libvpx/libvpx/vpx_dsp/x86/sad_sse2.asm @@ -106,15 +106,17 @@ RET %endmacro INIT_XMM sse2 SAD64XN 64 ; sad64x64_sse2 +%if CONFIG_ENCODERS SAD64XN 32 ; sad64x32_sse2 SAD64XN 64, 1 ; sad64x64_avg_sse2 SAD64XN 32, 1 ; sad64x32_avg_sse2 SAD64XN 64, 2 ; sad64x64_skip_sse2 SAD64XN 32, 2 ; sad64x32_skip_sse2 +%endif ; CONFIG_ENCODERS ; unsigned int vpx_sad32x32_sse2(uint8_t *src, int src_stride, ; uint8_t *ref, int ref_stride); %macro SAD32XN 1-2 0 SAD_FN 32, %1, 5, %2 @@ -157,19 +159,21 @@ movd eax, m0 RET %endmacro INIT_XMM sse2 +SAD32XN 32 ; sad32x32_sse2 +%if CONFIG_ENCODERS SAD32XN 64 ; sad32x64_sse2 -SAD32XN 32 ; sad32x32_sse2 SAD32XN 16 ; sad32x16_sse2 SAD32XN 64, 1 ; sad32x64_avg_sse2 SAD32XN 32, 1 ; sad32x32_avg_sse2 SAD32XN 16, 1 ; sad32x16_avg_sse2 SAD32XN 64, 2 ; sad32x64_skip_sse2 SAD32XN 32, 2 ; sad32x32_skip_sse2 SAD32XN 16, 2 ; sad32x16_skip_sse2 +%endif ; CONFIG_ENCODERS ; unsigned int vpx_sad16x{8,16}_sse2(uint8_t *src, int src_stride, ; uint8_t *ref, int ref_stride); %macro SAD16XN 1-2 0 SAD_FN 16, %1, 7, %2 @@ -213,12 +217,13 @@ movd eax, m0 RET %endmacro INIT_XMM sse2 +SAD16XN 16 ; sad16x16_sse2 +%if CONFIG_ENCODERS SAD16XN 32 ; sad16x32_sse2 -SAD16XN 16 ; sad16x16_sse2 SAD16XN 8 ; sad16x8_sse2 SAD16XN 32, 1 ; sad16x32_avg_sse2 SAD16XN 16, 1 ; sad16x16_avg_sse2 SAD16XN 8, 1 ; sad16x8_avg_sse2 SAD16XN 32, 2 ; sad16x32_skip_sse2 @@ -328,5 +333,7 @@ SAD4XN 8 ; sad4x8_sse SAD4XN 4 ; sad4x4_sse SAD4XN 8, 1 ; sad4x8_avg_sse SAD4XN 4, 1 ; sad4x4_avg_sse SAD4XN 8, 2 ; sad4x8_skip_sse + +%endif ; CONFIG_ENCODERS Index: media/libvpx/libvpx/vpx_ports/aarch64_cpudetect.c =================================================================== --- media/libvpx/libvpx/vpx_ports/aarch64_cpudetect.c +++ media/libvpx/libvpx/vpx_ports/aarch64_cpudetect.c @@ -14,11 +14,11 @@ #if defined(__APPLE__) #include #endif -#if !CONFIG_RUNTIME_CPU_DETECT || defined(__OpenBSD__) +#if !CONFIG_RUNTIME_CPU_DETECT static int arm_get_cpu_caps(void) { // This function should actually be a no-op. There is no way to adjust any of // these because the RTCD tables do not exist: the functions are called // statically. @@ -27,11 +27,11 @@ flags |= HAS_NEON; #endif // HAVE_NEON return flags; } -#elif defined(__APPLE__) // end !CONFIG_RUNTIME_CPU_DETECT || defined(__OpenBSD__) +#elif defined(__APPLE__) // end !CONFIG_RUNTIME_CPU_DETECT // sysctlbyname() parameter documentation for instruction set characteristics: // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics static INLINE int64_t have_feature(const char *feature) { int64_t feature_present = 0; Index: media/libvpx/libvpx/vpx_ports/x86.h =================================================================== --- media/libvpx/libvpx/vpx_ports/x86.h +++ media/libvpx/libvpx/vpx_ports/x86.h @@ -174,10 +174,15 @@ #define AVX_BITS (BIT(27) | BIT(28)) #define AVX2_BITS BIT(5) // Bits 16 (AVX-512F) & 17 (AVX-512DQ) & 28 (AVX-512CD) & 30 (AVX-512BW) // & 31 (AVX-512VL) #define AVX512_BITS (BIT(16) | BIT(17) | BIT(28) | BIT(30) | BIT(31)) +// Bits 1 (AVX512-VBMI) & 6 (AVX512-VBMI2) & 8 (AVX512-GFNI) & 9 (AVX512-VAES) & +// 10 (AVX512-VPCLMULQDQ) & 11 (AVX512-VNNI) & 12 (AVX512-BITALG) & +// 14 (AVX512-POPCNTDQ) +#define AVX512_DL_BITS \ + (BIT(1) | BIT(6) | BIT(8) | BIT(9) | BIT(10) | BIT(11) | BIT(12) | BIT(14)) #define FEATURE_SET(reg, feature) \ (((reg) & (feature##_BITS)) == (feature##_BITS)) static INLINE int x86_simd_caps(void) { @@ -216,11 +221,15 @@ /* Get the leaf 7 feature flags. Needed to check for AVX2 support */ cpuid(7, 0, reg_eax, reg_ebx, reg_ecx, reg_edx); flags |= FEATURE_SET(reg_ebx, AVX2) ? HAS_AVX2 : 0; if (FEATURE_SET(reg_ebx, AVX512)) { // Check for OS-support of ZMM and YMM state. Necessary for AVX-512. - if ((xgetbv() & 0xe6) == 0xe6) flags |= HAS_AVX512; + if ((xgetbv() & 0xe6) == 0xe6) { + // Older AVX512 implementations (such as Skylake) have turbo curves + // that are currently problematic for mixed AVX512/AVX2 code + flags |= FEATURE_SET(reg_ecx, AVX512_DL) ? HAS_AVX512 : 0; + } } } } } (void)reg_eax; // Avoid compiler warning on unused-but-set variable. Index: media/libvpx/libvpx/vpx_util/vpx_pthread.h =================================================================== --- media/libvpx/libvpx/vpx_util/vpx_pthread.h +++ media/libvpx/libvpx/vpx_util/vpx_pthread.h @@ -24,11 +24,10 @@ // Prevent leaking max/min macros. #undef NOMINMAX #define NOMINMAX #undef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN -#include // NOLINT #include // NOLINT #include // NOLINT #include // NOLINT typedef HANDLE pthread_t; typedef SRWLOCK pthread_mutex_t; Index: media/libvpx/libvpx/vpxdec.c =================================================================== --- media/libvpx/libvpx/vpxdec.c +++ media/libvpx/libvpx/vpxdec.c @@ -694,25 +694,26 @@ if (!fn) { free(argv); fprintf(stderr, "No input file specified!\n"); usage_exit(); } - /* Open file */ - infile = strcmp(fn, "-") ? fopen(fn, "rb") : set_binary_mode(stdin); - - if (!infile) { - fatal("Failed to open input file '%s'", strcmp(fn, "-") ? fn : "stdin"); - } #if CONFIG_OS_SUPPORT /* Make sure we don't dump to the terminal, unless forced to with -o - */ if (!outfile_pattern && isatty(fileno(stdout)) && !do_md5 && !noblit) { fprintf(stderr, "Not dumping raw video to your terminal. Use '-o -' to " "override.\n"); return EXIT_FAILURE; } #endif + + /* Open file */ + infile = strcmp(fn, "-") ? fopen(fn, "rb") : set_binary_mode(stdin); + + if (!infile) { + fatal("Failed to open input file '%s'", strcmp(fn, "-") ? fn : "stdin"); + } input.vpx_input_ctx->file = infile; if (file_is_ivf(input.vpx_input_ctx)) input.vpx_input_ctx->file_type = FILE_TYPE_IVF; #if CONFIG_WEBM_IO else if (file_is_webm(input.webm_ctx, input.vpx_input_ctx)) @@ -744,20 +745,20 @@ if (use_y4m && !noblit) { if (!single_file) { fprintf(stderr, "YUV4MPEG2 not supported with output patterns," " try --i420 or --yv12 or --rawvideo.\n"); - return EXIT_FAILURE; + goto fail2; } #if CONFIG_WEBM_IO if (vpx_input_ctx.file_type == FILE_TYPE_WEBM) { if (webm_guess_framerate(input.webm_ctx, input.vpx_input_ctx)) { fprintf(stderr, "Failed to guess framerate -- error parsing " "webm file?\n"); - return EXIT_FAILURE; + goto fail2; } } #endif } Index: media/libvpx/moz.yaml =================================================================== --- media/libvpx/moz.yaml +++ media/libvpx/moz.yaml @@ -18,15 +18,15 @@ # Usually different from repository url url: https://chromium.googlesource.com/webm/libvpx # Human-readable identifier for this version/release # Generally "version NNN", "tag SSS", "bookmark SSS" - release: ab83db6108180e4663bd0f2ed3cdc3e525c6b35f (Fri May 22 18:55:47 2026). + release: 41e48324dd06c775d852b2c3d7d5ccc46aa72225 (Wed Jun 10 23:49:52 2026). # Revision to pull in # Must be a long or short commit SHA (long preferred) - revision: ab83db6108180e4663bd0f2ed3cdc3e525c6b35f + revision: 41e48324dd06c775d852b2c3d7d5ccc46aa72225 # The package's license, where possible using the mnemonic from # https://spdx.org/licenses/ # Multiple licenses can be specified (as a YAML list) # A "LICENSE" file must exist containing the full license text