platform/upstream/libvpx.git
7 months agopsnr.h,cosmetics: fix a typo (PNSR -> PSNR)
James Zern [Thu, 30 Nov 2023 00:47:34 +0000 (16:47 -0800)]
psnr.h,cosmetics: fix a typo (PNSR -> PSNR)

Change-Id: I2adea9f150852c106acc57e5aeeac571d6bd15fb

7 months agoMerge "vp9 rc: support screen content" into main
Jerome Jiang [Wed, 29 Nov 2023 23:52:13 +0000 (23:52 +0000)]
Merge "vp9 rc: support screen content" into main

7 months agovp9 rc: support screen content
Jerome Jiang [Sat, 11 Nov 2023 01:38:31 +0000 (20:38 -0500)]
vp9 rc: support screen content

Bug: b/281463780
Change-Id: I23668550257b28031bdca0537459f93ec63f1e2e

7 months agoAdd VP9Encoder class to simplify fuzz test cases
Wan-Teh Chang [Wed, 29 Nov 2023 22:22:10 +0000 (14:22 -0800)]
Add VP9Encoder class to simplify fuzz test cases

Bug: b:306422625
Change-Id: I8344cb7fb4e1aee87d46f683746517cdcddf5c5d

7 months agoMerge "Adding "const" to vpx_codec_iface_t is redundant" into main
Wan-Teh Chang [Wed, 29 Nov 2023 20:04:24 +0000 (20:04 +0000)]
Merge "Adding "const" to vpx_codec_iface_t is redundant" into main

7 months agoMerge "ratectrl_rtc: Remove duplicated DropFrameReason enum class" into main
Hirokazu Honda [Wed, 29 Nov 2023 01:32:21 +0000 (01:32 +0000)]
Merge "ratectrl_rtc: Remove duplicated DropFrameReason enum class" into main

7 months agoMerge "Add vpx_sse and vpx_highbd_sse" into main
Wan-Teh Chang [Tue, 28 Nov 2023 18:39:49 +0000 (18:39 +0000)]
Merge "Add vpx_sse and vpx_highbd_sse" into main

7 months agoMerge "rtc: Set nonrd keyframe under dynamic change of deadline" into main
Marco Paniconi [Tue, 28 Nov 2023 17:24:48 +0000 (17:24 +0000)]
Merge "rtc: Set nonrd keyframe under dynamic change of deadline" into main

7 months agortc: Set nonrd keyframe under dynamic change of deadline
Marco Paniconi [Tue, 21 Nov 2023 22:00:16 +0000 (14:00 -0800)]
rtc: Set nonrd keyframe under dynamic change of deadline

For realtime mode: if the deadline mode (good/best/realtime)
is changed on the fly (via codec_encode() call), force a
key frame and set the speed feature nonrd_keyframe = 1 to
avoid entering the rd pickmode.

nonrd_pickmode=0/off is the only feature in realtime mode that
involves rd pickmode, so by forcing it on/1 we can cleanly
separate nonrd (realtime) from rd (good/best), so we can
avoid possible issues on this dynamic mode switch, such as in
bug listed below.

Dynamic change of deadline, in particular for realtime mode,
involves a lot of coding/speed feature changes, so best to
also force reset with keyframe.

Added unitest that triggers the issue in the bug.
Bug: b/310663186

Change-Id: Idf8fd7c9ee54b301968184be5481ee9faa06468d

7 months agoMerge "Tests kf_max_dist in one-pass zero-lag encoding" into main
Wan-Teh Chang [Mon, 27 Nov 2023 23:54:04 +0000 (23:54 +0000)]
Merge "Tests kf_max_dist in one-pass zero-lag encoding" into main

7 months agoUnitest for issue: b/310477034
Marco Paniconi [Mon, 27 Nov 2023 04:38:01 +0000 (20:38 -0800)]
Unitest for issue: b/310477034

Fix is made here:
https://chromium-review.googlesource.com/c/webm/libvpx/+/5055827

Bug: b/310477034
Change-Id: Id1cc7a6a95e1ea5d1a022f36d7971915c9918339

7 months agoTests kf_max_dist in one-pass zero-lag encoding
Wan-Teh Chang [Wed, 22 Nov 2023 22:49:56 +0000 (14:49 -0800)]
Tests kf_max_dist in one-pass zero-lag encoding

The test shows that the comment for kf_max_dist in vpx/vpx_encoder.h
differs from its behavior by one. We should modify the comment to match
the encoding behavior.

Bug: webm:1829
Change-Id: Icdc58b8f6b25353f10ce8ecc481c862bd3fe86df

7 months agoDisable intra mode search speed features conditionally
Jingning Han [Wed, 22 Nov 2023 23:38:27 +0000 (15:38 -0800)]
Disable intra mode search speed features conditionally

When all the inter reference frames are invalid, disable the speed
features that bypass intra mode search.

BUG=b/312517065

Change-Id: I246c953fad3be61b9d307da11c752a21a36b90ff

7 months agoAdding "const" to vpx_codec_iface_t is redundant
Wan-Teh Chang [Wed, 22 Nov 2023 23:38:04 +0000 (15:38 -0800)]
Adding "const" to vpx_codec_iface_t is redundant

vpx_codec_iface_t is defined as follows:

  typedef const struct vpx_codec_iface vpx_codec_iface_t;

Since vpx_codec_iface_t is already a const struct, it is redundant to
add "const" to vpx_codec_iface_t.

Note: I think vpx_codec_iface_t should not have been defined as a const
struct, but it is too late to change that now.

Change-Id: Ifbd3f8a63c1d48e9169ff77fa0b505ea1e65519d

7 months agoRemove invalid reference frames
Jingning Han [Wed, 22 Nov 2023 23:07:04 +0000 (15:07 -0800)]
Remove invalid reference frames

Remove the reference frames whose scaling factor is not in the
supported range.

BUG=b/312517065

Change-Id: Iaf8610ff7a95cd4a433bf529f741459d820d4f8b

7 months agoConditionally skip using inter frames in speed features
Jingning Han [Wed, 22 Nov 2023 23:06:08 +0000 (15:06 -0800)]
Conditionally skip using inter frames in speed features

When the reference frame's scaling factor is not in the supported
range, skip using it for motion compensation prediction in the
partition speed features.

BUG=b/312517065

Change-Id: Ie3687186521ad2616be258e80d3e5b16e5f2d5e9

8 months agoCheck null ptr before use
Jerome Jiang [Tue, 21 Nov 2023 16:18:54 +0000 (11:18 -0500)]
Check null ptr before use

prev_mi is a pointer to pointer

Bug: b/310401647
Bug: b/310590556
Change-Id: Ic3c39a7eec14693357bd2485a5451d4b7f031b5e

8 months agoratectrl_rtc: Remove duplicated DropFrameReason enum class
Hirokazu Honda [Tue, 21 Nov 2023 08:03:53 +0000 (17:03 +0900)]
ratectrl_rtc: Remove duplicated DropFrameReason enum class

DropFrameReason is declared in two places. This moves it
to the common place.

Change-Id: I04c16db4a49135588edff7e1746dcf9172750bb9

8 months agoMerge "vp8_dx_iface.c: add include for MAX_PARTITIONS" into main
James Zern [Tue, 21 Nov 2023 02:21:20 +0000 (02:21 +0000)]
Merge "vp8_dx_iface.c: add include for MAX_PARTITIONS" into main

8 months agoAdd vpx_sse and vpx_highbd_sse
Wan-Teh Chang [Fri, 29 Sep 2023 17:45:32 +0000 (10:45 -0700)]
Add vpx_sse and vpx_highbd_sse

The code is ported from libaom's aom_sse and aom_highbd_sse at
commit 1e20d2da96515524864b21010dbe23809cff2e9b.

The vpx_sse and vpx_highbd_sse functions will be used by vpx_dsp/psnr.c.

Bug: webm:1819
Change-Id: I4fbffa9000ab92755de5387b1ddd4370cb7020f7

8 months agovp8_dx_iface.c: add include for MAX_PARTITIONS
James Zern [Mon, 20 Nov 2023 19:54:50 +0000 (11:54 -0800)]
vp8_dx_iface.c: add include for MAX_PARTITIONS

fixes clang-tidy warning:
no header providing "MAX_PARTITIONS" is directly included

Change-Id: Iba7a9d95df7f5bdee76e7975df764cd71461fc93

8 months agovp8_ratectrl_rtc.h: fix a few typos
James Zern [Mon, 20 Nov 2023 19:49:14 +0000 (11:49 -0800)]
vp8_ratectrl_rtc.h: fix a few typos

is -> if
returns -> computes

in the documentation for ComputeQP().

This is the same as:
9142314c2 ratectrl_rtc.h: fix a few typos

+ remove a duplicate, commented out, version of GetLoopfilterLevel()

Change-Id: I8832e628b63b0b7dac6236631072f36ad55d90e8

8 months agoratectrl_rtc.h: fix a few typos
James Zern [Wed, 15 Nov 2023 01:57:04 +0000 (17:57 -0800)]
ratectrl_rtc.h: fix a few typos

is -> if
returns -> computes

in the documentation for ComputeQP().

Change-Id: If70706736b0dc2ae56e45e2489dc208c61fd557a

8 months agortc: Add frame dropper to VP8 external RC
Marco Paniconi [Sun, 12 Nov 2023 08:39:14 +0000 (00:39 -0800)]
rtc: Add frame dropper to VP8 external RC

Move some internal drop_frame code to separate
function so the external RC can use.
And add new flag setting under VP8E_SET_RTC_EXTERNAL_RATECTRL
to disable vp8_drop_encodedframe_overshoot() for
testing the external RC.

Unittest added for single layer and 3 temporal layers.

Bug: b/280363228

Change-Id: Ibea2f627cc54e7156ff35259a64dd111d42d146c

8 months agoMerge "Delete -Wdeclaration-after-statement" into main
Wan-Teh Chang [Sat, 11 Nov 2023 02:29:46 +0000 (02:29 +0000)]
Merge "Delete -Wdeclaration-after-statement" into main

8 months agoDocument how VP9 treats a negative speed value
Wan-Teh Chang [Fri, 10 Nov 2023 21:14:18 +0000 (13:14 -0800)]
Document how VP9 treats a negative speed value

Change-Id: I12948b08a7bb5beb5024b8676de9dafc239f8e89

8 months agoDelete -Wdeclaration-after-statement
Wan-Teh Chang [Thu, 9 Nov 2023 05:05:15 +0000 (21:05 -0800)]
Delete -Wdeclaration-after-statement

Older versions of MSVC do not allow declarations after statements in C
files. We don't need to support those versions of MSVC now.

Use -std=gnu99 instead of -std=gnu89.

Change-Id: I76ba962f5a2bca30d6a5b2b05c5786507398ad32

8 months agoFix ClangTidy warnings
Wan-Teh Chang [Fri, 10 Nov 2023 02:35:51 +0000 (18:35 -0800)]
Fix ClangTidy warnings

Most are related to include-what-you-use. One is to avoid using the
unsigned long type explicitly (by passing VPX_DL_REALTIME directly to
vpx_codec_encode).

Change-Id: Ieaf3418382ad8516cb4b172f7678893286fcb8cf

8 months agoMerge "Declare oxcf arg of vp8_create_compressor as const" into main
Wan-Teh Chang [Fri, 10 Nov 2023 01:40:17 +0000 (01:40 +0000)]
Merge "Declare oxcf arg of vp8_create_compressor as const" into main

8 months agoMerge "Fix float-cast-overflow in vp8_change_config()" into main
Wan-Teh Chang [Thu, 9 Nov 2023 23:10:35 +0000 (23:10 +0000)]
Merge "Fix float-cast-overflow in vp8_change_config()" into main

8 months agoDeclare oxcf arg of vp8_create_compressor as const
Wan-Teh Chang [Thu, 9 Nov 2023 20:42:58 +0000 (12:42 -0800)]
Declare oxcf arg of vp8_create_compressor as const

Declare the oxcf parameters of vp8_create_compressor() and init_config()
as const. This helps code analysis.

Change-Id: I344ef3e6afc3adced2b2865b7e0057c6d4b1d3c0

8 months agoDocument the units of VP8 target_bandwidth/bitrate
Wan-Teh Chang [Thu, 9 Nov 2023 18:19:47 +0000 (10:19 -0800)]
Document the units of VP8 target_bandwidth/bitrate

Change-Id: I6298a0acb4ef546ae198bb1f16dea50ed34b2dae

8 months agoFix float-cast-overflow in vp8_change_config()
Wan-Teh Chang [Wed, 8 Nov 2023 23:16:13 +0000 (15:16 -0800)]
Fix float-cast-overflow in vp8_change_config()

Bug: b:309716574
Change-Id: I9c523d5e9211f895c7497a9e3674b55f6be6c742

8 months agoMerge "Use symbolic constant VPX_CBR instead of 1" into main
Wan-Teh Chang [Wed, 8 Nov 2023 02:40:28 +0000 (02:40 +0000)]
Merge "Use symbolic constant VPX_CBR instead of 1" into main

8 months agoUse symbolic constant VPX_CBR instead of 1
Wan-Teh Chang [Tue, 7 Nov 2023 23:47:43 +0000 (15:47 -0800)]
Use symbolic constant VPX_CBR instead of 1

Change-Id: Idae94cfc6d7a882691deeb4fa3ce0015f80ed937

8 months agoMerge "Check fragments count before use" into main
Jerome Jiang [Tue, 7 Nov 2023 15:26:52 +0000 (15:26 +0000)]
Merge "Check fragments count before use" into main

8 months agoconfigure: detect PIE and enable PIC
James Zern [Mon, 6 Nov 2023 18:21:56 +0000 (10:21 -0800)]
configure: detect PIE and enable PIC

Fixes the creation of DT_TEXTREL entries in binaries built with PIE
enabled:
  /usr/bin/ld: warning: creating DT_TEXTREL in a PIE

This matches the changes made in libaom:
1df26009da aom_configure: only override CONFIG_PIC if not set on cmd line
7235e65746 aom_configure.cmake: detect PIE and set CONFIG_PIC

Change-Id: I0a43e964af2d8eb8c5e7811ce14ad39285eec3a8

8 months agoCheck fragments count before use
Jerome Jiang [Fri, 3 Nov 2023 19:22:04 +0000 (15:22 -0400)]
Check fragments count before use

Bug: webm:1827
Change-Id: I8d603d5db92476222cbee1c61fece957ad03a49f

8 months agoMerge "Modify C vs SIMD test script" into main
Yunqing Wang [Fri, 3 Nov 2023 16:11:24 +0000 (16:11 +0000)]
Merge "Modify C vs SIMD test script" into main

8 months agoModify C vs SIMD test script
Anupam Pandey [Thu, 5 Oct 2023 05:49:19 +0000 (11:19 +0530)]
Modify C vs SIMD test script

- Enable C vs SIMD test for x86 32-bit platform
- Correct a print message in run_tests()

BUG=webm:1800

Change-Id: Ib1ccd3a87a64b5ec6cde524a14d5d1b7e200abfb

8 months agoMerge "Add an emms instruction to vpx_subtract_block" into main
Yunqing Wang [Thu, 2 Nov 2023 03:39:59 +0000 (03:39 +0000)]
Merge "Add an emms instruction to vpx_subtract_block" into main

8 months agovp9-RC: Add drop_frame support to external RC
Marco Paniconi [Tue, 24 Oct 2023 18:03:56 +0000 (11:03 -0700)]
vp9-RC: Add drop_frame support to external RC

Supports single layer and svc. For svc only the
framedrop_mode = FULL_SUPERFRAME_DROP is allowed
for now.

Dropping frames due to overshoot is enabled by the
oxcf->drop_frames_water_mark, which is zero as default.
Note that this CL also allows for drop/skip encoding of
enhancement layers if that layer bitrate is zero.

max_consec_drop is also added, set to INT_MAX as default.
Note that max_consec_drop is only used for svc mode.
It has not been added yet for single layer in libvpx encoder.

Tests added for single layer and svc case.

Change-Id: Ic12f6a0eb3fbf07d8eb8456c46cec27b2e1930d3

8 months agoMerge "calc_pframe_target_size: fix integer overflow" into main
James Zern [Mon, 30 Oct 2023 19:20:46 +0000 (19:20 +0000)]
Merge "calc_pframe_target_size: fix integer overflow" into main

8 months agoMerge "Fix 'unused variable' warning when neon_i8mm is disabled" into main
James Zern [Mon, 30 Oct 2023 19:20:18 +0000 (19:20 +0000)]
Merge "Fix 'unused variable' warning when neon_i8mm is disabled" into main

8 months agoFix 'unused variable' warning when neon_i8mm is disabled
Jonathan Wright [Mon, 30 Oct 2023 15:24:12 +0000 (15:24 +0000)]
Fix 'unused variable' warning when neon_i8mm is disabled

Guard hwcap2 feature interrogation on HAVE_NEON_I8MM so that it gets
disabled if neon_i8mm is disabled when configuring the build.

Bug: webm:1825
Change-Id: Ic6ff71f17387b96219591928a583d43560bb7c7a

8 months agocalc_pframe_target_size: fix integer overflow
Xiahong Bao [Fri, 27 Oct 2023 23:52:04 +0000 (08:52 +0900)]
calc_pframe_target_size: fix integer overflow

The intermediate value in the target bandwidth
calculation may exceed integer bounds.

Bug: 308007926

Change-Id: I8288c5820db06a550d88bf91fccc86106996deaa
Signed-off-by: Xiahong Bao <xiahong.bao@nxp.com>
8 months agoClear some clang-tidy complaints on header includes
Marco Paniconi [Fri, 27 Oct 2023 16:24:06 +0000 (09:24 -0700)]
Clear some clang-tidy complaints on header includes

Change-Id: Id6f54dc4643172f6a5576dc4846c47c8eda31c0f

8 months agoAdd Arm SVE build flags and run-time CPU feature detection
Jonathan Wright [Tue, 24 Oct 2023 07:37:27 +0000 (08:37 +0100)]
Add Arm SVE build flags and run-time CPU feature detection

Add 'sve' arch options to the configure, build and unit test files -
adding appropriate conditional options where necessary. Arm SIMD
extensions are treated as supersets in libvpx, so disable SVE if
either Neon DotProd or I8MM are unavailable.

Change-Id: I39dd24f2b209251084d1e28d7ac68099460309bb

9 months agoMerge "Reduce memory usage of test with large frame size" into main
Jerome Jiang [Fri, 20 Oct 2023 21:14:18 +0000 (21:14 +0000)]
Merge "Reduce memory usage of test with large frame size" into main

9 months agoReduce memory usage of test with large frame size
Jerome Jiang [Fri, 20 Oct 2023 18:25:14 +0000 (14:25 -0400)]
Reduce memory usage of test with large frame size

 - Use smaller frame size that still triggers the overflow
 - Do not run encoder as the encoder init also triggers the overflow

Bug: chromium:1492864
Change-Id: I392549abf69f1cfb3754cc847a214513ec9bedc5

9 months agoAlso test VPX_ARCH_AARCH64 for 64-bit platforms
Wan-Teh Chang [Fri, 20 Oct 2023 01:28:48 +0000 (18:28 -0700)]
Also test VPX_ARCH_AARCH64 for 64-bit platforms

Change-Id: Ic11ccd791ff78801e0aba1d12ad2d99b9941ce9d

9 months agoRun bitrate overflow test only on 64bit systems
Jerome Jiang [Thu, 19 Oct 2023 14:06:50 +0000 (10:06 -0400)]
Run bitrate overflow test only on 64bit systems

Frame size caps the target bitrate internally, so the frame size needs
to be large enough to reproduce the target bitrate overflow in the
fuzzing test.

However the frame size needed exceeds the max buffer allowed on 32bit
system defined by VPX_MAX_ALLOCABLE_MEMORY

Bug: chromium:1492864

Change-Id: Ia3a9a78cd35516373897039a7769b492e29e8450

9 months agoCap avg_frame_bandwidth at INT_MAX
Jerome Jiang [Mon, 16 Oct 2023 20:26:18 +0000 (16:26 -0400)]
Cap avg_frame_bandwidth at INT_MAX

avg_frame_bandwidth = target_bandwidth / framerate

If target_bandwidth is too big and/or framerate is too small (< 1),
avg_frame_bandwidth could be overflow

Bug: chromium:1492864
Change-Id: I32314da1414b472ae4bf2acdcd81b8a948286146

9 months agoFix ubsan failure caused by left shift of negative
Jerome Jiang [Mon, 16 Oct 2023 15:22:48 +0000 (11:22 -0400)]
Fix ubsan failure caused by left shift of negative

Bug: b/305642441
Change-Id: Iddb1572c284161140da48f61b04cf600e5b57ecc

9 months agoForce mode search on 64x64 if no mode is selected
Jerome Jiang [Tue, 10 Oct 2023 21:43:16 +0000 (17:43 -0400)]
Force mode search on 64x64 if no mode is selected

A speed feature disable_split_mask (set to 63) could cause no mode and
partition to be selected in rd_pick_partition because:

-> thresh_mult_sub8x8 all INT_MAX
-> All modes skipped for sub8x8 blocks
-> found_best_rd is 0 -> break from the loop of 4 sub blocks
-> sum_rdc is INT_MAX -> No rd update -> should_encode_sb is 0
-> Propagating to top of the tree
-> No partition / mode is selected

Bug: b/290499385
Change-Id: Ia655e262f3b32445347ae0aaf1a2d868cea997f3

9 months agoHandle Arm/AArch64 runtime feature detection
Wan-Teh Chang [Sat, 7 Oct 2023 14:06:36 +0000 (07:06 -0700)]
Handle Arm/AArch64 runtime feature detection

Port the following libaom CLs to libvpx:
https://aomedia-review.googlesource.com/c/aom/+/178361
https://aomedia-review.googlesource.com/c/aom/+/180701
https://aomedia-review.googlesource.com/c/aom/+/181821

The tests themselves are not feature-gated in the same way that they are
used in the rest of the codebase since they are not controlled by
rtcd.pl. This means that tests that assume the existence of features not
present on the target can cause SIGILL to be thrown.

This commit extends init_vpx_test.cc to match the behaviour for other
targets and automatically disable testing for features that are not
available on the machine running the tests.

Call arm_cpu_caps() and x86_simd_caps() inside #if !CONFIG_SHARED.
All the SIMD-specialized functions (arm or x86) are internal functions,
so they are not exported from the libvpx shared library. If
CONFIG_SHARED is 1, it is not necessary to call arm_cpu_caps(),
x86_simd_caps(), and append_negative_gtest_filter() either.

Change-Id: I330631816bdb52842020c5aa2a1ad802865cc285

9 months agoDeclare some "VP8_CONFIG *oxcf" params as const
Wan-Teh Chang [Sun, 1 Oct 2023 00:31:09 +0000 (17:31 -0700)]
Declare some "VP8_CONFIG *oxcf" params as const

Change-Id: Ia5e8445098e18da5978aacf17281f16252413f17

9 months agoVP8: allow thread count changes
Wan-Teh Chang [Sat, 30 Sep 2023 22:50:14 +0000 (15:50 -0700)]
VP8: allow thread count changes

Fix the TODO(https://crbug.com/1486441) comment in vp8/vp8_cx_iface.c.

Make vp8cx_create_encoder_threads() work after it has been called
before. If there are already the exact number of threads it needs to
create, return immediately. Otherwise, shut down the existing threads
(by calling vp8cx_remove_encoder_threads()) and create the required
number of threads.

Call vp8cx_create_encoder_threads() in vp8e_set_config() to respond to
changes in g_threads or g_w (which also affects the number of threads
through cm->mb_cols and cpi->mt_sync_range).

Change-Id: I552eeca5b1f1f5313f59559eb1da396f270a2429

9 months agoVP8: Allocate cpi->mt_current_mb_col array lazily
Wan-Teh Chang [Wed, 4 Oct 2023 02:30:12 +0000 (19:30 -0700)]
VP8: Allocate cpi->mt_current_mb_col array lazily

Add the mt_current_mb_col_size field to VP8_COMP to record the size of
the mt_current_mb_col array.

Move the allocation of the mt_current_mb_col array from
vp8_alloc_compressor_data() to vp8_encode_frame(), where the use of
mt_current_mb_col starts. Allocate mt_current_mb_col right before use
if mt_current_mb_col hasn't been allocated or if the current size is
incorrect.

Move the deallocation of the mt_current_mb_col array from
dealloc_compressor_data() to vp8cx_remove_encoder_threads().

Move the TODO(https://crbug.com/1486441) comment from
vp8/encoder/onyx_if.c to vp8/vp8_cx_iface.c.

Change-Id: Ic5a0793278c2cc94876669aaa0dd732412876673

9 months agoMerge "Clean up vp8cx_create/remove_encoder_threads()" into main
Wan-Teh Chang [Wed, 4 Oct 2023 19:50:20 +0000 (19:50 +0000)]
Merge "Clean up vp8cx_create/remove_encoder_threads()" into main

9 months agoMerge "Use correct include guards for init_vpx_test.h" into main
Jerome Jiang [Wed, 4 Oct 2023 13:42:09 +0000 (13:42 +0000)]
Merge "Use correct include guards for init_vpx_test.h" into main

9 months agoAdd an emms instruction to vpx_subtract_block
Anupam Pandey [Tue, 3 Oct 2023 09:16:36 +0000 (14:46 +0530)]
Add an emms instruction to vpx_subtract_block

This CL adds an `emms` instruction at the end of the MMX assembly
for the vpx_subtract_block function, to properly clear the register
state. This resolves a mismatch between x86 build and C only build.

BUG=webm:1816

Change-Id: I79d2947da7f587f3558a2ae17df214d2faf59e74

9 months agoMerge "vp9_encoder: normalize sizeof() calls" into main
James Zern [Wed, 4 Oct 2023 04:42:16 +0000 (04:42 +0000)]
Merge "vp9_encoder: normalize sizeof() calls" into main

9 months agoMerge "Declare cur_row inside #if CONFIG_MULTITHREAD" into main
Wan-Teh Chang [Wed, 4 Oct 2023 03:50:39 +0000 (03:50 +0000)]
Merge "Declare cur_row inside #if CONFIG_MULTITHREAD" into main

9 months agoMerge "Have vp9_enc_build and vp9_enc_test restore cwd" into main
Wan-Teh Chang [Wed, 4 Oct 2023 03:21:50 +0000 (03:21 +0000)]
Merge "Have vp9_enc_build and vp9_enc_test restore cwd" into main

9 months agoMerge "Fix a potential resource leak and add alloc checks" into main
Wan-Teh Chang [Wed, 4 Oct 2023 03:20:27 +0000 (03:20 +0000)]
Merge "Fix a potential resource leak and add alloc checks" into main

9 months agoClean up vp8cx_create/remove_encoder_threads()
Wan-Teh Chang [Wed, 4 Oct 2023 03:08:18 +0000 (20:08 -0700)]
Clean up vp8cx_create/remove_encoder_threads()

Make vp8cx_create_encoder_threads() undo everything cleanly before
returning an error.

Make vp8cx_remove_encoder_threads() reset pointer fields to NULL after
freeing them, reset encoding_thread_count to 0, and reset b_lpf_running
to 0 (false). This makes it safe to call vp8cx_create_encoder_threads()
after calling vp8cx_remove_encoder_threads().

Change-Id: I586f06ce3d5b1c88ca46884bb4d6667ffc97e440

9 months agoDeclare cur_row inside #if CONFIG_MULTITHREAD
Wan-Teh Chang [Sat, 30 Sep 2023 18:17:30 +0000 (11:17 -0700)]
Declare cur_row inside #if CONFIG_MULTITHREAD

Fix the following compiler warning when libvpx is configured with
the --disable-multithread option:

  vp9/common/vp9_thread_common.c:391:7: warning:
  variable 'cur_row' set but not used [-Wunused-but-set-variable]
    int cur_row;
        ^

Change-Id: I53aa279152715083df40990eb7fdcaeb77a66777

9 months agoUse correct include guards for init_vpx_test.h
Jerome Jiang [Wed, 4 Oct 2023 02:00:02 +0000 (22:00 -0400)]
Use correct include guards for init_vpx_test.h

Bug: b/303112617
Change-Id: Ie18df33b2bcab91c18e920825f4ed3a29e18373b

9 months agoInclude vpx_config.h for macros
Jerome Jiang [Tue, 3 Oct 2023 14:14:43 +0000 (10:14 -0400)]
Include vpx_config.h for macros

Clear some clang-tidy complaints

Change-Id: I6690428d336c81709befd19a33e11c1367275df3

9 months agoFactor out common code used in test binaries
Jerome Jiang [Tue, 3 Oct 2023 13:58:23 +0000 (09:58 -0400)]
Factor out common code used in test binaries

Bug: b/303112617
Change-Id: Icbe16e95ff334a9578a692cc51b4773393ad0005

9 months agoUse big cfg.g_w in ConfigResizeChangeThreadCount
Wan-Teh Chang [Sun, 1 Oct 2023 02:45:35 +0000 (19:45 -0700)]
Use big cfg.g_w in ConfigResizeChangeThreadCount

vp8cx_create_encoder_threads() caps the thread count at
(cm->mb_cols / cpi->mt_sync_range) - 1. If cfg.g_w is 16, cm->mb_cols is
only 1 (see vp8_alloc_frame_buffers: mb_cols = width >> 4), so we won't
be using multiple threads. To reproduce bug chromium:1486441, the test
just needs to increase cfg.g_h sufficiently.

Bug: chromium:1486441
Change-Id: Ie6b2da2e31cfa1717a481f55eebc8c875db94d87

9 months agoMerge "Merge tag 'v1.13.1'" into main
James Zern [Mon, 2 Oct 2023 19:11:51 +0000 (19:11 +0000)]
Merge "Merge tag 'v1.13.1'" into main

9 months agoHave vp9_enc_build and vp9_enc_test restore cwd
Wan-Teh Chang [Thu, 28 Sep 2023 23:35:54 +0000 (16:35 -0700)]
Have vp9_enc_build and vp9_enc_test restore cwd

Use $PWD to get the current directory.

Quote directory pathnames.

Suggested by James Zern.

Bug: webm:1800
Change-Id: I51e922b24da0e89d936370f858eab55d193ebdcb

9 months agoDisable vpx_highbd_8_mse16x16_neon_dotprod, etc.
Wan-Teh Chang [Fri, 29 Sep 2023 23:58:26 +0000 (16:58 -0700)]
Disable vpx_highbd_8_mse16x16_neon_dotprod, etc.

These functions assume the uint16_t samples are <= 255 (bit depth 8),
but vpx_highbd_8_mse16x16() is called for any bit depth, not just 8.

A better fix is to port the libaom CL
https://aomedia-review.googlesource.com/c/aom/+/175063 to libvpx, but
that requires porting aom_sse() and aom_highbd_sse() to libvpx, which is
quite involved. So disable vpx_highbd_8_mse16x16_neon_dotprod, etc.
first.

Bug: webm:1819
Change-Id: If495a5dedc58d9981317b9993c9fbb81ff3ab50c

9 months agoMerge tag 'v1.13.1'
James Zern [Fri, 29 Sep 2023 23:33:29 +0000 (16:33 -0700)]
Merge tag 'v1.13.1'

libvpx 1.13.1

2023-09-29 v1.13.1 "Ugly Duckling"
  This release contains two security related fixes. One each for VP8 and VP9.

  - Upgrading:
    This release is ABI compatible with the previous release.

  - Bug fixes:
    https://crbug.com/1486441 (CVE-2023-5217)
    Fix to a crash related to VP9 encoding (#1642)

* tag 'v1.13.1':
  update CHANGELOG
  update version to 1.13.1
  Fix bug with smaller width bigger size
  vp9_alloccommon: clear allocation sizes on free
  VP8: disallow thread count changes
  encode_api_test: add ConfigResizeChangeThreadCount
  README: update release version to 1.13.0

Bug: webm:1818
Change-Id: I732e2423f635d4115890f00fd63f9886e31f39a6

9 months agovp9_encoder: normalize sizeof() calls
James Zern [Fri, 29 Sep 2023 22:16:46 +0000 (15:16 -0700)]
vp9_encoder: normalize sizeof() calls

use sizeof(var) instead of sizeof(type) and sizeof(*var) instead of
sizeof(var[0]) for consistency in some places.

Change-Id: Ibd9a783cfef5ce1d06131df3831a4093821a502f

9 months agoFix a potential resource leak and add alloc checks
Wan-Teh Chang [Fri, 22 Sep 2023 22:50:17 +0000 (15:50 -0700)]
Fix a potential resource leak and add alloc checks

Backport fixes from libaom:
https://aomedia-review.googlesource.com/c/aom/+/109061
https://aomedia-review.googlesource.com/c/aom/+/158102

Change-Id: Ia9d42d474be2898f9ae2fdc28606273377da3e90

9 months agoupdate CHANGELOG
James Zern [Fri, 29 Sep 2023 18:32:27 +0000 (11:32 -0700)]
update CHANGELOG

Bug: webm:1818
Change-Id: Ic0a943b5d1c69a3621ad3f91012fb5308a0c11f1

9 months agoupdate version to 1.13.1
James Zern [Fri, 29 Sep 2023 18:21:35 +0000 (11:21 -0700)]
update version to 1.13.1

SO_VERSION_MAJOR = 8
SO_VERSION_MINOR = 0
SO_VERSION_PATCH = 1

The increase of the patch number corresponds to the revision number in
the libtool text.

3. If the library source code has changed at all since the last update,
then increment revision (‘c:r:a’ becomes ‘c:r+1:a’).

Bug: webm:1818
Change-Id: Ia114368e9fd7a908e7fcf6e4d3142f142770e3f4

9 months agoFix bug with smaller width bigger size
Jerome Jiang [Thu, 30 Jun 2022 17:48:56 +0000 (13:48 -0400)]
Fix bug with smaller width bigger size

Fixed previous patch that clusterfuzz failed on.

Local fuzzing passing overnight.

Bug: webm:1642
Change-Id: If0e08e72abd2e042efe4dcfac21e4cc51afdfdb9
(cherry picked from commit 263682c9a29395055f3b3afe2d97be1828a6223f)

9 months agovp9_alloccommon: clear allocation sizes on free
James Zern [Tue, 27 Jun 2023 02:06:51 +0000 (19:06 -0700)]
vp9_alloccommon: clear allocation sizes on free

This fixes reallocations (and avoids potential crashes) if any
allocations fails and the application continues to call
vpx_codec_decode().

Found with vpx_dec_fuzzer_vp9 & Nallocfuzz
(https://github.com/catenacyber/nallocfuzz).

Bug: webm:1807
Change-Id: If5dc96b73c02efc94ec84c25eb50d10ad6b645a6
(cherry picked from commit 02ab555e992c191e5c509ed87b3cc48ed915b447)

9 months agoUpdate 32-bit version of horizontal_add_uint32x2
Wan-Teh Chang [Fri, 29 Sep 2023 17:35:20 +0000 (10:35 -0700)]
Update 32-bit version of horizontal_add_uint32x2

The code was originally added in
https://aomedia-review.googlesource.com/c/aom/+/162267
by Jonathan Wright.

Change-Id: Iafd9e31d82abe22387e0d68f02c7ab81e85367ed

9 months agoProperly determine end of sequence
Cheng Chen [Fri, 29 Sep 2023 00:47:54 +0000 (17:47 -0700)]
Properly determine end of sequence

When the next frame is null and the current frame is an overlay
frame, which is equivalent to there is an active alt ref frame,
we call this an end of sequence.

Change-Id: I49c2cf7a001df98aff8b62ba034317e408274bd4

9 months agoMerge "vp9_c_vs_simd_encode: Restore cwd at end of test" into main
Wan-Teh Chang [Thu, 28 Sep 2023 17:52:22 +0000 (17:52 +0000)]
Merge "vp9_c_vs_simd_encode: Restore cwd at end of test" into main

9 months agoMerge "Fix bug with smaller width bigger size" into main
Jerome Jiang [Thu, 28 Sep 2023 17:39:23 +0000 (17:39 +0000)]
Merge "Fix bug with smaller width bigger size" into main

9 months agovp9_c_vs_simd_encode: Restore cwd at end of test
Wan-Teh Chang [Thu, 28 Sep 2023 15:58:36 +0000 (08:58 -0700)]
vp9_c_vs_simd_encode: Restore cwd at end of test

Restore the original current directory at the end of
vp9_c_vs_simd_enc_test().

Bug: webm:1800
Change-Id: Iad64848a231e3c900149cc2b248055b02dda80a6

9 months agoSkip the y4m_360p_10bit_input clip for armv8
Wan-Teh Chang [Wed, 27 Sep 2023 23:12:12 +0000 (16:12 -0700)]
Skip the y4m_360p_10bit_input clip for armv8

It is a known mismatch.

Bug: webm:1819
Change-Id: Ieb707a6f53ddf6c7b0d1202c6520599d3e45da76

9 months agoMerge "Modify vp9_c_vs_simd_enc_test script" into main
Yunqing Wang [Wed, 27 Sep 2023 20:33:39 +0000 (20:33 +0000)]
Merge "Modify vp9_c_vs_simd_enc_test script" into main

9 months agoFix bug with smaller width bigger size
Jerome Jiang [Thu, 30 Jun 2022 17:48:56 +0000 (13:48 -0400)]
Fix bug with smaller width bigger size

Fixed previous patch that clusterfuzz failed on.

Bug: webm:1642
Change-Id: If0e08e72abd2e042efe4dcfac21e4cc51afdfdb9

9 months agoVP8: disallow thread count changes
James Zern [Tue, 26 Sep 2023 01:55:59 +0000 (18:55 -0700)]
VP8: disallow thread count changes

Currently allocations are done at encoder creation time. Going from
threaded to non-threaded would cause a crash.

Bug: chromium:1486441
Change-Id: Ie301c2a70847dff2f0daae408fbef1e4d42e73d4
(cherry picked from commit 3fbd1dca6a4d2dad332a2110d646e4ffef36d590)

9 months agoencode_api_test: add ConfigResizeChangeThreadCount
James Zern [Tue, 26 Sep 2023 01:53:41 +0000 (18:53 -0700)]
encode_api_test: add ConfigResizeChangeThreadCount

Update thread counts and resolution to ensure allocations are updated
correctly. VP8 is disabled to avoid a crash.

Bug: chromium:1486441
Change-Id: Ie89776d9818d27dc351eff298a44c699e850761b
(cherry picked from commit af6dedd715f4307669366944cca6e0417b290282)

9 months agoModify vp9_c_vs_simd_enc_test script
Yunqing Wang [Thu, 21 Sep 2023 20:49:09 +0000 (13:49 -0700)]
Modify vp9_c_vs_simd_enc_test script

Applied James' change to the script. Enabled the test:
vp9_c_vs_simd_enc_test

BUG=webm:1800

Change-Id: If1e33e5ccb6ca9315004f3e3f5b910f8a8255317

9 months agoVP8: disallow thread count changes
James Zern [Tue, 26 Sep 2023 01:55:59 +0000 (18:55 -0700)]
VP8: disallow thread count changes

Currently allocations are done at encoder creation time. Going from
threaded to non-threaded would cause a crash.

Bug: chromium:1486441
Change-Id: Ie301c2a70847dff2f0daae408fbef1e4d42e73d4

9 months agoencode_api_test: add ConfigResizeChangeThreadCount
James Zern [Tue, 26 Sep 2023 01:53:41 +0000 (18:53 -0700)]
encode_api_test: add ConfigResizeChangeThreadCount

Update thread counts and resolution to ensure allocations are updated
correctly. VP8 is disabled to avoid a crash.

Bug: chromium:1486441
Change-Id: Ie89776d9818d27dc351eff298a44c699e850761b

10 months agoDo not call WebM RC for new GOP at the end of seq
Jerome Jiang [Thu, 21 Sep 2023 19:26:01 +0000 (15:26 -0400)]
Do not call WebM RC for new GOP at the end of seq

define_gf_group is called at the last frame of each GOP to get GOP size
for next one, which means it'll also be called at the last GOP of the
sequence, when calling WebM RC will be returned with error since WebM RC
does not have any more GOP to return.

When gop_coding_frames from the encoder is 1, it means it's running out
of firstpass stats, which means end of sequence.

Bug: b/299610956
Change-Id: I30e077a28fe41593ebabbc1dc0c2915a4bcbece3

10 months agoaarch64: Generalize Windows cpu detection to any Windows variant
Martin Storsjo [Fri, 15 Sep 2023 09:29:32 +0000 (12:29 +0300)]
aarch64: Generalize Windows cpu detection to any Windows variant

This cpu detection implementation doesn't do anything MSVC specific,
it just calls the IsProcessorFeaturePresent function. This can be
compiled with mingw compilers just as well.

Change-Id: I55e607a47c8f5b70d9f707ef96b2fa7553f2f79f

10 months agoAdd max/min_gf_interval to vpx_rc_config_t
Jerome Jiang [Thu, 14 Sep 2023 20:04:19 +0000 (16:04 -0400)]
Add max/min_gf_interval to vpx_rc_config_t

Bug: b/300499738
Change-Id: Id32cb5e3ce667539c0d1efe1ff5fcc7a49e35329

10 months agoFix ref frame buffer in TPL stats for RC
Jerome Jiang [Thu, 14 Sep 2023 17:27:39 +0000 (13:27 -0400)]
Fix ref frame buffer in TPL stats for RC

The original ref frame index was the index in the GF group; RC expects
the index to be the one for ref frame buffer.

Change-Id: I9a2b0e72b6332023fb2e8da131b557f82db02e39

10 months agoSet frame width height for 1st TPL GOP frame
Jerome Jiang [Thu, 14 Sep 2023 15:59:57 +0000 (11:59 -0400)]
Set frame width height for 1st TPL GOP frame

Change-Id: Ic92dfd232bf90e8cbe6c6233af523ed40d12097a