Compare commits

..

385 Commits

Author SHA1 Message Date
hui su
be407e001b Adjust optimize_b RD parameters
Coding gain
lowres 0.51%
midres 0.36%

Change-Id: I1e9f2f9341bad12d9023f97c73d0e991ae5ec7f0
2016-05-06 09:56:59 -07:00
hui su
5af706210b Enable optimize_b for intra blocks
Coding gain
lowres 0.13%
midres 0.36%

Change-Id: Ia65d2d7513685dfcffbe3939fea473fb6d7036b9
2016-05-06 09:55:45 -07:00
Geza Lore
6d9bec4366 Configure tiles in tests when using row-tile.
With row-tile enabled, the encoder test driver needs to configure the
decoder in order to decode all tiles correctly.

Change-Id: I8b00a766cf5e41255625846f92fd71915c614ec1
2016-05-03 14:42:17 -07:00
Debargha Mukherjee
7a2934550b Merge "Quantization Profiles Strictly on Entropy Context" into nextgen 2016-05-02 19:15:13 +00:00
Brandon Young
43195061b7 Quantization Profiles Strictly on Entropy Context
Allow for 3 quant profiles from entropy context

Refactored dq_offset bands to allow for re-optimization based on number
of quantization profiles

Change-Id: Ib8d7e8854ad4e0bf8745038df28833d91efcfbea
2016-05-01 12:25:57 -07:00
Sarah Parker
b8bf8085be Merge "Search parameter space around gm parameters" into nextgen 2016-04-26 22:08:20 +00:00
Sarah Parker
31257e5406 Merge "Make feature based motion estimation the default" into nextgen 2016-04-22 01:21:09 +00:00
Sarah Parker
ba6423c564 Make feature based motion estimation the default
Optical flow parameters still need to be tweaked and is much slower
so feature based should be the default for now.

Change-Id: Id6cafb5a245e329f728e9c66c89c0ed1018c347c
2016-04-21 11:50:05 -07:00
Sarah Parker
70266ab130 Increase precision for gm parameters
Change-Id: I151ca8ec9b0c8a920745f4b1665d369a258f6ccb
2016-04-21 11:48:13 -07:00
Sarah Parker
7fa7f4c14a Fix comipler warnings in opticalflow.c
Change-Id: I4561c2676d8a7793ade47e1995e026ba9d521fdd
2016-04-20 17:27:13 -07:00
Debargha Mukherjee
3e3f40acb9 Fix for libwebm upgrade
To allow runborgs to run on the nextgen branch

Change-Id: Icbd425c5e65dd4bcb061a3a1ed4dbe0393dc2c5d
2016-04-19 10:27:42 -07:00
Sarah Parker
de085787ec Search parameter space around gm parameters
For each global motion parameter, search some step
size to the left and right to try and minimize warp
mse and correct for error.

Change-Id: I1f0b464b0924d56b15460e509f89736af9b7e78f
2016-04-13 17:56:25 -07:00
Brandon Young
50619bacfd Fix error with cumbins to allow multiple profiles
Change-Id: I23aadc8f7551771197b55465a3264250b40838ff
2016-04-08 13:16:34 -07:00
Debargha Mukherjee
72ee991598 Adds function to return superblock entropy context
For use with switchable quant profiles.

Change-Id: I2a4aa93204f086094457860d1646707d71f33f5e
2016-03-15 14:27:45 -07:00
Debargha Mukherjee
a399281daa Merge "Framework to incorporate switchable dequant levels" into nextgen 2016-03-14 16:34:04 +00:00
Debargha Mukherjee
b8a7d1fe02 Framework to incorporate switchable dequant levels
Changed experiment to allow switchable QUANT_PROFILES

Change-Id: I8e5e76239a4103273e9ef759d46400104ef55599
2016-03-11 23:07:26 -08:00
Geza Lore
d8739359a1 Make vpxenc --test-decode work with --enable-row-tile
Change-Id: I352c8ccdaa5faa4fd345f0cb0f7e614af669f0bc
2016-02-29 14:14:16 +00:00
Debargha Mukherjee
f90038c3a1 Remove key_frame_tile config option
Change-Id: I8ae22e9f706727ee258dc24780644b99087c8d23
2016-02-23 13:07:09 -08:00
Debargha Mukherjee
fb6bf251d4 Merge key_frame_tile experiment with row_tile
Since they are used together no need to keep them separate.

Change-Id: Ia7b4bec06ca6924fffd806f772638224292fddb2
2016-02-23 09:57:25 -08:00
Yunqing Wang
efb93f518f Merge "Implement a tile copying method in large-scale tile coding" into nextgen 2016-02-05 23:10:08 +00:00
Yunqing Wang
6e4dff92a4 Implement a tile copying method in large-scale tile coding
A tile copy mode is introduced, while allows a tile to use
another tile's coded data directly at bitstream level. This
largely reduces the bit rate in this use case. Our tests
showed that 10% - 20% bit rate reduction was achieved.

Change-Id: Icf5ae00320e27193b15ce95297720f8b6f5e7fd9
2016-02-01 11:08:30 -08:00
Sarah Parker
36cbc27587 Merge "Optical flow for computing global motion params" into nextgen 2016-01-25 22:06:32 +00:00
Yunqing Wang
990e30b8a7 Merge "Make set_reference control API work in VP9" into nextgen 2016-01-25 19:27:42 +00:00
Yunqing Wang
bcdc6befd2 Make set_reference control API work in VP9
1. Made VP8_SET_REFERENCE vpx_codec_control API work in VP9 based
on Ryan Overbeck's patch. (Thanks.)
2. Added vp9cx_set_ref example, which demonstrated how to set
VP8_SET_REFERENCE vpx_codec_control in encoder and decoder. If
we only set_reference in the encoder, the encoder/decoder
mismatch would be observed.
3. Also updated test/cx_set_ref.sh.

Change-Id: I433a6220616947ca8c73e65a5fb3694751ea84b6
2016-01-25 10:37:15 -08:00
Sarah Parker
a7aab42915 Optical flow for computing global motion params
Addressing comments, fixing style issues

Change-Id: I91b72ab5cdf80d68476858f442616ab3af41e709
2016-01-22 11:29:33 -08:00
Debargha Mukherjee
b765dc8e39 Merge "Changes to CONFIG_NEW_QUANT experiment." into nextgen 2016-01-22 00:15:05 +00:00
Brandon Young
9c9beb1c40 Changes to CONFIG_NEW_QUANT experiment.
Added dq_off_index attribute to mbmi to allow for switching between
dequantization modes.
Reduced number of different dequantization modes from 5 to 3.
Changed dequant_val_nuq to be allow for 3 dequant levels instead of 1.
Fixed lint errors

Change-Id: I7aee3548011aa4eee18adb09d835051c3108d2ee
2016-01-19 15:59:50 -08:00
Debargha Mukherjee
c20adb59b2 Merge "Rework wedge experiment to improve speed." into nextgen 2016-01-14 16:13:38 +00:00
Brandon Young
839ab586f6 Merge "Simplify new_quant experiment" into nextgen 2016-01-14 00:51:56 +00:00
Debargha Mukherjee
f93bdebcf9 Rework wedge experiment to improve speed.
Implements wedge mask generation by pre-computing arrays.
Improves encode speed by 15-20%.

Also consolidates the mask generation code for inter-inter
and inter-intra.

Change-Id: If1d4ae2babb2c05bd50cc30affce22785fd59f95
2016-01-12 15:23:54 -08:00
Yunqing Wang
15a90668a5 Adaptively determine the number of bytes used for tile-data size transmission
In large-scale tile coding, when the number of tiles is large and the tile
size is small, using a fixed number of bytes in the tile header to store
tile-data size information as done in current VP9 codec would bring high
overhead for each tile. This patch implemented 2 ways to lower that overhead
and adaptively determine the number of bytes needed for tile-data size
transmission.

The test on a test clip having the tile size of 64x64 showed that the number
of bytes used for storing tile-data size was reduced from 4 to 1, which
substantially improved the compression ratio in large-scale tile coding.

Change-Id: Ia02fc43eda67fa252fbc2554321957790f53f6fd
2016-01-11 12:46:04 -08:00
Brandon Young
604b909e06 Simplify new_quant experiment
Changes number of non-uniform bins from 5 to 3.
Changed all references to 'KNOTES' to 'KNOTS'.

Change-Id: If39d7cef00dbe07307035e44cb29194d0783b475
2015-12-17 12:25:27 -08:00
Debargha Mukherjee
e6790e30c5 Replace DST1 with DST2 for ext-tx experiment
A small gain (0.1 - 0.2%) with this experiment on derflr/hevcmr.

The DST2 can be implemened very efficiently using sign flipping
of odd indexed inputs, followed by DCT, followed by reversal of
the output. This is how it is implemented in this patch.
SIMD optimization is pending.

Change-Id: Ic2fc211ce0e6b7c6702974d76d6573f55cc4da0e
2015-12-14 13:54:41 -08:00
Debargha Mukherjee
d7eb423a72 Merge "SSSE3 optimisations of high bit depth masked variance functions" into nextgen 2015-12-08 21:54:03 +00:00
Peter de Rivaz
087a93eae5 Fix to avoid overflow in highbd_masked_variance64.
Change-Id: I98731c5f50c4821c604f53480f43110a75205d25
2015-12-08 11:12:35 -08:00
Julia Robson
711600e5f1 SSSE3 optimisations of high bit depth masked variance functions
Includes tests which compare output of new SSSE3 functions with
their C equivalents, and fixes to the C code to ensure these tests
pass.

Change-Id: Iec3980cce95a8ee6bf9421fa4793130e92c162e3
2015-12-04 11:59:30 -08:00
Julia Robson
997595e8a6 Code refactoring to remove duplication in masked sub pixel var fns
Change-Id: Idcc93ff94ed2c68367225b6bebfcae0b7952f074
2015-12-03 17:57:35 +00:00
Yunqing Wang
9227a372d3 Merge "Reduce the memset call in tile decoding" into nextgen 2015-12-02 00:24:06 +00:00
Julia Robson
ea167a5855 Adding SSSE3 accelerations of masked SAD functions
Includes tests of masked SAD function optimisations against C
versions

Change-Id: I42f198767a113b58ae9456841f4ec71075591720
2015-12-01 09:55:24 -08:00
Julia Robson
8e4d779137 SSSE3 optimisations of masked variance function (8bit ONLY)
Includes test which compares output of new SSSE3 functions with their
C equivalents

Change-Id: I4488cd7672cdb57efff93c0b3b8bff07f07ec544
2015-12-01 12:07:22 +00:00
Julia Robson
ef01ea152d Changes so other expts work with 128x128 coding unit size expt
Changes ensure wedge_partition, interintra and palette expts all
work alongside the ext_coding_unit_size experiment.

Change-Id: I18f17acb29071f6fc6784e815661c73cc21144d6
2015-11-26 17:43:00 +00:00
Yunqing Wang
7099feaeed Reduce the memset call in tile decoding
When the error resilient mode is on, the decoder resets mode info structure
to zero once per frame. This makes decoder about 10x slower if we decode
a single tile at a time. This patch resolves the issue by only memset mode
info of those decoded tiles. Currently, to decode a frame, tile decoding is
less than 2x slower than frame decoding.

Change-Id: Ia3fd88d91a4e74e7bbbc6547d87c24d085a1533e
2015-11-25 15:28:03 -08:00
Julia Robson
d52cc33891 Changes to allow 128x128 to work with copy_mode
Change-Id: I1fff46e7733e5e1d15c012d6a204536243c6e090
2015-11-24 10:15:10 -08:00
Peter de Rivaz
d79850e60c Bug fix for high bitdepth using flipped transforms.
Fixes mismatch and performance drop.

Change-Id: Ib99711eb3b78257a8105073e2b6d7031459357bb
2015-11-23 12:04:55 -08:00
Geza Lore
85ab9d56cc Flip the result of the inv transform for FLIPADST.
This is a port of 4f5108090a

This commit also fixes a bug where FLIPADST transforms when combined
with a DST (that is FLIPADST_DST and DST_FLIPADST) did not actually did
a flipped transform but a straight ADST instead. This was due to the C
implementation that it fell back on not implementing flipping.  This is
now fixed as well and FLIPADST_DST and DST_FLIPADST does what it is
supposed to do.

There are 3 functions in the SR_MODE experiment that should be updated,
but given that the build of SR_MODE is broken at the upstream tip of
nextgen, I could not test these, so I have put in assertions and FIXME
notes at the problematic places.

Change-Id: I5b8175b85f944f2369b183a26256e08d97f4bdef
2015-11-17 14:31:28 -08:00
Debargha Mukherjee
f1f3a8ab14 Increase extension for ext-coding-unti-size expt
Change-Id: Ifc7fe5df6831cb7190b9b6e84125de13b9e0146f
2015-11-16 16:57:50 -08:00
Debargha Mukherjee
484c8858f0 Remove last4-ref config option
Change-Id: I12ab2f8b039e328210ae8eadc663f751e19c0c09
2015-11-13 16:22:28 -08:00
Debargha Mukherjee
0c29af2767 Merge last4_ref with multi-ref experiment
Change-Id: I9778670ff6d02fb021099b17f292edadf87603e6
2015-11-13 14:54:38 -08:00
Debargha Mukherjee
ec6d31781d Merge "Remove dst1 config option and merge with ext-tx" into nextgen 2015-11-13 21:01:21 +00:00
Debargha Mukherjee
3a45a1edfd Remove dst1 config option and merge with ext-tx
Change-Id: I0152ed352ae2a0a725a508b5c209ef2c1dc2302d
2015-11-13 11:24:38 -08:00
Julia Robson
3d9133b2a5 SSE2 optim of vp9_subtract_block for 128x128 units
Extending the SSE2 implementation of vp9_subtract_block to work
with the 128x128 coding unit experiment

Change-Id: Ib3cc16bf5801ef2c7eecc19d3cc07a8c50631580
2015-11-13 11:12:56 -08:00
Debargha Mukherjee
3436acb347 Merge "Adding encoder support for 128x128 coding units" into nextgen 2015-11-13 18:52:09 +00:00
Debargha Mukherjee
a542190830 Merge "Eliminate copying for FLIPADST in fwd transforms." into nextgen 2015-11-13 18:23:49 +00:00
Geza Lore
177ad11981 Eliminate copying for FLIPADST in fwd transforms.
This is a port of 01bb4a318d

This commit also fixes a bug where FLIPADST transforms when combined
with a DST (that is FLIPADST_DST and DST_FLIPADST) did not actually did
a flipped transform but a straight ADST instead. This was due to the C
implementation that it fell back on not implementing flipping.  This is
now fixed as well and FLIPADST_DST and DST_FLIPADST does what it is
supposed to do.

Change-Id: I89c67ca1d5e06808a1567c51e7d6bec4998182bd
2015-11-13 09:34:26 -08:00
Debargha Mukherjee
59de0c0bc7 Adding encoder support for 128x128 coding units
Changes to allow the encoder to make use of 128x128 coding units.

Change-Id: I340bd38f9d9750cb6346d83885efb00443852910
2015-11-13 09:21:22 -08:00
Debargha Mukherjee
9d9962aec9 Some fixes on context size for the 128x128 expt
Change-Id: I56f050502e3a750ce74b196d033b780218df2c1f
2015-11-13 07:06:19 -08:00
Johann Koenig
a0c13e6757 Merge "Cherry pick the rest of 661802, the important part" into nextgen 2015-11-13 00:47:05 +00:00
Julia Robson
d90a3265f0 Changes to use defined constants rather than hard-coded numbers
Also fixes a valgrind error when optimizations are disabled.
Done in preparation for the work on the extended coding unit size
experiment.

Change-Id: Ib074c5a02c94ebed7dd61ff0465d26fa89834545
2015-11-12 15:42:32 -08:00
Johann
a877c6e9a6 Cherry pick the rest of 661802, the important part
Change-Id: I85f1d2c07b89c874ea6c30df32dda9ecaa8d2c3f
2015-11-12 15:41:24 -08:00
Debargha Mukherjee
bd7a34d5a3 Merge "Fixing issue with calculation of block_idx" into nextgen 2015-11-12 23:39:35 +00:00
Johann
26272dd366 Cherry pick 661802 to fix 64bit arm build
Remove default cortex-a8 tuning.

Probably not even the dominant platform the library is being built for.
Add --cpu= option description to help. The option already exists.

Don't allow passing just --cpu as a no-op.

BUG=826

Change-Id: Iaa3f4f693ec78b18927b159b480daafeba0549c0
2015-11-12 14:51:53 -08:00
Julia Robson
598a11d04a Fixing issue with calculation of block_idx
For tall rectangular blocks, the block_idx of the lower transform
block was being mis-calculated.

Does not affect results the way this function is being used now.

Change-Id: I470464d19be0bf0f42003d0cc29793bc42db8f52
2015-11-12 08:21:53 -08:00
Julia Robson
84a5403bab Added decoder support for 128x128 coding units
Change-Id: Icf3c6b64caaf8a86cd27231aa27baf5fd99c0fde
2015-11-02 16:03:30 +00:00
Julia Robson
2a1f8c74aa Changes to use defined constants rather than hard-coded numbers
These changes have been made in preparation for the work on the
extended coding unit size experiment.

Change-Id: I83f289812426bb9aba6c4a5fedd2b0e0a4fe17cb
2015-11-02 16:02:55 +00:00
Sarah Parker
42abac9374 Fixed final style issues
WIP.

Change-Id: Iafcbcfdc2139e77eb2c6849a52a9dc94ea498d66
2015-10-27 18:39:54 -07:00
Debargha Mukherjee
9ef4023569 Remove some unused variables
Change-Id: I3ab263b4c42cc3bfd598a1fc280fbaffba2d4461
2015-10-15 12:50:15 -07:00
Julia Robson
dff4e683fd Added extended coding unit size experiment
Change-Id: I45e2efe22c8e2f23e3305d00906bc08229a85c17
2015-10-07 16:54:10 +01:00
Debargha Mukherjee
9fc51184b7 Merge "Speed up of wedge search" into nextgen 2015-10-06 00:33:50 +00:00
Debargha Mukherjee
597204298a Speed up of wedge search
Speeds up wedge search by pre-calculating single predictions
before computing the wedge combination.

About 20% speed up achieved.

Change-Id: I72f76568559d1899c8ac0afaa133d433ba388e6d
2015-10-04 23:43:25 -07:00
Debargha Mukherjee
ff6a66a0b2 Merge "tx64 prob tweaks." into nextgen 2015-10-03 17:59:54 +00:00
Debargha Mukherjee
b80a04bd63 tx64 prob tweaks.
A little improvement in results on hevchd

Change-Id: Ib71a57c4bec34bf688e1d53dbf73eb4525e7805b
2015-10-02 11:44:02 -07:00
Debargha Mukherjee
ff9aa146cb Reimplementatio of dst1 for speed
Encoder with --enable-ext-tx --enable-dst1 is now 4 times faster.

Change-Id: Ia750ad3516698ce94da4ceb566b1c51539537a95
2015-10-02 11:06:55 -07:00
Debargha Mukherjee
4f371ac4f2 Merge "64x64 idct fix." into nextgen 2015-09-25 23:36:42 +00:00
Zoe Liu
90dede3f5b Merge "Merged LAST2 and LAST3 to one experiment MULTI_REF" into nextgen 2015-09-25 16:47:28 +00:00
Debargha Mukherjee
5a25d567d7 64x64 idct fix.
Change-Id: If0e0cd7cbe71e9586657f5e8ffa87dcdebc686ba
2015-09-25 05:54:23 -07:00
Debargha Mukherjee
1e2cbf515e Merge "tx64x64 experiment fix for high-bitdepth" into nextgen 2015-09-25 03:22:54 +00:00
Zoe Liu
e8e58402f0 Merged LAST2 and LAST3 to one experiment MULTI_REF
Change-Id: I220be17af317520dccb62fa6b19da5c7ce10652d
2015-09-24 17:08:15 -07:00
Zoe Liu
a9900eb2b1 Merge "Added another reference frame LAST4_FRAME" into nextgen 2015-09-24 15:58:22 +00:00
Debargha Mukherjee
cdcebfba29 tx64x64 experiment fix for high-bitdepth
Change-Id: Ia8d769b43bad0f9ad0684ecf6925e580339c7397
2015-09-24 05:45:03 -07:00
Zoe Liu
829dbf7a79 Added another reference frame LAST4_FRAME
Under the experiment of CONFIG_LAST4_REF. On derflr testset, using
highbitdepth (HBD), in average PSNR,

(1) LAST2+LAST3+LAST4 obtained +0.361% against LAST2+LAST3;
(2) LAST2+LAST3+LAST4 obtained +1.567% against baesline.

Change-Id: Ic8b14272de6a569df2b54418fa72b505e1ed3aad
2015-09-23 17:10:44 -07:00
hui su
71d0af90f8 Adjust rd calculation in choose_tx_size_from_rd
Change-Id: I3649f28196a87663b116b9fe6446b1fbe6eeab4a
2015-09-23 14:37:45 -07:00
Zoe Liu
411c490bc3 Improved LAST3's single ref prob context design a little
On derflr testset, using 12-bit HightBitDepth mode, this CL obtained a
small gain of +0.031% by turning on LAST2+LAST3.

Change-Id: Ib6c9d595e56269634bf29d684eabcd806fc08cc9
2015-09-21 15:03:43 -07:00
Zoe Liu
9144967ca8 Fixed a couple of bugs for LAST3
Change-Id: I63126a844c255df4a447aac7f630ba54cc7d7d7a
2015-09-21 11:50:35 -07:00
Zoe Liu
c0889b9a8c Added a 3rd reference frame LAST3_FRAME
Under experiment CONFIG_LAST3_REF, which can only be turned on when
the experiment of CONFIG_MULTI_REF is on, i.e. LAST3_FRAME can only
be used when LAST2_FRAME is used. CONFIG_LAST3_REF would most likely
be combined with CONFIG_MULTI_REF once the performance improvement
is further confirmed.

On the testset of derflr, using Average PSNR metrics, with HighBitDepth
(HBD) on:

(1) LAST2 HBD obtained +0.579% against base HBD;
(2) LAST2 + LAST3 HBD obtained +0.591% against LAST2 HBD;
(3) LAST2 + LAST3 HBD obtained +1.173% against base HBD.

Change-Id: I1aa2b2e2d2c9834e5f8e61bf2d8818c7b1516669
2015-09-18 15:25:46 -07:00
Debargha Mukherjee
b6d5b0838b ext-tx extension to intra blocks
derflr: improves to 1.692%

Change-Id: Idf583216b40ed02526b9b39031eaf2fb72fed11d
2015-09-17 14:21:24 -07:00
Debargha Mukherjee
c104998b61 Merge "Redo DST1 in the ext-tx experiment" into nextgen 2015-09-16 18:38:03 +00:00
Debargha Mukherjee
4dbaf9a5ab Redo DST1 in the ext-tx experiment
Moved from nextgenv2 branch to test with other experiments.

derflr: +1.629%

Change-Id: Ie7c720053ed8b628177679c4351bb31b54716a71
2015-09-16 09:46:13 -07:00
Zoe Liu
9b0635fc75 Fixed a bug on the number of MAX_MODES in baseline
All the numbers of MAX_MODES have been changed assuming
CONFIG_MULTI_REF. Now correct numbers have been put in for both with and
without the enabling of the experiment MULTI_REF.

Change-Id: I70ffe2f1a89fa572d612dd3d311d3af19fe3a632
2015-09-15 14:12:12 -07:00
Zoe Liu
f48a159430 Added more LAST2 modes for INTERINTRA
Turning on all the other experiments, compared the RD performance
between with and without the use of LAST2_FRAME, on derflr testset,
on Average PSNR:

8-bit: +0.653% (All positive except one,
max: mobile_cif: 2.019%; min: paris_cif: -0.081%)
12-bit HBD: +0.735% (All positive,
max: bridge_far_cif: 2.416%; min: bowing_cif: 0.132%)

Change-Id: Ia0a375667e228c8ba3d2e223abff608206f2f545
2015-09-15 11:57:18 -07:00
Zoe Liu
ec8864a8bf Added MACRO for reference frame encoding
This CL introduces a few macros plus code cleaning on the encoding of
the reference frames. Coding performance remains unchanged.

For the encoding of either the compound reference or the single reference
case, since each bit has different contexts, the tree structure may not
be applied to treat the combined bits as one symbol. It is possible we may
explore the sharing of the same context for all the bits to introduce
the use of tree structure for the next step.

Change-Id: I6916ae53c66be1a0b23e6273811c0139515484df
2015-09-11 14:57:31 -07:00
Zoe Liu
897192be43 Added one more reference frame LAST2_FRAME
Under the experiment CONFIG_MULTI_REF. Current version shows
LAST2 vs base in nextgen on the testset of derflr:

(1) 8-bit: Average PSNR +0.53%
(worst: students_cif: -0.247%; best: mobile_cif: 1.902%)
(2) 12-bit HBD: Average PSNR +0.63%
(worst: pamphlet_cif: -0.213%, best: mobile_cif: 2.101%)

More tuning on the reference frame context design and default
probs are being conducted. This version does not guarantee to
work with other experiments in nextgen. A separate CL will address
the working with all other experiments.

Change-Id: I7f40d2522517afc26ca389c995bad56989587f65
2015-09-09 14:27:05 -07:00
Shunyao Li
2de18d1fd2 Super resolution mode (+CONFIG_SR_MODE)
CONFIG_SR_MODE=1, enable SR mode
USE_POST_F=1, enable SR post filter
SR_USE_MULTI_F=1, enable SR post filter family
Not compatible with other experiments yet

Change-Id: I116f1d898cc2ff7dd114d7379664304907afe0ec
2015-08-31 15:29:39 -07:00
Shunyao Li
c7d886d96a Add transform size rate for intra skip mode in rdopt
Change-Id: I81fedd99cd39c12b66b93b786cb43234c867b84b
2015-08-31 11:28:27 -07:00
Debargha Mukherjee
9c685602d0 Make tests work with new configurations
Disables some test vector tests when Vp8/Vp9 decoders are disabled
in configuration. Also moves some macros to the vpx level in
line with recent refactoring on the master branch.

Change-Id: Iaac8008992110398ae096c36b9726f723164c207
2015-08-27 14:05:59 -07:00
Debargha Mukherjee
4525961d80 Some tweaks to probabilities for ext-tx with dst1
derflr: up to 1.429% from a little less than 1.3% when
--enable-dst1 is also enabled with --enable-ext-tx.

Change-Id: I301229f2239b18acb96accc4fc44b64fa6927ace
2015-08-12 14:31:31 -07:00
hui su
d5eaca7fee code cleanup in encode_block_intra
Change-Id: I376b7e9b243178d79141a96e0aeafcbc15758e97
2015-07-30 15:28:51 -07:00
Cheng Chen
cc4d523d9f Resolve bug of DST1 in ext_tx experiment.
Change-Id: I828569e3596f9b9e8487aec7c4056e66cf1fc1f2
2015-07-28 10:58:14 -07:00
Debargha Mukherjee
23690fc5d1 Adds support for DST1 transforms for inter blocks
Adds an additional transform in the ext_tx experiment that
is a 2d DST1-DST1 combination.

To enable use --enable-ext-tx --enable-dst1.

This needs to be later extended to combine DST1 with DCT
or ADST.

Change-Id: I6d29f1b778ef8294bcfb6a512a78fc5eda20723b
2015-07-24 16:23:09 -07:00
Shunyao Li
188087202c Speed up of supertx
Limited the prediction extension to 8 pixels at each edge
Fixed a bug in the combination of wedge prediction and supertx

~10% speed up in decoder
derflr:     -0.004
derflr+hbd: +0.002
hevcmr:     +0.015

Change-Id: I777518896894a612c9704d3de0e7902bf498b0ea
2015-07-24 11:19:19 -07:00
Debargha Mukherjee
4b57a8b356 Add extended transforms for 32x32 and 64x64
Framework for alternate transforms for inter 32x32 and larger based
on dwt-dct hybrid is implemented.
Further experiments are to be condcuted with different
variations of hybrid dct/dwt or plain dwt, as well as super-resolution
mode.

Change-Id: I9a2bf49ba317e7668002cf1499211d7da6fa14ad
2015-07-23 18:01:22 -07:00
Yunqing Wang
7959dd012c Nextgen branch cleanup: remove elevate_newmv_thresh feature
Code cleanup.

Change-Id: Idf00d5359e5f3d943ee39b4a00f8d40325c0f8b3
2015-07-14 14:28:56 -07:00
Yunqing Wang
527f88316c Nextgen branch cleanup: remove real-time speed features
Removed inter_mode_mask and max_intra_bsize.

Change-Id: I835d31f95af64a524b2fdb685d1d09a6b0ad5c9f
2015-07-14 14:26:17 -07:00
Yunqing Wang
6c2035744a Merge "Nextgen branch cleanup: add back some SVC functions" into nextgen 2015-07-08 23:26:35 +00:00
Yunqing Wang
da013eed3f Nextgen branch cleanup: add back some SVC functions
Several SVC functions were added back to ensure Borg test build.

Change-Id: I2cff676407fa74e2255606094ff12bd840287b6d
2015-07-08 14:13:57 -07:00
Zoe Liu
08effeaad5 A small code cleanup for the encoder workflow.
Change-Id: I543a69ad5a34cd9a0671b57131cafc541d595d9a
2015-07-08 12:12:47 -07:00
Alex Converse
7932eb014e Merge "intrabc: Allow odd pel displacement for non-444" into nextgen 2015-07-08 04:06:24 +00:00
Shunyao Li
e8885d4a50 Merge "Optimize bilateral filter to improve speed" into nextgen 2015-07-07 20:17:13 +00:00
Yunqing Wang
ca42973ea2 Nextgen branch cleanup: remove svc code
Spatial/temporal svc code was removed.

Change-Id: Ie25c7a58ee5feb662d4de526406d8cd834d19977
2015-07-06 21:19:05 -07:00
Yunqing Wang
020293588d Nextgen branch cleanup: remove unused functions
Removed unused real-time functions.

Change-Id: I0cbcee67fb8f495f87c6330e04ed6d56ed8e2625
2015-07-06 12:07:33 -07:00
Yunqing Wang
cc6dc0b7d9 Nextgen branch cleanup: remove nonrd code
Code cleanup.

Change-Id: I4d8d7fa2fc61a58b819c9a18bf25cda53e3fd88c
2015-07-06 10:03:23 -07:00
Alex Converse
5241acf6e2 intrabc: Allow odd pel displacement for non-444
intrabc:
screen_content: -0.618 derflr: +0.015

intrabc+tx_skip+palette:
screen_content: -0.124 derflr: -0.048

Change-Id: Iabea4be19dce2f6fdab8f639e585a424c90c81b4
2015-06-30 10:11:46 -07:00
Shunyao Li
dac589d6d4 Optimize bilateral filter to improve speed
Optimization of bilateral filter:
1) Pre-calculate the bilateral filters at all the
levels at the initialization.
2) Convert 1D matrix to 2D matrix, avoid too many
multiplications in the bilateral filter loop.
3) Fix a bug in "loop_bilateral_filter_highbd".
The right-shifted range index can be larger than 255.

Change-Id: I42f6177e896706948e2403bd9edce46e3eb5cbf8
2015-06-29 14:48:59 -07:00
Alex Converse
a4f4ed60cf Merge "intrabc: displacement vector prediction" into nextgen 2015-06-25 20:55:21 +00:00
Alex Converse
93cd5cf3f4 intrabc: displacement vector prediction
Predict displacement vector with the same logic as NEARESTMV. If no
neighbors are available fall back to the current one block left or up
prediction.

vp9+intrabc+tx_skip+palette: -0.489
vp9+intrabc: -0.771

Change-Id: If67d08b54f1a3b847cf7ab8c7b800c55baa1a86b
2015-06-24 10:02:50 -07:00
Peter de Rivaz
fbfeb03f02 Fix for copy-mode with segmentation
Change-Id: Icfc97826e494b856aa80fbefe4811dff99f3a0b4
2015-06-24 09:25:23 +01:00
Debargha Mukherjee
567e4c754f Merge "Removing some compiler warnings" into nextgen 2015-06-23 19:13:09 +00:00
Peter de Rivaz
269f6e2cb1 Added support for extended partitions with copy_mode
Change-Id: I815374bd89e3faf2bac1b4155dbbe7366f0a1d29
2015-06-23 11:09:34 -07:00
hui su
ffcd76e328 Merge "Fix a bug induced by qctx-tprobs experiment" into nextgen 2015-06-23 17:54:35 +00:00
hui su
2f1325049a Merge "Bug fix in tx-skip" into nextgen 2015-06-23 17:42:41 +00:00
hui su
591b03a915 Fix a bug induced by qctx-tprobs experiment
Change-Id: I8d31b8e6037464c36b514fddccd5d7edee024a47
2015-06-23 10:20:27 -07:00
Debargha Mukherjee
3a18fc6784 Removing some compiler warnings
Change-Id: I572594a9c00ba5a2b8000d3b4c86ec5757aa586c
2015-06-22 15:26:25 -07:00
Peter de Rivaz
bad321d9e4 Added palette support to extended partitions
Change-Id: Ide11bd3fcc9fb26b27ae39cdf216a2c32b853348
2015-06-22 20:34:26 +01:00
Julia Robson
84d0da63d0 Palette high bit depth functionality
Changes to allow high bit depth and palette to be enabled at the
same time by using a 16 bit (instead of 8bit) palette when high
bit depth is enabled and modifying related functions accordingly.

Change-Id: I97d30b4d9338d3a51db02c94bc568eba60a8905d
2015-06-22 18:53:34 +01:00
hui su
c96afa256f Merge "Add q-index as context for initial token probs" into nextgen 2015-06-22 17:44:26 +00:00
Debargha Mukherjee
1c96a0bb09 Merge "Fix for supertx decode with segments" into nextgen 2015-06-22 17:28:31 +00:00
Debargha Mukherjee
adc9ed5a87 Merge "Fix supertx HORZ and VERT partitioning." into nextgen 2015-06-22 17:11:39 +00:00
hui su
315351e9de Bug fix in tx-skip
This patch avoids using tx_size larger than 16x16 in lossless mode.
Big block quantization (32x32 or larger) is not lossless.

Change-Id: I69cd84d4f3fd06d641048d6096da1bfde18ad24e
2015-06-22 09:54:42 -07:00
hui su
5963fd35dd Add q-index as context for initial token probs
There are 4 entropy tables to select for initial entropy table,
depending on the frame base q-index. The entropy tables are
trained with derf, yt, and stdhd sets. About 0.2% gain on
the following test sets:

derflr       0.227%
yt           0.277%
stdhd        0.233%
hevclr       0.221%
hevcmr       0.155%
hevchr       0.182%

Change-Id: I3fde846c47fc020e80c814897690b4cda1da569c

Change-Id: I460408372586c823974f945ed9fd8dcb0360fbaf
2015-06-21 13:09:57 -07:00
Peter de Rivaz
3b09cc1945 Fix for supertx decode with segments
Change-Id: I5e07b0b9fafd2578ecfacf20fb70b07fd6977d98
2015-06-18 18:16:07 +00:00
Peter de Rivaz
bdbae2520a Fix supertx HORZ and VERT partitioning.
Change-Id: I9a44d70dc2514baf679025335badc2744eeb4b88
2015-06-17 22:02:58 -07:00
Peter de Rivaz
100fff09b6 Added ext_partitions to supertx
Change-Id: I0e2a0253e5a8dcdb5b765836a3301299409e9d0a
2015-06-17 20:28:32 +00:00
Peter de Rivaz
3a3fb8d100 Fix seg fault in count_segs_sb with ext_partitions
Change-Id: I609f429006e7d2b849fe0a509f5d9f5123ecf0ec
2015-06-17 08:25:58 +00:00
Pieter Kapsenberg
d0e9499f94 Fixing skip simplifcation with SuperTX experiment
Combination of MISC_ENTROPY and SUPERTX resulted in compilation error

Change-Id: Ibcf28216712d93f00f38f3786fce8fcdca3f835e
2015-06-15 16:50:10 -07:00
hui su
0809dc09cb Merge "Fix tx-skip warnings on Windows" into nextgen 2015-06-15 19:41:24 +00:00
Alex Converse
a046bece1e Merge changes I9d80152b,I4e13da4b into nextgen
* changes:
  intrabc: Add a frame level flag
  intrabc: Remove NEWDV from the intra mode tree.
2015-06-15 16:57:05 +00:00
Debargha Mukherjee
ec8b957efe Merge "Added tests for high bit depth quantize functions" into nextgen 2015-06-12 20:59:16 +00:00
Debargha Mukherjee
dcb3d7f398 Bug fix in highbd psnr computation with postproc
Change-Id: I6944a5fc38d6a89e1bb739938c6ecae7ec731b8d
2015-06-12 11:57:40 -07:00
Peter de Rivaz
3bf31c4c98 Allow extended partition support to encode
Change-Id: I75246e2ee35a1b7c1ad46669c464e582e3a9961c
2015-06-11 11:52:45 -07:00
Debargha Mukherjee
e0617385d6 Merge "Add extended partition support to decode" into nextgen 2015-06-11 18:47:29 +00:00
hui su
c80386a5ab Fix tx-skip warnings on Windows
Change-Id: I2a515abe20e6989de233fc8ae2c31d8ee462add2
2015-06-11 11:20:16 -07:00
hui su
0c8bcb43a0 Merge "Fix palette build on windows" into nextgen 2015-06-11 17:56:26 +00:00
hui su
5d132c799e Fix palette build on windows
Change-Id: I2a90e235ab5bdf95eb83f684e46ef844553ba629
2015-06-11 10:44:05 -07:00
Peter de Rivaz
31d17053f3 Add extended partition support to decode
Change-Id: I65f7aed37d65dbba76999d2b9585129c48e70b11
2015-06-11 09:37:00 -07:00
Peter de Rivaz
999fabc183 Added extended partition experiment
Change-Id: Ife89c95f04212e9dceb4c4e663280a85b5718c13
2015-06-11 09:37:00 -07:00
Debargha Mukherjee
db90b74c1a Merge "Fix copy mode bug: searches made outside of the current tile" into nextgen 2015-06-11 16:30:23 +00:00
Jack Haughton
286983b8c6 Fix copy mode bug: searches made outside of the current tile
Change-Id: Ib3cf4bf4da0a575053493609956e133d1ce028a1
2015-06-11 09:23:32 +01:00
Debargha Mukherjee
ee5f9c7181 Merge "Fix to loopfilter tests" into nextgen 2015-06-11 05:30:50 +00:00
Debargha Mukherjee
278de7b73a Merge "Fix cost array overrun bug in search_bilateral_level()" into nextgen 2015-06-11 05:28:43 +00:00
Alex Converse
c3e884f5be intrabc: Add a frame level flag
For the combination of this and removing NEWDV from the tree:
derflr: -0.101 screen_content: +0.053

The bulk of the decline in screen content effecincy is from the liquify
clip. These should be recoverable by further entropy tweaks.

Change-Id: I9d80152b8492e60a0367c31797fb6932fb09bba9
2015-06-09 11:23:23 -07:00
Debargha Mukherjee
36eec6a9b1 Merge "Fix masked_variance overflow for non-highbitdepth" into nextgen 2015-06-09 17:07:13 +00:00
Jack Haughton
fa4b1ca714 Fix cost array overrun bug in search_bilateral_level()
Change-Id: I9b7b727cb45328040a82477a2ce8eb3d15feec77
2015-06-09 14:21:55 +01:00
Julia Robson
ece7479208 Fix to loopfilter tests
Ensuring the random numbers used by the loopfilter tests
are in a valid range

Change-Id: If8130145c413dbe7e29180046eca3e4f7d941706
2015-06-09 13:09:09 +01:00
Debargha Mukherjee
b433dd4443 Adds wavelet transforms + hybrid dct/dwt variants
The wavelets implemented are 2/6, 5/3 and 9/7 each with
a lifting based scheme for even block sizes. The 9/7
one is a double implementation currently.

This is to start experiments with:
1. Replacing large transforms (32x32 and 64x64) with wavelets
or wavelet-dct hybrids that can hopefully localize errors better
spatially. (Will also need alternate entropy coder)
2. Super-resolution modes where the higher sub-bands may be
selectively skipped from being conveyed, while a smart
reconstruction recovers the lost frequencies.

The current patch includes two types of 32x32 and 64x64
transforms: one where only wavelets are used, and another
where a single level wavelet decomposition is followed
by a lower resolution dct on the low-low band.

Change-Id: I2d6755c4e6c8ec9386a04633dacbe0de3b0043ec
2015-06-08 23:30:38 -07:00
Jack Haughton
2799fad98c Fix masked_variance overflow for non-highbitdepth
Change-Id: I668b034111ccc877c70cf65035a9c748fe00aeba
2015-06-08 12:09:48 -07:00
Debargha Mukherjee
5a69abc66b Merge "Windows build fix" into nextgen 2015-06-05 17:40:06 +00:00
Debargha Mukherjee
ad2cf9b444 Windows build fix
Change-Id: I663e0d61c4115a5297baeb25f39743e1eea95fbf
2015-06-05 10:24:24 -07:00
hui su
507857786d Fix lossless mode in tx-skip experiment
Change-Id: I205fa8614a9079ce7e6ca87d7b08fe3602bbd376
2015-06-04 15:13:37 -07:00
Julia Robson
33199783ea Added tests for high bit depth quantize functions
This was originally part of change-id:Idef18f90b111a0d0c9546543d3347e551908fd78
but the rest of that patch has previously been incorporated into nextgen
without these tests.

Change-Id: I6ac491ed1cfc153e0ed3cb999c76feac9d5e74e3
2015-06-04 16:00:39 +01:00
Debargha Mukherjee
b8a793458a Fix lossless mode with new_quant experiment
Change-Id: Ia0b00746e3f7aacf8d9488db3522ab72d9dc22fd
2015-06-04 02:45:54 -07:00
Alex Converse
1f537e3818 intrabc: Remove NEWDV from the intra mode tree.
Change-Id: I4e13da4bf70386f6f70ea733fb9adeb41682c735
2015-06-03 13:26:03 -07:00
Alex Converse
f35fb46c48 intrabc: Fix mismatch introduced by 85a7485.
Change-Id: I1ea51ebbd1e3cb60a13a30e3252253493c28baec
2015-06-03 13:07:49 -07:00
Alex Converse
783d18d22a Merge "intrabc: Include NEWDV in mode_2_counter" into nextgen 2015-06-03 16:09:36 +00:00
Debargha Mukherjee
d6ff3b3b22 Merge "Implied skip is 0 for intra blocks" into nextgen 2015-06-02 21:10:18 +00:00
Alex Converse
7944249b80 Merge "intrabc: Add odd-pel support for 444." into nextgen 2015-06-02 19:03:15 +00:00
Alex Converse
8cbed23cdf intrabc: Include NEWDV in mode_2_counter
This fixes a failure to decode as VP9 with frame level signalling
patched in and removed to implictly force it off.

This is primarily a correctness fix, but there were small coding gains.
0.074% smaller on derlf
0.180% smaller on screen_content

Change-Id: I4cc264bf4d9016201924be198a0c5b8374020fd9
2015-06-02 11:01:00 -07:00
Pieter Kapsenberg
ec1e91847c Implied skip is 0 for intra blocks
Skip flag is removed from the bitstream for all blocks coded in intra
mode. Very minor coding gain in derf and stdhd sets (0.048 and 0.1)

Change-Id: I79f03300f16d6fa84ce54405cafecab8a021cd7d
2015-06-01 18:27:34 -07:00
Jingning Han
b71176b477 Fix the upper limit of row/column tile index
If the decoder is configured to decode a tile indexed above the
upper limit, the internal codec will clip the index to the upper
limits.

Change-Id: Icbc1bb7b14069ac009e0a2042dd66a46d6f76679
2015-05-29 09:12:05 -07:00
Jingning Han
f5660af165 Allow vpxdec to produce target tile reconstruction
This commit allows the vpxdec to produce the target tile
reconstruction as its output. When the provided tile index is -1,
the entire corresponding row/column tiles will be reconstructed.
If the tile index is over the upper limit, the decoder will decode
left-most/bottom tile.

Change-Id: I4c18bdb32099f736f99b8842f7f177a32b3fee09
2015-05-28 23:20:24 -07:00
Jingning Han
89747d09cc Enable selective key frame tile decoding
This commit allows the decoder to decode selective tiles according
to decoder configuration settings. To decode a single tile out of
the provided key frame bit-stream (test_kf.webm), set compiler
configuration:

--enable-experimental --enable-row-tile --enable-key-frame-tile

use the command:

vpxdec -o test_dec.y4m test_kf.webm --tile-row=1 --tile-column=2

where the tile's row and column indexes are 1 and 2, respectively.

To decode all row tiles inside a provided column index, use:
--tile-row=-1 --tile-column=2

To decode all column tiles inside a provided row index, use:
--tile-row=2 --tile-column=-1

Change-Id: Ib73c266414dcee7eaab5d741b90d0058970dae56
2015-05-28 16:10:13 -07:00
Alex Converse
85a7485137 intrabc: Add odd-pel support for 444.
Odd pel still needs more testing on 4:2:0.

0.2% smaller on the PNG set. 4095 better, 1324 worse.

Change-Id: Idf2f108a96462c7696e63d533605e4a926a8b203
2015-05-28 15:44:15 -07:00
Debargha Mukherjee
fe79548bc8 Merge "Intrabc high bit depth functionality" into nextgen 2015-05-28 22:40:38 +00:00
Debargha Mukherjee
8f82bc172c Merge "Turn on global rotation-zoom warping prediction" into nextgen 2015-05-28 22:07:29 +00:00
Julia Robson
153d824207 Intrabc high bit depth functionality
Fixing compile errors when intrabc and vp9_highbitdepth are both enabled.
Error arose because intrabc uses vp9_setup_scale_factors_for_frame()
which takes an additional argument (use_highbitdepth) when
vp9_highbitdepth is enabled.

Change-Id: I6a15b09dcea0d35525f4c25efb6848804ae5cfab
2015-05-28 12:05:37 +01:00
Alex Converse
f80879d452 Merge "palette: don't repeat calc_dist for j = 0" into nextgen 2015-05-28 01:55:05 +00:00
Jingning Han
30fb5831da Merge "Fix a memory overflow issue in large scale tile use case" into nextgen 2015-05-28 01:53:56 +00:00
Jingning Han
d8d30cfb9b Merge "Configure selective tile decoding" into nextgen 2015-05-28 01:53:38 +00:00
Alex Converse
3df4a571a4 palette: don't repeat calc_dist for j = 0
Change-Id: I043c3b9696dbfa76436763ef871600cb54ade212
2015-05-27 11:45:00 -07:00
Debargha Mukherjee
5930a90cc9 Turn on global rotation-zoom warping prediction
With this patch, the ZEROMV mode is overloaded to represent
a single global dominant motion using one of three models:
1. True zero translation motion (as before)
2. A translation motion different from 0
3. A Rotation-zoom affine model where the predictor is warped
The actual model used is indicated at the frame level for
each reference frame.
A metric that computes the ratio of the error with a global
non-zero model to the error for zero motion, is used to
determine on the encoder side whether to use one of the two
non-zero models or not.

Change-Id: I1f3d235b8860e543191237024a89041ff3aad689
2015-05-27 11:33:33 -07:00
Jingning Han
ceda343d0b Fix a memory overflow issue in large scale tile use case
Increase the tok_count array size defined in VP9_COMP to avoid
out of boundary memory access.

Change-Id: Ib277c1102cb5f8355b1d69991532a94e24a2242e
2015-05-27 11:18:06 -07:00
hui su
c4f04808eb Merge "Fixed a bug in palette expt for 444 video format" into nextgen 2015-05-27 18:14:16 +00:00
hui su
f3f2645f24 Fixed a bug in palette expt for 444 video format
The bug was that palette color map was not correctly recorded.

Change-Id: I237494d1d6449c53c5d24eed8c25dcf2f8d21e66
2015-05-27 10:53:17 -07:00
Jingning Han
3b6901730f Merge "Make the tile coding syntax support large scale tile decoding" into nextgen 2015-05-27 16:40:49 +00:00
Jingning Han
f00bf10de0 Configure selective tile decoding
Add decoder control to extract single tile from key frame.

Change-Id: Id018bf267d748bfd96a6261055de4194f632190c
2015-05-27 09:22:34 -07:00
Alex Converse
57fefc1d73 Merge "intrabc: Fix probs of illegal modes." into nextgen 2015-05-27 01:03:02 +00:00
Jingning Han
f7a39d7f08 Make the tile coding syntax support large scale tile decoding
This commit makes the bit-stream syntax support fast selective tile
decoding in a large scale tile array. It reduces the computational
complexity of computing the target tile offset in the bit-stream
from quadratic to linear scale, while maintaining relatively small
stack space requirement (in the order of 1024 bytes instead of 1M
bytes). The overhead cost due to tile separation remains identical.

Change-Id: Id60c6915733d33a627f49e167c57d2534e70aa96
2015-05-26 12:54:00 -07:00
Alex Converse
1748a59f83 intrabc: Fix probs of illegal modes.
ibc: derflr -0.069 screen_content -0.085
ibc+tx+pal: derflr +0.017 screen_content -0.029

Change-Id: I79c0ca0a5c38c53afd209286dbcd78873e070098
2015-05-26 12:51:53 -07:00
Jingning Han
7099fd12bd Fix assertion conditions for tile coding
Allow up to 1024 row/col tiles instead of 4 for row tile and 64 for
column tile.

Change-Id: I1702254e241401821f3aaab1645f6df6dbc48b8d
2015-05-26 16:38:15 +00:00
Debargha Mukherjee
a14e3616b3 Merge "Loop_postfilter high bit depth functionality" into nextgen 2015-05-25 08:04:04 +00:00
Zoe Liu
98f6f54d93 Merge "Refined the mv ref candidate selection" into nextgen 2015-05-23 00:00:15 +00:00
Zoe Liu
e84c1d24bc Refined the mv ref candidate selection
Now this is an on-going work on the re-work on the motion vector
references for all Inter coding modes. Currently implementation on
sub8x8 and BLOCK_8X8 is done. More work will be added along the way.

Essetial ideas include:

(1) Added new nearestmv algorithm through adaptive median search, out of
the four nearest neighbors: TOP, LEFT, TOPLEFT, and TOPRIGHT;

(2) Added new sheme for sub8x8 to obtain the mv ref candidates,
specially, mv ref candidates are obtained depending on the sub8x8 mode
of the current block as well as the sub8x8 mode of the neighboring
block;

(3) Added top right corner mv ref candidate whenever it is available;
The adding of the top right mv ref has showed potential in helping such
video clips as bridge_far_cif.

Change-Id: I573c04cd346ed7010f4ad87a6eaa6bab6e2caf9c
2015-05-22 16:06:45 -07:00
Julia Robson
650e12dd63 Loop_postfilter high bit depth functionality
Adding a high bit depth version of the function loop_bilateral_filter()
and ensuring the appropriate version of this function is called when
vp9_highbitdepth is enabled.

Change-Id: I7a78029c733a9a79b3b2f39af0de0824239ad5a3
2015-05-22 10:34:44 -07:00
hui su
8806e25215 Code cleanup in tx-skip expt
No effect on performance

Change-Id: I493da0d4d8fb3a7d95f07574b800cb6c85705229
2015-05-22 10:20:58 -07:00
Pieter Kapsenberg
70ddd92d9a Removing skip inferrence with all 0 TX
If a non-skipped block has all transform blocks with only 0 data, then
decoder infers skip flag. This affects the loopfilter. No real encoder
would do this though, so it is pointless. Also, it causes headaches in
HW implmentations as the loop filter cannot proceed until all TX blocks
in the block have been checked. There could be up to 768 of them in
64x64 4:4:4 with 4x4 transform.

Change-Id: I45a021d1f27ca7feefed2242605777e70ce7cabd
2015-05-21 23:03:16 +00:00
Jingning Han
c238d6cd72 Merge "Enable arbitrary tile size support" into nextgen 2015-05-21 22:56:59 +00:00
Alex Converse
feb3a14e44 Merge "intrabc: Cleanup." into nextgen 2015-05-21 22:27:56 +00:00
Alex Converse
afea20e94c Merge "intrabc: Fix costing for tx_skip." into nextgen 2015-05-21 22:27:47 +00:00
Alex Converse
57f6a6d225 Merge "intrabc: Don't double account for skip" into nextgen 2015-05-21 22:27:40 +00:00
Jingning Han
bae6229884 Merge "Make internal codec support arbitrary tile size" into nextgen 2015-05-21 22:24:28 +00:00
Jingning Han
73ca749ddb Merge "Refactor internal tile_info variables to support 1024 tiles" into nextgen 2015-05-21 22:24:05 +00:00
Jingning Han
ad5ede6e36 Merge "Support up to 64 row tile coding" into nextgen 2015-05-21 22:23:42 +00:00
Jingning Han
c604b9a86c Enable arbitrary tile size support
This commit allows the encoder to process tile coding per 64x64
block. The supported upper limit of tile resolution is the minimum
of frame size and 4096 in each dimension. To turn on, set
--experiment --row-tile
and compile.

It overwrite the old --tile-columns and --tile-rows configurations.
These two parameters now tell the encoder the width and height of
tile in the unit of 64x64 block. For example,
--tile-columns=1 --tile-rows=1
will make a tile contains a single 64x64 block.

Change-Id: Id515749a05cfeb9e9d008291b76bdfb720de0948
2015-05-21 14:57:05 -07:00
Jingning Han
a0d950345b Merge "Support up to 1024 row/column tiles in bit-stream syntax" into nextgen 2015-05-21 19:50:12 +00:00
Jingning Han
a3a3fee09f Merge "Set row and col tile number upper limit as 1024" into nextgen 2015-05-21 19:49:59 +00:00
Alex Converse
1110f09385 intrabc: Cleanup.
Change-Id: I71ad705e579a62563af8282846dbda522c3c971e
2015-05-21 12:00:05 -07:00
Alex Converse
32bec3f0ec intrabc: Fix costing for tx_skip.
ibc+tx+pal: derflr: -0.033 screen_content: -0.145

Change-Id: I446ef1c890eb9afa12454e53b24dc0ef6a80b02b
2015-05-21 12:00:05 -07:00
Alex Converse
5e6ab9935e intrabc: Don't double account for skip
ibc: derflr +0.007 screen_content -0.025
ibc+tx+pal: derflr -0.208 screen_content +0.003

Change-Id: I5e46e84fd545f3810ae7a5d13dc3618e1b077f76
2015-05-21 12:00:05 -07:00
Jingning Han
98339250c1 Make internal codec support arbitrary tile size
This commit allows the internal codec handle arbitrary tile size
in the unit of 64x64 pixel blocks.

Change-Id: I3ad24de392064645bebab887c94e1db957794916
2015-05-21 09:20:31 -07:00
Debargha Mukherjee
d43544137b Rename NEAR_FORNEW to NEW2
Change-Id: I2928b0d28dcbf9c6b705d3ebf20550aeec9b99b3
2015-05-20 17:31:20 -07:00
Jingning Han
225097a7ed Refactor internal tile_info variables to support 1024 tiles
Move the 2D tile info arrays as global variables. This resolves
the local function stack overflow issue due to excessively large
tile info variables. This allows the internal operation to support
up to 1024 row and column tiles.

Change-Id: I6644cc929e5d3a778a5c03a712ebfc0b8729f576
2015-05-20 10:19:01 -07:00
Jingning Han
8e3099aa2b Support up to 64 row tile coding
This commit allows the codec to use up to row tiles (optionally
in combination with up to 64 column tiles per row tile). The
minimum tile size is set to be 256x256 pixel block.

Change-Id: I811ca93f0c5eba41e190f6c7c0f064d1083f530f
2015-05-19 17:27:05 -07:00
Jingning Han
97adfb32bd Support up to 1024 row/column tiles in bit-stream syntax
Add syntax support to allow up to 1024 row/column tiles
respectively.

Change-Id: I84278589364b658d6c4dd05f0771795f732ad68f
2015-05-19 17:20:36 -07:00
Jingning Han
46afda0908 Set row and col tile number upper limit as 1024
Increase the supported row and col tile numbers from 4 and 64,
respectively to 1024 both.

Change-Id: Ic07435ff6783940a466a549a69a11ab3faf3247a
2015-05-19 17:20:36 -07:00
Jingning Han
f5445e124c Rename variables in tile info decoding
The max and min tile number reference should be used to support
both row and column tiles. This commit renames the previous col
prefix to avoid confusion.

Change-Id: I487bea43701af946b79023597a9a9a0516480380
2015-05-19 17:20:36 -07:00
Zoe Liu
2bbddcf0a5 Removed the unused modes newmvref and compound-modes
Change-Id: Ia51913d48a09a7ea7502e8c49ee0159492e58b96
2015-05-19 16:20:37 -07:00
Zoe Liu
6437c3cb6d Combined two experiments of NEWMVREF and COMPOUND_MODES to NEW_INTER
Runborgs results on derflr show consistent results between NEW_INTER
and the previous combination of NEWMVREF and COMPOUND_MODES.

Change-Id: Ieba239c4faa7f93bc5c05ad656a7a3b818b4fbfc
2015-05-19 14:04:22 -07:00
Julia Robson
0a1c529b26 Merge "Fix mismatch in handling of 8x4/4x8 blocks with supertx" into nextgen 2015-05-19 16:06:26 +00:00
Pieter Kapsenberg
418956690e Removing unnecessary syntax remaping for mc filter type
Change-Id: Iba067eb2bcf519dc5776976c3ab0a694ff3feb12
2015-05-18 13:56:56 -07:00
Julia Robson
8718262437 Fix mismatch in handling of 8x4/4x8 blocks with supertx
Test VP9/EndToEndTestLarge.EndtoEndPSNRTest/1 (422 stream) failed when
supertx enabled. This was because 4x8 and 8x4 blocks were not being
split into 4x4s during tokenization in the encoder. This patch
uses vp9_foreach_transformed_block() to fix this.

Change-Id: I1f1cb27474eb9e04347067f5c4aff1942bbea8d9
2015-05-18 11:59:51 +01:00
hui su
10834f4373 Merge "Fix a bug in tx-skip experiment" into nextgen 2015-05-18 04:31:27 +00:00
Debargha Mukherjee
e82fffd416 Row tile fix
Fixes mismatch with intrabc experiment.

Change-Id: I1d83a8aa5584fb35396351f7fae7f9365598d00f
2015-05-15 08:01:21 -07:00
Debargha Mukherjee
520e861e03 Merge "Global motion enhancements" into nextgen 2015-05-15 05:48:26 +00:00
Debargha Mukherjee
fb093a337f Global motion enhancements
Adds warping functions. Also includes some refactoring.

Change-Id: I909830650f29046edf108ddaddceb1a5e7c6c61c
2015-05-14 16:33:01 -07:00
Zoe Liu
987d44f5d0 Added a new experiment "NEW_INTER"
Down the road this experiment will combine and replace both NEWMVREF
and COMPOUND_MODES.

Change-Id: I383291f94f3e80e5cbbabab45e31c4b48669f2e5
2015-05-14 14:39:45 -07:00
hui su
4fcb86251d Fix a bug in tx-skip experiment
Fix potential mismatch.

Change-Id: I51f9241c73d70c0c38fd7e2c15f4381350b60388
2015-05-12 09:38:14 -07:00
Julia Robson
b4d8b235dd Changed tokenize to correct tx_size for 440 input
Change-Id: I41995cfa03038ec45b5f0d6c68195cfa36d58ec8
2015-05-12 09:34:04 -07:00
Zoe Liu
60b71edf2b Merge "Removed unused macro for INTERINTRA" into nextgen 2015-05-12 00:25:01 +00:00
Zoe Liu
d29384192c Removed unused macro for INTERINTRA
Change-Id: Ibdf4da969c17d4b1dff14a777ccb405763a62b75
2015-05-11 13:01:25 -07:00
Jingning Han
7a2f9bbda4 Add row tile coding support in bit-stream
Fix the row tile boundary detection issues. This allows to use
more resources for parallel encoding/decoding when avaiable.

Change-Id: Ifda9f66d1d7c2567dd4e0a572a99a83f179b55f9
2015-05-11 12:30:03 -07:00
Zoe Liu
9e0466d0fd Cleaned mv search code and added a few fixes on the experiments
Besides code cleaning, this patch contains 3 fixes:
(1) Fixed the COMPOUND_MODES for the NEW_NEWMV mode;
(2) Fixed the joint search when the NEAR_FORNEWMV mode (in NEWMVREF)
is being evaluated;
(3) Fixed the WEDGE_PARTITION when the NEAR_FORNEWMV mode (in NEWMVREF)
is being evaluated.
(4) Adjusted the entropy probability value for NEAR_FORNEW mode.

On derflr turning on all 14 experiments (except for global-motion), the
average gain w.r.t. PSNR is +0.07%:
Maximum on bridge_far_cif: +1.02%
Minimum on hallmonitor_cif: -0.16%

Change-Id: I4c9c6ee24a981af7e655a629580641d9f9745f91
2015-05-10 23:38:44 -07:00
hui su
bada9f0b87 Merge "Optimize entropy coding of non-transform tokens" into nextgen 2015-05-08 18:18:49 +00:00
Alex Converse
d28a10870f Merge "Try non-traditional intra prediction even when spatial isn't good." into nextgen 2015-05-08 01:27:13 +00:00
hui su
00c793ee5f Optimize entropy coding of non-transform tokens
Use separate token probabilities and counters for non-transform
blocks (pixel domain) . Initial probabilities are trained with screen_content
clips. On screen_content, it improves coding performance by about
2% (from +16.4% to +18.45%).

The initial probabilities are not optimized for natural videos. So it should
not be used for natural videos. Set FOR_SCREEN_CONTENT as 0/1 to specify
whether or not to enable this patch.

Change-Id: Ifa361c94bb62aa4b783cbfa50de08c3fecae0984
2015-05-07 07:58:19 -07:00
Debargha Mukherjee
e6889b28e9 Merge "Fix a bug in copy_mode experiment" into nextgen 2015-05-07 05:10:01 +00:00
Debargha Mukherjee
5e7bc81128 Merge "Global motion continued" into nextgen 2015-05-07 05:09:34 +00:00
Yaowu Xu
d1f04fb5b2 Fix a bug in copy_mode experiment
Change-Id: I1cf7d51ba99e5b6f5cf7e0d1a5d86ce4f19046e5
2015-05-06 17:03:32 -07:00
Peter de Rivaz
d6153aa447 Added highbitdepth sse2 acceleration for quantize and block error
This is a partial cherry-pick of db7192e

Change-Id: Idef18f90b111a0d0c9546543d3347e551908fd78
2015-05-06 15:14:01 -07:00
Debargha Mukherjee
caae13d54f Global motion continued
Implements a first version of global motion where the
existing ZEROMV mode is converted to a translation only
global motion mode.
A lot of the code for supporting a rotation-zoom affine
model is also incorporated.
WIP.

Change-Id: Ia1288a8dfe82f89484d4e291780288388e56d91b
2015-05-06 14:59:38 -07:00
Alex Converse
47cd96fb49 Try non-traditional intra prediction even when spatial isn't good.
Change-Id: I3a9b94d52cc0e962d91827a9b7ca8b65e82130ca
2015-05-06 10:23:22 -07:00
Peter de Rivaz
16add99f0d Corrected optimization of 8x8 DCT code
The 8x8 DCT uses a fast version whenever possible.
There was a mistake in the checking code which
meant sometimes the fast version was used when it
was not safe to do so.

Change-Id: I154c84c9e2d836764768a11082947ca30f4b5ab7
2015-05-06 10:10:19 -07:00
Peter de Rivaz
6aed50370c Added tests for high bitdepth variance sse2 functions
Change-Id: I72735e2e07464a0f7e44968fb14a195c84a58992
2015-05-06 10:10:19 -07:00
Peter de Rivaz
ecf677ede6 Fixed idct16x16_10 highbitdepth transform
In the case when there are only non-zero coefficients
in the first 4x4 block a special routine is called.
The highbitdepth optimized version of this routine
examined the wrong positions when deciding whether
to call an assembler or C inverse transform.

Change-Id: I62da663ca11775dadb66e402e42f4a1cb1927893
2015-05-06 10:10:18 -07:00
Deb Mukherjee
963393321c Iadst transforms to use internal low precision
Change-Id: I266777d40c300bc53b45b205144520b85b0d6e58
2015-05-06 10:10:18 -07:00
Peter de Rivaz
2dad1a7c8e Added high bitdepth sse2 transform functions
Change-Id: If359f0e9a71bca9c2ba685a87a355873536bb282
2015-05-06 10:10:18 -07:00
Peter de Rivaz
2189a51891 Added sse2 acceleration for highbitdepth variance
This is a combination of:
  4a19fa6 Added sse2 acceleration for highbitdepth variance
  c6f5d3b Fix high bit depth assembly function bugs

Change-Id: I446bdf3a405e4e9d2aa633d6281d66ea0cdfd79f
2015-05-06 10:04:08 -07:00
Peter de Rivaz
41973e0e3e Refactored idct routines and headers
This change is made in preparation for a
subsequent patch which adds acceleration
for the highbitdepth transform functions.

The highbitdepth transform functions attempt
to use 16/32bit sse instructions where possible,
but fallback to using the C implementations if
potential overflow is detected.  For this reason
the dct routines are made global so they can be
called from the acceleration functions in the
subsequent patch.

Change-Id: Ia921f191bf6936ccba4f13e8461624b120c1f665
2015-05-06 09:59:20 -07:00
Peter de Rivaz
0e82cba628 Added highbitdepth sse2 SAD acceleration and tests
Change-Id: I9f09e404e3136951e5cc15bf40b915c1fe10b620
2015-05-06 09:00:53 -07:00
Yaowu Xu
846396ddda Enable build with vs20013
Change-Id: I0592b9e92c3ca45e0a81d9ce49a9f2381bec3e39
2015-05-04 14:08:52 -07:00
Zoe Liu
9b083e8271 Changed nearmv for one of the sub8x8 partitions
It is a minor change, but the essential idea is to use the mv of the
top right block as the nearmv for the bottom left partition in the
sub8x8 block. The change is under the experiment of NEWMVREF.

When all 13 experiments are on (except for INTRABC), the gain is +0.05%:
Worse on bowing_cif: -0.17%
Best on foreman_cif: +0.42%; and bridge_far_cif: +0.40%
The total 13 experiments achieved a gain of +6.97% against base.

Change-Id: I3a51d9e28b34b0943fe16a984d62bfb38304ebca
2015-04-30 22:59:32 -07:00
Alex Converse
9b638cded6 tx_skip: Avoid undefined shift behavior.
vp9_quantize_rect did illegal shifts but didn't use the results.
The shift |a << b| is unfortunately undefined if |a < 0|, but the
more verbose |a * (1 << b)| generates the same machine code.

Change-Id: I7ceac66fa20a700630cf8ed008949146b161dab4
2015-04-30 12:56:27 -07:00
Alex Converse
aaa50de4ca Fix integer overflows in TX skipping
Change-Id: Ic1fc0f1271065180cffcbd2906e8faac6d07d08d
2015-04-30 11:42:31 -07:00
Debargha Mukherjee
4e3cf9bdfd Merge "Consolidate common count updates" into nextgen 2015-04-29 22:08:26 +00:00
Debargha Mukherjee
735360f70e Consolidate common count updates
Cleanup - does not have any change in RD performance.

Change-Id: Iaca9c7378b294bd8c780958f5e33e697690eebfa
2015-04-29 14:12:03 -07:00
Yaowu Xu
dfa47eb64b Merge "Add a necessary include file" into nextgen 2015-04-28 23:48:50 +00:00
Yaowu Xu
9d5035ce38 Add a necessary include file
The include is necessary for --enable-coefficient-range-checking

Change-Id: I5cf7b2fca0ddd610815398b1e77f17df42f9785c
2015-04-28 15:44:16 -07:00
Yaowu Xu
5652851391 Merge changes I33c72799,I3ee8974a,I38a42ed1,Iaad3dc3c into nextgen
* changes:
  usage.dox: fix doxygen warnings in 1.8.x
  Fix doxygen warning with usage.dox
  Remove obsolete doxygen tags
  Fix comments for doxygen
2015-04-28 21:16:10 +00:00
Alex Converse
8d9c600d44 Merge "palette: Add missing consts" into nextgen 2015-04-28 19:51:16 +00:00
James Zern
368f7c806a usage.dox: fix doxygen warnings in 1.8.x
use \li to denote list items with \if.

fixes the following likely visible in <1.8.3:
usage.dox: warning: Invalid list item found
usage.dox: warning: End of list marker found without any preceding list items

Change-Id: I33c72799edf9f8866596ac8f79247050b8c75681
2015-04-28 12:07:56 -07:00
Yaowu Xu
4674152287 Fix doxygen warning with usage.dox
Change-Id: I3ee8974a66f186fb0eb15b1078a3c7b9cbf5ec80
2015-04-28 12:07:56 -07:00
Yaowu Xu
856e549027 Remove obsolete doxygen tags
Change-Id: I38a42ed1d0be4fbfce6c9f3f5d021055107933d7
2015-04-28 12:07:56 -07:00
Alex Converse
cb437f800f Merge "Refactor 4:4:4 palette selection." into nextgen 2015-04-28 19:07:41 +00:00
Yaowu Xu
b1f93f56a1 Fix comments for doxygen
Change-Id: Iaad3dc3cdd25275939b475706eb7d136a5a10174
2015-04-28 12:06:56 -07:00
Alex Converse
7ae0b65f32 palette: Add missing consts
Change-Id: I83a2e57dc5dbc328c7bfea421ffbaeb83b7ca3bd
2015-04-28 11:35:17 -07:00
Alex Converse
d0cb4e75bc Refactor 4:4:4 palette selection.
Move 444 palette selection out of vp9_rd_pick_intra_mode_sb and into
a subfunction.

Change-Id: Ib323b740318626e2a68cd3d106dbd27c8f4652a6
2015-04-28 11:21:04 -07:00
hui su
1f7b49f7cd Use uniform quantization settings for non-transform blocks
Do not treat first element (dc) differently.

on screen_content
tx-skip only: +16.4% (was +15.45%)

no significant impact on natrual videos

Change-Id: I79415a9e948ebbb4a69109311c10126d8a0b96ab
2015-04-28 07:54:16 -07:00
hui su
761cd0b010 Fix bugs in palette and intrabc expt
palette expt: correctly update color buffer
intrabc expt: update zcoeff_blk so that residue coding will not
              be mistakenly skipped

Change-Id: I870f5b742c2ac394f4c871aa65e6591e293d8ef6
2015-04-27 15:27:11 -07:00
Alex Converse
98d4f09a7a Replace vp9_get_bit_depth with vp9_ceil_log2.
The current name is confusing with regard to high bit depth buffers.

Change-Id: Ieacd55ec22c81bd2f013f2e3d73a095affc93689
2015-04-23 10:26:57 -07:00
Debargha Mukherjee
96213ac5e7 Merge "Some minor improvements in bilateral filter expt." into nextgen 2015-04-23 01:14:45 +00:00
Debargha Mukherjee
425a45a45c Some minor improvements in bilateral filter expt.
Changes include:

* Uses double for RD cost computation to guard against overflow
for large resolution frames.
* Use previous frame's filter level to code the level better.
* Change precision of the filter parameters.
* Allow spatial variance for x and y to be different

Change-Id: I1669f65eb0ab1e8519962954c92d59e04f1277b7
derflr: +0.556% (a little up from before)
2015-04-22 18:09:42 -07:00
hui su
9e0750c2d2 Modify scan order for non-transform coding blocks
Use raster scan order for non-transform blocks

+15.45% (+2.1%) on screen_content
no significant change on natural videos

Change-Id: I0e264cb69e8624540639302d131f7de9c31c3ba7
2015-04-21 14:23:52 -07:00
hui su
33207fb170 Remove unused variable in new-quant expt
remove dequant_val_nuq in macroblock_plane

Change-Id: I4b4070ae2d01c2403c781433030204d6e95c3750
2015-04-20 11:14:51 -07:00
Alex Converse
90b3838fca Merge "Don't use old uv scores for NEWDV and cleanup mbmi saving." into nextgen 2015-04-17 12:47:23 -07:00
hui su
ebd3666940 Merge "Add high bit depth support for tx-skip expt" into nextgen 2015-04-17 11:37:39 -07:00
Alex Converse
e45e18593b Don't use old uv scores for NEWDV and cleanup mbmi saving.
Change-Id: Ic0fae1b348ad7659e4a41db29d075ae5eb6cdc82
2015-04-17 10:54:33 -07:00
Debargha Mukherjee
fb001c2e2f Merge "Simplify bilateral filter search for speed" into nextgen 2015-04-16 18:58:03 -07:00
Debargha Mukherjee
017baf9f4b Simplify bilateral filter search for speed
Adds an internal buffer in the encoder to store the deblocked
result to help speed up the search for the best bilateral filter.

Very small change in performance but a lot faster:
derflr: +0.518%

Change-Id: I5d37e016088e559c16317789cfb1c2f49334b2b9
2015-04-16 15:33:34 -07:00
hui su
8c00c7a9cd Fix palette expt asan failure
Account for 422 video format.

Change-Id: Ic5af661720fc5fa7142210d907dd25e1e79ff653
2015-04-16 15:08:06 -07:00
hui su
b69152db79 Add high bit depth support for tx-skip expt
+0.3% on 10-bit
+0.3% on 12-bit

With other high bit compatible experiments on 12-bit
+12.44% (+0.17) over 8-bit baseline

Change-Id: I40b4c382fa54ba4640d08d9d01950ea8c1200bc9
2015-04-16 14:54:39 -07:00
hui su
871c51b30a Fix a bug in tx_skip expt
tx_skip is not enabled for sub8x8 blocks.

Change-Id: I3797238735f85fb2bd07b50ca2845611b198bff6
2015-04-14 11:25:55 -07:00
hui su
294159d41e Merge "refactoring in tx_skip experiment" into nextgen 2015-04-14 08:12:08 -07:00
hui su
261a9bac5a refactoring in tx_skip experiment
simplify code logic

Change-Id: Ifafc712f3f85abafadb429a04e295cf8cbb185d2
2015-04-13 17:14:05 -07:00
Debargha Mukherjee
febb434356 Merge "High bit-depth support for wedge partition expt" into nextgen 2015-04-13 10:09:51 -07:00
Debargha Mukherjee
343c092e2e High bit-depth support for wedge partition expt
Change-Id: Idbd27e66d4f4a7953f888137d5752856215a6760
2015-04-13 09:28:15 -07:00
hui su
359bf925ce Fix a mismatch bug
In the tx_skip experiment, dpcm is not used for 64x64 blocks.

Change-Id: Iafbed3b5e411954b80e898f10def3757f2cf44c1
2015-04-11 09:38:49 -07:00
Debargha Mukherjee
8fa0b12cf7 Merge "An experiment introducing a bilateral loop filter" into nextgen 2015-04-10 16:46:16 -07:00
Debargha Mukherjee
fe4b6ac652 An experiment introducing a bilateral loop filter
Adds a framework to incorporate a parameterized loop
postfilter in the coding loop after the application of the
standard deblocking loop filter.

The first version uses a straight bilateral filter
where the parameters conveyed are just spatial and
intensity gaussian variances.

Results on derflr:
+0.523% (only with this experiment)
+6.714% (with all expts other than intrabc)

Change-Id: I20d47285b4d25b8c6386ff8af2a75ff88ac2b69b
2015-04-10 16:05:00 -07:00
hui su
bfc27bb614 tx-skip experiment: improve entropy coding of coeff tokens
This patch allows the prediction residues of tx-skipped blocks
to use probs that are different from regular transfrom
coefficients for token entropy coding. Prediction residues are
assumed as in band 6.

The initial value of probs is obtained with stats from limited
tests. The statistic model for constrained token nodes has not
been optimized. The probs for token extra bits have not been
optimized. These can be future work.

Certain coding improvment is observed:
derflr with all experiments:                +6.26%  (+0.10%)
screen_content with palette:               +22.48%  (+1.28%)

Change-Id: I1c0d78178ee9f3655febb6f30cdaef8ee9f8e3cc
2015-04-10 11:33:42 -07:00
Debargha Mukherjee
b19df73ce8 Preparation for end to end test turn on
Change-Id: Ibc53bf50c8164b413749aaa8baa08e2f6e928e1b
2015-04-03 16:44:40 -07:00
Alex Converse
16e5e713fa Add an intra block copy mode (NEWDV).
Change-Id: I82b261c54ac9db33706bb057613dcbe66fc71387
2015-04-03 11:59:57 -07:00
Zoe Liu
e1cae5eebf Clean the COMPOUND_MODES mv initialization for sub8x8
Change-Id: I04f4ad41c002c761d55093432d6c437c25e5bddd
2015-04-02 16:30:48 -07:00
Zoe Liu
2ae3d4f266 Add a new PREDICTION mode using NEARMV as ref mv
This experiment, referred as NEWMVREF, also merged with NEWMVREF_SUB8X8
and the latter one has been removed. Runborgs results show that:

(1) Turning on this experiment only, compared against the base:
derflf: Average PSNR 0.40%; Overall PSNR 0.40%; SSIM 0.35%
(2) Turning on all the experiments including this feature, compared against
that without this feature, on the highbitdepth case using 12-bit:
derflf: Average PSNR 0.33%; Overall PSNR 0.32%; SSIM 0.30%.

Now for highbitdepth using 12-bit, compared against base:
derflf: Average PSNR 11.12%; Overall PSNR 11.07%; SSIM 20.27%.

Change-Id: Ie61dbfd5a19b8652920d2c602201a25a018a87a6
2015-04-02 14:37:22 -07:00
hui su
9eada94a3e palette experiment: remove run-length coding
Change-Id: I1e52475d0179cf019841d09a53b3b7fc53c79336
2015-03-31 11:09:30 -07:00
hui su
65d39f9fae Merge "Palette experiment: encode color indices based on context" into nextgen 2015-03-26 18:34:43 -07:00
hui su
a3af20f56e Merge "Palette experiment: adaptly update probs" into nextgen 2015-03-26 18:34:28 -07:00
hui su
6ad18db24f Palette experiment: encode color indices based on context
The basic idea is to use a pixel’s neighboring colors as
context to predict its own color. Up to 4 neighbors are
considered here: left, left-above, above, right-above.
To reduce the number of contexts,  the combination of any
4 (or less) colors are mapped to a reduced number of
patterns. For example, 1111, 2222, 3333, … , can be mapped
to the same pattern: AAAA. SImilarly, 1122, 1133, 2233, …,
can be mapped to the pattern AABB. In this way, the total
number of color contexts is reduced to 16.

This almost doubles the gain of palette coding on screen
content videos.

on screen_content
--enable-palette                                  +14.2%
--enable-palette --enable-tx-skip                 +21.2%

on derflr
--enable-palette                                  +0.12%
with all other experiments                        +6.16%

Change-Id: I560306dae216f2ac11a9214968c2ad2319fa1718
2015-03-26 15:48:08 -07:00
Debargha Mukherjee
3d965883f4 Merge "Add palette coding mode for inter frames" into nextgen 2015-03-26 11:59:36 -07:00
hui su
e18b104462 Palette experiment: adaptly update probs
Also make changes to transmit palette-enabled flag using
neighbor blocks as context.

on screen_content
--enable-palette                            +7.35%

on derflr
with all other experiments                  +6.05%

Change-Id: Id6c2f726d21913d54a3f86ecfea474a4044c27f6
2015-03-25 09:12:57 -07:00
Zoe Liu
2a5648dca5 Cleaned the code in handle_inter_mode
borgs show consistent results as before this patch

Change-Id: I3d21623cb03ea169a031328e9dde9c26ba1bd016
2015-03-23 15:33:25 -07:00
hui su
070d635657 Add palette coding mode for inter frames
on screen_content
--enable-palette                                    +6.74%

on derflr
with all other experiments                          +6.02%
(--enable-supertx --enable-copy-mode
 --enable-ext-tx --enable-filterintra
 --enable-tx64x64 --enable-tx-skip
 --enable-interintra --enable-wedge-partition
 --enable-compound-modes --enable-new-quant
 --enable-palette)

Change-Id: Ib85049b4c3fcf52bf95efbc9d6aecf53d53ca1a3
2015-03-23 08:41:51 -07:00
Deb Mukherjee
73dcd41b72 Merge "Make interintra experiment work with highbitdepth" into nextgen 2015-03-22 22:48:56 -07:00
Deb Mukherjee
c082df2359 Make interintra experiment work with highbitdepth
Also includes some adjustments to the algorithm.
All stats look good.

Change-Id: I824ef8ecf25b34f3feb358623d14fe375c3e4eb7
2015-03-21 07:35:40 -07:00
Deb Mukherjee
8c5ac79e66 Some build fixes with highbitdepth and new quant
Highbitdepth performance about the same as 8-bit.

Change-Id: If737962d8588dd190083edae4383b731f9d22873
2015-03-21 06:53:58 -07:00
Deb Mukherjee
c8ed36432e Non-uniform quantization experiment
This framework allows lower quantization bins to be shrunk down or
expanded to match closer the source distribution (assuming a generalized
gaussian-like central peaky model for the coefficients) in an
entropy-constrained sense. Specifically, the width of the bins 0-4 are
modified as a factor of the nominal quantization step size and from 5
onwards all bins become the same as the nominal quantization step size.
Further, different bin width profiles as well as reconstruction values
can be used based on the coefficient band as well as the quantization step
size divided into 5 ranges.

A small gain currently on derflr of about 0.16% is observed with the
same paraemters for all q values.
Optimizing the parameters based on qstep value is left as a TODO for now.

Results on derflr with all expts on is +6.08% (up from 5.88%).

Experiments are in progress to tune the parameters for different
coefficient bands and quantization step ranges.

Change-Id: I88429d8cb0777021bfbb689ef69b764eafb3a1de
2015-03-17 21:42:55 -07:00
Alex Converse
9a92891ac4 interintra: wedge: Get the correct wedge params.
Fixes an asan issue.

Change-Id: I671ffc382c77c2b38673e0b148f54e7bce2ce9c2
2015-03-17 10:49:22 -07:00
Alex Converse
7ca745a2df palette: Fix an illegal read
Change-Id: I71649f0a85d98b96efd08c8a9e3ee7372fd7d327
2015-03-16 17:13:15 -07:00
Deb Mukherjee
961fe77e70 Merge "Misc changes to support high-bitdepth with supertx" into nextgen 2015-03-12 17:42:20 -07:00
Deb Mukherjee
35d38646ec Misc changes to support high-bitdepth with supertx
Change-Id: I0331646d1c55deb6e4631e64bd6b092fb892a43e
2015-03-12 16:52:25 -07:00
Zoe Liu
0337ae5218 Fixed a bug & a build warning for newmvref-sub8x8
Change-Id: I799fc3fb4c1201da14c97bf66e06dec655f6a620
2015-03-12 11:31:33 -07:00
hui su
7621c779e5 Add palette coding mode for UV
For 444 videos, a single palette of 3-d colors is
generated for YUV. For 420 videos, there may be two
palettes, one for Y, and the other for UV.

Also fixed a bug when palette and tx-skip are both on.

on derflr
--enable-palette                    +0.00%
with all experiments                +5.87% (was +5.93%)

on screen_content
--enable-palette                    +6.00%
--enable-palette --enable-tx_skip   +15.3%

on screen_content 444 version
--enable-palette                    +6.76%
--enable-palette --enable-tx_skip   +19.5%

Change-Id: I7287090aecc90eebcd4335d132a8c2c3895dfdd4
2015-03-10 13:38:19 -07:00
Debargha Mukherjee
ee2f0bdfcd Merge "Global motion work continued" into nextgen 2015-03-10 11:27:04 -07:00
Spencer Egart
faaaf85fc3 Global motion work continued
Interface change for the global Mv functions.

Change-Id: Ie4722faa638ac557f99743f7b33ff46c3d29e9a1
2015-03-10 10:47:12 -07:00
Deb Mukherjee
d835821fa1 Merge "Make filterintra experiment work with highbitdepth" into nextgen 2015-03-10 10:42:58 -07:00
Deb Mukherjee
78bcc48756 Make filterintra experiment work with highbitdepth
All stats look fine.
derflr: +0.912 with respect to 10-bit internal baseline
               (Was +0.747% w.r.t. 8 bit)
        +5.545 with respect to 8-bit baseline

Change-Id: I3c14fd17718a640ea2f6bd39534e0b5cbe04fb66
2015-03-10 07:59:59 -07:00
Alex Converse
efe2b3cbc6 Fix tx_skip debug build.
Change-Id: I20a3e4e34f10485aa5e6723cd33b0311bdbf1320
2015-03-09 14:57:13 -07:00
Yaowu Xu
41eb20d1e9 Add encoder control for setting color space
This commit adds encoder side control for vp9 to set color space info
in the output compressed bitstream.

It also amends the "vp9_encoder_params_get_to_decoder" test to verify
the correct color space information is passed from the encoder end to
decoder end.

Change-Id: Ibf5fba2edcb2a8dc37557f6fae5c7816efa52650
(cherry picked from commit e94b415c34)
2015-03-06 16:42:09 -08:00
Yaowu Xu
63537df4c0 Enable decoder to pass through color space info
This commit added a field to vpx_image_t for indicating color space,
the field is also added to YUV_BUFFER_CONFIG. This allows the color
space information pass through the decoder from input stream to the
output buffer.

The commit also updates compare_img() function with added verification
of matching color space to ensure the color space information to be
correctly passed from encode to decoder in compressed vp9 streams.

Change-Id: I412776ec83defd8a09d76759aeb057b8fa690371
(cherry picked from commit 6b223fcb58)
2015-03-06 15:57:12 -08:00
Yaowu Xu
b7913deb7e Added plumbing for setting color space
Change-Id: If64052cc6e404abc8a64a889f42930d14fad21d3
(cherry picked from commit ce52b0f8d3)
2015-03-06 14:51:49 -08:00
James Zern
cd152849ea vp9_highbd_tm_predictor_16x16: fix win64
by saving xmm8; cglobal's xmm reg arg is 0-based

Change-Id: Ic8426ec9ac59ab4478716aa812452a6406794dcb
(cherry picked from commit 923cc0bf51)
2015-03-06 13:29:00 -08:00
Yaowu Xu
6fcaa06911 Correct the miscalculation in uv dimensions
The calculation of required extension used in HBD case was wrong due
to rounding for UV when y dimension is odd. This commit replace the
computation with correct version.

This fixes a crash caused by writting beyond buffer boundary.

Change-Id: Ic7c9afeb7388cd1341ec4974a611dacfb74ac6b6
(cherry picked from commit 4bca73b609)
2015-03-06 09:47:57 -08:00
Yaowu Xu
7b4ff46175 Prevent VP8 encoding crash
This commit changes the value of highbitdepth flag to avoid conflict
with vp8 refresh_last_frame flag.

Change-Id: Idcff2cf44f0a200bd935b326f785c0cf32d7228a
(cherry picked from commit dd27307cac)
2015-03-06 09:47:56 -08:00
Zoe Liu
cf004a0845 Merge "Fixed the build for newmvref-sub8x8" into nextgen 2015-03-06 08:54:11 -08:00
Zoe Liu
6c7b4ed355 Fixed the build for newmvref-sub8x8
Change-Id: Ie042001e69d80b1fc52368f29617ad2e51a5e250
2015-03-06 00:01:30 -08:00
Zoe Liu
756a18663c Merge "Cleaned code further for newmvref-sub8x8 and compound-modes" into nextgen 2015-03-05 15:41:28 -08:00
Zoe Liu
1192f99976 Cleaned code further for newmvref-sub8x8 and compound-modes
Change-Id: I9f869c37566aaf81910d1d6ab1b2ac0d2a2f0a23
2015-03-05 15:40:36 -08:00
Zoe Liu
e222d46658 Merge "Changed mv ref to nearestmv always for sub8x8" into nextgen 2015-03-05 11:57:21 -08:00
Zoe Liu
b359952c2c Changed mv ref to nearestmv always for sub8x8
For all sub8x8 partition, the mv ref has changed to its own nearest_mv
instead of the nearest_mv of the super 8x8 block:

--enable-newmvref-sub8x8: ~0.1% gain for derflr

Besides the above new experiment, code has been cleaned largely for the
sub8x8 motion search, such that the mv ref can be fairly easily changed to
use other options, e.g., the next step's global motion effort.

Change-Id: I8e3f4aaa8553ba8c445369692e079db5ce282593
2015-03-05 11:09:58 -08:00
Zoe Liu
a9040ea40c Corrected comment in mode_2_counter for compound
Change-Id: I5459550e62cff79182fa0ac5a24edb56cb64d608
2015-03-04 10:16:25 -08:00
Zoe Liu
30720adf6e Fixed the build for denoiser in new compound mode
Change-Id: Ifb824ce87db9c00c8c87f52d9b8718669fb39d05
2015-03-04 09:29:05 -08:00
Deb Mukherjee
4c1049d7a8 Some fixes to quantization and compiler warnings
The bugs affected only the tx64x64 experiment. This patch fixes
them.

Also fixes some compiler warnings

Change-Id: I4cf1e24a4f1fa59831bf29750cf6daa8373e8e8f
2015-03-03 14:07:17 -08:00
Deb Mukherjee
9909903229 Adds translation model to global motion estimation
Change-Id: Ie1791ab7cfdd3f7a1b03404627246c923f1bd51f
2015-02-25 09:57:33 -08:00
hui su
caccf06acd Palette-based coding experiment
Added palette coding option for Y channel only, key frame only.
Palette colors are obtained with k-means clustering algorithm.
Run-length coding is used to compress the color indices.

On screen_content:
--enable-palette                            + 5.75%
--enable-palette --enable-tx_skip           +15.04% (was 13.3%)

On derflr:
--enable-palette                            - 0.03%
with all the other expriments               + 5.95% (was 5.98%)

Change-Id: I6d1cf45c889be764d14083170fdf14a424bd31b5
2015-02-23 09:23:50 -08:00
Zoe Liu
7d8840a082 Removed redundant src_mi in mv ref candidates
Change-Id: I4eb144e7c9d2c8568388ae58001cc7b7498967e4
2015-02-19 09:44:05 -08:00
Spencer Egart
d8983f0dd7 Global Motion block-based
Uses block-based motion fields with ransac to find transformation between
frames.

Change-Id: I6293fbb690cdad854a1140fb6af76b326abfe964
2015-02-18 11:52:39 -08:00
Spencer Egart
edffe3f956 Global motion experiment
Added a function to compute a motion field for a pair of buffers, for use in
finding an affine transform or homography.

Change-Id: Id5169cc811a61037e877dfd57fccaca89d93936f
2015-02-10 11:15:39 -08:00
Deb Mukherjee
2aef964519 Merge "Adds code for corner detection and ransac" into nextgen 2015-02-10 08:18:03 -08:00
Deb Mukherjee
1fc70e47cd Adds code for corner detection and ransac
This code is to start experiments with global motion models.

The corner detection can be either fast_9 or Harris.
Corner matching is currently based on normalized correlation.
Three flavors of ransac are used to estimate either a
homography (8-param), or an affine model (6-param) or a
rotation-zoom only affine model (4-param).

The highest level API for the library is in vp9_global_motion.h,
where there are two functions - one for computing a single model
and another for computing multiple models up to a maximum number
provided or until a desired inlier probability is achieved.

Change-Id: I3f9788ec2dc0635cbc65f5c66c6ea8853cfcf2dd
2015-02-10 00:48:56 -08:00
Zoe Liu
48da7bf004 Cleaned up the COMPOUND_MODES code in sub8x8
Change-Id: I571ff39799c3257b5c6db82660364ce412c7f6e2
2015-02-09 11:58:54 -08:00
hui su
2118f66a91 Enable tx_skip for inter blocks
Enable tx_skip for inter blocks whose q-index is smaller than 64.

tx_skip experiment alone:
derflr: +0.233% (was +0.038%)

all experiments:
derflr: +5.98% (was +5.94%)

Change-Id: I35245a476ff7039fec8468a92a6aa63feaf74831
2015-02-08 17:57:51 -08:00
hui su
1ae3989558 Fix a bug in filterintra experiment
All expts together: +5.946% (up about 0.3%)

Change-Id: If686e5e97209b4cc4a8115f920e1f4f35ded5a1d
2015-01-31 00:43:06 -08:00
Yue Chen
2ed2f29d21 Fix a bug in COPY_MODE + EXT_TX experiment
Remove the duplicated step counting the overhead for ext_tx, because
it has been counted in super_block_yrd().

Change-Id: I50bc01d8166572bc0847305565cf33c14ee516e6
2015-01-27 12:02:54 -08:00
Jingning Han
50cab76f12 Removal of legacy zbin_extra / zbin_oq_value.
Change-Id: I07f77a63aa98087626e45c4e87aa5dcafc0b0b07
(cherry picked from commit d0f2377027)
2015-01-21 20:37:19 -08:00
Deb Mukherjee
7a993f850e Adds inter-intra combination with wedge partitions
Also fixes some build issues with certain experimental combinations.

Results on derflr with all experiments on: +5.516%

Change-Id: I9b492f3d3556bd1f057005571dc9bee63167dd95
2015-01-21 15:45:22 -08:00
Deb Mukherjee
760219d0fd Some build fixes
Related zbin boost removal.

Change-Id: I0f34d31038c29d5cb78bc5d110159df01e41e328
2015-01-21 13:37:24 -08:00
Paul Wilkins
dfed541f21 Remove mode dependent zbin boost.
Initial patch to remove get_zbin_mode_boost() and
cpi->zbin_mode_boost.

For now sets a dummy value of 0 for zbin extra pending
a further clean up patch.

Change-Id: I64a1e1eca2d39baa8ffb0871b515a0be05c9a6af
(cherry picked from commit 60e9b731cf)
2015-01-21 11:05:55 -08:00
Spencer Egart
347c31b48f Created COMPOUND_MODES experiment.
COMPOUND_MODES experiment encodes separate MV modes for each frame in a compound
reference prediction.  Added modes NEAREST_NEARESTMV, ZERO_ZEROMV,
NEW_NEWMV, NEAREST_NEARMV, NEAR_NEARESTMV, NEW_NEARESTMV, NEAR_NEWMV,
NEW_NEARMV, and NEAREST_NEWMV.

Also enhances the wedge-partition expt to work better with compound
modes.

Results:
derflr +0.227
All experiments on: derflr +5.218

Change-Id: I719e8a34826bf1f1fe3988dac5733a845a89ef2b
2015-01-16 14:48:56 -08:00
Deb Mukherjee
db5dd49996 Adds wedge-partitions for compound prediction
Results with this experiment only: +0.642% on derflr.
With other experiments: +4.733%

Change-Id: Ieb2022f8e49ac38a7e7129e261a6bf69ae9666b9
2015-01-15 15:59:33 -08:00
punksu
5f0093bb98 Merge "dpcm intra prediction for tx_skip" into nextgen 2015-01-15 11:53:06 -08:00
punksu
571fdbb05f dpcm intra prediction for tx_skip
Implements vertical, horizontal, and tm dpcm intra prediction for
blocks in tx_skip mode. Typical coding gain on screen content video
is 2%~5%.

Change-Id: Idd5bd84ac59daa586ec0cd724680cef695981651
2015-01-14 14:54:09 -08:00
Zoe Liu
a56ff2d323 Fixed a bug in the experiment EXT_TX.
Change-Id: I1adf0e916f9414e6dfe1d07cefc0693bc63b7e97
2015-01-14 14:27:51 -08:00
hui su
f60b844974 Merge "Turn on tx_skip for inter modes" into nextgen 2015-01-14 08:57:41 -08:00
Deb Mukherjee
3960e92c8b Merge "Some fixes in interintra expt" into nextgen 2015-01-13 12:34:24 -08:00
hui su
2c68b07d7d Turn on tx_skip for inter modes
Fixed the mismatch issue in lossless case

Change-Id: Ia2fd98865b4687e664fdc75f62b402e8289a1968
2015-01-13 11:28:08 -08:00
Deb Mukherjee
cb165354e7 Some fixes in interintra expt
Removes some redundant information when supertx and interintra
both are used.

Change-Id: I40b0fddbc1ba54607c6e8068bde128c21c14d997
2015-01-13 00:52:25 -08:00
Zoe Liu
919692d6c5 Cleaned up the code a little for the CONFIG_EXT_TX experiment on the
16x16 and 8x8 transform sizes, both for the regular case and the high
bit depth (CONFIG_VP9_HIGHBITDEPTH) case.

Change-Id: I34a9d3c73c3687f967105194ce4def48c3ec435c
2015-01-12 12:11:37 -08:00
Deb Mukherjee
b43beffc3c Merge "Adds an inter-intra combination mode" into nextgen 2015-01-12 09:22:21 -08:00
Deb Mukherjee
2dba1221b4 Adds an inter-intra combination mode
A smooth weighting scheme is used to put more weight
on the intra predictor samples near the left/top boundaries
and decaying it to favor the inter predictor samples more as
we move away from these boundaries in the direction of
prediction.

Results:
derflr: +0.609% with only this experiment
derflr: +3.901% with all experiments

Change-Id: Ic9dbe599ad6162fb05900059cbd6fc88b203a09c
2015-01-12 00:28:01 -08:00
Zoe Liu
b342c8405b Merge "Fixed a bug in the CONFIG_EXT_TX experiment for the forward 16x16 transform size when CONFIG_VP9_HIGHBITDEPTH is enabled." into nextgen 2015-01-09 13:32:53 -08:00
Deb Mukherjee
f61bcfbafa Merge "Segment id fix in tx-skip/supertx experiment" into nextgen 2015-01-09 10:37:59 -08:00
punksu
9100fe3944 Merge "Fix conflict b/w tx_skip and copy_mode in lossless mode" into nextgen 2015-01-08 17:06:41 -08:00
Zoe Liu
d7d5c75c69 Fixed a bug in the CONFIG_EXT_TX experiment for the forward 16x16
transform size when CONFIG_VP9_HIGHBITDEPTH is enabled.

Change-Id: I475f64eac2c31094a47bc0d557968940cad01c86
2015-01-08 09:03:53 -08:00
Deb Mukherjee
28258c5fe2 Segment id fix in tx-skip/supertx experiment
Change-Id: Ice9e833ad7f60e943acc011260dc3121ad3b136f
2015-01-08 02:05:11 -08:00
Deb Mukherjee
9a19ef0add Turn off tx-skip for intermodes temporarily
Will be re-enabled when a mismatch issue is resolved.

Change-Id: I303d80effa69eeb0ebf1921bbb4eaeeb34497e4b
2015-01-06 18:14:00 -08:00
punksu
42dfd9a728 Fix conflict b/w tx_skip and copy_mode in lossless mode
Change-Id: Idb12344adda99dddde8d2cd010ffffe6425aca62
2015-01-06 20:51:46 +08:00
Yue Chen
695c4bc321 Fix mismatch in SUPERTX experiment
Disable SUPERTX mode when lossless mode is enabled because the largest
lossless transform size is 4X4.

Change-Id: I4167959a282728d62354119ced99ca29febabfd1
2014-12-28 02:27:16 -08:00
punksu
b0ef621f84 Merge "Allow large tx_size in lossless coding with transform skipping" into nextgen 2014-12-27 20:52:36 -08:00
Deb Mukherjee
2b959d4ee8 Fix frame-parallel modes
This fix is already incorporated in master.

Change-Id: I7b0c048ebef4d92f041cc8727bc276843f17d50d
2014-12-27 01:55:27 -08:00
Deb Mukherjee
9aa76fdb69 Adds a copy mode experiment
Experiment to copy motion and mode from block neighbors.

Results:
--------
--enable-experimental --enable-copy-mode:
derflr: +0.727%

With other expts:
--enable-experimental --enable-copy-mode --enable-supertx
--enable-ext-tx --enable-filterintra --enable-tx-skip --enable-tx64x64
derflr: +3.43%

Change-Id: Iae74b9a855a1a690bf76131b42d247bbc54dec17
2014-12-24 17:52:55 -08:00
punksu
8a41d18bd0 Allow large tx_size in lossless coding with transform skipping
In lossless coding, tx_size can be larger than 4x4 when transform
skipping is activated. Compared to regular vp9 lossless coding,
performance improvement for derf is about 5%; gain is larger
for screen content videos.

Change-Id: Ib20ece7e117f29fb91543612757302a2400110b4
2014-12-22 22:56:52 +08:00
Debargha Mukherjee
2f7de8c887 Bug fix in rdopt
Change-Id: Ieab80902755456e97583636f13d1417269b332b5
2014-12-18 02:43:27 -08:00
Deb Mukherjee
7ec9792f96 Adds forward prob updates for supertx expt
Also refactors the supertx prob models, and includes other
cleanups.

Change-Id: I74de6c01d872ae09bf6d43a31f53d43283b6b226
2014-12-15 21:55:58 -08:00
hui su
5de9280ae9 tx_skip mode for lossy coding
This patch improves the non-transform coding mode. At this
point, the coding gain on screen content videos is about
12% for lossless, an 15% for lossy case.

1. Encode tx_skip flags with context. Y tx_skip flag context is
whether the prediction mode is inter or intra. UV flag context
is Y flag.

2. Transform skipping is less helpful when the Q-index is high.
So it is enabled only when the Q-index is smaller than a
threshold. Currently the threshold is set as 255 for intra blocks,
and 0 for inter blocks.

3. The shift of the prediction residue, when copying them to the
coeff buffer, is set as 3 when the Q-index is larger than a
threshold (currently set as 0), and 2 otherwise.

Change-Id: I372973c7518cf385f6e542b22d0f803016e693b0
2014-12-15 10:46:41 -08:00
Deb Mukherjee
625c0961ff Adds supertx experiment adopted from playground
Reimplements the supertx experiment from the playground branch.
Makes it work with other experiments.

Results:
With --enable-superttx
derflr: +0.958

With --enable-supertx --enable-ext-tx
derflr: +2.25%

With --enable-supertx --enable-ext-tx --enable-filterintra
derflr: +2.73%

Change-Id: I5012418ef2556bf2758146d90c4e2fb8a14610c7
2014-12-11 16:06:23 -08:00
Deb Mukherjee
1fdc274900 Extends ext_tx expt to include all hybrid variants
Extends the ext-tx experiment to include all 9 DST/DCT
variants.

Results with ext_tx experiment:
derflr: +1.338 derflr (improved from 1.12)

Change-Id: I24b5564f96bce6ccaa13d88ca6cb9d0c57000597
2014-11-21 07:21:38 -08:00
Deb Mukherjee
c82de3bede Extending ext_tx expt to include dst variants
Extends the ext-tx experiment to include regular and flipped
DST variants. A total of 9 transforms are thus possible for
each inter block with transform size <= 16x16.

In this patch currently only the four ADST_ADST variants
(flipped or non-flipped in both dimensions) are enabled
for inter blocks.

The gain with the ext-tx experiment grows to +1.12 on derflr.
Further experiments are underway.

Change-Id: Ia2ed19a334face6135b064748f727fdc9db278ec
2014-11-20 14:25:40 -08:00
hui su
d97fd3eef6 Non transform coding experiment
Non-transform option is enabled in both intra and inter modes.
In lossless case, the average coding gain on screen content
clips is 11.3% in my test.

Change-Id: I2e8de515fb39e74c61bb86ce0f682d5f79e15188
2014-11-19 21:20:21 -08:00
Deb Mukherjee
e2a8e90874 Misc cleanups on ext_tx expt.
Change-Id: I599d9fb00a2accdf24def65df52bef56d014a0b6
2014-11-16 00:03:18 -08:00
Deb Mukherjee
52e4dfe1b1 Merge "Adds missing EXT_TX checks" into nextgen 2014-11-13 20:13:40 -08:00
Deb Mukherjee
f62d19752d Adds missing EXT_TX checks
Change-Id: Ia0ca39c9041f17da0b7f522e55868498f31de848
2014-11-13 15:59:50 -08:00
Spencer Egart
83e50d6412 Refactoring in nonrd_ methods in vp9_encodeframe
Refactored some of the more repetitive code in the nonrd methods in
vp9_encodeframe.c.

Change-Id: Ib71dcd14f74fb6e5fd123b3ffea8f253aaa04b1a
2014-11-13 13:00:15 -08:00
hui su
cf7dc66e34 Fix lossless mismatch in EXT_TX
In lossless mode, transform should not be altered.

Change-Id: I216d1700963b4d1c35e059cd7ff7b0cefaf46133
2014-11-13 05:07:37 -08:00
Spencer Egart
1c562aebd8 Migrate EXT_TX from playground to nextgen.
Change-Id: I1cb0584104323fb3781e66bb65d44ebbe853c9c8
2014-11-11 07:55:49 -08:00
Spencer Egart
e55808d9a7 Migrated FILTERINTRA from playground to nextgen
derf +0.385
derflr +0.411
with --enable-tx64x64, derflr +0.433

Added fix for integration with TX64X64

Change-Id: Ie24825de06021d007ba215ac7f6de40638c57e12
2014-11-10 10:13:32 -08:00
Deb Mukherjee
613ea21ae7 Tx64x64 bug fixes
Change-Id: Iac595a3ae8f1466d8485c3627219b4b623efc8ad
2014-11-05 20:19:43 -08:00
Deb Mukherjee
a137e3c3ba Fixes in 64x64 transform
Extends quantizer range and some other fixes.

Change-Id: Ia9adf7848e772783365d6501efd07585bff80c15
stdhd: +0.166%, turns positive a little
derf: -0.036% (very few blocks use the 64x64 mode)
2014-11-03 17:00:43 -08:00
Deb Mukherjee
8bdf4cebb9 Merge "Adding a 64x64 transform mode" into nextgen 2014-10-30 00:51:35 -07:00
Deb Mukherjee
0c7a94f49b Adding a 64x64 transform mode
Preliminary 64x64 transform implementation.
Includes all code changes.
All mismatches resolved.

Coding results for derf and stdhd are within noise. stdhd is slightly
higher, derf is slightly lower.

To be further refined.

Change-Id: I091c183f62b156d23ed6f648202eb96c82e69b4b
2014-10-30 00:45:57 -07:00
541 changed files with 102152 additions and 57142 deletions

1
.gitignore vendored
View File

@@ -44,6 +44,7 @@
/ivfenc.dox /ivfenc.dox
/libvpx.so* /libvpx.so*
/libvpx.ver /libvpx.ver
/obj_int_extract
/samples.dox /samples.dox
/test_libvpx /test_libvpx
/vp8_api1_migration.dox /vp8_api1_migration.dox

View File

@@ -1,26 +1,18 @@
Adrian Grange <agrange@google.com> Adrian Grange <agrange@google.com>
Alex Converse <aconverse@google.com> <alex.converse@gmail.com>
Alexis Ballier <aballier@gentoo.org> <alexis.ballier@gmail.com> Alexis Ballier <aballier@gentoo.org> <alexis.ballier@gmail.com>
Alpha Lam <hclam@google.com> <hclam@chromium.org>
Deb Mukherjee <debargha@google.com>
Erik Niemeyer <erik.a.niemeyer@intel.com> <erik.a.niemeyer@gmail.com>
Guillaume Martres <gmartres@google.com> <smarter3@gmail.com>
Hangyu Kuang <hkuang@google.com> Hangyu Kuang <hkuang@google.com>
Jim Bankoski <jimbankoski@google.com> Jim Bankoski <jimbankoski@google.com>
John Koleszar <jkoleszar@google.com>
Johann Koenig <johannkoenig@google.com> Johann Koenig <johannkoenig@google.com>
Johann Koenig <johannkoenig@google.com> <johann.koenig@duck.com> Johann Koenig <johannkoenig@google.com> <johann.koenig@duck.com>
John Koleszar <jkoleszar@google.com> Johann Koenig <johannkoenig@google.com> <johannkoenig@dhcp-172-19-7-52.mtv.corp.google.com>
Joshua Litt <joshualitt@google.com> <joshualitt@chromium.org>
Marco Paniconi <marpan@google.com>
Marco Paniconi <marpan@google.com> <marpan@chromium.org>
Pascal Massimino <pascal.massimino@gmail.com> Pascal Massimino <pascal.massimino@gmail.com>
Paul Wilkins <paulwilkins@google.com>
Ralph Giles <giles@xiph.org> <giles@entropywave.com>
Ralph Giles <giles@xiph.org> <giles@mozilla.com>
Sami Pietilä <samipietila@google.com> Sami Pietilä <samipietila@google.com>
Tamar Levy <tamar.levy@intel.com>
Tamar Levy <tamar.levy@intel.com> <levytamar82@gmail.com>
Tero Rintaluoma <teror@google.com> <tero.rintaluoma@on2.com> Tero Rintaluoma <teror@google.com> <tero.rintaluoma@on2.com>
Timothy B. Terriberry <tterribe@xiph.org> Tim Terriberry <tterriberry@mozilla.com> Timothy B. Terriberry <tterribe@xiph.org> Tim Terriberry <tterriberry@mozilla.com>
Tom Finegan <tomfinegan@google.com> Tom Finegan <tomfinegan@google.com>
Ralph Giles <giles@xiph.org> <giles@entropywave.com>
Ralph Giles <giles@xiph.org> <giles@mozilla.com>
Alpha Lam <hclam@google.com> <hclam@chromium.org>
Deb Mukherjee <debargha@google.com>
Yaowu Xu <yaowu@google.com> <yaowu@xuyaowu.com> Yaowu Xu <yaowu@google.com> <yaowu@xuyaowu.com>

29
AUTHORS
View File

@@ -3,11 +3,10 @@
Aaron Watry <awatry@gmail.com> Aaron Watry <awatry@gmail.com>
Abo Talib Mahfoodh <ab.mahfoodh@gmail.com> Abo Talib Mahfoodh <ab.mahfoodh@gmail.com>
Adam Xu <adam@xuyaowu.com>
Adrian Grange <agrange@google.com> Adrian Grange <agrange@google.com>
Ahmad Sharif <asharif@google.com> Ahmad Sharif <asharif@google.com>
Alexander Voronov <avoronov@graphics.cs.msu.ru> Alexander Voronov <avoronov@graphics.cs.msu.ru>
Alex Converse <aconverse@google.com> Alex Converse <alex.converse@gmail.com>
Alexis Ballier <aballier@gentoo.org> Alexis Ballier <aballier@gentoo.org>
Alok Ahuja <waveletcoeff@gmail.com> Alok Ahuja <waveletcoeff@gmail.com>
Alpha Lam <hclam@google.com> Alpha Lam <hclam@google.com>
@@ -15,58 +14,44 @@ A.Mahfoodh <ab.mahfoodh@gmail.com>
Ami Fischman <fischman@chromium.org> Ami Fischman <fischman@chromium.org>
Andoni Morales Alastruey <ylatuya@gmail.com> Andoni Morales Alastruey <ylatuya@gmail.com>
Andres Mejia <mcitadel@gmail.com> Andres Mejia <mcitadel@gmail.com>
Andrew Russell <anrussell@google.com>
Aron Rosenberg <arosenberg@logitech.com> Aron Rosenberg <arosenberg@logitech.com>
Attila Nagy <attilanagy@google.com> Attila Nagy <attilanagy@google.com>
changjun.yang <changjun.yang@intel.com> changjun.yang <changjun.yang@intel.com>
Charles 'Buck' Krasic <ckrasic@google.com>
chm <chm@rock-chips.com> chm <chm@rock-chips.com>
Christian Duvivier <cduvivier@google.com> Christian Duvivier <cduvivier@google.com>
Daniel Kang <ddkang@google.com> Daniel Kang <ddkang@google.com>
Deb Mukherjee <debargha@google.com> Deb Mukherjee <debargha@google.com>
Dim Temp <dimtemp0@gmail.com>
Dmitry Kovalev <dkovalev@google.com> Dmitry Kovalev <dkovalev@google.com>
Dragan Mrdjan <dmrdjan@mips.com> Dragan Mrdjan <dmrdjan@mips.com>
Ehsan Akhgari <ehsan.akhgari@gmail.com> Erik Niemeyer <erik.a.niemeyer@gmail.com>
Erik Niemeyer <erik.a.niemeyer@intel.com>
Fabio Pedretti <fabio.ped@libero.it> Fabio Pedretti <fabio.ped@libero.it>
Frank Galligan <fgalligan@google.com> Frank Galligan <fgalligan@google.com>
Fredrik Söderquist <fs@opera.com> Fredrik Söderquist <fs@opera.com>
Fritz Koenig <frkoenig@google.com> Fritz Koenig <frkoenig@google.com>
Gaute Strokkenes <gaute.strokkenes@broadcom.com> Gaute Strokkenes <gaute.strokkenes@broadcom.com>
Giuseppe Scrivano <gscrivano@gnu.org> Giuseppe Scrivano <gscrivano@gnu.org>
Gordana Cmiljanovic <gordana.cmiljanovic@imgtec.com>
Guillaume Martres <gmartres@google.com> Guillaume Martres <gmartres@google.com>
Guillermo Ballester Valor <gbvalor@gmail.com> Guillermo Ballester Valor <gbvalor@gmail.com>
Hangyu Kuang <hkuang@google.com> Hangyu Kuang <hkuang@google.com>
Hanno Böck <hanno@hboeck.de>
Henrik Lundin <hlundin@google.com> Henrik Lundin <hlundin@google.com>
Hui Su <huisu@google.com> Hui Su <huisu@google.com>
Ivan Maltz <ivanmaltz@google.com> Ivan Maltz <ivanmaltz@google.com>
Jacek Caban <cjacek@gmail.com>
JackyChen <jackychen@google.com>
James Berry <jamesberry@google.com> James Berry <jamesberry@google.com>
James Yu <james.yu@linaro.org>
James Zern <jzern@google.com> James Zern <jzern@google.com>
Jan Gerber <j@mailb.org>
Jan Kratochvil <jan.kratochvil@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com>
Janne Salonen <jsalonen@google.com> Janne Salonen <jsalonen@google.com>
Jeff Faust <jfaust@google.com> Jeff Faust <jfaust@google.com>
Jeff Muizelaar <jmuizelaar@mozilla.com> Jeff Muizelaar <jmuizelaar@mozilla.com>
Jeff Petkau <jpet@chromium.org> Jeff Petkau <jpet@chromium.org>
Jia Jia <jia.jia@linaro.org>
Jim Bankoski <jimbankoski@google.com> Jim Bankoski <jimbankoski@google.com>
Jingning Han <jingning@google.com> Jingning Han <jingning@google.com>
Joey Parrish <joeyparrish@google.com>
Johann Koenig <johannkoenig@google.com> Johann Koenig <johannkoenig@google.com>
John Koleszar <jkoleszar@google.com> John Koleszar <jkoleszar@google.com>
John Stark <jhnstrk@gmail.com>
Joshua Bleecher Snyder <josh@treelinelabs.com> Joshua Bleecher Snyder <josh@treelinelabs.com>
Joshua Litt <joshualitt@google.com> Joshua Litt <joshualitt@google.com>
Justin Clift <justin@salasaga.org> Justin Clift <justin@salasaga.org>
Justin Lebar <justin.lebar@gmail.com> Justin Lebar <justin.lebar@gmail.com>
KO Myung-Hun <komh@chollian.net> KO Myung-Hun <komh@chollian.net>
Lawrence Velázquez <larryv@macports.org>
Lou Quillio <louquillio@google.com> Lou Quillio <louquillio@google.com>
Luca Barbato <lu_zero@gentoo.org> Luca Barbato <lu_zero@gentoo.org>
Makoto Kato <makoto.kt@gmail.com> Makoto Kato <makoto.kt@gmail.com>
@@ -80,7 +65,6 @@ Michael Kohler <michaelkohler@live.com>
Mike Frysinger <vapier@chromium.org> Mike Frysinger <vapier@chromium.org>
Mike Hommey <mhommey@mozilla.com> Mike Hommey <mhommey@mozilla.com>
Mikhal Shemer <mikhal@google.com> Mikhal Shemer <mikhal@google.com>
Minghai Shang <minghai@google.com>
Morton Jonuschat <yabawock@gmail.com> Morton Jonuschat <yabawock@gmail.com>
Parag Salasakar <img.mips1@gmail.com> Parag Salasakar <img.mips1@gmail.com>
Pascal Massimino <pascal.massimino@gmail.com> Pascal Massimino <pascal.massimino@gmail.com>
@@ -88,8 +72,6 @@ Patrik Westin <patrik.westin@gmail.com>
Paul Wilkins <paulwilkins@google.com> Paul Wilkins <paulwilkins@google.com>
Pavol Rusnak <stick@gk2.sk> Pavol Rusnak <stick@gk2.sk>
Paweł Hajdan <phajdan@google.com> Paweł Hajdan <phajdan@google.com>
Pengchong Jin <pengchong@google.com>
Peter de Rivaz <peter.derivaz@gmail.com>
Philip Jägenstedt <philipj@opera.com> Philip Jägenstedt <philipj@opera.com>
Priit Laes <plaes@plaes.org> Priit Laes <plaes@plaes.org>
Rafael Ávila de Espíndola <rafael.espindola@gmail.com> Rafael Ávila de Espíndola <rafael.espindola@gmail.com>
@@ -97,29 +79,22 @@ Rafaël Carré <funman@videolan.org>
Ralph Giles <giles@xiph.org> Ralph Giles <giles@xiph.org>
Rob Bradford <rob@linux.intel.com> Rob Bradford <rob@linux.intel.com>
Ronald S. Bultje <rbultje@google.com> Ronald S. Bultje <rbultje@google.com>
Rui Ueyama <ruiu@google.com>
Sami Pietilä <samipietila@google.com> Sami Pietilä <samipietila@google.com>
Scott Graham <scottmg@chromium.org> Scott Graham <scottmg@chromium.org>
Scott LaVarnway <slavarnway@google.com> Scott LaVarnway <slavarnway@google.com>
Sean McGovern <gseanmcg@gmail.com>
Sergey Ulanov <sergeyu@chromium.org>
Shimon Doodkin <helpmepro1@gmail.com> Shimon Doodkin <helpmepro1@gmail.com>
Stefan Holmer <holmer@google.com> Stefan Holmer <holmer@google.com>
Suman Sunkara <sunkaras@google.com> Suman Sunkara <sunkaras@google.com>
Taekhyun Kim <takim@nvidia.com> Taekhyun Kim <takim@nvidia.com>
Takanori MATSUURA <t.matsuu@gmail.com> Takanori MATSUURA <t.matsuu@gmail.com>
Tamar Levy <tamar.levy@intel.com> Tamar Levy <tamar.levy@intel.com>
Tao Bai <michaelbai@chromium.org>
Tero Rintaluoma <teror@google.com> Tero Rintaluoma <teror@google.com>
Thijs Vermeir <thijsvermeir@gmail.com> Thijs Vermeir <thijsvermeir@gmail.com>
Tim Kopp <tkopp@google.com>
Timothy B. Terriberry <tterribe@xiph.org> Timothy B. Terriberry <tterribe@xiph.org>
Tom Finegan <tomfinegan@google.com> Tom Finegan <tomfinegan@google.com>
Vignesh Venkatasubramanian <vigneshv@google.com> Vignesh Venkatasubramanian <vigneshv@google.com>
Yaowu Xu <yaowu@google.com> Yaowu Xu <yaowu@google.com>
Yongzhe Wang <yongzhe@google.com>
Yunqing Wang <yunqingwang@google.com> Yunqing Wang <yunqingwang@google.com>
Zoe Liu <zoeliu@google.com>
Google Inc. Google Inc.
The Mozilla Foundation The Mozilla Foundation
The Xiph.Org Foundation The Xiph.Org Foundation

View File

@@ -1,26 +1,3 @@
2015-04-03 v1.4.0 "Indian Runner Duck"
This release includes significant improvements to the VP9 codec.
- Upgrading:
This release is ABI incompatible with 1.3.0. It drops the compatibility
layer, requiring VPX_IMG_FMT_* instead of IMG_FMT_*, and adds several codec
controls for VP9.
- Enhancements:
Faster VP9 encoding and decoding
Multithreaded VP9 decoding (tile and frame-based)
Multithreaded VP9 encoding - on by default
YUV 4:2:2 and 4:4:4 support in VP9
10 and 12bit support in VP9
64bit ARM support by replacing ARM assembly with intrinsics
- Bug Fixes:
Fixes a VP9 bitstream issue in Profile 1. This only affected non-YUV 4:2:0
files.
- Known Issues:
Frame Parallel decoding fails for segmented and non-420 files.
2013-11-15 v1.3.0 "Forest" 2013-11-15 v1.3.0 "Forest"
This release introduces the VP9 codec in a backward-compatible way. This release introduces the VP9 codec in a backward-compatible way.
All existing users of VP8 can continue to use the library without All existing users of VP8 can continue to use the library without

View File

@@ -17,7 +17,7 @@ or agree to the institution of patent litigation or any other patent
enforcement activity against any entity (including a cross-claim or enforcement activity against any entity (including a cross-claim or
counterclaim in a lawsuit) alleging that any of these implementations of WebM counterclaim in a lawsuit) alleging that any of these implementations of WebM
or any code incorporated within any of these implementations of WebM or any code incorporated within any of these implementations of WebM
constitute direct or contributory patent infringement, or inducement of constitutes direct or contributory patent infringement, or inducement of
patent infringement, then any patent rights granted to you under this License patent infringement, then any patent rights granted to you under this License
for these implementations of WebM shall terminate as of the date such for these implementations of WebM shall terminate as of the date such
litigation is filed. litigation is filed.

15
README
View File

@@ -1,4 +1,4 @@
README - 23 March 2015 README - 30 May 2014
Welcome to the WebM VP8/VP9 Codec SDK! Welcome to the WebM VP8/VP9 Codec SDK!
@@ -47,6 +47,10 @@ COMPILING THE APPLICATIONS/LIBRARIES:
--help output of the configure script. As of this writing, the list of --help output of the configure script. As of this writing, the list of
available targets is: available targets is:
armv5te-android-gcc
armv5te-linux-rvct
armv5te-linux-gcc
armv5te-none-rvct
armv6-darwin-gcc armv6-darwin-gcc
armv6-linux-rvct armv6-linux-rvct
armv6-linux-gcc armv6-linux-gcc
@@ -62,6 +66,12 @@ COMPILING THE APPLICATIONS/LIBRARIES:
armv7s-darwin-gcc armv7s-darwin-gcc
mips32-linux-gcc mips32-linux-gcc
mips64-linux-gcc mips64-linux-gcc
ppc32-darwin8-gcc
ppc32-darwin9-gcc
ppc32-linux-gcc
ppc64-darwin8-gcc
ppc64-darwin9-gcc
ppc64-linux-gcc
sparc-solaris-gcc sparc-solaris-gcc
x86-android-gcc x86-android-gcc
x86-darwin8-gcc x86-darwin8-gcc
@@ -72,7 +82,6 @@ COMPILING THE APPLICATIONS/LIBRARIES:
x86-darwin11-gcc x86-darwin11-gcc
x86-darwin12-gcc x86-darwin12-gcc
x86-darwin13-gcc x86-darwin13-gcc
x86-darwin14-gcc
x86-iphonesimulator-gcc x86-iphonesimulator-gcc
x86-linux-gcc x86-linux-gcc
x86-linux-icc x86-linux-icc
@@ -90,7 +99,6 @@ COMPILING THE APPLICATIONS/LIBRARIES:
x86_64-darwin11-gcc x86_64-darwin11-gcc
x86_64-darwin12-gcc x86_64-darwin12-gcc
x86_64-darwin13-gcc x86_64-darwin13-gcc
x86_64-darwin14-gcc
x86_64-iphonesimulator-gcc x86_64-iphonesimulator-gcc
x86_64-linux-gcc x86_64-linux-gcc
x86_64-linux-icc x86_64-linux-icc
@@ -107,7 +115,6 @@ COMPILING THE APPLICATIONS/LIBRARIES:
universal-darwin11-gcc universal-darwin11-gcc
universal-darwin12-gcc universal-darwin12-gcc
universal-darwin13-gcc universal-darwin13-gcc
universal-darwin14-gcc
generic-gnu generic-gnu
The generic-gnu target, in conjunction with the CROSS environment variable, The generic-gnu target, in conjunction with the CROSS environment variable,

View File

@@ -0,0 +1,18 @@
REM Copyright (c) 2013 The WebM project authors. All Rights Reserved.
REM
REM Use of this source code is governed by a BSD-style license
REM that can be found in the LICENSE file in the root of the source
REM tree. An additional intellectual property rights grant can be found
REM in the file PATENTS. All contributing project authors may
REM be found in the AUTHORS file in the root of the source tree.
echo on
REM Arguments:
REM %1 - Relative path to the directory containing the vp8 and vpx_scale
REM source directories.
REM %2 - Path to obj_int_extract.exe.
cl /I. /I%1 /nologo /c /DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP "%~1/vp8/encoder/vp8_asm_enc_offsets.c"
%2\obj_int_extract.exe rvds "vp8_asm_enc_offsets.obj" > "vp8_asm_enc_offsets.asm"
cl /I. /I%1 /nologo /c /DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP "%~1/vpx_scale/vpx_scale_asm_offsets.c"
%2\obj_int_extract.exe rvds "vpx_scale_asm_offsets.obj" > "vpx_scale_asm_offsets.asm"

View File

@@ -43,7 +43,7 @@
# will remove any NEON dependency. # will remove any NEON dependency.
# To change to building armeabi, run ./libvpx/configure again, but with # To change to building armeabi, run ./libvpx/configure again, but with
# --target=armv6-android-gcc and modify the Application.mk file to # --target=arm5te-android-gcc and modify the Application.mk file to
# set APP_ABI := armeabi # set APP_ABI := armeabi
# #
# Running ndk-build will build libvpx and include it in your project. # Running ndk-build will build libvpx and include it in your project.
@@ -60,7 +60,7 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
include $(CONFIG_DIR)libs-armv7-android-gcc.mk include $(CONFIG_DIR)libs-armv7-android-gcc.mk
LOCAL_ARM_MODE := arm LOCAL_ARM_MODE := arm
else ifeq ($(TARGET_ARCH_ABI),armeabi) else ifeq ($(TARGET_ARCH_ABI),armeabi)
include $(CONFIG_DIR)libs-armv6-android-gcc.mk include $(CONFIG_DIR)libs-armv5te-android-gcc.mk
LOCAL_ARM_MODE := arm LOCAL_ARM_MODE := arm
else ifeq ($(TARGET_ARCH_ABI),arm64-v8a) else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
include $(CONFIG_DIR)libs-armv8-android-gcc.mk include $(CONFIG_DIR)libs-armv8-android-gcc.mk
@@ -91,8 +91,51 @@ LOCAL_CFLAGS := -O3
# like x86inc.asm and x86_abi_support.asm # like x86inc.asm and x86_abi_support.asm
LOCAL_ASMFLAGS := -I$(LIBVPX_PATH) LOCAL_ASMFLAGS := -I$(LIBVPX_PATH)
# -----------------------------------------------------------------------------
# Template : asm_offsets_template
# Arguments : 1: assembly offsets file to be created
# 2: c file to base assembly offsets on
# Returns : None
# Usage : $(eval $(call asm_offsets_template,<asmfile>, <srcfile>
# Rationale : Create offsets at compile time using for structures that are
# defined in c, but used in assembly functions.
# -----------------------------------------------------------------------------
define asm_offsets_template
_SRC:=$(2)
_OBJ:=$(ASM_CNV_PATH)/$$(notdir $(2)).S
_FLAGS = $$($$(my)CFLAGS) \
$$(call get-src-file-target-cflags,$(2)) \
$$(call host-c-includes,$$(LOCAL_C_INCLUDES) $$(CONFIG_DIR)) \
$$(LOCAL_CFLAGS) \
$$(NDK_APP_CFLAGS) \
$$(call host-c-includes,$$($(my)C_INCLUDES)) \
-DINLINE_ASM \
-S \
_TEXT = "Compile $$(call get-src-file-text,$(2))"
_CC = $$(TARGET_CC)
$$(eval $$(call ev-build-file))
$(1) : $$(_OBJ) $(2)
@mkdir -p $$(dir $$@)
@grep $(OFFSET_PATTERN) $$< | tr -d '\#' | $(CONFIG_DIR)$(ASM_CONVERSION) > $$@
endef
# Use ads2gas script to convert from RVCT format to GAS format. This
# puts the processed file under $(ASM_CNV_PATH). Local clean rule
# to handle removing these
ifeq ($(CONFIG_VP8_ENCODER), yes)
ASM_CNV_OFFSETS_DEPEND += $(ASM_CNV_PATH)/vp8_asm_enc_offsets.asm
endif
ifeq ($(HAVE_NEON_ASM), yes)
ASM_CNV_OFFSETS_DEPEND += $(ASM_CNV_PATH)/vpx_scale_asm_offsets.asm
endif
.PRECIOUS: %.asm.s .PRECIOUS: %.asm.s
$(ASM_CNV_PATH)/libvpx/%.asm.s: $(LIBVPX_PATH)/%.asm $(ASM_CNV_PATH)/libvpx/%.asm.s: $(LIBVPX_PATH)/%.asm $(ASM_CNV_OFFSETS_DEPEND)
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@$(CONFIG_DIR)$(ASM_CONVERSION) <$< > $@ @$(CONFIG_DIR)$(ASM_CONVERSION) <$< > $@
@@ -158,6 +201,8 @@ LOCAL_CFLAGS += \
LOCAL_MODULE := libvpx LOCAL_MODULE := libvpx
LOCAL_LDLIBS := -llog
ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes) ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes)
LOCAL_STATIC_LIBRARIES := cpufeatures LOCAL_STATIC_LIBRARIES := cpufeatures
endif endif
@@ -179,13 +224,22 @@ endif
clean: clean:
@echo "Clean: ads2gas files [$(TARGET_ARCH_ABI)]" @echo "Clean: ads2gas files [$(TARGET_ARCH_ABI)]"
@$(RM) $(CODEC_SRCS_ASM_ADS2GAS) $(CODEC_SRCS_ASM_NEON_ADS2GAS) @$(RM) $(CODEC_SRCS_ASM_ADS2GAS) $(CODEC_SRCS_ASM_NEON_ADS2GAS)
@$(RM) $(patsubst %.asm, %.*, $(ASM_CNV_OFFSETS_DEPEND))
@$(RM) -r $(ASM_CNV_PATH) @$(RM) -r $(ASM_CNV_PATH)
@$(RM) $(CLEAN-OBJS) @$(RM) $(CLEAN-OBJS)
ifeq ($(ENABLE_SHARED),1) include $(BUILD_SHARED_LIBRARY)
include $(BUILD_SHARED_LIBRARY)
else ifeq ($(HAVE_NEON), yes)
include $(BUILD_STATIC_LIBRARY) $(eval $(call asm_offsets_template,\
$(ASM_CNV_PATH)/vpx_scale_asm_offsets.asm, \
$(LIBVPX_PATH)/vpx_scale/vpx_scale_asm_offsets.c))
endif
ifeq ($(CONFIG_VP8_ENCODER), yes)
$(eval $(call asm_offsets_template,\
$(ASM_CNV_PATH)/vp8_asm_enc_offsets.asm, \
$(LIBVPX_PATH)/vp8/encoder/vp8_asm_enc_offsets.c))
endif endif
ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes) ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes)

View File

@@ -146,7 +146,6 @@ $(BUILD_PFX)%.c.d: %.c
$(BUILD_PFX)%.c.o: %.c $(BUILD_PFX)%.c.o: %.c
$(if $(quiet),@echo " [CC] $@") $(if $(quiet),@echo " [CC] $@")
$(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
$(qexec)$(CC) $(INTERNAL_CFLAGS) $(CFLAGS) -c -o $@ $< $(qexec)$(CC) $(INTERNAL_CFLAGS) $(CFLAGS) -c -o $@ $<
$(BUILD_PFX)%.cc.d: %.cc $(BUILD_PFX)%.cc.d: %.cc
@@ -156,7 +155,6 @@ $(BUILD_PFX)%.cc.d: %.cc
$(BUILD_PFX)%.cc.o: %.cc $(BUILD_PFX)%.cc.o: %.cc
$(if $(quiet),@echo " [CXX] $@") $(if $(quiet),@echo " [CXX] $@")
$(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
$(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $< $(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $<
$(BUILD_PFX)%.cpp.d: %.cpp $(BUILD_PFX)%.cpp.d: %.cpp
@@ -166,7 +164,6 @@ $(BUILD_PFX)%.cpp.d: %.cpp
$(BUILD_PFX)%.cpp.o: %.cpp $(BUILD_PFX)%.cpp.o: %.cpp
$(if $(quiet),@echo " [CXX] $@") $(if $(quiet),@echo " [CXX] $@")
$(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
$(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $< $(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $<
$(BUILD_PFX)%.asm.d: %.asm $(BUILD_PFX)%.asm.d: %.asm
@@ -177,7 +174,6 @@ $(BUILD_PFX)%.asm.d: %.asm
$(BUILD_PFX)%.asm.o: %.asm $(BUILD_PFX)%.asm.o: %.asm
$(if $(quiet),@echo " [AS] $@") $(if $(quiet),@echo " [AS] $@")
$(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
$(qexec)$(AS) $(ASFLAGS) -o $@ $< $(qexec)$(AS) $(ASFLAGS) -o $@ $<
$(BUILD_PFX)%.s.d: %.s $(BUILD_PFX)%.s.d: %.s
@@ -188,14 +184,12 @@ $(BUILD_PFX)%.s.d: %.s
$(BUILD_PFX)%.s.o: %.s $(BUILD_PFX)%.s.o: %.s
$(if $(quiet),@echo " [AS] $@") $(if $(quiet),@echo " [AS] $@")
$(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
$(qexec)$(AS) $(ASFLAGS) -o $@ $< $(qexec)$(AS) $(ASFLAGS) -o $@ $<
.PRECIOUS: %.c.S .PRECIOUS: %.c.S
%.c.S: CFLAGS += -DINLINE_ASM %.c.S: CFLAGS += -DINLINE_ASM
$(BUILD_PFX)%.c.S: %.c $(BUILD_PFX)%.c.S: %.c
$(if $(quiet),@echo " [GEN] $@") $(if $(quiet),@echo " [GEN] $@")
$(qexec)$(if $(CONFIG_DEPENDENCY_TRACKING),,mkdir -p $(dir $@))
$(qexec)$(CC) -S $(CFLAGS) -o $@ $< $(qexec)$(CC) -S $(CFLAGS) -o $@ $<
.PRECIOUS: %.asm.s .PRECIOUS: %.asm.s
@@ -222,6 +216,14 @@ else
$(qexec)cp $< $@ $(qexec)cp $< $@
endif endif
#
# Rule to extract assembly constants from C sources
#
obj_int_extract: build/make/obj_int_extract.c
$(if $(quiet),@echo " [HOSTCC] $@")
$(qexec)$(HOSTCC) -I. -I$(SRC_PATH_BARE) -o $@ $<
CLEAN-OBJS += obj_int_extract
# #
# Utility functions # Utility functions
# #
@@ -338,11 +340,9 @@ endif
skip_deps := $(filter %clean,$(MAKECMDGOALS)) skip_deps := $(filter %clean,$(MAKECMDGOALS))
skip_deps += $(findstring testdata,$(MAKECMDGOALS)) skip_deps += $(findstring testdata,$(MAKECMDGOALS))
ifeq ($(strip $(skip_deps)),) ifeq ($(strip $(skip_deps)),)
ifeq ($(CONFIG_DEPENDENCY_TRACKING),yes) # Older versions of make don't like -include directives with no arguments
# Older versions of make don't like -include directives with no arguments ifneq ($(filter %.d,$(OBJS-yes:.o=.d)),)
ifneq ($(filter %.d,$(OBJS-yes:.o=.d)),) -include $(filter %.d,$(OBJS-yes:.o=.d))
-include $(filter %.d,$(OBJS-yes:.o=.d))
endif
endif endif
endif endif
@@ -383,8 +383,8 @@ LIBS=$(call enabled,LIBS)
.libs: $(LIBS) .libs: $(LIBS)
@touch $@ @touch $@
$(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib)))) $(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib))))
$(foreach lib,$(filter %so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib)))) $(foreach lib,$(filter %so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib))))
$(foreach lib,$(filter %$(SO_VERSION_MAJOR).dylib,$(LIBS)),$(eval $(call dl_template,$(lib)))) $(foreach lib,$(filter %$(VERSION_MAJOR).dylib,$(LIBS)),$(eval $(call dl_template,$(lib))))
INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS) INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
ifeq ($(MAKECMDGOALS),dist) ifeq ($(MAKECMDGOALS),dist)
@@ -424,7 +424,11 @@ ifneq ($(call enabled,DIST-SRCS),)
DIST-SRCS-$(CONFIG_MSVS) += build/make/gen_msvs_sln.sh DIST-SRCS-$(CONFIG_MSVS) += build/make/gen_msvs_sln.sh
DIST-SRCS-$(CONFIG_MSVS) += build/make/gen_msvs_vcxproj.sh DIST-SRCS-$(CONFIG_MSVS) += build/make/gen_msvs_vcxproj.sh
DIST-SRCS-$(CONFIG_MSVS) += build/make/msvs_common.sh DIST-SRCS-$(CONFIG_MSVS) += build/make/msvs_common.sh
DIST-SRCS-$(CONFIG_MSVS) += build/x86-msvs/obj_int_extract.bat
DIST-SRCS-$(CONFIG_MSVS) += build/arm-msvs/obj_int_extract.bat
DIST-SRCS-$(CONFIG_RVCT) += build/make/armlink_adapter.sh DIST-SRCS-$(CONFIG_RVCT) += build/make/armlink_adapter.sh
# Include obj_int_extract if we use offsets from *_asm_*_offsets
DIST-SRCS-$(ARCH_ARM)$(ARCH_X86)$(ARCH_X86_64) += build/make/obj_int_extract.c
DIST-SRCS-$(ARCH_ARM) += build/make/ads2gas.pl DIST-SRCS-$(ARCH_ARM) += build/make/ads2gas.pl
DIST-SRCS-$(ARCH_ARM) += build/make/ads2gas_apple.pl DIST-SRCS-$(ARCH_ARM) += build/make/ads2gas_apple.pl
DIST-SRCS-$(ARCH_ARM) += build/make/ads2armasm_ms.pl DIST-SRCS-$(ARCH_ARM) += build/make/ads2armasm_ms.pl

File diff suppressed because it is too large Load Diff

View File

@@ -295,7 +295,22 @@ generate_vcproj() {
case "$target" in case "$target" in
x86*) x86*)
case "$name" in case "$name" in
obj_int_extract)
tag Tool \
Name="VCCLCompilerTool" \
Optimization="0" \
AdditionalIncludeDirectories="$incs" \
PreprocessorDefinitions="WIN32;DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" \
RuntimeLibrary="$debug_runtime" \
WarningLevel="3" \
DebugInformationFormat="1" \
$warn_64bit \
;;
vpx) vpx)
tag Tool \
Name="VCPreBuildEventTool" \
CommandLine="call obj_int_extract.bat &quot;$src_path_bare&quot; $plat_no_ws\\\$(ConfigurationName)" \
tag Tool \ tag Tool \
Name="VCCLCompilerTool" \ Name="VCCLCompilerTool" \
Optimization="0" \ Optimization="0" \
@@ -332,6 +347,11 @@ generate_vcproj() {
case "$target" in case "$target" in
x86*) x86*)
case "$name" in case "$name" in
obj_int_extract)
tag Tool \
Name="VCLinkerTool" \
GenerateDebugInformation="true" \
;;
*) *)
tag Tool \ tag Tool \
Name="VCLinkerTool" \ Name="VCLinkerTool" \
@@ -380,7 +400,24 @@ generate_vcproj() {
case "$target" in case "$target" in
x86*) x86*)
case "$name" in case "$name" in
obj_int_extract)
tag Tool \
Name="VCCLCompilerTool" \
Optimization="2" \
FavorSizeorSpeed="1" \
AdditionalIncludeDirectories="$incs" \
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE" \
RuntimeLibrary="$release_runtime" \
UsePrecompiledHeader="0" \
WarningLevel="3" \
DebugInformationFormat="0" \
$warn_64bit \
;;
vpx) vpx)
tag Tool \
Name="VCPreBuildEventTool" \
CommandLine="call obj_int_extract.bat &quot;$src_path_bare&quot; $plat_no_ws\\\$(ConfigurationName)" \
tag Tool \ tag Tool \
Name="VCCLCompilerTool" \ Name="VCCLCompilerTool" \
Optimization="2" \ Optimization="2" \
@@ -419,6 +456,11 @@ generate_vcproj() {
case "$target" in case "$target" in
x86*) x86*)
case "$name" in case "$name" in
obj_int_extract)
tag Tool \
Name="VCLinkerTool" \
GenerateDebugInformation="true" \
;;
*) *)
tag Tool \ tag Tool \
Name="VCLinkerTool" \ Name="VCLinkerTool" \

View File

@@ -262,9 +262,15 @@ case "$target" in
asm_Release_cmdline="yasm -Xvc -f win32 ${yasmincs} &quot;%(FullPath)&quot;" asm_Release_cmdline="yasm -Xvc -f win32 ${yasmincs} &quot;%(FullPath)&quot;"
;; ;;
arm*) arm*)
platforms[0]="ARM"
asm_Debug_cmdline="armasm -nologo &quot;%(FullPath)&quot;" asm_Debug_cmdline="armasm -nologo &quot;%(FullPath)&quot;"
asm_Release_cmdline="armasm -nologo &quot;%(FullPath)&quot;" asm_Release_cmdline="armasm -nologo &quot;%(FullPath)&quot;"
if [ "$name" = "obj_int_extract" ]; then
# We don't want to build this tool for the target architecture,
# but for an architecture we can run locally during the build.
platforms[0]="Win32"
else
platforms[0]="ARM"
fi
;; ;;
*) die "Unsupported target $target!" *) die "Unsupported target $target!"
;; ;;
@@ -394,13 +400,23 @@ generate_vcxproj() {
if [ "$hostplat" == "ARM" ]; then if [ "$hostplat" == "ARM" ]; then
hostplat=Win32 hostplat=Win32
fi fi
open_tag PreBuildEvent
tag_content Command "call obj_int_extract.bat &quot;$src_path_bare&quot; $hostplat\\\$(Configuration)"
close_tag PreBuildEvent
fi fi
open_tag ClCompile open_tag ClCompile
if [ "$config" = "Debug" ]; then if [ "$config" = "Debug" ]; then
opt=Disabled opt=Disabled
runtime=$debug_runtime runtime=$debug_runtime
curlibs=$debug_libs curlibs=$debug_libs
debug=_DEBUG case "$name" in
obj_int_extract)
debug=DEBUG
;;
*)
debug=_DEBUG
;;
esac
else else
opt=MaxSpeed opt=MaxSpeed
runtime=$release_runtime runtime=$release_runtime
@@ -408,7 +424,14 @@ generate_vcxproj() {
tag_content FavorSizeOrSpeed Speed tag_content FavorSizeOrSpeed Speed
debug=NDEBUG debug=NDEBUG
fi fi
extradefines=";$defines" case "$name" in
obj_int_extract)
extradefines=";_CONSOLE"
;;
*)
extradefines=";$defines"
;;
esac
tag_content Optimization $opt tag_content Optimization $opt
tag_content AdditionalIncludeDirectories "$incs;%(AdditionalIncludeDirectories)" tag_content AdditionalIncludeDirectories "$incs;%(AdditionalIncludeDirectories)"
tag_content PreprocessorDefinitions "WIN32;$debug;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE$extradefines;%(PreprocessorDefinitions)" tag_content PreprocessorDefinitions "WIN32;$debug;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE$extradefines;%(PreprocessorDefinitions)"
@@ -428,6 +451,10 @@ generate_vcxproj() {
case "$proj_kind" in case "$proj_kind" in
exe) exe)
open_tag Link open_tag Link
if [ "$name" != "obj_int_extract" ]; then
tag_content AdditionalDependencies "$curlibs;%(AdditionalDependencies)"
tag_content AdditionalLibraryDirectories "$libdirs;%(AdditionalLibraryDirectories)"
fi
tag_content GenerateDebugInformation true tag_content GenerateDebugInformation true
# Console is the default normally, but if # Console is the default normally, but if
# AppContainerApplication is set, we need to override it. # AppContainerApplication is set, we need to override it.

View File

@@ -18,19 +18,15 @@ set -e
devnull='> /dev/null 2>&1' devnull='> /dev/null 2>&1'
BUILD_ROOT="_iosbuild" BUILD_ROOT="_iosbuild"
CONFIGURE_ARGS="--disable-docs
--disable-examples
--disable-libyuv
--disable-unit-tests"
DIST_DIR="_dist" DIST_DIR="_dist"
FRAMEWORK_DIR="VPX.framework" FRAMEWORK_DIR="VPX.framework"
HEADER_DIR="${FRAMEWORK_DIR}/Headers/vpx" HEADER_DIR="${FRAMEWORK_DIR}/Headers/vpx"
MAKE_JOBS=1 MAKE_JOBS=1
SCRIPT_DIR=$(dirname "$0") LIBVPX_SOURCE_DIR=$(dirname "$0" | sed -e s,/build/make,,)
LIBVPX_SOURCE_DIR=$(cd ${SCRIPT_DIR}/../..; pwd)
LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo) LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo)
ORIG_PWD="$(pwd)" ORIG_PWD="$(pwd)"
TARGETS="arm64-darwin-gcc TARGETS="arm64-darwin-gcc
armv6-darwin-gcc
armv7-darwin-gcc armv7-darwin-gcc
armv7s-darwin-gcc armv7s-darwin-gcc
x86-iphonesimulator-gcc x86-iphonesimulator-gcc
@@ -46,8 +42,8 @@ build_target() {
mkdir "${target}" mkdir "${target}"
cd "${target}" cd "${target}"
eval "${LIBVPX_SOURCE_DIR}/configure" --target="${target}" \ eval "../../${LIBVPX_SOURCE_DIR}/configure" --target="${target}" \
${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS} ${devnull} --disable-docs ${EXTRA_CONFIGURE_ARGS} ${devnull}
export DIST_DIR export DIST_DIR
eval make -j ${MAKE_JOBS} dist ${devnull} eval make -j ${MAKE_JOBS} dist ${devnull}
cd "${old_pwd}" cd "${old_pwd}"
@@ -62,6 +58,9 @@ target_to_preproc_symbol() {
arm64-*) arm64-*)
echo "__aarch64__" echo "__aarch64__"
;; ;;
armv6-*)
echo "__ARM_ARCH_6__"
;;
armv7-*) armv7-*)
echo "__ARM_ARCH_7A__" echo "__ARM_ARCH_7A__"
;; ;;
@@ -177,13 +176,8 @@ build_framework() {
# Trap function. Cleans up the subtree used to build all targets contained in # Trap function. Cleans up the subtree used to build all targets contained in
# $TARGETS. # $TARGETS.
cleanup() { cleanup() {
local readonly res=$?
cd "${ORIG_PWD}" cd "${ORIG_PWD}"
if [ $res -ne 0 ]; then
elog "build exited with error ($res)"
fi
if [ "${PRESERVE_BUILD_OUTPUT}" != "yes" ]; then if [ "${PRESERVE_BUILD_OUTPUT}" != "yes" ]; then
rm -rf "${BUILD_ROOT}" rm -rf "${BUILD_ROOT}"
fi fi
@@ -193,21 +187,14 @@ iosbuild_usage() {
cat << EOF cat << EOF
Usage: ${0##*/} [arguments] Usage: ${0##*/} [arguments]
--help: Display this message and exit. --help: Display this message and exit.
--extra-configure-args <args>: Extra args to pass when configuring libvpx.
--jobs: Number of make jobs. --jobs: Number of make jobs.
--preserve-build-output: Do not delete the build directory. --preserve-build-output: Do not delete the build directory.
--show-build-output: Show output from each library build. --show-build-output: Show output from each library build.
--targets <targets>: Override default target list. Defaults:
${TARGETS}
--verbose: Output information about the environment and each stage of the --verbose: Output information about the environment and each stage of the
build. build.
EOF EOF
} }
elog() {
echo "${0##*/} failed because: $@" 1>&2
}
vlog() { vlog() {
if [ "${VERBOSE}" = "yes" ]; then if [ "${VERBOSE}" = "yes" ]; then
echo "$@" echo "$@"
@@ -237,10 +224,6 @@ while [ -n "$1" ]; do
--show-build-output) --show-build-output)
devnull= devnull=
;; ;;
--targets)
TARGETS="$2"
shift
;;
--verbose) --verbose)
VERBOSE=yes VERBOSE=yes
;; ;;
@@ -256,7 +239,6 @@ if [ "${VERBOSE}" = "yes" ]; then
cat << EOF cat << EOF
BUILD_ROOT=${BUILD_ROOT} BUILD_ROOT=${BUILD_ROOT}
DIST_DIR=${DIST_DIR} DIST_DIR=${DIST_DIR}
CONFIGURE_ARGS=${CONFIGURE_ARGS}
EXTRA_CONFIGURE_ARGS=${EXTRA_CONFIGURE_ARGS} EXTRA_CONFIGURE_ARGS=${EXTRA_CONFIGURE_ARGS}
FRAMEWORK_DIR=${FRAMEWORK_DIR} FRAMEWORK_DIR=${FRAMEWORK_DIR}
HEADER_DIR=${HEADER_DIR} HEADER_DIR=${HEADER_DIR}
@@ -270,5 +252,3 @@ EOF
fi fi
build_framework "${TARGETS}" build_framework "${TARGETS}"
echo "Successfully built '${FRAMEWORK_DIR}' for:"
echo " ${TARGETS}"

View File

@@ -0,0 +1,857 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vpx_config.h"
#include "vpx/vpx_integer.h"
typedef enum {
OUTPUT_FMT_PLAIN,
OUTPUT_FMT_RVDS,
OUTPUT_FMT_GAS,
OUTPUT_FMT_C_HEADER,
} output_fmt_t;
int log_msg(const char *fmt, ...) {
int res;
va_list ap;
va_start(ap, fmt);
res = vfprintf(stderr, fmt, ap);
va_end(ap);
return res;
}
#if defined(__GNUC__) && __GNUC__
#if defined(FORCE_PARSE_ELF)
#if defined(__MACH__)
#undef __MACH__
#endif
#if !defined(__ELF__)
#define __ELF__
#endif
#endif
#if defined(__MACH__)
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
int print_macho_equ(output_fmt_t mode, uint8_t* name, int val) {
switch (mode) {
case OUTPUT_FMT_RVDS:
printf("%-40s EQU %5d\n", name, val);
return 0;
case OUTPUT_FMT_GAS:
printf(".set %-40s, %5d\n", name, val);
return 0;
case OUTPUT_FMT_C_HEADER:
printf("#define %-40s %5d\n", name, val);
return 0;
default:
log_msg("Unsupported mode: %d", mode);
return 1;
}
}
int parse_macho(uint8_t *base_buf, size_t sz, output_fmt_t mode) {
int i, j;
struct mach_header header;
uint8_t *buf = base_buf;
int base_data_section = 0;
int bits = 0;
/* We can read in mach_header for 32 and 64 bit architectures
* because it's identical to mach_header_64 except for the last
* element (uint32_t reserved), which we don't use. Then, when
* we know which architecture we're looking at, increment buf
* appropriately.
*/
memcpy(&header, buf, sizeof(struct mach_header));
if (header.magic == MH_MAGIC) {
if (header.cputype == CPU_TYPE_ARM
|| header.cputype == CPU_TYPE_X86) {
bits = 32;
buf += sizeof(struct mach_header);
} else {
log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_[ARM|X86].\n");
goto bail;
}
} else if (header.magic == MH_MAGIC_64) {
if (header.cputype == CPU_TYPE_X86_64) {
bits = 64;
buf += sizeof(struct mach_header_64);
} else {
log_msg("Bad cputype for object file. Currently only tested for CPU_TYPE_X86_64.\n");
goto bail;
}
} else {
log_msg("Bad magic number for object file. 0x%x or 0x%x expected, 0x%x found.\n",
MH_MAGIC, MH_MAGIC_64, header.magic);
goto bail;
}
if (header.filetype != MH_OBJECT) {
log_msg("Bad filetype for object file. Currently only tested for MH_OBJECT.\n");
goto bail;
}
for (i = 0; i < header.ncmds; i++) {
struct load_command lc;
memcpy(&lc, buf, sizeof(struct load_command));
if (lc.cmd == LC_SEGMENT) {
uint8_t *seg_buf = buf;
struct section s;
struct segment_command seg_c;
memcpy(&seg_c, seg_buf, sizeof(struct segment_command));
seg_buf += sizeof(struct segment_command);
/* Although each section is given it's own offset, nlist.n_value
* references the offset of the first section. This isn't
* apparent without debug information because the offset of the
* data section is the same as the first section. However, with
* debug sections mixed in, the offset of the debug section
* increases but n_value still references the first section.
*/
if (seg_c.nsects < 1) {
log_msg("Not enough sections\n");
goto bail;
}
memcpy(&s, seg_buf, sizeof(struct section));
base_data_section = s.offset;
} else if (lc.cmd == LC_SEGMENT_64) {
uint8_t *seg_buf = buf;
struct section_64 s;
struct segment_command_64 seg_c;
memcpy(&seg_c, seg_buf, sizeof(struct segment_command_64));
seg_buf += sizeof(struct segment_command_64);
/* Explanation in LG_SEGMENT */
if (seg_c.nsects < 1) {
log_msg("Not enough sections\n");
goto bail;
}
memcpy(&s, seg_buf, sizeof(struct section_64));
base_data_section = s.offset;
} else if (lc.cmd == LC_SYMTAB) {
if (base_data_section != 0) {
struct symtab_command sc;
uint8_t *sym_buf = base_buf;
uint8_t *str_buf = base_buf;
memcpy(&sc, buf, sizeof(struct symtab_command));
if (sc.cmdsize != sizeof(struct symtab_command)) {
log_msg("Can't find symbol table!\n");
goto bail;
}
sym_buf += sc.symoff;
str_buf += sc.stroff;
for (j = 0; j < sc.nsyms; j++) {
/* Location of string is cacluated each time from the
* start of the string buffer. On darwin the symbols
* are prefixed by "_", so we bump the pointer by 1.
* The target value is defined as an int in *_asm_*_offsets.c,
* which is 4 bytes on all targets we currently use.
*/
if (bits == 32) {
struct nlist nl;
int val;
memcpy(&nl, sym_buf, sizeof(struct nlist));
sym_buf += sizeof(struct nlist);
memcpy(&val, base_buf + base_data_section + nl.n_value,
sizeof(val));
print_macho_equ(mode, str_buf + nl.n_un.n_strx + 1, val);
} else { /* if (bits == 64) */
struct nlist_64 nl;
int val;
memcpy(&nl, sym_buf, sizeof(struct nlist_64));
sym_buf += sizeof(struct nlist_64);
memcpy(&val, base_buf + base_data_section + nl.n_value,
sizeof(val));
print_macho_equ(mode, str_buf + nl.n_un.n_strx + 1, val);
}
}
}
}
buf += lc.cmdsize;
}
return 0;
bail:
return 1;
}
#elif defined(__ELF__)
#include "elf.h"
#define COPY_STRUCT(dst, buf, ofst, sz) do {\
if(ofst + sizeof((*(dst))) > sz) goto bail;\
memcpy(dst, buf+ofst, sizeof((*(dst))));\
} while(0)
#define ENDIAN_ASSIGN(val, memb) do {\
if(!elf->le_data) {log_msg("Big Endian data not supported yet!\n");goto bail;}\
(val) = (memb);\
} while(0)
#define ENDIAN_ASSIGN_IN_PLACE(memb) do {\
ENDIAN_ASSIGN(memb, memb);\
} while(0)
typedef struct {
uint8_t *buf; /* Buffer containing ELF data */
size_t sz; /* Buffer size */
int le_data; /* Data is little-endian */
unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
int bits; /* 32 or 64 */
Elf32_Ehdr hdr32;
Elf64_Ehdr hdr64;
} elf_obj_t;
int parse_elf_header(elf_obj_t *elf) {
int res;
/* Verify ELF Magic numbers */
COPY_STRUCT(&elf->e_ident, elf->buf, 0, elf->sz);
res = elf->e_ident[EI_MAG0] == ELFMAG0;
res &= elf->e_ident[EI_MAG1] == ELFMAG1;
res &= elf->e_ident[EI_MAG2] == ELFMAG2;
res &= elf->e_ident[EI_MAG3] == ELFMAG3;
res &= elf->e_ident[EI_CLASS] == ELFCLASS32
|| elf->e_ident[EI_CLASS] == ELFCLASS64;
res &= elf->e_ident[EI_DATA] == ELFDATA2LSB;
if (!res) goto bail;
elf->le_data = elf->e_ident[EI_DATA] == ELFDATA2LSB;
/* Read in relevant values */
if (elf->e_ident[EI_CLASS] == ELFCLASS32) {
elf->bits = 32;
COPY_STRUCT(&elf->hdr32, elf->buf, 0, elf->sz);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_type);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_machine);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_version);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_entry);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_phoff);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shoff);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_flags);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_ehsize);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_phentsize);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_phnum);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shentsize);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shnum);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr32.e_shstrndx);
} else { /* if (elf->e_ident[EI_CLASS] == ELFCLASS64) */
elf->bits = 64;
COPY_STRUCT(&elf->hdr64, elf->buf, 0, elf->sz);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_type);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_machine);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_version);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_entry);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_phoff);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shoff);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_flags);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_ehsize);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_phentsize);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_phnum);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shentsize);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shnum);
ENDIAN_ASSIGN_IN_PLACE(elf->hdr64.e_shstrndx);
}
return 0;
bail:
log_msg("Failed to parse ELF file header");
return 1;
}
int parse_elf_section(elf_obj_t *elf, int idx, Elf32_Shdr *hdr32, Elf64_Shdr *hdr64) {
if (hdr32) {
if (idx >= elf->hdr32.e_shnum)
goto bail;
COPY_STRUCT(hdr32, elf->buf, elf->hdr32.e_shoff + idx * elf->hdr32.e_shentsize,
elf->sz);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_name);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_type);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_flags);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_addr);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_offset);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_size);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_link);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_info);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_addralign);
ENDIAN_ASSIGN_IN_PLACE(hdr32->sh_entsize);
} else { /* if (hdr64) */
if (idx >= elf->hdr64.e_shnum)
goto bail;
COPY_STRUCT(hdr64, elf->buf, elf->hdr64.e_shoff + idx * elf->hdr64.e_shentsize,
elf->sz);
ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_name);
ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_type);
ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_flags);
ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_addr);
ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_offset);
ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_size);
ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_link);
ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_info);
ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_addralign);
ENDIAN_ASSIGN_IN_PLACE(hdr64->sh_entsize);
}
return 0;
bail:
return 1;
}
const char *parse_elf_string_table(elf_obj_t *elf, int s_idx, int idx) {
if (elf->bits == 32) {
Elf32_Shdr shdr;
if (parse_elf_section(elf, s_idx, &shdr, NULL)) {
log_msg("Failed to parse ELF string table: section %d, index %d\n",
s_idx, idx);
return "";
}
return (char *)(elf->buf + shdr.sh_offset + idx);
} else { /* if (elf->bits == 64) */
Elf64_Shdr shdr;
if (parse_elf_section(elf, s_idx, NULL, &shdr)) {
log_msg("Failed to parse ELF string table: section %d, index %d\n",
s_idx, idx);
return "";
}
return (char *)(elf->buf + shdr.sh_offset + idx);
}
}
int parse_elf_symbol(elf_obj_t *elf, unsigned int ofst, Elf32_Sym *sym32, Elf64_Sym *sym64) {
if (sym32) {
COPY_STRUCT(sym32, elf->buf, ofst, elf->sz);
ENDIAN_ASSIGN_IN_PLACE(sym32->st_name);
ENDIAN_ASSIGN_IN_PLACE(sym32->st_value);
ENDIAN_ASSIGN_IN_PLACE(sym32->st_size);
ENDIAN_ASSIGN_IN_PLACE(sym32->st_info);
ENDIAN_ASSIGN_IN_PLACE(sym32->st_other);
ENDIAN_ASSIGN_IN_PLACE(sym32->st_shndx);
} else { /* if (sym64) */
COPY_STRUCT(sym64, elf->buf, ofst, elf->sz);
ENDIAN_ASSIGN_IN_PLACE(sym64->st_name);
ENDIAN_ASSIGN_IN_PLACE(sym64->st_value);
ENDIAN_ASSIGN_IN_PLACE(sym64->st_size);
ENDIAN_ASSIGN_IN_PLACE(sym64->st_info);
ENDIAN_ASSIGN_IN_PLACE(sym64->st_other);
ENDIAN_ASSIGN_IN_PLACE(sym64->st_shndx);
}
return 0;
bail:
return 1;
}
int parse_elf(uint8_t *buf, size_t sz, output_fmt_t mode) {
elf_obj_t elf;
unsigned int ofst;
int i;
Elf32_Off strtab_off32;
Elf64_Off strtab_off64; /* save String Table offset for later use */
memset(&elf, 0, sizeof(elf));
elf.buf = buf;
elf.sz = sz;
/* Parse Header */
if (parse_elf_header(&elf))
goto bail;
if (elf.bits == 32) {
Elf32_Shdr shdr;
for (i = 0; i < elf.hdr32.e_shnum; i++) {
parse_elf_section(&elf, i, &shdr, NULL);
if (shdr.sh_type == SHT_STRTAB) {
char strtsb_name[128];
strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name));
if (!(strcmp(strtsb_name, ".shstrtab"))) {
/* log_msg("found section: %s\n", strtsb_name); */
strtab_off32 = shdr.sh_offset;
break;
}
}
}
} else { /* if (elf.bits == 64) */
Elf64_Shdr shdr;
for (i = 0; i < elf.hdr64.e_shnum; i++) {
parse_elf_section(&elf, i, NULL, &shdr);
if (shdr.sh_type == SHT_STRTAB) {
char strtsb_name[128];
strcpy(strtsb_name, (char *)(elf.buf + shdr.sh_offset + shdr.sh_name));
if (!(strcmp(strtsb_name, ".shstrtab"))) {
/* log_msg("found section: %s\n", strtsb_name); */
strtab_off64 = shdr.sh_offset;
break;
}
}
}
}
/* Parse all Symbol Tables */
if (elf.bits == 32) {
Elf32_Shdr shdr;
for (i = 0; i < elf.hdr32.e_shnum; i++) {
parse_elf_section(&elf, i, &shdr, NULL);
if (shdr.sh_type == SHT_SYMTAB) {
for (ofst = shdr.sh_offset;
ofst < shdr.sh_offset + shdr.sh_size;
ofst += shdr.sh_entsize) {
Elf32_Sym sym;
parse_elf_symbol(&elf, ofst, &sym, NULL);
/* For all OBJECTS (data objects), extract the value from the
* proper data segment.
*/
/* if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT && sym.st_name)
log_msg("found data object %s\n",
parse_elf_string_table(&elf,
shdr.sh_link,
sym.st_name));
*/
if (ELF32_ST_TYPE(sym.st_info) == STT_OBJECT
&& sym.st_size == 4) {
Elf32_Shdr dhdr;
int val = 0;
char section_name[128];
parse_elf_section(&elf, sym.st_shndx, &dhdr, NULL);
/* For explanition - refer to _MSC_VER version of code */
strcpy(section_name, (char *)(elf.buf + strtab_off32 + dhdr.sh_name));
/* log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type); */
if (strcmp(section_name, ".bss")) {
if (sizeof(val) != sym.st_size) {
/* The target value is declared as an int in
* *_asm_*_offsets.c, which is 4 bytes on all
* targets we currently use. Complain loudly if
* this is not true.
*/
log_msg("Symbol size is wrong\n");
goto bail;
}
memcpy(&val,
elf.buf + dhdr.sh_offset + sym.st_value,
sym.st_size);
}
if (!elf.le_data) {
log_msg("Big Endian data not supported yet!\n");
goto bail;
}
switch (mode) {
case OUTPUT_FMT_RVDS:
printf("%-40s EQU %5d\n",
parse_elf_string_table(&elf,
shdr.sh_link,
sym.st_name),
val);
break;
case OUTPUT_FMT_GAS:
printf(".equ %-40s, %5d\n",
parse_elf_string_table(&elf,
shdr.sh_link,
sym.st_name),
val);
break;
case OUTPUT_FMT_C_HEADER:
printf("#define %-40s %5d\n",
parse_elf_string_table(&elf,
shdr.sh_link,
sym.st_name),
val);
break;
default:
printf("%s = %d\n",
parse_elf_string_table(&elf,
shdr.sh_link,
sym.st_name),
val);
}
}
}
}
}
} else { /* if (elf.bits == 64) */
Elf64_Shdr shdr;
for (i = 0; i < elf.hdr64.e_shnum; i++) {
parse_elf_section(&elf, i, NULL, &shdr);
if (shdr.sh_type == SHT_SYMTAB) {
for (ofst = shdr.sh_offset;
ofst < shdr.sh_offset + shdr.sh_size;
ofst += shdr.sh_entsize) {
Elf64_Sym sym;
parse_elf_symbol(&elf, ofst, NULL, &sym);
/* For all OBJECTS (data objects), extract the value from the
* proper data segment.
*/
/* if (ELF64_ST_TYPE(sym.st_info) == STT_OBJECT && sym.st_name)
log_msg("found data object %s\n",
parse_elf_string_table(&elf,
shdr.sh_link,
sym.st_name));
*/
if (ELF64_ST_TYPE(sym.st_info) == STT_OBJECT
&& sym.st_size == 4) {
Elf64_Shdr dhdr;
int val = 0;
char section_name[128];
parse_elf_section(&elf, sym.st_shndx, NULL, &dhdr);
/* For explanition - refer to _MSC_VER version of code */
strcpy(section_name, (char *)(elf.buf + strtab_off64 + dhdr.sh_name));
/* log_msg("Section_name: %s, Section_type: %d\n", section_name, dhdr.sh_type); */
if ((strcmp(section_name, ".bss"))) {
if (sizeof(val) != sym.st_size) {
/* The target value is declared as an int in
* *_asm_*_offsets.c, which is 4 bytes on all
* targets we currently use. Complain loudly if
* this is not true.
*/
log_msg("Symbol size is wrong\n");
goto bail;
}
memcpy(&val,
elf.buf + dhdr.sh_offset + sym.st_value,
sym.st_size);
}
if (!elf.le_data) {
log_msg("Big Endian data not supported yet!\n");
goto bail;
}
switch (mode) {
case OUTPUT_FMT_RVDS:
printf("%-40s EQU %5d\n",
parse_elf_string_table(&elf,
shdr.sh_link,
sym.st_name),
val);
break;
case OUTPUT_FMT_GAS:
printf(".equ %-40s, %5d\n",
parse_elf_string_table(&elf,
shdr.sh_link,
sym.st_name),
val);
break;
default:
printf("%s = %d\n",
parse_elf_string_table(&elf,
shdr.sh_link,
sym.st_name),
val);
}
}
}
}
}
}
if (mode == OUTPUT_FMT_RVDS)
printf(" END\n");
return 0;
bail:
log_msg("Parse error: File does not appear to be valid ELF32 or ELF64\n");
return 1;
}
#endif
#endif /* defined(__GNUC__) && __GNUC__ */
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
/* See "Microsoft Portable Executable and Common Object File Format Specification"
for reference.
*/
#define get_le32(x) ((*(x)) | (*(x+1)) << 8 |(*(x+2)) << 16 | (*(x+3)) << 24 )
#define get_le16(x) ((*(x)) | (*(x+1)) << 8)
int parse_coff(uint8_t *buf, size_t sz) {
unsigned int nsections, symtab_ptr, symtab_sz, strtab_ptr;
unsigned int sectionrawdata_ptr;
unsigned int i;
uint8_t *ptr;
uint32_t symoffset;
char **sectionlist; // this array holds all section names in their correct order.
// it is used to check if the symbol is in .bss or .rdata section.
nsections = get_le16(buf + 2);
symtab_ptr = get_le32(buf + 8);
symtab_sz = get_le32(buf + 12);
strtab_ptr = symtab_ptr + symtab_sz * 18;
if (nsections > 96) {
log_msg("Too many sections\n");
return 1;
}
sectionlist = malloc(nsections * sizeof(sectionlist));
if (sectionlist == NULL) {
log_msg("Allocating first level of section list failed\n");
return 1;
}
// log_msg("COFF: Found %u symbols in %u sections.\n", symtab_sz, nsections);
/*
The size of optional header is always zero for an obj file. So, the section header
follows the file header immediately.
*/
ptr = buf + 20; // section header
for (i = 0; i < nsections; i++) {
char sectionname[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
strncpy(sectionname, ptr, 8);
// log_msg("COFF: Parsing section %s\n",sectionname);
sectionlist[i] = malloc(strlen(sectionname) + 1);
if (sectionlist[i] == NULL) {
log_msg("Allocating storage for %s failed\n", sectionname);
goto bail;
}
strcpy(sectionlist[i], sectionname);
// check if it's .rdata and is not a COMDAT section.
if (!strcmp(sectionname, ".rdata") &&
(get_le32(ptr + 36) & 0x1000) == 0) {
sectionrawdata_ptr = get_le32(ptr + 20);
}
ptr += 40;
}
// log_msg("COFF: Symbol table at offset %u\n", symtab_ptr);
// log_msg("COFF: raw data pointer ofset for section .rdata is %u\n", sectionrawdata_ptr);
/* The compiler puts the data with non-zero offset in .rdata section, but puts the data with
zero offset in .bss section. So, if the data in in .bss section, set offset=0.
Note from Wiki: In an object module compiled from C, the bss section contains
the local variables (but not functions) that were declared with the static keyword,
except for those with non-zero initial values. (In C, static variables are initialized
to zero by default.) It also contains the non-local (both extern and static) variables
that are also initialized to zero (either explicitly or by default).
*/
// move to symbol table
/* COFF symbol table:
offset field
0 Name(*)
8 Value
12 SectionNumber
14 Type
16 StorageClass
17 NumberOfAuxSymbols
*/
ptr = buf + symtab_ptr;
for (i = 0; i < symtab_sz; i++) {
int16_t section = get_le16(ptr + 12); // section number
if (section > 0 && ptr[16] == 2) {
// if(section > 0 && ptr[16] == 3 && get_le32(ptr+8)) {
if (get_le32(ptr)) {
char name[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
strncpy(name, ptr, 8);
// log_msg("COFF: Parsing symbol %s\n",name);
/* The 64bit Windows compiler doesn't prefix with an _.
* Check what's there, and bump if necessary
*/
if (name[0] == '_')
printf("%-40s EQU ", name + 1);
else
printf("%-40s EQU ", name);
} else {
// log_msg("COFF: Parsing symbol %s\n",
// buf + strtab_ptr + get_le32(ptr+4));
if ((buf + strtab_ptr + get_le32(ptr + 4))[0] == '_')
printf("%-40s EQU ",
buf + strtab_ptr + get_le32(ptr + 4) + 1);
else
printf("%-40s EQU ", buf + strtab_ptr + get_le32(ptr + 4));
}
if (!(strcmp(sectionlist[section - 1], ".bss"))) {
symoffset = 0;
} else {
symoffset = get_le32(buf + sectionrawdata_ptr + get_le32(ptr + 8));
}
// log_msg(" Section: %d\n",section);
// log_msg(" Class: %d\n",ptr[16]);
// log_msg(" Address: %u\n",get_le32(ptr+8));
// log_msg(" Offset: %u\n", symoffset);
printf("%5d\n", symoffset);
}
ptr += 18;
}
printf(" END\n");
for (i = 0; i < nsections; i++) {
free(sectionlist[i]);
}
free(sectionlist);
return 0;
bail:
for (i = 0; i < nsections; i++) {
free(sectionlist[i]);
}
free(sectionlist);
return 1;
}
#endif /* defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) */
int main(int argc, char **argv) {
output_fmt_t mode = OUTPUT_FMT_PLAIN;
const char *f;
uint8_t *file_buf;
int res;
FILE *fp;
long int file_size;
if (argc < 2 || argc > 3) {
fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]);
fprintf(stderr, " <obj file>\tobject file to parse\n");
fprintf(stderr, "Output Formats:\n");
fprintf(stderr, " gas - compatible with GNU assembler\n");
fprintf(stderr, " rvds - compatible with armasm\n");
fprintf(stderr, " cheader - c/c++ header file\n");
goto bail;
}
f = argv[2];
if (!strcmp(argv[1], "rvds"))
mode = OUTPUT_FMT_RVDS;
else if (!strcmp(argv[1], "gas"))
mode = OUTPUT_FMT_GAS;
else if (!strcmp(argv[1], "cheader"))
mode = OUTPUT_FMT_C_HEADER;
else
f = argv[1];
fp = fopen(f, "rb");
if (!fp) {
perror("Unable to open file");
goto bail;
}
if (fseek(fp, 0, SEEK_END)) {
perror("stat");
goto bail;
}
file_size = ftell(fp);
file_buf = malloc(file_size);
if (!file_buf) {
perror("malloc");
goto bail;
}
rewind(fp);
if (fread(file_buf, sizeof(char), file_size, fp) != file_size) {
perror("read");
goto bail;
}
if (fclose(fp)) {
perror("close");
goto bail;
}
#if defined(__GNUC__) && __GNUC__
#if defined(__MACH__)
res = parse_macho(file_buf, file_size, mode);
#elif defined(__ELF__)
res = parse_elf(file_buf, file_size, mode);
#endif
#endif
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
res = parse_coff(file_buf, file_size);
#endif
free(file_buf);
if (!res)
return EXIT_SUCCESS;
bail:
return EXIT_FAILURE;
}

View File

@@ -376,18 +376,17 @@ if ($opts{arch} eq 'x86') {
@ALL_ARCHS = filter("$opts{arch}", qw/dspr2/); @ALL_ARCHS = filter("$opts{arch}", qw/dspr2/);
last; last;
} }
if (/HAVE_MSA=yes/) {
@ALL_ARCHS = filter("$opts{arch}", qw/msa/);
last;
}
} }
close CONFIG_FILE; close CONFIG_FILE;
mips; mips;
} elsif ($opts{arch} eq 'armv6') { } elsif ($opts{arch} eq 'armv5te') {
@ALL_ARCHS = filter(qw/media/); @ALL_ARCHS = filter(qw/edsp/);
arm; arm;
} elsif ($opts{arch} =~ /armv7\w?/) { } elsif ($opts{arch} eq 'armv6') {
@ALL_ARCHS = filter(qw/media neon_asm neon/); @ALL_ARCHS = filter(qw/edsp media/);
arm;
} elsif ($opts{arch} eq 'armv7') {
@ALL_ARCHS = filter(qw/edsp media neon_asm neon/);
@REQUIRES = filter(keys %required ? keys %required : qw/media/); @REQUIRES = filter(keys %required ? keys %required : qw/media/);
&require(@REQUIRES); &require(@REQUIRES);
arm; arm;

View File

@@ -0,0 +1,15 @@
REM Copyright (c) 2011 The WebM project authors. All Rights Reserved.
REM
REM Use of this source code is governed by a BSD-style license
REM that can be found in the LICENSE file in the root of the source
REM tree. An additional intellectual property rights grant can be found
REM in the file PATENTS. All contributing project authors may
REM be found in the AUTHORS file in the root of the source tree.
echo on
REM Arguments:
REM %1 - Relative path to the directory containing the vp8 source directory.
REM %2 - Path to obj_int_extract.exe.
cl /I. /I%1 /nologo /c "%~1/vp8/encoder/vp8_asm_enc_offsets.c"
%2\obj_int_extract.exe rvds "vp8_asm_enc_offsets.obj" > "vp8_asm_enc_offsets.asm"

67
configure vendored
View File

@@ -36,10 +36,10 @@ Advanced options:
${toggle_codec_srcs} in/exclude codec library source code ${toggle_codec_srcs} in/exclude codec library source code
${toggle_debug_libs} in/exclude debug version of libraries ${toggle_debug_libs} in/exclude debug version of libraries
${toggle_static_msvcrt} use static MSVCRT (VS builds only) ${toggle_static_msvcrt} use static MSVCRT (VS builds only)
${toggle_vp9_highbitdepth} use VP9 high bit depth (10/12) profiles
${toggle_vp8} VP8 codec support ${toggle_vp8} VP8 codec support
${toggle_vp9} VP9 codec support ${toggle_vp9} VP9 codec support
${toggle_internal_stats} output of encoder internal stats for debug, if supported (encoders) ${toggle_internal_stats} output of encoder internal stats for debug, if supported (encoders)
${toggle_mem_tracker} track memory usage
${toggle_postproc} postprocessing ${toggle_postproc} postprocessing
${toggle_vp9_postproc} vp9 specific postprocessing ${toggle_vp9_postproc} vp9 specific postprocessing
${toggle_multithread} multithreaded encoding and decoding ${toggle_multithread} multithreaded encoding and decoding
@@ -57,8 +57,6 @@ Advanced options:
${toggle_postproc_visualizer} macro block / block level visualizers ${toggle_postproc_visualizer} macro block / block level visualizers
${toggle_multi_res_encoding} enable multiple-resolution encoding ${toggle_multi_res_encoding} enable multiple-resolution encoding
${toggle_temporal_denoising} enable temporal denoising and disable the spatial denoiser ${toggle_temporal_denoising} enable temporal denoising and disable the spatial denoiser
${toggle_vp9_temporal_denoising}
enable vp9 temporal denoising
${toggle_webm_io} enable input from and output to WebM container ${toggle_webm_io} enable input from and output to WebM container
${toggle_libyuv} enable libyuv ${toggle_libyuv} enable libyuv
@@ -96,6 +94,10 @@ EOF
# all_platforms is a list of all supported target platforms. Maintain # all_platforms is a list of all supported target platforms. Maintain
# alphabetically by architecture, generic-gnu last. # alphabetically by architecture, generic-gnu last.
all_platforms="${all_platforms} armv5te-android-gcc"
all_platforms="${all_platforms} armv5te-linux-rvct"
all_platforms="${all_platforms} armv5te-linux-gcc"
all_platforms="${all_platforms} armv5te-none-rvct"
all_platforms="${all_platforms} armv6-darwin-gcc" all_platforms="${all_platforms} armv6-darwin-gcc"
all_platforms="${all_platforms} armv6-linux-rvct" all_platforms="${all_platforms} armv6-linux-rvct"
all_platforms="${all_platforms} armv6-linux-gcc" all_platforms="${all_platforms} armv6-linux-gcc"
@@ -111,6 +113,12 @@ all_platforms="${all_platforms} armv7-win32-vs12"
all_platforms="${all_platforms} armv7s-darwin-gcc" all_platforms="${all_platforms} armv7s-darwin-gcc"
all_platforms="${all_platforms} mips32-linux-gcc" all_platforms="${all_platforms} mips32-linux-gcc"
all_platforms="${all_platforms} mips64-linux-gcc" all_platforms="${all_platforms} mips64-linux-gcc"
all_platforms="${all_platforms} ppc32-darwin8-gcc"
all_platforms="${all_platforms} ppc32-darwin9-gcc"
all_platforms="${all_platforms} ppc32-linux-gcc"
all_platforms="${all_platforms} ppc64-darwin8-gcc"
all_platforms="${all_platforms} ppc64-darwin9-gcc"
all_platforms="${all_platforms} ppc64-linux-gcc"
all_platforms="${all_platforms} sparc-solaris-gcc" all_platforms="${all_platforms} sparc-solaris-gcc"
all_platforms="${all_platforms} x86-android-gcc" all_platforms="${all_platforms} x86-android-gcc"
all_platforms="${all_platforms} x86-darwin8-gcc" all_platforms="${all_platforms} x86-darwin8-gcc"
@@ -121,7 +129,6 @@ all_platforms="${all_platforms} x86-darwin10-gcc"
all_platforms="${all_platforms} x86-darwin11-gcc" all_platforms="${all_platforms} x86-darwin11-gcc"
all_platforms="${all_platforms} x86-darwin12-gcc" all_platforms="${all_platforms} x86-darwin12-gcc"
all_platforms="${all_platforms} x86-darwin13-gcc" all_platforms="${all_platforms} x86-darwin13-gcc"
all_platforms="${all_platforms} x86-darwin14-gcc"
all_platforms="${all_platforms} x86-iphonesimulator-gcc" all_platforms="${all_platforms} x86-iphonesimulator-gcc"
all_platforms="${all_platforms} x86-linux-gcc" all_platforms="${all_platforms} x86-linux-gcc"
all_platforms="${all_platforms} x86-linux-icc" all_platforms="${all_platforms} x86-linux-icc"
@@ -139,7 +146,6 @@ all_platforms="${all_platforms} x86_64-darwin10-gcc"
all_platforms="${all_platforms} x86_64-darwin11-gcc" all_platforms="${all_platforms} x86_64-darwin11-gcc"
all_platforms="${all_platforms} x86_64-darwin12-gcc" all_platforms="${all_platforms} x86_64-darwin12-gcc"
all_platforms="${all_platforms} x86_64-darwin13-gcc" all_platforms="${all_platforms} x86_64-darwin13-gcc"
all_platforms="${all_platforms} x86_64-darwin14-gcc"
all_platforms="${all_platforms} x86_64-iphonesimulator-gcc" all_platforms="${all_platforms} x86_64-iphonesimulator-gcc"
all_platforms="${all_platforms} x86_64-linux-gcc" all_platforms="${all_platforms} x86_64-linux-gcc"
all_platforms="${all_platforms} x86_64-linux-icc" all_platforms="${all_platforms} x86_64-linux-icc"
@@ -156,7 +162,6 @@ all_platforms="${all_platforms} universal-darwin10-gcc"
all_platforms="${all_platforms} universal-darwin11-gcc" all_platforms="${all_platforms} universal-darwin11-gcc"
all_platforms="${all_platforms} universal-darwin12-gcc" all_platforms="${all_platforms} universal-darwin12-gcc"
all_platforms="${all_platforms} universal-darwin13-gcc" all_platforms="${all_platforms} universal-darwin13-gcc"
all_platforms="${all_platforms} universal-darwin14-gcc"
all_platforms="${all_platforms} generic-gnu" all_platforms="${all_platforms} generic-gnu"
# all_targets is a list of all targets that can be configured # all_targets is a list of all targets that can be configured
@@ -202,7 +207,6 @@ enable_feature install_libs
enable_feature static enable_feature static
enable_feature optimizations enable_feature optimizations
enable_feature dependency_tracking
enable_feature fast_unaligned #allow unaligned accesses, if supported by hw enable_feature fast_unaligned #allow unaligned accesses, if supported by hw
enable_feature spatial_resampling enable_feature spatial_resampling
enable_feature multithread enable_feature multithread
@@ -240,6 +244,8 @@ ARCH_LIST="
mips mips
x86 x86
x86_64 x86_64
ppc32
ppc64
" "
ARCH_EXT_LIST=" ARCH_EXT_LIST="
edsp edsp
@@ -249,7 +255,7 @@ ARCH_EXT_LIST="
mips32 mips32
dspr2 dspr2
msa
mips64 mips64
mmx mmx
@@ -260,6 +266,8 @@ ARCH_EXT_LIST="
sse4_1 sse4_1
avx avx
avx2 avx2
altivec
" "
HAVE_LIST=" HAVE_LIST="
${ARCH_EXT_LIST} ${ARCH_EXT_LIST}
@@ -272,11 +280,35 @@ HAVE_LIST="
" "
EXPERIMENT_LIST=" EXPERIMENT_LIST="
spatial_svc spatial_svc
vp9_temporal_denoising
fp_mb_stats fp_mb_stats
emulate_hardware emulate_hardware
tx64x64
filterintra
ext_tx
tx_skip
supertx
copy_mode
interintra
wedge_partition
global_motion
palette
new_quant
intrabc
loop_postfilter
row_tile
new_inter
bitstream_fixes
newmvref
misc_entropy
wavelets
ext_partition
qctx_tprobs
sr_mode
multi_ref
ext_coding_unit_size
" "
CONFIG_LIST=" CONFIG_LIST="
dependency_tracking
external_build external_build
install_docs install_docs
install_bins install_bins
@@ -295,6 +327,9 @@ CONFIG_LIST="
codec_srcs codec_srcs
debug_libs debug_libs
fast_unaligned fast_unaligned
mem_manager
mem_tracker
mem_checks
dequant_tokens dequant_tokens
dc_recon dc_recon
@@ -324,7 +359,6 @@ CONFIG_LIST="
encode_perf_tests encode_perf_tests
multi_res_encoding multi_res_encoding
temporal_denoising temporal_denoising
vp9_temporal_denoising
coefficient_range_checking coefficient_range_checking
vp9_highbitdepth vp9_highbitdepth
experimental experimental
@@ -332,7 +366,6 @@ CONFIG_LIST="
${EXPERIMENT_LIST} ${EXPERIMENT_LIST}
" "
CMDLINE_SELECT=" CMDLINE_SELECT="
dependency_tracking
external_build external_build
extra_warnings extra_warnings
werror werror
@@ -369,6 +402,7 @@ CMDLINE_SELECT="
${CODECS} ${CODECS}
${CODEC_FAMILIES} ${CODEC_FAMILIES}
static_msvcrt static_msvcrt
mem_tracker
spatial_resampling spatial_resampling
realtime_only realtime_only
onthefly_bitpacking onthefly_bitpacking
@@ -384,7 +418,6 @@ CMDLINE_SELECT="
encode_perf_tests encode_perf_tests
multi_res_encoding multi_res_encoding
temporal_denoising temporal_denoising
vp9_temporal_denoising
coefficient_range_checking coefficient_range_checking
vp9_highbitdepth vp9_highbitdepth
experimental experimental
@@ -443,6 +476,8 @@ process_targets() {
enabled child || write_common_config_banner enabled child || write_common_config_banner
enabled universal || write_common_target_config_h ${BUILD_PFX}vpx_config.h enabled universal || write_common_target_config_h ${BUILD_PFX}vpx_config.h
# TODO: add host tools target (obj_int_extract, etc)
# For fat binaries, call configure recursively to configure for each # For fat binaries, call configure recursively to configure for each
# binary architecture to be included. # binary architecture to be included.
if enabled universal; then if enabled universal; then
@@ -606,6 +641,12 @@ process_toolchain() {
universal-darwin*) universal-darwin*)
darwin_ver=${tgt_os##darwin} darwin_ver=${tgt_os##darwin}
# Snow Leopard (10.6/darwin10) dropped support for PPC
# Include PPC support for all prior versions
if [ $darwin_ver -lt 10 ]; then
fat_bin_archs="$fat_bin_archs ppc32-${tgt_os}-gcc"
fi
# Tiger (10.4/darwin8) brought support for x86 # Tiger (10.4/darwin8) brought support for x86
if [ $darwin_ver -ge 8 ]; then if [ $darwin_ver -ge 8 ]; then
fat_bin_archs="$fat_bin_archs x86-${tgt_os}-${tgt_cc}" fat_bin_archs="$fat_bin_archs x86-${tgt_os}-${tgt_cc}"
@@ -706,7 +747,7 @@ process_toolchain() {
esac esac
# Other toolchain specific defaults # Other toolchain specific defaults
case $toolchain in x86*|universal*) soft_enable postproc;; esac case $toolchain in x86*|ppc*|universal*) soft_enable postproc;; esac
if enabled postproc_visualizer; then if enabled postproc_visualizer; then
enabled postproc || die "postproc_visualizer requires postproc to be enabled" enabled postproc || die "postproc_visualizer requires postproc to be enabled"

View File

@@ -35,20 +35,30 @@ LIBYUV_SRCS += third_party/libyuv/include/libyuv/basic_types.h \
third_party/libyuv/source/scale_posix.cc \ third_party/libyuv/source/scale_posix.cc \
third_party/libyuv/source/scale_win.cc \ third_party/libyuv/source/scale_win.cc \
LIBWEBM_MUXER_SRCS += third_party/libwebm/mkvmuxer.cpp \ LIBWEBM_COMMON_SRCS += third_party/libwebm/common/hdr_util.cc \
third_party/libwebm/mkvmuxerutil.cpp \ third_party/libwebm/common/hdr_util.h \
third_party/libwebm/mkvwriter.cpp \ third_party/libwebm/common/webmids.h
third_party/libwebm/mkvmuxer.hpp \
third_party/libwebm/mkvmuxertypes.hpp \
third_party/libwebm/mkvmuxerutil.hpp \
third_party/libwebm/mkvparser.hpp \
third_party/libwebm/mkvwriter.hpp \
third_party/libwebm/webmids.hpp
LIBWEBM_PARSER_SRCS = third_party/libwebm/mkvparser.cpp \ LIBWEBM_MUXER_SRCS += third_party/libwebm/mkvmuxer/mkvmuxer.cc \
third_party/libwebm/mkvreader.cpp \ third_party/libwebm/mkvmuxer/mkvmuxerutil.cc \
third_party/libwebm/mkvparser.hpp \ third_party/libwebm/mkvmuxer/mkvwriter.cc \
third_party/libwebm/mkvreader.hpp third_party/libwebm/mkvmuxer/mkvmuxer.h \
third_party/libwebm/mkvmuxer/mkvmuxertypes.h \
third_party/libwebm/mkvmuxer/mkvmuxerutil.h \
third_party/libwebm/mkvparser/mkvparser.h \
third_party/libwebm/mkvmuxer/mkvwriter.h
LIBWEBM_PARSER_SRCS = third_party/libwebm/mkvparser/mkvparser.cc \
third_party/libwebm/mkvparser/mkvreader.cc \
third_party/libwebm/mkvparser/mkvparser.h \
third_party/libwebm/mkvparser/mkvreader.h
# Add compile flags and include path for libwebm sources.
ifeq ($(CONFIG_WEBM_IO),yes)
CXXFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/libwebm
INC_PATH-yes += $(SRC_PATH_BARE)/third_party/libwebm
endif
# List of examples to build. UTILS are tools meant for distribution # List of examples to build. UTILS are tools meant for distribution
# while EXAMPLES demonstrate specific portions of the API. # while EXAMPLES demonstrate specific portions of the API.
@@ -66,6 +76,8 @@ ifeq ($(CONFIG_LIBYUV),yes)
vpxdec.SRCS += $(LIBYUV_SRCS) vpxdec.SRCS += $(LIBYUV_SRCS)
endif endif
ifeq ($(CONFIG_WEBM_IO),yes) ifeq ($(CONFIG_WEBM_IO),yes)
vpxdec.SRCS += $(LIBWEBM_COMMON_SRCS)
vpxdec.SRCS += $(LIBWEBM_MUXER_SRCS)
vpxdec.SRCS += $(LIBWEBM_PARSER_SRCS) vpxdec.SRCS += $(LIBWEBM_PARSER_SRCS)
vpxdec.SRCS += webmdec.cc webmdec.h vpxdec.SRCS += webmdec.cc webmdec.h
endif endif
@@ -86,34 +98,18 @@ ifeq ($(CONFIG_LIBYUV),yes)
vpxenc.SRCS += $(LIBYUV_SRCS) vpxenc.SRCS += $(LIBYUV_SRCS)
endif endif
ifeq ($(CONFIG_WEBM_IO),yes) ifeq ($(CONFIG_WEBM_IO),yes)
vpxenc.SRCS += $(LIBWEBM_COMMON_SRCS)
vpxenc.SRCS += $(LIBWEBM_MUXER_SRCS) vpxenc.SRCS += $(LIBWEBM_MUXER_SRCS)
vpxenc.SRCS += $(LIBWEBM_PARSER_SRCS)
vpxenc.SRCS += webmenc.cc webmenc.h vpxenc.SRCS += webmenc.cc webmenc.h
endif endif
vpxenc.GUID = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1 vpxenc.GUID = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1
vpxenc.DESCRIPTION = Full featured encoder vpxenc.DESCRIPTION = Full featured encoder
ifeq ($(CONFIG_SPATIAL_SVC),yes)
EXAMPLES-$(CONFIG_VP9_ENCODER) += vp9_spatial_svc_encoder.c
vp9_spatial_svc_encoder.SRCS += args.c args.h
vp9_spatial_svc_encoder.SRCS += ivfenc.c ivfenc.h
vp9_spatial_svc_encoder.SRCS += tools_common.c tools_common.h
vp9_spatial_svc_encoder.SRCS += video_common.h
vp9_spatial_svc_encoder.SRCS += video_writer.h video_writer.c
vp9_spatial_svc_encoder.SRCS += vpxstats.c vpxstats.h
vp9_spatial_svc_encoder.GUID = 4A38598D-627D-4505-9C7B-D4020C84100D
vp9_spatial_svc_encoder.DESCRIPTION = VP9 Spatial SVC Encoder
endif
ifneq ($(CONFIG_SHARED),yes) ifneq ($(CONFIG_SHARED),yes)
EXAMPLES-$(CONFIG_VP9_ENCODER) += resize_util.c EXAMPLES-$(CONFIG_VP9_ENCODER) += resize_util.c
endif endif
EXAMPLES-$(CONFIG_ENCODERS) += vpx_temporal_svc_encoder.c
vpx_temporal_svc_encoder.SRCS += ivfenc.c ivfenc.h
vpx_temporal_svc_encoder.SRCS += tools_common.c tools_common.h
vpx_temporal_svc_encoder.SRCS += video_common.h
vpx_temporal_svc_encoder.SRCS += video_writer.h video_writer.c
vpx_temporal_svc_encoder.GUID = B18C08F2-A439-4502-A78E-849BE3D60947
vpx_temporal_svc_encoder.DESCRIPTION = Temporal SVC Encoder
EXAMPLES-$(CONFIG_DECODERS) += simple_decoder.c EXAMPLES-$(CONFIG_DECODERS) += simple_decoder.c
simple_decoder.GUID = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC simple_decoder.GUID = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC
simple_decoder.SRCS += ivfdec.h ivfdec.c simple_decoder.SRCS += ivfdec.h ivfdec.c
@@ -186,7 +182,13 @@ vp8cx_set_ref.SRCS += video_common.h
vp8cx_set_ref.SRCS += video_writer.h video_writer.c vp8cx_set_ref.SRCS += video_writer.h video_writer.c
vp8cx_set_ref.GUID = C5E31F7F-96F6-48BD-BD3E-10EBF6E8057A vp8cx_set_ref.GUID = C5E31F7F-96F6-48BD-BD3E-10EBF6E8057A
vp8cx_set_ref.DESCRIPTION = VP8 set encoder reference frame vp8cx_set_ref.DESCRIPTION = VP8 set encoder reference frame
EXAMPLES-$(CONFIG_VP9_ENCODER) += vp9cx_set_ref.c
vp9cx_set_ref.SRCS += ivfenc.h ivfenc.c
vp9cx_set_ref.SRCS += tools_common.h tools_common.c
vp9cx_set_ref.SRCS += video_common.h
vp9cx_set_ref.SRCS += video_writer.h video_writer.c
vp9cx_set_ref.GUID = 65D7F14A-2EE6-4293-B958-AB5107A03B55
vp9cx_set_ref.DESCRIPTION = VP9 set encoder reference frame
ifeq ($(CONFIG_MULTI_RES_ENCODING),yes) ifeq ($(CONFIG_MULTI_RES_ENCODING),yes)
ifeq ($(CONFIG_LIBYUV),yes) ifeq ($(CONFIG_LIBYUV),yes)
@@ -338,7 +340,6 @@ $(foreach proj,$(call enabled,PROJECTS),\
# #
%.dox: %.c %.dox: %.c
@echo " [DOXY] $@" @echo " [DOXY] $@"
@mkdir -p $(dir $@)
@echo "/*!\page example_$(@F:.dox=) $(@F:.dox=)" > $@ @echo "/*!\page example_$(@F:.dox=) $(@F:.dox=)" > $@
@echo " \includelineno $(<F)" >> $@ @echo " \includelineno $(<F)" >> $@
@echo "*/" >> $@ @echo "*/" >> $@

View File

@@ -36,9 +36,9 @@
#include "vpx/vp8dx.h" #include "vpx/vp8dx.h"
#include "vpx/vpx_decoder.h" #include "vpx/vpx_decoder.h"
#include "../md5_utils.h" #include "./md5_utils.h"
#include "../tools_common.h" #include "./tools_common.h"
#include "../video_reader.h" #include "./video_reader.h"
#include "./vpx_config.h" #include "./vpx_config.h"
static void get_image_md5(const vpx_image_t *img, unsigned char digest[16]) { static void get_image_md5(const vpx_image_t *img, unsigned char digest[16]) {

View File

@@ -59,8 +59,8 @@
#include "vpx/vp8dx.h" #include "vpx/vp8dx.h"
#include "vpx/vpx_decoder.h" #include "vpx/vpx_decoder.h"
#include "../tools_common.h" #include "./tools_common.h"
#include "../video_reader.h" #include "./video_reader.h"
#include "./vpx_config.h" #include "./vpx_config.h"
static const char *exec_name; static const char *exec_name;

View File

@@ -46,8 +46,8 @@
#include "vpx/vp8dx.h" #include "vpx/vp8dx.h"
#include "vpx/vpx_decoder.h" #include "vpx/vpx_decoder.h"
#include "../tools_common.h" #include "./tools_common.h"
#include "../video_reader.h" #include "./video_reader.h"
#include "./vpx_config.h" #include "./vpx_config.h"
static const char *exec_name; static const char *exec_name;

View File

@@ -15,22 +15,15 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "../vp9/encoder/vp9_resize.h" #include "./vp9/encoder/vp9_resize.h"
static const char *exec_name = NULL; static void usage(char *progname) {
static void usage() {
printf("Usage:\n"); printf("Usage:\n");
printf("%s <input_yuv> <width>x<height> <target_width>x<target_height> ", printf("%s <input_yuv> <width>x<height> <target_width>x<target_height> ",
exec_name); progname);
printf("<output_yuv> [<frames>]\n"); printf("<output_yuv> [<frames>]\n");
} }
void usage_exit() {
usage();
exit(EXIT_FAILURE);
}
static int parse_dim(char *v, int *width, int *height) { static int parse_dim(char *v, int *width, int *height) {
char *x = strchr(v, 'x'); char *x = strchr(v, 'x');
if (x == NULL) if (x == NULL)
@@ -54,11 +47,9 @@ int main(int argc, char *argv[]) {
int f, frames; int f, frames;
int width, height, target_width, target_height; int width, height, target_width, target_height;
exec_name = argv[0];
if (argc < 5) { if (argc < 5) {
printf("Incorrect parameters:\n"); printf("Incorrect parameters:\n");
usage(); usage(argv[0]);
return 1; return 1;
} }
@@ -66,25 +57,25 @@ int main(int argc, char *argv[]) {
fout = argv[4]; fout = argv[4];
if (!parse_dim(argv[2], &width, &height)) { if (!parse_dim(argv[2], &width, &height)) {
printf("Incorrect parameters: %s\n", argv[2]); printf("Incorrect parameters: %s\n", argv[2]);
usage(); usage(argv[0]);
return 1; return 1;
} }
if (!parse_dim(argv[3], &target_width, &target_height)) { if (!parse_dim(argv[3], &target_width, &target_height)) {
printf("Incorrect parameters: %s\n", argv[3]); printf("Incorrect parameters: %s\n", argv[3]);
usage(); usage(argv[0]);
return 1; return 1;
} }
fpin = fopen(fin, "rb"); fpin = fopen(fin, "rb");
if (fpin == NULL) { if (fpin == NULL) {
printf("Can't open file %s to read\n", fin); printf("Can't open file %s to read\n", fin);
usage(); usage(argv[0]);
return 1; return 1;
} }
fpout = fopen(fout, "wb"); fpout = fopen(fout, "wb");
if (fpout == NULL) { if (fpout == NULL) {
printf("Can't open file %s to write\n", fout); printf("Can't open file %s to write\n", fout);
usage(); usage(argv[0]);
return 1; return 1;
} }
if (argc >= 6) if (argc >= 6)

View File

@@ -50,8 +50,8 @@
#include "vpx/vp8cx.h" #include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h" #include "vpx/vpx_encoder.h"
#include "../tools_common.h" #include "./tools_common.h"
#include "../video_writer.h" #include "./video_writer.h"
static const char *exec_name; static const char *exec_name;

View File

@@ -82,8 +82,8 @@
#include "vpx/vpx_decoder.h" #include "vpx/vpx_decoder.h"
#include "../tools_common.h" #include "./tools_common.h"
#include "../video_reader.h" #include "./video_reader.h"
#include "./vpx_config.h" #include "./vpx_config.h"
static const char *exec_name; static const char *exec_name;

View File

@@ -101,8 +101,8 @@
#include "vpx/vpx_encoder.h" #include "vpx/vpx_encoder.h"
#include "../tools_common.h" #include "./tools_common.h"
#include "../video_writer.h" #include "./video_writer.h"
static const char *exec_name; static const char *exec_name;

View File

@@ -53,8 +53,8 @@
#include "vpx/vpx_encoder.h" #include "vpx/vpx_encoder.h"
#include "../tools_common.h" #include "./tools_common.h"
#include "../video_writer.h" #include "./video_writer.h"
static const char *exec_name; static const char *exec_name;

View File

@@ -8,730 +8,292 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
/*
* This is an example demonstrating multi-resolution encoding in VP8.
* High-resolution input video is down-sampled to lower-resolutions. The
* encoder then encodes the video and outputs multiple bitstreams with
* different resolutions.
*
* This test also allows for settings temporal layers for each spatial layer.
* Different number of temporal layers per spatial stream may be used.
* Currently up to 3 temporal layers per spatial stream (encoder) are supported
* in this test.
*/
#include "./vpx_config.h" // This is an example demonstrating multi-resolution encoding in VP8.
// High-resolution input video is down-sampled to lower-resolutions. The
// encoder then encodes the video and outputs multiple bitstreams with
// different resolutions.
//
// Configure with --enable-multi-res-encoding flag to enable this example.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
#include <string.h> #include <string.h>
#include <math.h>
#include <assert.h>
#include <sys/time.h>
#if USE_POSIX_MMAP
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#endif
#include "vpx_ports/vpx_timer.h"
#define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vpx_encoder.h"
#include "vpx/vp8cx.h"
#include "vpx_ports/mem_ops.h"
#include "./tools_common.h"
#define interface (vpx_codec_vp8_cx())
#define fourcc 0x30385056
void usage_exit() {
exit(EXIT_FAILURE);
}
/*
* The input video frame is downsampled several times to generate a multi-level
* hierarchical structure. NUM_ENCODERS is defined as the number of encoding
* levels required. For example, if the size of input video is 1280x720,
* NUM_ENCODERS is 3, and down-sampling factor is 2, the encoder outputs 3
* bitstreams with resolution of 1280x720(level 0), 640x360(level 1), and
* 320x180(level 2) respectively.
*/
/* Number of encoders (spatial resolutions) used in this test. */
#define NUM_ENCODERS 3
/* Maximum number of temporal layers allowed for this test. */
#define MAX_NUM_TEMPORAL_LAYERS 3
/* This example uses the scaler function in libyuv. */
#include "third_party/libyuv/include/libyuv/basic_types.h" #include "third_party/libyuv/include/libyuv/basic_types.h"
#include "third_party/libyuv/include/libyuv/scale.h" #include "third_party/libyuv/include/libyuv/scale.h"
#include "third_party/libyuv/include/libyuv/cpu_id.h" #include "third_party/libyuv/include/libyuv/cpu_id.h"
int (*read_frame_p)(FILE *f, vpx_image_t *img); #include "vpx/vpx_encoder.h"
#include "vpx/vp8cx.h"
static int read_frame(FILE *f, vpx_image_t *img) { #include "./tools_common.h"
size_t nbytes, to_read; #include "./video_writer.h"
int res = 1;
to_read = img->w*img->h*3/2; // The input video frame is downsampled several times to generate a
nbytes = fread(img->planes[0], 1, to_read, f); // multi-level hierarchical structure. kNumEncoders is defined as the number
if(nbytes != to_read) { // of encoding levels required. For example, if the size of input video is
res = 0; // 1280x720, kNumEncoders is 3, and down-sampling factor is 2, the encoder
if(nbytes > 0) // outputs 3 bitstreams with resolution of 1280x720(level 0),
printf("Warning: Read partial frame. Check your width & height!\n"); // 640x360(level 1), and 320x180(level 2) respectively.
} #define kNumEncoders 3
return res;
static const char *exec_name;
void usage_exit() {
fprintf(stderr,
"Usage: %s <width> <height> <infile> <outfile(s)> <output psnr?>\n",
exec_name);
exit(EXIT_FAILURE);
} }
static int read_frame_by_row(FILE *f, vpx_image_t *img) { int main(int argc, char *argv[]) {
size_t nbytes, to_read; int frame_cnt = 0;
int res = 1; FILE *infile = NULL;
int plane; VpxVideoWriter *writers[kNumEncoders];
vpx_codec_ctx_t codec[kNumEncoders];
vpx_codec_enc_cfg_t cfg[kNumEncoders];
vpx_image_t raw[kNumEncoders];
const VpxInterface *const encoder = get_vpx_encoder_by_name("vp8");
// Currently, only realtime mode is supported in multi-resolution encoding.
const int arg_deadline = VPX_DL_REALTIME;
int i;
int width = 0;
int height = 0;
int frame_avail = 0;
int got_data = 0;
for (plane = 0; plane < 3; plane++) // Set show_psnr to 1/0 to show/not show PSNR. Choose show_psnr=0 if you
// don't need to know PSNR, which will skip PSNR calculation and save
// encoding time.
int show_psnr = 0;
uint64_t psnr_sse_total[kNumEncoders] = {0};
uint64_t psnr_samples_total[kNumEncoders] = {0};
double psnr_totals[kNumEncoders][4] = {{0, 0}};
int psnr_count[kNumEncoders] = {0};
// Set the required target bitrates for each resolution level.
// If target bitrate for highest-resolution level is set to 0,
// (i.e. target_bitrate[0]=0), we skip encoding at that level.
unsigned int target_bitrate[kNumEncoders] = {1000, 500, 100};
// Enter the frame rate of the input video.
const int framerate = 30;
// Set down-sampling factor for each resolution level.
// dsf[0] controls down sampling from level 0 to level 1;
// dsf[1] controls down sampling from level 1 to level 2;
// dsf[2] is not used.
vpx_rational_t dsf[kNumEncoders] = {{2, 1}, {2, 1}, {1, 1}};
exec_name = argv[0];
if (!encoder)
die("Unsupported codec.");
// exe_name, input width, input height, input file,
// output file 1, output file 2, output file 3, psnr on/off
if (argc != (5 + kNumEncoders))
die("Invalid number of input options.");
printf("Using %s\n", vpx_codec_iface_name(encoder->codec_interface()));
width = strtol(argv[1], NULL, 0);
height = strtol(argv[2], NULL, 0);
if (width < 16 || width % 2 || height < 16 || height % 2)
die("Invalid resolution: %ldx%ld", width, height);
// Open input video file for encoding
if (!(infile = fopen(argv[3], "rb")))
die("Failed to open %s for reading", argv[3]);
show_psnr = strtol(argv[kNumEncoders + 4], NULL, 0);
// Populate default encoder configuration
for (i = 0; i < kNumEncoders; ++i) {
vpx_codec_err_t res =
vpx_codec_enc_config_default(encoder->codec_interface(), &cfg[i], 0);
if (res != VPX_CODEC_OK) {
printf("Failed to get config: %s\n", vpx_codec_err_to_string(res));
return EXIT_FAILURE;
}
}
// Update the default configuration according to needs of the application.
// Highest-resolution encoder settings
cfg[0].g_w = width;
cfg[0].g_h = height;
cfg[0].g_threads = 1;
cfg[0].rc_dropframe_thresh = 30;
cfg[0].rc_end_usage = VPX_CBR;
cfg[0].rc_resize_allowed = 0;
cfg[0].rc_min_quantizer = 4;
cfg[0].rc_max_quantizer = 56;
cfg[0].rc_undershoot_pct = 98;
cfg[0].rc_overshoot_pct = 100;
cfg[0].rc_buf_initial_sz = 500;
cfg[0].rc_buf_optimal_sz = 600;
cfg[0].rc_buf_sz = 1000;
cfg[0].g_error_resilient = 1;
cfg[0].g_lag_in_frames = 0;
cfg[0].kf_mode = VPX_KF_AUTO; // VPX_KF_DISABLED
cfg[0].kf_min_dist = 3000;
cfg[0].kf_max_dist = 3000;
cfg[0].rc_target_bitrate = target_bitrate[0];
cfg[0].g_timebase.num = 1;
cfg[0].g_timebase.den = framerate;
// Other-resolution encoder settings
for (i = 1; i < kNumEncoders; ++i) {
cfg[i] = cfg[0];
cfg[i].g_threads = 1;
cfg[i].rc_target_bitrate = target_bitrate[i];
// Note: Width & height of other-resolution encoders are calculated
// from the highest-resolution encoder's size and the corresponding
// down_sampling_factor.
{ {
unsigned char *ptr; unsigned int iw = cfg[i - 1].g_w * dsf[i - 1].den + dsf[i - 1].num - 1;
int w = (plane ? (1 + img->d_w) / 2 : img->d_w); unsigned int ih = cfg[i - 1].g_h * dsf[i - 1].den + dsf[i - 1].num - 1;
int h = (plane ? (1 + img->d_h) / 2 : img->d_h); cfg[i].g_w = iw / dsf[i - 1].num;
int r; cfg[i].g_h = ih / dsf[i - 1].num;
}
/* Determine the correct plane based on the image format. The for-loop // Make width & height to be multiplier of 2.
* always counts in Y,U,V order, but this may not match the order of if ((cfg[i].g_w) % 2)
* the data on disk. cfg[i].g_w++;
*/
switch (plane) if ((cfg[i].g_h) % 2)
{ cfg[i].g_h++;
case 1: }
ptr = img->planes[img->fmt==VPX_IMG_FMT_YV12? VPX_PLANE_V : VPX_PLANE_U];
// Open output file for each encoder to output bitstreams
for (i = 0; i < kNumEncoders; ++i) {
VpxVideoInfo info = {
encoder->fourcc,
cfg[i].g_w,
cfg[i].g_h,
{cfg[i].g_timebase.num, cfg[i].g_timebase.den}
};
if (!(writers[i] = vpx_video_writer_open(argv[i+4], kContainerIVF, &info)))
die("Failed to open %s for writing", argv[i+4]);
}
// Allocate image for each encoder
for (i = 0; i < kNumEncoders; ++i)
if (!vpx_img_alloc(&raw[i], VPX_IMG_FMT_I420, cfg[i].g_w, cfg[i].g_h, 32))
die("Failed to allocate image", cfg[i].g_w, cfg[i].g_h);
// Initialize multi-encoder
if (vpx_codec_enc_init_multi(&codec[0], encoder->codec_interface(), &cfg[0],
kNumEncoders,
show_psnr ? VPX_CODEC_USE_PSNR : 0, &dsf[0]))
die_codec(&codec[0], "Failed to initialize encoder");
// The extra encoding configuration parameters can be set as follows.
for (i = 0; i < kNumEncoders; i++) {
// Set encoding speed
if (vpx_codec_control(&codec[i], VP8E_SET_CPUUSED, -6))
die_codec(&codec[i], "Failed to set cpu_used");
// Set static threshold.
if (vpx_codec_control(&codec[i], VP8E_SET_STATIC_THRESHOLD, 1))
die_codec(&codec[i], "Failed to set static threshold");
// Set NOISE_SENSITIVITY to do TEMPORAL_DENOISING
// Enable denoising for the highest-resolution encoder.
if (vpx_codec_control(&codec[0], VP8E_SET_NOISE_SENSITIVITY, i == 0))
die_codec(&codec[0], "Failed to set noise_sensitivity");
}
frame_avail = 1;
got_data = 0;
while (frame_avail || got_data) {
vpx_codec_iter_t iter[kNumEncoders] = {NULL};
const vpx_codec_cx_pkt_t *pkt[kNumEncoders];
frame_avail = vpx_img_read(&raw[0], infile);
if (frame_avail) {
for (i = 1; i < kNumEncoders; ++i) {
vpx_image_t *const prev = &raw[i - 1];
// Scale the image down a number of times by downsampling factor
// FilterMode 1 or 2 give better psnr than FilterMode 0.
I420Scale(prev->planes[VPX_PLANE_Y], prev->stride[VPX_PLANE_Y],
prev->planes[VPX_PLANE_U], prev->stride[VPX_PLANE_U],
prev->planes[VPX_PLANE_V], prev->stride[VPX_PLANE_V],
prev->d_w, prev->d_h,
raw[i].planes[VPX_PLANE_Y], raw[i].stride[VPX_PLANE_Y],
raw[i].planes[VPX_PLANE_U], raw[i].stride[VPX_PLANE_U],
raw[i].planes[VPX_PLANE_V], raw[i].stride[VPX_PLANE_V],
raw[i].d_w, raw[i].d_h, 1);
}
}
// Encode frame.
if (vpx_codec_encode(&codec[0], frame_avail? &raw[0] : NULL,
frame_cnt, 1, 0, arg_deadline)) {
die_codec(&codec[0], "Failed to encode frame");
}
for (i = kNumEncoders - 1; i >= 0; i--) {
got_data = 0;
while ((pkt[i] = vpx_codec_get_cx_data(&codec[i], &iter[i]))) {
got_data = 1;
switch (pkt[i]->kind) {
case VPX_CODEC_CX_FRAME_PKT:
vpx_video_writer_write_frame(writers[i], pkt[i]->data.frame.buf,
pkt[i]->data.frame.sz, frame_cnt - 1);
break;
case VPX_CODEC_PSNR_PKT:
if (show_psnr) {
int j;
psnr_sse_total[i] += pkt[i]->data.psnr.sse[0];
psnr_samples_total[i] += pkt[i]->data.psnr.samples[0];
for (j = 0; j < 4; j++)
psnr_totals[i][j] += pkt[i]->data.psnr.psnr[j];
psnr_count[i]++;
}
break; break;
case 2: default:
ptr = img->planes[img->fmt==VPX_IMG_FMT_YV12?VPX_PLANE_U : VPX_PLANE_V];
break; break;
default:
ptr = img->planes[plane];
} }
printf(pkt[i]->kind == VPX_CODEC_CX_FRAME_PKT &&
(pkt[i]->data.frame.flags & VPX_FRAME_IS_KEY)? "K":".");
fflush(stdout);
}
}
frame_cnt++;
}
printf("\n");
for (r = 0; r < h; r++) fclose(infile);
{
to_read = w;
nbytes = fread(ptr, 1, to_read, f); printf("Processed %d frames.\n", frame_cnt - 1);
if(nbytes != to_read) { for (i = 0; i < kNumEncoders; ++i) {
res = 0; // Calculate PSNR and print it out
if(nbytes > 0) if (show_psnr && psnr_count[i] > 0) {
printf("Warning: Read partial frame. Check your width & height!\n"); int j;
break; double ovpsnr = sse_to_psnr(psnr_samples_total[i], 255.0,
} psnr_sse_total[i]);
ptr += img->stride[plane]; fprintf(stderr, "\n ENC%d PSNR (Overall/Avg/Y/U/V)", i);
} fprintf(stderr, " %.3lf", ovpsnr);
if (!res) for (j = 0; j < 4; j++)
break; fprintf(stderr, " %.3lf", psnr_totals[i][j]/psnr_count[i]);
} }
return res; if (vpx_codec_destroy(&codec[i]))
} die_codec(&codec[i], "Failed to destroy codec");
static void write_ivf_file_header(FILE *outfile, vpx_img_free(&raw[i]);
const vpx_codec_enc_cfg_t *cfg, vpx_video_writer_close(writers[i]);
int frame_cnt) { }
char header[32]; printf("\n");
if(cfg->g_pass != VPX_RC_ONE_PASS && cfg->g_pass != VPX_RC_LAST_PASS) return EXIT_SUCCESS;
return;
header[0] = 'D';
header[1] = 'K';
header[2] = 'I';
header[3] = 'F';
mem_put_le16(header+4, 0); /* version */
mem_put_le16(header+6, 32); /* headersize */
mem_put_le32(header+8, fourcc); /* headersize */
mem_put_le16(header+12, cfg->g_w); /* width */
mem_put_le16(header+14, cfg->g_h); /* height */
mem_put_le32(header+16, cfg->g_timebase.den); /* rate */
mem_put_le32(header+20, cfg->g_timebase.num); /* scale */
mem_put_le32(header+24, frame_cnt); /* length */
mem_put_le32(header+28, 0); /* unused */
(void) fwrite(header, 1, 32, outfile);
}
static void write_ivf_frame_header(FILE *outfile,
const vpx_codec_cx_pkt_t *pkt)
{
char header[12];
vpx_codec_pts_t pts;
if(pkt->kind != VPX_CODEC_CX_FRAME_PKT)
return;
pts = pkt->data.frame.pts;
mem_put_le32(header, pkt->data.frame.sz);
mem_put_le32(header+4, pts&0xFFFFFFFF);
mem_put_le32(header+8, pts >> 32);
(void) fwrite(header, 1, 12, outfile);
}
/* Temporal scaling parameters */
/* This sets all the temporal layer parameters given |num_temporal_layers|,
* including the target bit allocation across temporal layers. Bit allocation
* parameters will be passed in as user parameters in another version.
*/
static void set_temporal_layer_pattern(int num_temporal_layers,
vpx_codec_enc_cfg_t *cfg,
int bitrate,
int *layer_flags)
{
assert(num_temporal_layers <= MAX_NUM_TEMPORAL_LAYERS);
switch (num_temporal_layers)
{
case 1:
{
/* 1-layer */
cfg->ts_number_layers = 1;
cfg->ts_periodicity = 1;
cfg->ts_rate_decimator[0] = 1;
cfg->ts_layer_id[0] = 0;
cfg->ts_target_bitrate[0] = bitrate;
// Update L only.
layer_flags[0] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
break;
}
case 2:
{
/* 2-layers, with sync point at first frame of layer 1. */
cfg->ts_number_layers = 2;
cfg->ts_periodicity = 2;
cfg->ts_rate_decimator[0] = 2;
cfg->ts_rate_decimator[1] = 1;
cfg->ts_layer_id[0] = 0;
cfg->ts_layer_id[1] = 1;
// Use 60/40 bit allocation as example.
cfg->ts_target_bitrate[0] = 0.6f * bitrate;
cfg->ts_target_bitrate[1] = bitrate;
/* 0=L, 1=GF */
// ARF is used as predictor for all frames, and is only updated on
// key frame. Sync point every 8 frames.
// Layer 0: predict from L and ARF, update L and G.
layer_flags[0] = VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_ARF;
// Layer 1: sync point: predict from L and ARF, and update G.
layer_flags[1] = VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ARF;
// Layer 0, predict from L and ARF, update L.
layer_flags[2] = VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF;
// Layer 1: predict from L, G and ARF, and update G.
layer_flags[3] = VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ENTROPY;
// Layer 0
layer_flags[4] = layer_flags[2];
// Layer 1
layer_flags[5] = layer_flags[3];
// Layer 0
layer_flags[6] = layer_flags[4];
// Layer 1
layer_flags[7] = layer_flags[5];
break;
}
case 3:
default:
{
// 3-layers structure where ARF is used as predictor for all frames,
// and is only updated on key frame.
// Sync points for layer 1 and 2 every 8 frames.
cfg->ts_number_layers = 3;
cfg->ts_periodicity = 4;
cfg->ts_rate_decimator[0] = 4;
cfg->ts_rate_decimator[1] = 2;
cfg->ts_rate_decimator[2] = 1;
cfg->ts_layer_id[0] = 0;
cfg->ts_layer_id[1] = 2;
cfg->ts_layer_id[2] = 1;
cfg->ts_layer_id[3] = 2;
// Use 40/20/40 bit allocation as example.
cfg->ts_target_bitrate[0] = 0.4f * bitrate;
cfg->ts_target_bitrate[1] = 0.6f * bitrate;
cfg->ts_target_bitrate[2] = bitrate;
/* 0=L, 1=GF, 2=ARF */
// Layer 0: predict from L and ARF; update L and G.
layer_flags[0] = VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF;
// Layer 2: sync point: predict from L and ARF; update none.
layer_flags[1] = VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ENTROPY;
// Layer 1: sync point: predict from L and ARF; update G.
layer_flags[2] = VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST;
// Layer 2: predict from L, G, ARF; update none.
layer_flags[3] = VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ENTROPY;
// Layer 0: predict from L and ARF; update L.
layer_flags[4] = VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF;
// Layer 2: predict from L, G, ARF; update none.
layer_flags[5] = layer_flags[3];
// Layer 1: predict from L, G, ARF; update G.
layer_flags[6] = VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST;
// Layer 2: predict from L, G, ARF; update none.
layer_flags[7] = layer_flags[3];
break;
}
}
}
/* The periodicity of the pattern given the number of temporal layers. */
static int periodicity_to_num_layers[MAX_NUM_TEMPORAL_LAYERS] = {1, 8, 8};
int main(int argc, char **argv)
{
FILE *infile, *outfile[NUM_ENCODERS];
FILE *downsampled_input[NUM_ENCODERS - 1];
char filename[50];
vpx_codec_ctx_t codec[NUM_ENCODERS];
vpx_codec_enc_cfg_t cfg[NUM_ENCODERS];
int frame_cnt = 0;
vpx_image_t raw[NUM_ENCODERS];
vpx_codec_err_t res[NUM_ENCODERS];
int i;
long width;
long height;
int length_frame;
int frame_avail;
int got_data;
int flags = 0;
int layer_id = 0;
int layer_flags[VPX_TS_MAX_PERIODICITY * NUM_ENCODERS]
= {0};
int flag_periodicity;
/*Currently, only realtime mode is supported in multi-resolution encoding.*/
int arg_deadline = VPX_DL_REALTIME;
/* Set show_psnr to 1/0 to show/not show PSNR. Choose show_psnr=0 if you
don't need to know PSNR, which will skip PSNR calculation and save
encoding time. */
int show_psnr = 0;
int key_frame_insert = 0;
uint64_t psnr_sse_total[NUM_ENCODERS] = {0};
uint64_t psnr_samples_total[NUM_ENCODERS] = {0};
double psnr_totals[NUM_ENCODERS][4] = {{0,0}};
int psnr_count[NUM_ENCODERS] = {0};
double cx_time = 0;
struct timeval tv1, tv2, difftv;
/* Set the required target bitrates for each resolution level.
* If target bitrate for highest-resolution level is set to 0,
* (i.e. target_bitrate[0]=0), we skip encoding at that level.
*/
unsigned int target_bitrate[NUM_ENCODERS]={1000, 500, 100};
/* Enter the frame rate of the input video */
int framerate = 30;
/* Set down-sampling factor for each resolution level.
dsf[0] controls down sampling from level 0 to level 1;
dsf[1] controls down sampling from level 1 to level 2;
dsf[2] is not used. */
vpx_rational_t dsf[NUM_ENCODERS] = {{2, 1}, {2, 1}, {1, 1}};
/* Set the number of temporal layers for each encoder/resolution level,
* starting from highest resoln down to lowest resoln. */
unsigned int num_temporal_layers[NUM_ENCODERS] = {3, 3, 3};
if(argc!= (7 + 3 * NUM_ENCODERS))
die("Usage: %s <width> <height> <frame_rate> <infile> <outfile(s)> "
"<rate_encoder(s)> <temporal_layer(s)> <key_frame_insert> <output psnr?> \n",
argv[0]);
printf("Using %s\n",vpx_codec_iface_name(interface));
width = strtol(argv[1], NULL, 0);
height = strtol(argv[2], NULL, 0);
framerate = strtol(argv[3], NULL, 0);
if(width < 16 || width%2 || height <16 || height%2)
die("Invalid resolution: %ldx%ld", width, height);
/* Open input video file for encoding */
if(!(infile = fopen(argv[4], "rb")))
die("Failed to open %s for reading", argv[4]);
/* Open output file for each encoder to output bitstreams */
for (i=0; i< NUM_ENCODERS; i++)
{
if(!target_bitrate[i])
{
outfile[i] = NULL;
continue;
}
if(!(outfile[i] = fopen(argv[i+5], "wb")))
die("Failed to open %s for writing", argv[i+4]);
}
// Bitrates per spatial layer: overwrite default rates above.
for (i=0; i< NUM_ENCODERS; i++)
{
target_bitrate[i] = strtol(argv[NUM_ENCODERS + 5 + i], NULL, 0);
}
// Temporal layers per spatial layers: overwrite default settings above.
for (i=0; i< NUM_ENCODERS; i++)
{
num_temporal_layers[i] = strtol(argv[2 * NUM_ENCODERS + 5 + i], NULL, 0);
if (num_temporal_layers[i] < 1 || num_temporal_layers[i] > 3)
die("Invalid temporal layers: %d, Must be 1, 2, or 3. \n",
num_temporal_layers);
}
/* Open file to write out each spatially downsampled input stream. */
for (i=0; i< NUM_ENCODERS - 1; i++)
{
// Highest resoln is encoder 0.
if (sprintf(filename,"ds%d.yuv",NUM_ENCODERS - i) < 0)
{
return EXIT_FAILURE;
}
downsampled_input[i] = fopen(filename,"wb");
}
key_frame_insert = strtol(argv[3 * NUM_ENCODERS + 5], NULL, 0);
show_psnr = strtol(argv[3 * NUM_ENCODERS + 6], NULL, 0);
/* Populate default encoder configuration */
for (i=0; i< NUM_ENCODERS; i++)
{
res[i] = vpx_codec_enc_config_default(interface, &cfg[i], 0);
if(res[i]) {
printf("Failed to get config: %s\n", vpx_codec_err_to_string(res[i]));
return EXIT_FAILURE;
}
}
/*
* Update the default configuration according to needs of the application.
*/
/* Highest-resolution encoder settings */
cfg[0].g_w = width;
cfg[0].g_h = height;
cfg[0].rc_dropframe_thresh = 0;
cfg[0].rc_end_usage = VPX_CBR;
cfg[0].rc_resize_allowed = 0;
cfg[0].rc_min_quantizer = 2;
cfg[0].rc_max_quantizer = 56;
cfg[0].rc_undershoot_pct = 100;
cfg[0].rc_overshoot_pct = 15;
cfg[0].rc_buf_initial_sz = 500;
cfg[0].rc_buf_optimal_sz = 600;
cfg[0].rc_buf_sz = 1000;
cfg[0].g_error_resilient = 1; /* Enable error resilient mode */
cfg[0].g_lag_in_frames = 0;
/* Disable automatic keyframe placement */
/* Note: These 3 settings are copied to all levels. But, except the lowest
* resolution level, all other levels are set to VPX_KF_DISABLED internally.
*/
cfg[0].kf_mode = VPX_KF_AUTO;
cfg[0].kf_min_dist = 3000;
cfg[0].kf_max_dist = 3000;
cfg[0].rc_target_bitrate = target_bitrate[0]; /* Set target bitrate */
cfg[0].g_timebase.num = 1; /* Set fps */
cfg[0].g_timebase.den = framerate;
/* Other-resolution encoder settings */
for (i=1; i< NUM_ENCODERS; i++)
{
memcpy(&cfg[i], &cfg[0], sizeof(vpx_codec_enc_cfg_t));
cfg[i].rc_target_bitrate = target_bitrate[i];
/* Note: Width & height of other-resolution encoders are calculated
* from the highest-resolution encoder's size and the corresponding
* down_sampling_factor.
*/
{
unsigned int iw = cfg[i-1].g_w*dsf[i-1].den + dsf[i-1].num - 1;
unsigned int ih = cfg[i-1].g_h*dsf[i-1].den + dsf[i-1].num - 1;
cfg[i].g_w = iw/dsf[i-1].num;
cfg[i].g_h = ih/dsf[i-1].num;
}
/* Make width & height to be multiplier of 2. */
// Should support odd size ???
if((cfg[i].g_w)%2)cfg[i].g_w++;
if((cfg[i].g_h)%2)cfg[i].g_h++;
}
// Set the number of threads per encode/spatial layer.
// (1, 1, 1) means no encoder threading.
cfg[0].g_threads = 2;
cfg[1].g_threads = 1;
cfg[2].g_threads = 1;
/* Allocate image for each encoder */
for (i=0; i< NUM_ENCODERS; i++)
if(!vpx_img_alloc(&raw[i], VPX_IMG_FMT_I420, cfg[i].g_w, cfg[i].g_h, 32))
die("Failed to allocate image", cfg[i].g_w, cfg[i].g_h);
if (raw[0].stride[VPX_PLANE_Y] == raw[0].d_w)
read_frame_p = read_frame;
else
read_frame_p = read_frame_by_row;
for (i=0; i< NUM_ENCODERS; i++)
if(outfile[i])
write_ivf_file_header(outfile[i], &cfg[i], 0);
/* Temporal layers settings */
for ( i=0; i<NUM_ENCODERS; i++)
{
set_temporal_layer_pattern(num_temporal_layers[i],
&cfg[i],
cfg[i].rc_target_bitrate,
&layer_flags[i * VPX_TS_MAX_PERIODICITY]);
}
/* Initialize multi-encoder */
if(vpx_codec_enc_init_multi(&codec[0], interface, &cfg[0], NUM_ENCODERS,
(show_psnr ? VPX_CODEC_USE_PSNR : 0), &dsf[0]))
die_codec(&codec[0], "Failed to initialize encoder");
/* The extra encoding configuration parameters can be set as follows. */
/* Set encoding speed */
for ( i=0; i<NUM_ENCODERS; i++)
{
int speed = -6;
/* Lower speed for the lowest resolution. */
if (i == NUM_ENCODERS - 1) speed = -4;
if(vpx_codec_control(&codec[i], VP8E_SET_CPUUSED, speed))
die_codec(&codec[i], "Failed to set cpu_used");
}
/* Set static threshold = 1 for all encoders */
for ( i=0; i<NUM_ENCODERS; i++)
{
if(vpx_codec_control(&codec[i], VP8E_SET_STATIC_THRESHOLD, 1))
die_codec(&codec[i], "Failed to set static threshold");
}
/* Set NOISE_SENSITIVITY to do TEMPORAL_DENOISING */
/* Enable denoising for the highest-resolution encoder. */
if(vpx_codec_control(&codec[0], VP8E_SET_NOISE_SENSITIVITY, 1))
die_codec(&codec[0], "Failed to set noise_sensitivity");
for ( i=1; i< NUM_ENCODERS; i++)
{
if(vpx_codec_control(&codec[i], VP8E_SET_NOISE_SENSITIVITY, 0))
die_codec(&codec[i], "Failed to set noise_sensitivity");
}
/* Set the number of token partitions */
for ( i=0; i<NUM_ENCODERS; i++)
{
if(vpx_codec_control(&codec[i], VP8E_SET_TOKEN_PARTITIONS, 1))
die_codec(&codec[i], "Failed to set static threshold");
}
/* Set the max intra target bitrate */
for ( i=0; i<NUM_ENCODERS; i++)
{
unsigned int max_intra_size_pct =
(int)(((double)cfg[0].rc_buf_optimal_sz * 0.5) * framerate / 10);
if(vpx_codec_control(&codec[i], VP8E_SET_MAX_INTRA_BITRATE_PCT,
max_intra_size_pct))
die_codec(&codec[i], "Failed to set static threshold");
//printf("%d %d \n",i,max_intra_size_pct);
}
frame_avail = 1;
got_data = 0;
while(frame_avail || got_data)
{
vpx_codec_iter_t iter[NUM_ENCODERS]={NULL};
const vpx_codec_cx_pkt_t *pkt[NUM_ENCODERS];
flags = 0;
frame_avail = read_frame_p(infile, &raw[0]);
if(frame_avail)
{
for ( i=1; i<NUM_ENCODERS; i++)
{
/*Scale the image down a number of times by downsampling factor*/
/* FilterMode 1 or 2 give better psnr than FilterMode 0. */
I420Scale(raw[i-1].planes[VPX_PLANE_Y], raw[i-1].stride[VPX_PLANE_Y],
raw[i-1].planes[VPX_PLANE_U], raw[i-1].stride[VPX_PLANE_U],
raw[i-1].planes[VPX_PLANE_V], raw[i-1].stride[VPX_PLANE_V],
raw[i-1].d_w, raw[i-1].d_h,
raw[i].planes[VPX_PLANE_Y], raw[i].stride[VPX_PLANE_Y],
raw[i].planes[VPX_PLANE_U], raw[i].stride[VPX_PLANE_U],
raw[i].planes[VPX_PLANE_V], raw[i].stride[VPX_PLANE_V],
raw[i].d_w, raw[i].d_h, 1);
/* Write out down-sampled input. */
length_frame = cfg[i].g_w * cfg[i].g_h *3/2;
if (fwrite(raw[i].planes[0], 1, length_frame,
downsampled_input[NUM_ENCODERS - i - 1]) !=
length_frame)
{
return EXIT_FAILURE;
}
}
}
/* Set the flags (reference and update) for all the encoders.*/
for ( i=0; i<NUM_ENCODERS; i++)
{
layer_id = cfg[i].ts_layer_id[frame_cnt % cfg[i].ts_periodicity];
flags = 0;
flag_periodicity = periodicity_to_num_layers
[num_temporal_layers[i] - 1];
flags = layer_flags[i * VPX_TS_MAX_PERIODICITY +
frame_cnt % flag_periodicity];
// Key frame flag for first frame.
if (frame_cnt == 0)
{
flags |= VPX_EFLAG_FORCE_KF;
}
if (frame_cnt > 0 && frame_cnt == key_frame_insert)
{
flags = VPX_EFLAG_FORCE_KF;
}
vpx_codec_control(&codec[i], VP8E_SET_FRAME_FLAGS, flags);
vpx_codec_control(&codec[i], VP8E_SET_TEMPORAL_LAYER_ID, layer_id);
}
gettimeofday(&tv1, NULL);
/* Encode each frame at multi-levels */
/* Note the flags must be set to 0 in the encode call if they are set
for each frame with the vpx_codec_control(), as done above. */
if(vpx_codec_encode(&codec[0], frame_avail? &raw[0] : NULL,
frame_cnt, 1, 0, arg_deadline))
{
die_codec(&codec[0], "Failed to encode frame");
}
gettimeofday(&tv2, NULL);
timersub(&tv2, &tv1, &difftv);
cx_time += (double)(difftv.tv_sec * 1000000 + difftv.tv_usec);
for (i=NUM_ENCODERS-1; i>=0 ; i--)
{
got_data = 0;
while( (pkt[i] = vpx_codec_get_cx_data(&codec[i], &iter[i])) )
{
got_data = 1;
switch(pkt[i]->kind) {
case VPX_CODEC_CX_FRAME_PKT:
write_ivf_frame_header(outfile[i], pkt[i]);
(void) fwrite(pkt[i]->data.frame.buf, 1,
pkt[i]->data.frame.sz, outfile[i]);
break;
case VPX_CODEC_PSNR_PKT:
if (show_psnr)
{
int j;
psnr_sse_total[i] += pkt[i]->data.psnr.sse[0];
psnr_samples_total[i] += pkt[i]->data.psnr.samples[0];
for (j = 0; j < 4; j++)
{
psnr_totals[i][j] += pkt[i]->data.psnr.psnr[j];
}
psnr_count[i]++;
}
break;
default:
break;
}
printf(pkt[i]->kind == VPX_CODEC_CX_FRAME_PKT
&& (pkt[i]->data.frame.flags & VPX_FRAME_IS_KEY)? "K":"");
fflush(stdout);
}
}
frame_cnt++;
}
printf("\n");
printf("FPS for encoding %d %f %f \n", frame_cnt, (float)cx_time / 1000000,
1000000 * (double)frame_cnt / (double)cx_time);
fclose(infile);
printf("Processed %ld frames.\n",(long int)frame_cnt-1);
for (i=0; i< NUM_ENCODERS; i++)
{
/* Calculate PSNR and print it out */
if ( (show_psnr) && (psnr_count[i]>0) )
{
int j;
double ovpsnr = sse_to_psnr(psnr_samples_total[i], 255.0,
psnr_sse_total[i]);
fprintf(stderr, "\n ENC%d PSNR (Overall/Avg/Y/U/V)", i);
fprintf(stderr, " %.3lf", ovpsnr);
for (j = 0; j < 4; j++)
{
fprintf(stderr, " %.3lf", psnr_totals[i][j]/psnr_count[i]);
}
}
if(vpx_codec_destroy(&codec[i]))
die_codec(&codec[i], "Failed to destroy codec");
vpx_img_free(&raw[i]);
if(!outfile[i])
continue;
/* Try to rewrite the file header with the actual frame count */
if(!fseek(outfile[i], 0, SEEK_SET))
write_ivf_file_header(outfile[i], &cfg[i], frame_cnt-1);
fclose(outfile[i]);
}
printf("\n");
return EXIT_SUCCESS;
} }

View File

@@ -53,8 +53,8 @@
#include "vpx/vp8cx.h" #include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h" #include "vpx/vpx_encoder.h"
#include "../tools_common.h" #include "./tools_common.h"
#include "../video_writer.h" #include "./video_writer.h"
static const char *exec_name; static const char *exec_name;

View File

@@ -15,8 +15,8 @@
#include "vpx/vpx_encoder.h" #include "vpx/vpx_encoder.h"
#include "vpx/vp8cx.h" #include "vpx/vp8cx.h"
#include "../tools_common.h" #include "./tools_common.h"
#include "../video_writer.h" #include "./video_writer.h"
static const char *exec_name; static const char *exec_name;

View File

@@ -1,448 +0,0 @@
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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.
*/
/*
* This is an example demonstrating how to implement a multi-layer
* VP9 encoding scheme based on spatial scalability for video applications
* that benefit from a scalable bitstream.
*/
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "../args.h"
#include "../tools_common.h"
#include "../video_writer.h"
#include "vpx/svc_context.h"
#include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h"
#include "../vpxstats.h"
static const arg_def_t skip_frames_arg =
ARG_DEF("s", "skip-frames", 1, "input frames to skip");
static const arg_def_t frames_arg =
ARG_DEF("f", "frames", 1, "number of frames to encode");
static const arg_def_t width_arg = ARG_DEF("w", "width", 1, "source width");
static const arg_def_t height_arg = ARG_DEF("h", "height", 1, "source height");
static const arg_def_t timebase_arg =
ARG_DEF("t", "timebase", 1, "timebase (num/den)");
static const arg_def_t bitrate_arg = ARG_DEF(
"b", "target-bitrate", 1, "encoding bitrate, in kilobits per second");
static const arg_def_t spatial_layers_arg =
ARG_DEF("sl", "spatial-layers", 1, "number of spatial SVC layers");
static const arg_def_t temporal_layers_arg =
ARG_DEF("tl", "temporal-layers", 1, "number of temporal SVC layers");
static const arg_def_t kf_dist_arg =
ARG_DEF("k", "kf-dist", 1, "number of frames between keyframes");
static const arg_def_t scale_factors_arg =
ARG_DEF("r", "scale-factors", 1, "scale factors (lowest to highest layer)");
static const arg_def_t passes_arg =
ARG_DEF("p", "passes", 1, "Number of passes (1/2)");
static const arg_def_t pass_arg =
ARG_DEF(NULL, "pass", 1, "Pass to execute (1/2)");
static const arg_def_t fpf_name_arg =
ARG_DEF(NULL, "fpf", 1, "First pass statistics file name");
static const arg_def_t min_q_arg =
ARG_DEF(NULL, "min-q", 1, "Minimum quantizer");
static const arg_def_t max_q_arg =
ARG_DEF(NULL, "max-q", 1, "Maximum quantizer");
static const arg_def_t min_bitrate_arg =
ARG_DEF(NULL, "min-bitrate", 1, "Minimum bitrate");
static const arg_def_t max_bitrate_arg =
ARG_DEF(NULL, "max-bitrate", 1, "Maximum bitrate");
static const arg_def_t lag_in_frame_arg =
ARG_DEF(NULL, "lag-in-frames", 1, "Number of frame to input before "
"generating any outputs");
static const arg_def_t rc_end_usage_arg =
ARG_DEF(NULL, "rc-end-usage", 1, "0 - 3: VBR, CBR, CQ, Q");
#if CONFIG_VP9_HIGHBITDEPTH
static const struct arg_enum_list bitdepth_enum[] = {
{"8", VPX_BITS_8},
{"10", VPX_BITS_10},
{"12", VPX_BITS_12},
{NULL, 0}
};
static const arg_def_t bitdepth_arg =
ARG_DEF_ENUM("d", "bit-depth", 1, "Bit depth for codec 8, 10 or 12. ",
bitdepth_enum);
#endif // CONFIG_VP9_HIGHBITDEPTH
static const arg_def_t *svc_args[] = {
&frames_arg, &width_arg, &height_arg,
&timebase_arg, &bitrate_arg, &skip_frames_arg, &spatial_layers_arg,
&kf_dist_arg, &scale_factors_arg, &passes_arg, &pass_arg,
&fpf_name_arg, &min_q_arg, &max_q_arg, &min_bitrate_arg,
&max_bitrate_arg, &temporal_layers_arg, &lag_in_frame_arg,
#if CONFIG_VP9_HIGHBITDEPTH
&bitdepth_arg,
#endif
&rc_end_usage_arg, NULL
};
static const uint32_t default_frames_to_skip = 0;
static const uint32_t default_frames_to_code = 60 * 60;
static const uint32_t default_width = 1920;
static const uint32_t default_height = 1080;
static const uint32_t default_timebase_num = 1;
static const uint32_t default_timebase_den = 60;
static const uint32_t default_bitrate = 1000;
static const uint32_t default_spatial_layers = 5;
static const uint32_t default_temporal_layers = 1;
static const uint32_t default_kf_dist = 100;
typedef struct {
const char *input_filename;
const char *output_filename;
uint32_t frames_to_code;
uint32_t frames_to_skip;
struct VpxInputContext input_ctx;
stats_io_t rc_stats;
int passes;
int pass;
} AppInput;
static const char *exec_name;
void usage_exit() {
fprintf(stderr, "Usage: %s <options> input_filename output_filename\n",
exec_name);
fprintf(stderr, "Options:\n");
arg_show_usage(stderr, svc_args);
exit(EXIT_FAILURE);
}
static void parse_command_line(int argc, const char **argv_,
AppInput *app_input, SvcContext *svc_ctx,
vpx_codec_enc_cfg_t *enc_cfg) {
struct arg arg = {0};
char **argv = NULL;
char **argi = NULL;
char **argj = NULL;
vpx_codec_err_t res;
int passes = 0;
int pass = 0;
const char *fpf_file_name = NULL;
unsigned int min_bitrate = 0;
unsigned int max_bitrate = 0;
char string_options[1024] = {0};
// initialize SvcContext with parameters that will be passed to vpx_svc_init
svc_ctx->log_level = SVC_LOG_DEBUG;
svc_ctx->spatial_layers = default_spatial_layers;
svc_ctx->temporal_layers = default_temporal_layers;
// start with default encoder configuration
res = vpx_codec_enc_config_default(vpx_codec_vp9_cx(), enc_cfg, 0);
if (res) {
die("Failed to get config: %s\n", vpx_codec_err_to_string(res));
}
// update enc_cfg with app default values
enc_cfg->g_w = default_width;
enc_cfg->g_h = default_height;
enc_cfg->g_timebase.num = default_timebase_num;
enc_cfg->g_timebase.den = default_timebase_den;
enc_cfg->rc_target_bitrate = default_bitrate;
enc_cfg->kf_min_dist = default_kf_dist;
enc_cfg->kf_max_dist = default_kf_dist;
enc_cfg->rc_end_usage = VPX_CQ;
// initialize AppInput with default values
app_input->frames_to_code = default_frames_to_code;
app_input->frames_to_skip = default_frames_to_skip;
// process command line options
argv = argv_dup(argc - 1, argv_ + 1);
for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) {
arg.argv_step = 1;
if (arg_match(&arg, &frames_arg, argi)) {
app_input->frames_to_code = arg_parse_uint(&arg);
} else if (arg_match(&arg, &width_arg, argi)) {
enc_cfg->g_w = arg_parse_uint(&arg);
} else if (arg_match(&arg, &height_arg, argi)) {
enc_cfg->g_h = arg_parse_uint(&arg);
} else if (arg_match(&arg, &timebase_arg, argi)) {
enc_cfg->g_timebase = arg_parse_rational(&arg);
} else if (arg_match(&arg, &bitrate_arg, argi)) {
enc_cfg->rc_target_bitrate = arg_parse_uint(&arg);
} else if (arg_match(&arg, &skip_frames_arg, argi)) {
app_input->frames_to_skip = arg_parse_uint(&arg);
} else if (arg_match(&arg, &spatial_layers_arg, argi)) {
svc_ctx->spatial_layers = arg_parse_uint(&arg);
} else if (arg_match(&arg, &temporal_layers_arg, argi)) {
svc_ctx->temporal_layers = arg_parse_uint(&arg);
} else if (arg_match(&arg, &kf_dist_arg, argi)) {
enc_cfg->kf_min_dist = arg_parse_uint(&arg);
enc_cfg->kf_max_dist = enc_cfg->kf_min_dist;
} else if (arg_match(&arg, &scale_factors_arg, argi)) {
snprintf(string_options, sizeof(string_options), "%s scale-factors=%s",
string_options, arg.val);
} else if (arg_match(&arg, &passes_arg, argi)) {
passes = arg_parse_uint(&arg);
if (passes < 1 || passes > 2) {
die("Error: Invalid number of passes (%d)\n", passes);
}
} else if (arg_match(&arg, &pass_arg, argi)) {
pass = arg_parse_uint(&arg);
if (pass < 1 || pass > 2) {
die("Error: Invalid pass selected (%d)\n", pass);
}
} else if (arg_match(&arg, &fpf_name_arg, argi)) {
fpf_file_name = arg.val;
} else if (arg_match(&arg, &min_q_arg, argi)) {
snprintf(string_options, sizeof(string_options), "%s min-quantizers=%s",
string_options, arg.val);
} else if (arg_match(&arg, &max_q_arg, argi)) {
snprintf(string_options, sizeof(string_options), "%s max-quantizers=%s",
string_options, arg.val);
} else if (arg_match(&arg, &min_bitrate_arg, argi)) {
min_bitrate = arg_parse_uint(&arg);
} else if (arg_match(&arg, &max_bitrate_arg, argi)) {
max_bitrate = arg_parse_uint(&arg);
} else if (arg_match(&arg, &lag_in_frame_arg, argi)) {
enc_cfg->g_lag_in_frames = arg_parse_uint(&arg);
} else if (arg_match(&arg, &rc_end_usage_arg, argi)) {
enc_cfg->rc_end_usage = arg_parse_uint(&arg);
#if CONFIG_VP9_HIGHBITDEPTH
} else if (arg_match(&arg, &bitdepth_arg, argi)) {
enc_cfg->g_bit_depth = arg_parse_enum_or_int(&arg);
switch (enc_cfg->g_bit_depth) {
case VPX_BITS_8:
enc_cfg->g_input_bit_depth = 8;
enc_cfg->g_profile = 0;
break;
case VPX_BITS_10:
enc_cfg->g_input_bit_depth = 10;
enc_cfg->g_profile = 2;
break;
case VPX_BITS_12:
enc_cfg->g_input_bit_depth = 12;
enc_cfg->g_profile = 2;
break;
default:
die("Error: Invalid bit depth selected (%d)\n", enc_cfg->g_bit_depth);
break;
}
#endif // CONFIG_VP9_HIGHBITDEPTH
} else {
++argj;
}
}
// There will be a space in front of the string options
if (strlen(string_options) > 0)
vpx_svc_set_options(svc_ctx, string_options + 1);
if (passes == 0 || passes == 1) {
if (pass) {
fprintf(stderr, "pass is ignored since there's only one pass\n");
}
enc_cfg->g_pass = VPX_RC_ONE_PASS;
} else {
if (pass == 0) {
die("pass must be specified when passes is 2\n");
}
if (fpf_file_name == NULL) {
die("fpf must be specified when passes is 2\n");
}
if (pass == 1) {
enc_cfg->g_pass = VPX_RC_FIRST_PASS;
if (!stats_open_file(&app_input->rc_stats, fpf_file_name, 0)) {
fatal("Failed to open statistics store");
}
} else {
enc_cfg->g_pass = VPX_RC_LAST_PASS;
if (!stats_open_file(&app_input->rc_stats, fpf_file_name, 1)) {
fatal("Failed to open statistics store");
}
enc_cfg->rc_twopass_stats_in = stats_get(&app_input->rc_stats);
}
app_input->passes = passes;
app_input->pass = pass;
}
if (enc_cfg->rc_target_bitrate > 0) {
if (min_bitrate > 0) {
enc_cfg->rc_2pass_vbr_minsection_pct =
min_bitrate * 100 / enc_cfg->rc_target_bitrate;
}
if (max_bitrate > 0) {
enc_cfg->rc_2pass_vbr_maxsection_pct =
max_bitrate * 100 / enc_cfg->rc_target_bitrate;
}
}
// Check for unrecognized options
for (argi = argv; *argi; ++argi)
if (argi[0][0] == '-' && strlen(argi[0]) > 1)
die("Error: Unrecognized option %s\n", *argi);
if (argv[0] == NULL || argv[1] == 0) {
usage_exit();
}
app_input->input_filename = argv[0];
app_input->output_filename = argv[1];
free(argv);
if (enc_cfg->g_w < 16 || enc_cfg->g_w % 2 || enc_cfg->g_h < 16 ||
enc_cfg->g_h % 2)
die("Invalid resolution: %d x %d\n", enc_cfg->g_w, enc_cfg->g_h);
printf(
"Codec %s\nframes: %d, skip: %d\n"
"layers: %d\n"
"width %d, height: %d,\n"
"num: %d, den: %d, bitrate: %d,\n"
"gop size: %d\n",
vpx_codec_iface_name(vpx_codec_vp9_cx()), app_input->frames_to_code,
app_input->frames_to_skip,
svc_ctx->spatial_layers, enc_cfg->g_w, enc_cfg->g_h,
enc_cfg->g_timebase.num, enc_cfg->g_timebase.den,
enc_cfg->rc_target_bitrate, enc_cfg->kf_max_dist);
}
int main(int argc, const char **argv) {
AppInput app_input = {0};
VpxVideoWriter *writer = NULL;
VpxVideoInfo info = {0};
vpx_codec_ctx_t codec;
vpx_codec_enc_cfg_t enc_cfg;
SvcContext svc_ctx;
uint32_t i;
uint32_t frame_cnt = 0;
vpx_image_t raw;
vpx_codec_err_t res;
int pts = 0; /* PTS starts at 0 */
int frame_duration = 1; /* 1 timebase tick per frame */
FILE *infile = NULL;
int end_of_stream = 0;
int frames_received = 0;
memset(&svc_ctx, 0, sizeof(svc_ctx));
svc_ctx.log_print = 1;
exec_name = argv[0];
parse_command_line(argc, argv, &app_input, &svc_ctx, &enc_cfg);
// Allocate image buffer
#if CONFIG_VP9_HIGHBITDEPTH
if (!vpx_img_alloc(&raw, enc_cfg.g_input_bit_depth == 8 ?
VPX_IMG_FMT_I420 : VPX_IMG_FMT_I42016,
enc_cfg.g_w, enc_cfg.g_h, 32)) {
die("Failed to allocate image %dx%d\n", enc_cfg.g_w, enc_cfg.g_h);
}
#else
if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, enc_cfg.g_w, enc_cfg.g_h, 32)) {
die("Failed to allocate image %dx%d\n", enc_cfg.g_w, enc_cfg.g_h);
}
#endif // CONFIG_VP9_HIGHBITDEPTH
if (!(infile = fopen(app_input.input_filename, "rb")))
die("Failed to open %s for reading\n", app_input.input_filename);
// Initialize codec
if (vpx_svc_init(&svc_ctx, &codec, vpx_codec_vp9_cx(), &enc_cfg) !=
VPX_CODEC_OK)
die("Failed to initialize encoder\n");
info.codec_fourcc = VP9_FOURCC;
info.time_base.numerator = enc_cfg.g_timebase.num;
info.time_base.denominator = enc_cfg.g_timebase.den;
if (!(app_input.passes == 2 && app_input.pass == 1)) {
// We don't save the bitstream for the 1st pass on two pass rate control
writer = vpx_video_writer_open(app_input.output_filename, kContainerIVF,
&info);
if (!writer)
die("Failed to open %s for writing\n", app_input.output_filename);
}
// skip initial frames
for (i = 0; i < app_input.frames_to_skip; ++i)
vpx_img_read(&raw, infile);
// Encode frames
while (!end_of_stream) {
vpx_codec_iter_t iter = NULL;
const vpx_codec_cx_pkt_t *cx_pkt;
if (frame_cnt >= app_input.frames_to_code || !vpx_img_read(&raw, infile)) {
// We need one extra vpx_svc_encode call at end of stream to flush
// encoder and get remaining data
end_of_stream = 1;
}
res = vpx_svc_encode(&svc_ctx, &codec, (end_of_stream ? NULL : &raw),
pts, frame_duration, VPX_DL_GOOD_QUALITY);
printf("%s", vpx_svc_get_message(&svc_ctx));
if (res != VPX_CODEC_OK) {
die_codec(&codec, "Failed to encode frame");
}
while ((cx_pkt = vpx_codec_get_cx_data(&codec, &iter)) != NULL) {
switch (cx_pkt->kind) {
case VPX_CODEC_CX_FRAME_PKT: {
if (cx_pkt->data.frame.sz > 0)
vpx_video_writer_write_frame(writer,
cx_pkt->data.frame.buf,
cx_pkt->data.frame.sz,
cx_pkt->data.frame.pts);
printf("SVC frame: %d, kf: %d, size: %d, pts: %d\n", frames_received,
!!(cx_pkt->data.frame.flags & VPX_FRAME_IS_KEY),
(int)cx_pkt->data.frame.sz, (int)cx_pkt->data.frame.pts);
++frames_received;
break;
}
case VPX_CODEC_STATS_PKT: {
stats_write(&app_input.rc_stats,
cx_pkt->data.twopass_stats.buf,
cx_pkt->data.twopass_stats.sz);
break;
}
default: {
break;
}
}
}
if (!end_of_stream) {
++frame_cnt;
pts += frame_duration;
}
}
printf("Processed %d frames\n", frame_cnt);
fclose(infile);
if (vpx_codec_destroy(&codec)) die_codec(&codec, "Failed to destroy codec");
if (app_input.passes == 2)
stats_close(&app_input.rc_stats, 1);
if (writer) {
vpx_video_writer_close(writer);
}
vpx_img_free(&raw);
// display average size, psnr
printf("%s", vpx_svc_dump_statistics(&svc_ctx));
vpx_svc_release(&svc_ctx);
return EXIT_SUCCESS;
}

443
examples/vp9cx_set_ref.c Normal file
View File

@@ -0,0 +1,443 @@
/*
* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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.
*/
// VP9 Set Reference Frame
// =======================
//
// This is an example demonstrating how to overwrite the VP9 encoder's
// internal reference frame. In the sample we set the last frame to the
// current frame. This technique could be used to bounce between two cameras.
//
// The decoder would also have to set the reference frame to the same value
// on the same frame, or the video will become corrupt. The 'test_decode'
// variable is set to 1 in this example that tests if the encoder and decoder
// results are matching.
//
// Usage
// -----
// This example encodes a raw video. And the last argument passed in specifies
// the frame number to update the reference frame on.
// The parameter is parsed as follows:
//
//
// Extra Variables
// ---------------
// This example maintains the frame number passed on the command line
// in the `update_frame_num` variable.
//
//
// Configuration
// -------------
//
// The reference frame is updated on the frame specified on the command
// line.
//
// Observing The Effects
// ---------------------
// The encoder and decoder results should be matching when the same reference
// frame setting operation is done in both encoder and decoder. Otherwise,
// the encoder/decoder mismatch would be seen.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vpx/vp8cx.h"
#include "vpx/vpx_decoder.h"
#include "vpx/vpx_encoder.h"
#include "./tools_common.h"
#include "./video_writer.h"
static const char *exec_name;
void usage_exit() {
fprintf(stderr, "Usage: %s <width> <height> <infile> <outfile> "
"<frame>\n",
exec_name);
exit(EXIT_FAILURE);
}
static int compare_img(const vpx_image_t *const img1,
const vpx_image_t *const img2) {
uint32_t l_w = img1->d_w;
uint32_t c_w =
(img1->d_w + img1->x_chroma_shift) >> img1->x_chroma_shift;
const uint32_t c_h =
(img1->d_h + img1->y_chroma_shift) >> img1->y_chroma_shift;
uint32_t i;
int match = 1;
match &= (img1->fmt == img2->fmt);
match &= (img1->d_w == img2->d_w);
match &= (img1->d_h == img2->d_h);
for (i = 0; i < img1->d_h; ++i)
match &= (memcmp(img1->planes[VPX_PLANE_Y] + i * img1->stride[VPX_PLANE_Y],
img2->planes[VPX_PLANE_Y] + i * img2->stride[VPX_PLANE_Y],
l_w) == 0);
for (i = 0; i < c_h; ++i)
match &= (memcmp(img1->planes[VPX_PLANE_U] + i * img1->stride[VPX_PLANE_U],
img2->planes[VPX_PLANE_U] + i * img2->stride[VPX_PLANE_U],
c_w) == 0);
for (i = 0; i < c_h; ++i)
match &= (memcmp(img1->planes[VPX_PLANE_V] + i * img1->stride[VPX_PLANE_V],
img2->planes[VPX_PLANE_V] + i * img2->stride[VPX_PLANE_V],
c_w) == 0);
return match;
}
#define mmin(a, b) ((a) < (b) ? (a) : (b))
static void find_mismatch(const vpx_image_t *const img1,
const vpx_image_t *const img2,
int yloc[4], int uloc[4], int vloc[4]) {
const uint32_t bsize = 64;
const uint32_t bsizey = bsize >> img1->y_chroma_shift;
const uint32_t bsizex = bsize >> img1->x_chroma_shift;
const uint32_t c_w =
(img1->d_w + img1->x_chroma_shift) >> img1->x_chroma_shift;
const uint32_t c_h =
(img1->d_h + img1->y_chroma_shift) >> img1->y_chroma_shift;
int match = 1;
uint32_t i, j;
yloc[0] = yloc[1] = yloc[2] = yloc[3] = -1;
for (i = 0, match = 1; match && i < img1->d_h; i += bsize) {
for (j = 0; match && j < img1->d_w; j += bsize) {
int k, l;
const int si = mmin(i + bsize, img1->d_h) - i;
const int sj = mmin(j + bsize, img1->d_w) - j;
for (k = 0; match && k < si; ++k) {
for (l = 0; match && l < sj; ++l) {
if (*(img1->planes[VPX_PLANE_Y] +
(i + k) * img1->stride[VPX_PLANE_Y] + j + l) !=
*(img2->planes[VPX_PLANE_Y] +
(i + k) * img2->stride[VPX_PLANE_Y] + j + l)) {
yloc[0] = i + k;
yloc[1] = j + l;
yloc[2] = *(img1->planes[VPX_PLANE_Y] +
(i + k) * img1->stride[VPX_PLANE_Y] + j + l);
yloc[3] = *(img2->planes[VPX_PLANE_Y] +
(i + k) * img2->stride[VPX_PLANE_Y] + j + l);
match = 0;
break;
}
}
}
}
}
uloc[0] = uloc[1] = uloc[2] = uloc[3] = -1;
for (i = 0, match = 1; match && i < c_h; i += bsizey) {
for (j = 0; match && j < c_w; j += bsizex) {
int k, l;
const int si = mmin(i + bsizey, c_h - i);
const int sj = mmin(j + bsizex, c_w - j);
for (k = 0; match && k < si; ++k) {
for (l = 0; match && l < sj; ++l) {
if (*(img1->planes[VPX_PLANE_U] +
(i + k) * img1->stride[VPX_PLANE_U] + j + l) !=
*(img2->planes[VPX_PLANE_U] +
(i + k) * img2->stride[VPX_PLANE_U] + j + l)) {
uloc[0] = i + k;
uloc[1] = j + l;
uloc[2] = *(img1->planes[VPX_PLANE_U] +
(i + k) * img1->stride[VPX_PLANE_U] + j + l);
uloc[3] = *(img2->planes[VPX_PLANE_U] +
(i + k) * img2->stride[VPX_PLANE_U] + j + l);
match = 0;
break;
}
}
}
}
}
vloc[0] = vloc[1] = vloc[2] = vloc[3] = -1;
for (i = 0, match = 1; match && i < c_h; i += bsizey) {
for (j = 0; match && j < c_w; j += bsizex) {
int k, l;
const int si = mmin(i + bsizey, c_h - i);
const int sj = mmin(j + bsizex, c_w - j);
for (k = 0; match && k < si; ++k) {
for (l = 0; match && l < sj; ++l) {
if (*(img1->planes[VPX_PLANE_V] +
(i + k) * img1->stride[VPX_PLANE_V] + j + l) !=
*(img2->planes[VPX_PLANE_V] +
(i + k) * img2->stride[VPX_PLANE_V] + j + l)) {
vloc[0] = i + k;
vloc[1] = j + l;
vloc[2] = *(img1->planes[VPX_PLANE_V] +
(i + k) * img1->stride[VPX_PLANE_V] + j + l);
vloc[3] = *(img2->planes[VPX_PLANE_V] +
(i + k) * img2->stride[VPX_PLANE_V] + j + l);
match = 0;
break;
}
}
}
}
}
}
static void testing_decode(vpx_codec_ctx_t *encoder,
vpx_codec_ctx_t *decoder,
vpx_codec_enc_cfg_t *cfg,
unsigned int frame_out,
int *mismatch_seen) {
vpx_image_t enc_img, dec_img;
struct vp9_ref_frame ref_enc, ref_dec;
if (*mismatch_seen)
return;
ref_enc.idx = 0;
ref_dec.idx = 0;
if (vpx_codec_control(encoder, VP9_GET_REFERENCE, &ref_enc))
die_codec(encoder, "Failed to get encoder reference frame");
enc_img = ref_enc.img;
if (vpx_codec_control(decoder, VP9_GET_REFERENCE, &ref_dec))
die_codec(decoder, "Failed to get decoder reference frame");
dec_img = ref_dec.img;
if (!compare_img(&enc_img, &dec_img)) {
int y[4], u[4], v[4];
*mismatch_seen = 1;
find_mismatch(&enc_img, &dec_img, y, u, v);
printf("Encode/decode mismatch on frame %d at"
" Y[%d, %d] {%d/%d},"
" U[%d, %d] {%d/%d},"
" V[%d, %d] {%d/%d}",
frame_out,
y[0], y[1], y[2], y[3],
u[0], u[1], u[2], u[3],
v[0], v[1], v[2], v[3]);
}
vpx_img_free(&enc_img);
vpx_img_free(&dec_img);
}
static int encode_frame(vpx_codec_ctx_t *ecodec,
vpx_codec_enc_cfg_t *cfg,
vpx_image_t *img,
unsigned int frame_in,
VpxVideoWriter *writer,
int test_decode,
vpx_codec_ctx_t *dcodec,
unsigned int *frame_out,
int *mismatch_seen) {
int got_pkts = 0;
vpx_codec_iter_t iter = NULL;
const vpx_codec_cx_pkt_t *pkt = NULL;
int got_data;
const vpx_codec_err_t res = vpx_codec_encode(ecodec, img, frame_in, 1,
0, VPX_DL_GOOD_QUALITY);
if (res != VPX_CODEC_OK)
die_codec(ecodec, "Failed to encode frame");
got_data = 0;
while ((pkt = vpx_codec_get_cx_data(ecodec, &iter)) != NULL) {
got_pkts = 1;
if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
const int keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0;
if (!(pkt->data.frame.flags & VPX_FRAME_IS_FRAGMENT)) {
*frame_out += 1;
}
if (!vpx_video_writer_write_frame(writer,
pkt->data.frame.buf,
pkt->data.frame.sz,
pkt->data.frame.pts)) {
die_codec(ecodec, "Failed to write compressed frame");
}
printf(keyframe ? "K" : ".");
fflush(stdout);
got_data = 1;
// Decode 1 frame.
if (test_decode) {
if (vpx_codec_decode(dcodec, pkt->data.frame.buf,
(unsigned int)pkt->data.frame.sz, NULL, 0))
die_codec(dcodec, "Failed to decode frame.");
}
}
}
// Mismatch checking
if (got_data && test_decode) {
testing_decode(ecodec, dcodec, cfg, *frame_out, mismatch_seen);
}
return got_pkts;
}
int main(int argc, char **argv) {
FILE *infile = NULL;
// Encoder
vpx_codec_ctx_t ecodec = {0};
vpx_codec_enc_cfg_t cfg = {0};
unsigned int frame_in = 0;
vpx_image_t raw;
vpx_codec_err_t res;
VpxVideoInfo info = {0};
VpxVideoWriter *writer = NULL;
const VpxInterface *encoder = NULL;
// Test encoder/decoder mismatch.
int test_decode = 1;
// Decoder
vpx_codec_ctx_t dcodec;
unsigned int frame_out = 0;
// The frame number to set reference frame on
int update_frame_num = 0;
int mismatch_seen = 0;
const int fps = 30;
const int bitrate = 500;
const char *codec_used = "vp9";
const char *width_arg = NULL;
const char *height_arg = NULL;
const char *infile_arg = NULL;
const char *outfile_arg = NULL;
exec_name = argv[0];
if (argc != 6)
die("Invalid number of arguments");
width_arg = argv[1];
height_arg = argv[2];
infile_arg = argv[3];
outfile_arg = argv[4];
encoder = get_vpx_encoder_by_name(codec_used);
if (!encoder)
die("Unsupported codec.");
update_frame_num = atoi(argv[5]);
if (update_frame_num <= 0)
die("Couldn't parse frame number '%s'\n", argv[5]);
info.codec_fourcc = encoder->fourcc;
info.frame_width = strtol(width_arg, NULL, 0);
info.frame_height = strtol(height_arg, NULL, 0);
info.time_base.numerator = 1;
info.time_base.denominator = fps;
if (info.frame_width <= 0 ||
info.frame_height <= 0 ||
(info.frame_width % 2) != 0 ||
(info.frame_height % 2) != 0) {
die("Invalid frame size: %dx%d", info.frame_width, info.frame_height);
}
if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width,
info.frame_height, 1)) {
die("Failed to allocate image.");
}
printf("Using %s\n", vpx_codec_iface_name(encoder->codec_interface()));
res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
if (res)
die_codec(&ecodec, "Failed to get default codec config.");
cfg.g_w = info.frame_width;
cfg.g_h = info.frame_height;
cfg.g_timebase.num = info.time_base.numerator;
cfg.g_timebase.den = info.time_base.denominator;
cfg.rc_target_bitrate = bitrate;
cfg.g_lag_in_frames = 25;
writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info);
if (!writer)
die("Failed to open %s for writing.", outfile_arg);
if (!(infile = fopen(infile_arg, "rb")))
die("Failed to open %s for reading.", infile_arg);
if (vpx_codec_enc_init(&ecodec, encoder->codec_interface(), &cfg, 0))
die_codec(&ecodec, "Failed to initialize encoder");
// Disable alt_ref.
if (vpx_codec_control(&ecodec, VP8E_SET_ENABLEAUTOALTREF, 0))
die_codec(&ecodec, "Failed to set enable auto alt ref");
if (test_decode) {
const VpxInterface *decoder = get_vpx_decoder_by_name(codec_used);
if (vpx_codec_dec_init(&dcodec, decoder->codec_interface(), NULL, 0))
die_codec(&dcodec, "Failed to initialize decoder.");
}
// Encode frames.
while (vpx_img_read(&raw, infile)) {
// In VP9, the reference buffers (cm->frame_buffs[i].buf) are allocated
// while calling vpx_codec_encode(), thus, setting reference for 1st frame
// isn't supported.
if (update_frame_num > 1 && frame_out + 1 == update_frame_num) {
vpx_ref_frame_t ref;
ref.frame_type = VP8_LAST_FRAME;
ref.img = raw;
// Set reference frame in encoder.
if (vpx_codec_control(&ecodec, VP8_SET_REFERENCE, &ref))
die_codec(&ecodec, "Failed to set reference frame");
// If set_reference in decoder is commented out, the enc/dec mismatch
// would be seen.
if (test_decode) {
if (vpx_codec_control(&dcodec, VP8_SET_REFERENCE, &ref))
die_codec(&dcodec, "Failed to set reference frame");
}
}
encode_frame(&ecodec, &cfg, &raw, frame_in, writer, test_decode,
&dcodec, &frame_out, &mismatch_seen);
frame_in++;
if (mismatch_seen)
break;
}
// Flush encoder.
if (!mismatch_seen)
while (encode_frame(&ecodec, &cfg, NULL, frame_in, writer, test_decode,
&dcodec, &frame_out, &mismatch_seen)) {};
printf("\n");
fclose(infile);
printf("Processed %d frames.\n", frame_out);
if (test_decode) {
if (!mismatch_seen)
printf("Encoder/decoder results are matching.\n");
else
printf("Encoder/decoder results are NOT matching.\n");
}
if (test_decode)
if (vpx_codec_destroy(&dcodec))
die_codec(&dcodec, "Failed to destroy decoder");
vpx_img_free(&raw);
if (vpx_codec_destroy(&ecodec))
die_codec(&ecodec, "Failed to destroy encoder.");
vpx_video_writer_close(writer);
return EXIT_SUCCESS;
}

View File

@@ -1,810 +0,0 @@
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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.
*/
// This is an example demonstrating how to implement a multi-layer VPx
// encoding scheme based on temporal scalability for video applications
// that benefit from a scalable bitstream.
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "./vpx_config.h"
#include "../vpx_ports/vpx_timer.h"
#include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h"
#include "../tools_common.h"
#include "../video_writer.h"
static const char *exec_name;
void usage_exit() {
exit(EXIT_FAILURE);
}
// Denoiser states, for temporal denoising.
enum denoiserState {
kDenoiserOff,
kDenoiserOnYOnly,
kDenoiserOnYUV,
kDenoiserOnYUVAggressive,
kDenoiserOnAdaptive
};
static int mode_to_num_layers[12] = {1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3};
// For rate control encoding stats.
struct RateControlMetrics {
// Number of input frames per layer.
int layer_input_frames[VPX_TS_MAX_LAYERS];
// Total (cumulative) number of encoded frames per layer.
int layer_tot_enc_frames[VPX_TS_MAX_LAYERS];
// Number of encoded non-key frames per layer.
int layer_enc_frames[VPX_TS_MAX_LAYERS];
// Framerate per layer layer (cumulative).
double layer_framerate[VPX_TS_MAX_LAYERS];
// Target average frame size per layer (per-frame-bandwidth per layer).
double layer_pfb[VPX_TS_MAX_LAYERS];
// Actual average frame size per layer.
double layer_avg_frame_size[VPX_TS_MAX_LAYERS];
// Average rate mismatch per layer (|target - actual| / target).
double layer_avg_rate_mismatch[VPX_TS_MAX_LAYERS];
// Actual encoding bitrate per layer (cumulative).
double layer_encoding_bitrate[VPX_TS_MAX_LAYERS];
// Average of the short-time encoder actual bitrate.
// TODO(marpan): Should we add these short-time stats for each layer?
double avg_st_encoding_bitrate;
// Variance of the short-time encoder actual bitrate.
double variance_st_encoding_bitrate;
// Window (number of frames) for computing short-timee encoding bitrate.
int window_size;
// Number of window measurements.
int window_count;
};
// Note: these rate control metrics assume only 1 key frame in the
// sequence (i.e., first frame only). So for temporal pattern# 7
// (which has key frame for every frame on base layer), the metrics
// computation will be off/wrong.
// TODO(marpan): Update these metrics to account for multiple key frames
// in the stream.
static void set_rate_control_metrics(struct RateControlMetrics *rc,
vpx_codec_enc_cfg_t *cfg) {
unsigned int i = 0;
// Set the layer (cumulative) framerate and the target layer (non-cumulative)
// per-frame-bandwidth, for the rate control encoding stats below.
const double framerate = cfg->g_timebase.den / cfg->g_timebase.num;
rc->layer_framerate[0] = framerate / cfg->ts_rate_decimator[0];
rc->layer_pfb[0] = 1000.0 * cfg->ts_target_bitrate[0] /
rc->layer_framerate[0];
for (i = 0; i < cfg->ts_number_layers; ++i) {
if (i > 0) {
rc->layer_framerate[i] = framerate / cfg->ts_rate_decimator[i];
rc->layer_pfb[i] = 1000.0 *
(cfg->ts_target_bitrate[i] - cfg->ts_target_bitrate[i - 1]) /
(rc->layer_framerate[i] - rc->layer_framerate[i - 1]);
}
rc->layer_input_frames[i] = 0;
rc->layer_enc_frames[i] = 0;
rc->layer_tot_enc_frames[i] = 0;
rc->layer_encoding_bitrate[i] = 0.0;
rc->layer_avg_frame_size[i] = 0.0;
rc->layer_avg_rate_mismatch[i] = 0.0;
}
rc->window_count = 0;
rc->window_size = 15;
rc->avg_st_encoding_bitrate = 0.0;
rc->variance_st_encoding_bitrate = 0.0;
}
static void printout_rate_control_summary(struct RateControlMetrics *rc,
vpx_codec_enc_cfg_t *cfg,
int frame_cnt) {
unsigned int i = 0;
int tot_num_frames = 0;
double perc_fluctuation = 0.0;
printf("Total number of processed frames: %d\n\n", frame_cnt -1);
printf("Rate control layer stats for %d layer(s):\n\n",
cfg->ts_number_layers);
for (i = 0; i < cfg->ts_number_layers; ++i) {
const int num_dropped = (i > 0) ?
(rc->layer_input_frames[i] - rc->layer_enc_frames[i]) :
(rc->layer_input_frames[i] - rc->layer_enc_frames[i] - 1);
tot_num_frames += rc->layer_input_frames[i];
rc->layer_encoding_bitrate[i] = 0.001 * rc->layer_framerate[i] *
rc->layer_encoding_bitrate[i] / tot_num_frames;
rc->layer_avg_frame_size[i] = rc->layer_avg_frame_size[i] /
rc->layer_enc_frames[i];
rc->layer_avg_rate_mismatch[i] = 100.0 * rc->layer_avg_rate_mismatch[i] /
rc->layer_enc_frames[i];
printf("For layer#: %d \n", i);
printf("Bitrate (target vs actual): %d %f \n", cfg->ts_target_bitrate[i],
rc->layer_encoding_bitrate[i]);
printf("Average frame size (target vs actual): %f %f \n", rc->layer_pfb[i],
rc->layer_avg_frame_size[i]);
printf("Average rate_mismatch: %f \n", rc->layer_avg_rate_mismatch[i]);
printf("Number of input frames, encoded (non-key) frames, "
"and perc dropped frames: %d %d %f \n", rc->layer_input_frames[i],
rc->layer_enc_frames[i],
100.0 * num_dropped / rc->layer_input_frames[i]);
printf("\n");
}
rc->avg_st_encoding_bitrate = rc->avg_st_encoding_bitrate / rc->window_count;
rc->variance_st_encoding_bitrate =
rc->variance_st_encoding_bitrate / rc->window_count -
(rc->avg_st_encoding_bitrate * rc->avg_st_encoding_bitrate);
perc_fluctuation = 100.0 * sqrt(rc->variance_st_encoding_bitrate) /
rc->avg_st_encoding_bitrate;
printf("Short-time stats, for window of %d frames: \n",rc->window_size);
printf("Average, rms-variance, and percent-fluct: %f %f %f \n",
rc->avg_st_encoding_bitrate,
sqrt(rc->variance_st_encoding_bitrate),
perc_fluctuation);
if ((frame_cnt - 1) != tot_num_frames)
die("Error: Number of input frames not equal to output! \n");
}
// Temporal scaling parameters:
// NOTE: The 3 prediction frames cannot be used interchangeably due to
// differences in the way they are handled throughout the code. The
// frames should be allocated to layers in the order LAST, GF, ARF.
// Other combinations work, but may produce slightly inferior results.
static void set_temporal_layer_pattern(int layering_mode,
vpx_codec_enc_cfg_t *cfg,
int *layer_flags,
int *flag_periodicity) {
switch (layering_mode) {
case 0: {
// 1-layer.
int ids[1] = {0};
cfg->ts_periodicity = 1;
*flag_periodicity = 1;
cfg->ts_number_layers = 1;
cfg->ts_rate_decimator[0] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
// Update L only.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF;
break;
}
case 1: {
// 2-layers, 2-frame period.
int ids[2] = {0, 1};
cfg->ts_periodicity = 2;
*flag_periodicity = 2;
cfg->ts_number_layers = 2;
cfg->ts_rate_decimator[0] = 2;
cfg->ts_rate_decimator[1] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
#if 1
// 0=L, 1=GF, Intra-layer prediction enabled.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF;
layer_flags[1] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_REF_ARF;
#else
// 0=L, 1=GF, Intra-layer prediction disabled.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF;
layer_flags[1] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_LAST;
#endif
break;
}
case 2: {
// 2-layers, 3-frame period.
int ids[3] = {0, 1, 1};
cfg->ts_periodicity = 3;
*flag_periodicity = 3;
cfg->ts_number_layers = 2;
cfg->ts_rate_decimator[0] = 3;
cfg->ts_rate_decimator[1] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
// 0=L, 1=GF, Intra-layer prediction enabled.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
layer_flags[1] =
layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
break;
}
case 3: {
// 3-layers, 6-frame period.
int ids[6] = {0, 2, 2, 1, 2, 2};
cfg->ts_periodicity = 6;
*flag_periodicity = 6;
cfg->ts_number_layers = 3;
cfg->ts_rate_decimator[0] = 6;
cfg->ts_rate_decimator[1] = 3;
cfg->ts_rate_decimator[2] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
// 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
layer_flags[3] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST;
layer_flags[1] =
layer_flags[2] =
layer_flags[4] =
layer_flags[5] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_LAST;
break;
}
case 4: {
// 3-layers, 4-frame period.
int ids[4] = {0, 2, 1, 2};
cfg->ts_periodicity = 4;
*flag_periodicity = 4;
cfg->ts_number_layers = 3;
cfg->ts_rate_decimator[0] = 4;
cfg->ts_rate_decimator[1] = 2;
cfg->ts_rate_decimator[2] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
// 0=L, 1=GF, 2=ARF, Intra-layer prediction disabled.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
layer_flags[1] =
layer_flags[3] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
break;
}
case 5: {
// 3-layers, 4-frame period.
int ids[4] = {0, 2, 1, 2};
cfg->ts_periodicity = 4;
*flag_periodicity = 4;
cfg->ts_number_layers = 3;
cfg->ts_rate_decimator[0] = 4;
cfg->ts_rate_decimator[1] = 2;
cfg->ts_rate_decimator[2] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
// 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled in layer 1, disabled
// in layer 2.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
layer_flags[2] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ARF;
layer_flags[1] =
layer_flags[3] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
break;
}
case 6: {
// 3-layers, 4-frame period.
int ids[4] = {0, 2, 1, 2};
cfg->ts_periodicity = 4;
*flag_periodicity = 4;
cfg->ts_number_layers = 3;
cfg->ts_rate_decimator[0] = 4;
cfg->ts_rate_decimator[1] = 2;
cfg->ts_rate_decimator[2] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
// 0=L, 1=GF, 2=ARF, Intra-layer prediction enabled.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
layer_flags[2] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ARF;
layer_flags[1] =
layer_flags[3] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
break;
}
case 7: {
// NOTE: Probably of academic interest only.
// 5-layers, 16-frame period.
int ids[16] = {0, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 4, 2, 4, 3, 4};
cfg->ts_periodicity = 16;
*flag_periodicity = 16;
cfg->ts_number_layers = 5;
cfg->ts_rate_decimator[0] = 16;
cfg->ts_rate_decimator[1] = 8;
cfg->ts_rate_decimator[2] = 4;
cfg->ts_rate_decimator[3] = 2;
cfg->ts_rate_decimator[4] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
layer_flags[0] = VPX_EFLAG_FORCE_KF;
layer_flags[1] =
layer_flags[3] =
layer_flags[5] =
layer_flags[7] =
layer_flags[9] =
layer_flags[11] =
layer_flags[13] =
layer_flags[15] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF;
layer_flags[2] =
layer_flags[6] =
layer_flags[10] =
layer_flags[14] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_GF;
layer_flags[4] =
layer_flags[12] = VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_UPD_ARF;
layer_flags[8] = VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF;
break;
}
case 8: {
// 2-layers, with sync point at first frame of layer 1.
int ids[2] = {0, 1};
cfg->ts_periodicity = 2;
*flag_periodicity = 8;
cfg->ts_number_layers = 2;
cfg->ts_rate_decimator[0] = 2;
cfg->ts_rate_decimator[1] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
// 0=L, 1=GF.
// ARF is used as predictor for all frames, and is only updated on
// key frame. Sync point every 8 frames.
// Layer 0: predict from L and ARF, update L and G.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_ARF;
// Layer 1: sync point: predict from L and ARF, and update G.
layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ARF;
// Layer 0, predict from L and ARF, update L.
layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF;
// Layer 1: predict from L, G and ARF, and update G.
layer_flags[3] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ENTROPY;
// Layer 0.
layer_flags[4] = layer_flags[2];
// Layer 1.
layer_flags[5] = layer_flags[3];
// Layer 0.
layer_flags[6] = layer_flags[4];
// Layer 1.
layer_flags[7] = layer_flags[5];
break;
}
case 9: {
// 3-layers: Sync points for layer 1 and 2 every 8 frames.
int ids[4] = {0, 2, 1, 2};
cfg->ts_periodicity = 4;
*flag_periodicity = 8;
cfg->ts_number_layers = 3;
cfg->ts_rate_decimator[0] = 4;
cfg->ts_rate_decimator[1] = 2;
cfg->ts_rate_decimator[2] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
// 0=L, 1=GF, 2=ARF.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ARF;
layer_flags[3] =
layer_flags[5] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF;
layer_flags[4] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF |
VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF;
layer_flags[6] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ARF;
layer_flags[7] = VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_ENTROPY;
break;
}
case 10: {
// 3-layers structure where ARF is used as predictor for all frames,
// and is only updated on key frame.
// Sync points for layer 1 and 2 every 8 frames.
int ids[4] = {0, 2, 1, 2};
cfg->ts_periodicity = 4;
*flag_periodicity = 8;
cfg->ts_number_layers = 3;
cfg->ts_rate_decimator[0] = 4;
cfg->ts_rate_decimator[1] = 2;
cfg->ts_rate_decimator[2] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
// 0=L, 1=GF, 2=ARF.
// Layer 0: predict from L and ARF; update L and G.
layer_flags[0] = VPX_EFLAG_FORCE_KF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF;
// Layer 2: sync point: predict from L and ARF; update none.
layer_flags[1] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ENTROPY;
// Layer 1: sync point: predict from L and ARF; update G.
layer_flags[2] = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST;
// Layer 2: predict from L, G, ARF; update none.
layer_flags[3] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ENTROPY;
// Layer 0: predict from L and ARF; update L.
layer_flags[4] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF;
// Layer 2: predict from L, G, ARF; update none.
layer_flags[5] = layer_flags[3];
// Layer 1: predict from L, G, ARF; update G.
layer_flags[6] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
// Layer 2: predict from L, G, ARF; update none.
layer_flags[7] = layer_flags[3];
break;
}
case 11:
default: {
// 3-layers structure as in case 10, but no sync/refresh points for
// layer 1 and 2.
int ids[4] = {0, 2, 1, 2};
cfg->ts_periodicity = 4;
*flag_periodicity = 8;
cfg->ts_number_layers = 3;
cfg->ts_rate_decimator[0] = 4;
cfg->ts_rate_decimator[1] = 2;
cfg->ts_rate_decimator[2] = 1;
memcpy(cfg->ts_layer_id, ids, sizeof(ids));
// 0=L, 1=GF, 2=ARF.
// Layer 0: predict from L and ARF; update L.
layer_flags[0] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF;
layer_flags[4] = layer_flags[0];
// Layer 1: predict from L, G, ARF; update G.
layer_flags[2] = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
layer_flags[6] = layer_flags[2];
// Layer 2: predict from L, G, ARF; update none.
layer_flags[1] = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_ENTROPY;
layer_flags[3] = layer_flags[1];
layer_flags[5] = layer_flags[1];
layer_flags[7] = layer_flags[1];
break;
}
}
}
int main(int argc, char **argv) {
VpxVideoWriter *outfile[VPX_TS_MAX_LAYERS] = {NULL};
vpx_codec_ctx_t codec;
vpx_codec_enc_cfg_t cfg;
int frame_cnt = 0;
vpx_image_t raw;
vpx_codec_err_t res;
unsigned int width;
unsigned int height;
int speed;
int frame_avail;
int got_data;
int flags = 0;
unsigned int i;
int pts = 0; // PTS starts at 0.
int frame_duration = 1; // 1 timebase tick per frame.
int layering_mode = 0;
int layer_flags[VPX_TS_MAX_PERIODICITY] = {0};
int flag_periodicity = 1;
#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
vpx_svc_layer_id_t layer_id = {0, 0};
#else
vpx_svc_layer_id_t layer_id = {0};
#endif
const VpxInterface *encoder = NULL;
FILE *infile = NULL;
struct RateControlMetrics rc;
int64_t cx_time = 0;
const int min_args_base = 11;
#if CONFIG_VP9_HIGHBITDEPTH
vpx_bit_depth_t bit_depth = VPX_BITS_8;
int input_bit_depth = 8;
const int min_args = min_args_base + 1;
#else
const int min_args = min_args_base;
#endif // CONFIG_VP9_HIGHBITDEPTH
double sum_bitrate = 0.0;
double sum_bitrate2 = 0.0;
double framerate = 30.0;
exec_name = argv[0];
// Check usage and arguments.
if (argc < min_args) {
#if CONFIG_VP9_HIGHBITDEPTH
die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
"<rate_num> <rate_den> <speed> <frame_drop_threshold> <mode> "
"<Rate_0> ... <Rate_nlayers-1> <bit-depth> \n", argv[0]);
#else
die("Usage: %s <infile> <outfile> <codec_type(vp8/vp9)> <width> <height> "
"<rate_num> <rate_den> <speed> <frame_drop_threshold> <mode> "
"<Rate_0> ... <Rate_nlayers-1> \n", argv[0]);
#endif // CONFIG_VP9_HIGHBITDEPTH
}
encoder = get_vpx_encoder_by_name(argv[3]);
if (!encoder)
die("Unsupported codec.");
printf("Using %s\n", vpx_codec_iface_name(encoder->codec_interface()));
width = strtol(argv[4], NULL, 0);
height = strtol(argv[5], NULL, 0);
if (width < 16 || width % 2 || height < 16 || height % 2) {
die("Invalid resolution: %d x %d", width, height);
}
layering_mode = strtol(argv[10], NULL, 0);
if (layering_mode < 0 || layering_mode > 12) {
die("Invalid layering mode (0..12) %s", argv[10]);
}
if (argc != min_args + mode_to_num_layers[layering_mode]) {
die("Invalid number of arguments");
}
#if CONFIG_VP9_HIGHBITDEPTH
switch (strtol(argv[argc-1], NULL, 0)) {
case 8:
bit_depth = VPX_BITS_8;
input_bit_depth = 8;
break;
case 10:
bit_depth = VPX_BITS_10;
input_bit_depth = 10;
break;
case 12:
bit_depth = VPX_BITS_12;
input_bit_depth = 12;
break;
default:
die("Invalid bit depth (8, 10, 12) %s", argv[argc-1]);
}
if (!vpx_img_alloc(&raw,
bit_depth == VPX_BITS_8 ? VPX_IMG_FMT_I420 :
VPX_IMG_FMT_I42016,
width, height, 32)) {
die("Failed to allocate image", width, height);
}
#else
if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, width, height, 32)) {
die("Failed to allocate image", width, height);
}
#endif // CONFIG_VP9_HIGHBITDEPTH
// Populate encoder configuration.
res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);
if (res) {
printf("Failed to get config: %s\n", vpx_codec_err_to_string(res));
return EXIT_FAILURE;
}
// Update the default configuration with our settings.
cfg.g_w = width;
cfg.g_h = height;
#if CONFIG_VP9_HIGHBITDEPTH
if (bit_depth != VPX_BITS_8) {
cfg.g_bit_depth = bit_depth;
cfg.g_input_bit_depth = input_bit_depth;
cfg.g_profile = 2;
}
#endif // CONFIG_VP9_HIGHBITDEPTH
// Timebase format e.g. 30fps: numerator=1, demoninator = 30.
cfg.g_timebase.num = strtol(argv[6], NULL, 0);
cfg.g_timebase.den = strtol(argv[7], NULL, 0);
speed = strtol(argv[8], NULL, 0);
if (speed < 0) {
die("Invalid speed setting: must be positive");
}
for (i = min_args_base;
(int)i < min_args_base + mode_to_num_layers[layering_mode];
++i) {
cfg.ts_target_bitrate[i - 11] = strtol(argv[i], NULL, 0);
}
// Real time parameters.
cfg.rc_dropframe_thresh = strtol(argv[9], NULL, 0);
cfg.rc_end_usage = VPX_CBR;
cfg.rc_resize_allowed = 0;
cfg.rc_min_quantizer = 2;
cfg.rc_max_quantizer = 56;
if (strncmp(encoder->name, "vp9", 3) == 0)
cfg.rc_max_quantizer = 52;
cfg.rc_undershoot_pct = 50;
cfg.rc_overshoot_pct = 50;
cfg.rc_buf_initial_sz = 500;
cfg.rc_buf_optimal_sz = 600;
cfg.rc_buf_sz = 1000;
// Use 1 thread as default.
cfg.g_threads = 1;
// Enable error resilient mode.
cfg.g_error_resilient = 1;
cfg.g_lag_in_frames = 0;
cfg.kf_mode = VPX_KF_AUTO;
// Disable automatic keyframe placement.
cfg.kf_min_dist = cfg.kf_max_dist = 3000;
set_temporal_layer_pattern(layering_mode,
&cfg,
layer_flags,
&flag_periodicity);
set_rate_control_metrics(&rc, &cfg);
// Target bandwidth for the whole stream.
// Set to ts_target_bitrate for highest layer (total bitrate).
cfg.rc_target_bitrate = cfg.ts_target_bitrate[cfg.ts_number_layers - 1];
// Open input file.
if (!(infile = fopen(argv[1], "rb"))) {
die("Failed to open %s for reading", argv[1]);
}
framerate = cfg.g_timebase.den / cfg.g_timebase.num;
// Open an output file for each stream.
for (i = 0; i < cfg.ts_number_layers; ++i) {
char file_name[PATH_MAX];
VpxVideoInfo info;
info.codec_fourcc = encoder->fourcc;
info.frame_width = cfg.g_w;
info.frame_height = cfg.g_h;
info.time_base.numerator = cfg.g_timebase.num;
info.time_base.denominator = cfg.g_timebase.den;
snprintf(file_name, sizeof(file_name), "%s_%d.ivf", argv[2], i);
outfile[i] = vpx_video_writer_open(file_name, kContainerIVF, &info);
if (!outfile[i])
die("Failed to open %s for writing", file_name);
assert(outfile[i] != NULL);
}
// No spatial layers in this encoder.
cfg.ss_number_layers = 1;
// Initialize codec.
#if CONFIG_VP9_HIGHBITDEPTH
if (vpx_codec_enc_init(
&codec, encoder->codec_interface(), &cfg,
bit_depth == VPX_BITS_8 ? 0 : VPX_CODEC_USE_HIGHBITDEPTH))
#else
if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
#endif // CONFIG_VP9_HIGHBITDEPTH
die_codec(&codec, "Failed to initialize encoder");
if (strncmp(encoder->name, "vp8", 3) == 0) {
vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed);
vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, kDenoiserOff);
vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 0);
} else if (strncmp(encoder->name, "vp9", 3) == 0) {
vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed);
vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3);
vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0);
vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, 0);
vpx_codec_control(&codec, VP8E_SET_STATIC_THRESHOLD, 0);
vpx_codec_control(&codec, VP9E_SET_TILE_COLUMNS, (cfg.g_threads >> 1));
if (vpx_codec_control(&codec, VP9E_SET_SVC, layering_mode > 0 ? 1: 0)) {
die_codec(&codec, "Failed to set SVC");
}
}
if (strncmp(encoder->name, "vp8", 3) == 0) {
vpx_codec_control(&codec, VP8E_SET_SCREEN_CONTENT_MODE, 0);
}
vpx_codec_control(&codec, VP8E_SET_TOKEN_PARTITIONS, 1);
// This controls the maximum target size of the key frame.
// For generating smaller key frames, use a smaller max_intra_size_pct
// value, like 100 or 200.
{
const int max_intra_size_pct = 900;
vpx_codec_control(&codec, VP8E_SET_MAX_INTRA_BITRATE_PCT,
max_intra_size_pct);
}
frame_avail = 1;
while (frame_avail || got_data) {
struct vpx_usec_timer timer;
vpx_codec_iter_t iter = NULL;
const vpx_codec_cx_pkt_t *pkt;
#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
// Update the temporal layer_id. No spatial layers in this test.
layer_id.spatial_layer_id = 0;
#endif
layer_id.temporal_layer_id =
cfg.ts_layer_id[frame_cnt % cfg.ts_periodicity];
if (strncmp(encoder->name, "vp9", 3) == 0) {
vpx_codec_control(&codec, VP9E_SET_SVC_LAYER_ID, &layer_id);
} else if (strncmp(encoder->name, "vp8", 3) == 0) {
vpx_codec_control(&codec, VP8E_SET_TEMPORAL_LAYER_ID,
layer_id.temporal_layer_id);
}
flags = layer_flags[frame_cnt % flag_periodicity];
if (layering_mode == 0)
flags = 0;
frame_avail = vpx_img_read(&raw, infile);
if (frame_avail)
++rc.layer_input_frames[layer_id.temporal_layer_id];
vpx_usec_timer_start(&timer);
if (vpx_codec_encode(&codec, frame_avail? &raw : NULL, pts, 1, flags,
VPX_DL_REALTIME)) {
die_codec(&codec, "Failed to encode frame");
}
vpx_usec_timer_mark(&timer);
cx_time += vpx_usec_timer_elapsed(&timer);
// Reset KF flag.
if (layering_mode != 7) {
layer_flags[0] &= ~VPX_EFLAG_FORCE_KF;
}
got_data = 0;
while ( (pkt = vpx_codec_get_cx_data(&codec, &iter)) ) {
got_data = 1;
switch (pkt->kind) {
case VPX_CODEC_CX_FRAME_PKT:
for (i = cfg.ts_layer_id[frame_cnt % cfg.ts_periodicity];
i < cfg.ts_number_layers; ++i) {
vpx_video_writer_write_frame(outfile[i], pkt->data.frame.buf,
pkt->data.frame.sz, pts);
++rc.layer_tot_enc_frames[i];
rc.layer_encoding_bitrate[i] += 8.0 * pkt->data.frame.sz;
// Keep count of rate control stats per layer (for non-key frames).
if (i == cfg.ts_layer_id[frame_cnt % cfg.ts_periodicity] &&
!(pkt->data.frame.flags & VPX_FRAME_IS_KEY)) {
rc.layer_avg_frame_size[i] += 8.0 * pkt->data.frame.sz;
rc.layer_avg_rate_mismatch[i] +=
fabs(8.0 * pkt->data.frame.sz - rc.layer_pfb[i]) /
rc.layer_pfb[i];
++rc.layer_enc_frames[i];
}
}
// Update for short-time encoding bitrate states, for moving window
// of size rc->window, shifted by rc->window / 2.
// Ignore first window segment, due to key frame.
if (frame_cnt > rc.window_size) {
sum_bitrate += 0.001 * 8.0 * pkt->data.frame.sz * framerate;
if (frame_cnt % rc.window_size == 0) {
rc.window_count += 1;
rc.avg_st_encoding_bitrate += sum_bitrate / rc.window_size;
rc.variance_st_encoding_bitrate +=
(sum_bitrate / rc.window_size) *
(sum_bitrate / rc.window_size);
sum_bitrate = 0.0;
}
}
// Second shifted window.
if (frame_cnt > rc.window_size + rc.window_size / 2) {
sum_bitrate2 += 0.001 * 8.0 * pkt->data.frame.sz * framerate;
if (frame_cnt > 2 * rc.window_size &&
frame_cnt % rc.window_size == 0) {
rc.window_count += 1;
rc.avg_st_encoding_bitrate += sum_bitrate2 / rc.window_size;
rc.variance_st_encoding_bitrate +=
(sum_bitrate2 / rc.window_size) *
(sum_bitrate2 / rc.window_size);
sum_bitrate2 = 0.0;
}
}
break;
default:
break;
}
}
++frame_cnt;
pts += frame_duration;
}
fclose(infile);
printout_rate_control_summary(&rc, &cfg, frame_cnt);
printf("\n");
printf("Frame cnt and encoding time/FPS stats for encoding: %d %f %f \n",
frame_cnt,
1000 * (float)cx_time / (double)(frame_cnt * 1000000),
1000000 * (double)frame_cnt / (double)cx_time);
if (vpx_codec_destroy(&codec))
die_codec(&codec, "Failed to destroy codec");
// Try to rewrite the output file headers with the actual frame count.
for (i = 0; i < cfg.ts_number_layers; ++i)
vpx_video_writer_close(outfile[i]);
vpx_img_free(&raw);
return EXIT_SUCCESS;
}

View File

@@ -36,7 +36,7 @@ DOXYFILE_ENCODING = UTF-8
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded # The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project. # by quotes) that should identify the project.
PROJECT_NAME = "WebM Codec SDK" PROJECT_NAME = "WebM VP8 Codec SDK"
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put. # base path where the generated documentation will be put.

80
libs.mk
View File

@@ -17,6 +17,32 @@ else
ASM:=.asm ASM:=.asm
endif endif
#
# Calculate platform- and compiler-specific offsets for hand coded assembly
#
ifeq ($(filter icc gcc,$(TGT_CC)), $(TGT_CC))
OFFSET_PATTERN:='^[a-zA-Z0-9_]* EQU'
define asm_offsets_template
$$(BUILD_PFX)$(1): $$(BUILD_PFX)$(2).S
@echo " [CREATE] $$@"
$$(qexec)LC_ALL=C grep $$(OFFSET_PATTERN) $$< | tr -d '$$$$\#' $$(ADS2GAS) > $$@
$$(BUILD_PFX)$(2).S: $(2)
CLEAN-OBJS += $$(BUILD_PFX)$(1) $(2).S
endef
else
ifeq ($(filter rvct,$(TGT_CC)), $(TGT_CC))
define asm_offsets_template
$$(BUILD_PFX)$(1): obj_int_extract
$$(BUILD_PFX)$(1): $$(BUILD_PFX)$(2).o
@echo " [CREATE] $$@"
$$(qexec)./obj_int_extract rvds $$< $$(ADS2GAS) > $$@
OBJS-yes += $$(BUILD_PFX)$(2).o
CLEAN-OBJS += $$(BUILD_PFX)$(1)
$$(filter %$$(ASM).o,$$(OBJS-yes)): $$(BUILD_PFX)$(1)
endef
endif # rvct
endif # !gcc
# #
# Rule to generate runtime cpu detection files # Rule to generate runtime cpu detection files
# #
@@ -89,7 +115,6 @@ ifeq ($(CONFIG_VP9_ENCODER),yes)
CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS)) CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS))
CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h
INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
INSTALL-LIBS-$(CONFIG_SPATIAL_SVC) += include/vpx/svc_context.h
INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/% INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
CODEC_DOC_SECTIONS += vp9 vp9_encoder CODEC_DOC_SECTIONS += vp9 vp9_encoder
@@ -179,13 +204,33 @@ INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
# based build systems. # based build systems.
libvpx_srcs.txt: libvpx_srcs.txt:
@echo " [CREATE] $@" @echo " [CREATE] $@"
@echo $(CODEC_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@ @echo $(CODEC_SRCS) | xargs -n1 echo | sort -u > $@
CLEAN-OBJS += libvpx_srcs.txt CLEAN-OBJS += libvpx_srcs.txt
ifeq ($(CONFIG_EXTERNAL_BUILD),yes) ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
ifeq ($(CONFIG_MSVS),yes) ifeq ($(CONFIG_MSVS),yes)
obj_int_extract.bat: $(SRC_PATH_BARE)/build/$(MSVS_ARCH_DIR)/obj_int_extract.bat
@cp $^ $@
obj_int_extract.$(VCPROJ_SFX): obj_int_extract.bat
obj_int_extract.$(VCPROJ_SFX): $(SRC_PATH_BARE)/build/make/obj_int_extract.c
@echo " [CREATE] $@"
$(qexec)$(GEN_VCPROJ) \
--exe \
--target=$(TOOLCHAIN) \
--name=obj_int_extract \
--ver=$(CONFIG_VS_VERSION) \
--proj-guid=E1360C65-D375-4335-8057-7ED99CC3F9B2 \
--src-path-bare="$(SRC_PATH_BARE)" \
$(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
--out=$@ $^ \
-I. \
-I"$(SRC_PATH_BARE)" \
PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.$(VCPROJ_SFX)
vpx.def: $(call enabled,CODEC_EXPORTS) vpx.def: $(call enabled,CODEC_EXPORTS)
@echo " [CREATE] $@" @echo " [CREATE] $@"
$(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\ $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
@@ -200,7 +245,7 @@ ASM_INCLUDES := \
vpx_config.asm \ vpx_config.asm \
vpx_ports/x86_abi_support.asm \ vpx_ports/x86_abi_support.asm \
vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def obj_int_extract.$(VCPROJ_SFX)
@echo " [CREATE] $@" @echo " [CREATE] $@"
$(qexec)$(GEN_VCPROJ) \ $(qexec)$(GEN_VCPROJ) \
$(if $(CONFIG_SHARED),--dll,--lib) \ $(if $(CONFIG_SHARED),--dll,--lib) \
@@ -230,27 +275,25 @@ $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED)) BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
SO_VERSION_MAJOR := 2
SO_VERSION_MINOR := 0
SO_VERSION_PATCH := 0
ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS)) ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib LIBVPX_SO := libvpx.$(VERSION_MAJOR).dylib
EXPORT_FILE := libvpx.syms EXPORT_FILE := libvpx.syms
LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \ LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
libvpx.dylib ) libvpx.dylib )
else else
LIBVPX_SO := libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH) LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
EXPORT_FILE := libvpx.ver EXPORT_FILE := libvpx.ver
SYM_LINK := libvpx.so
LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \ LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
libvpx.so libvpx.so.$(SO_VERSION_MAJOR) \ libvpx.so libvpx.so.$(VERSION_MAJOR) \
libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR)) libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
endif endif
LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\ LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
$(notdir $(LIBVPX_SO_SYMLINKS)) $(notdir $(LIBVPX_SO_SYMLINKS))
$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE) $(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm $(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(SO_VERSION_MAJOR) $(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
$(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE) $(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
libvpx.ver: $(call enabled,CODEC_EXPORTS) libvpx.ver: $(call enabled,CODEC_EXPORTS)
@@ -333,7 +376,7 @@ CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
endif endif
# #
# Add assembler dependencies for configuration. # Add assembler dependencies for configuration and offsets
# #
$(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm $(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
@@ -342,6 +385,12 @@ $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
$(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h) $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
CLEAN-OBJS += $(BUILD_PFX)vpx_version.h CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
#
# Add include path for libwebm sources.
#
ifeq ($(CONFIG_WEBM_IO),yes)
CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/libwebm
endif
## ##
## libvpx test directives ## libvpx test directives
@@ -358,7 +407,7 @@ libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
libvpx_test_srcs.txt: libvpx_test_srcs.txt:
@echo " [CREATE] $@" @echo " [CREATE] $@"
@echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@ @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | sort -u > $@
CLEAN-OBJS += libvpx_test_srcs.txt CLEAN-OBJS += libvpx_test_srcs.txt
$(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1 $(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1
@@ -415,6 +464,7 @@ test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_
$(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
--out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \ --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
-I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \ -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
$(if $(CONFIG_WEBM_IO),-I"$(SRC_PATH_BARE)/third_party/libwebm") \
-L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^ -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX) PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX)
@@ -491,11 +541,7 @@ libs.doxy: $(CODEC_DOC_SRCS)
@echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@ @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
## Generate rtcd.h for all objects ## Generate rtcd.h for all objects
ifeq ($(CONFIG_DEPENDENCY_TRACKING),yes)
$(OBJS-yes:.o=.d): $(RTCD) $(OBJS-yes:.o=.d): $(RTCD)
else
$(OBJS-yes): $(RTCD)
endif
## Update the global src list ## Update the global src list
SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS) SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)

View File

@@ -1,4 +1,4 @@
/*!\mainpage WebM Codec SDK /*!\mainpage WebM VP8 Codec SDK
\section main_contents Page Contents \section main_contents Page Contents
- \ref main_intro - \ref main_intro
@@ -6,11 +6,11 @@
- \ref main_support - \ref main_support
\section main_intro Introduction \section main_intro Introduction
Welcome to the WebM Codec SDK. This SDK allows you to integrate your Welcome to the WebM VP8 Codec SDK. This SDK allows you to integrate your
applications with the VP8 and VP9 video codecs, high quality, royalty free, applications with the VP8 video codec, a high quality, royalty free, open
open source codecs deployed on billions of computers and devices worldwide. source codec deployed on millions of computers and devices worldwide.
This distribution of the WebM Codec SDK includes the following support: This distribution of the WebM VP8 Codec SDK includes the following support:
\if vp8_encoder \if vp8_encoder
- \ref vp8_encoder - \ref vp8_encoder
@@ -28,12 +28,12 @@
- Read the \ref samples "sample code" for examples of how to interact with the - Read the \ref samples "sample code" for examples of how to interact with the
codec. codec.
- \ref codec reference - \ref codec reference
\if encoder \if encoder
- \ref encoder reference - \ref encoder reference
\endif \endif
\if decoder \if decoder
- \ref decoder reference - \ref decoder reference
\endif \endif
\section main_support Support Options & FAQ \section main_support Support Options & FAQ
The WebM project is an open source project supported by its community. For The WebM project is an open source project supported by its community. For

View File

@@ -9,7 +9,7 @@
## ##
# libvpx reverse dependencies (targets that depend on libvpx) # libvpx reverse dependencies (targets that depend on libvpx)
VPX_NONDEPS=$(addsuffix .$(VCPROJ_SFX),vpx gtest) VPX_NONDEPS=$(addsuffix .$(VCPROJ_SFX),vpx gtest obj_int_extract)
VPX_RDEPS=$(foreach vcp,\ VPX_RDEPS=$(foreach vcp,\
$(filter-out $(VPX_NONDEPS),$^), --dep=$(vcp:.$(VCPROJ_SFX)=):vpx) $(filter-out $(VPX_NONDEPS),$^), --dep=$(vcp:.$(VCPROJ_SFX)=):vpx)
@@ -17,6 +17,7 @@ vpx.sln: $(wildcard *.$(VCPROJ_SFX))
@echo " [CREATE] $@" @echo " [CREATE] $@"
$(SRC_PATH_BARE)/build/make/gen_msvs_sln.sh \ $(SRC_PATH_BARE)/build/make/gen_msvs_sln.sh \
$(if $(filter vpx.$(VCPROJ_SFX),$^),$(VPX_RDEPS)) \ $(if $(filter vpx.$(VCPROJ_SFX),$^),$(VPX_RDEPS)) \
--dep=vpx:obj_int_extract \
--dep=test_libvpx:gtest \ --dep=test_libvpx:gtest \
--ver=$(CONFIG_VS_VERSION)\ --ver=$(CONFIG_VS_VERSION)\
--out=$@ $^ --out=$@ $^

View File

@@ -29,14 +29,14 @@ class ACMRandom {
uint16_t Rand16(void) { uint16_t Rand16(void) {
const uint32_t value = const uint32_t value =
random_.Generate(testing::internal::Random::kMaxRange); random_.Generate(testing::internal::Random::kMaxRange);
return (value >> 15) & 0xffff; return (value >> 16) & 0xffff;
} }
uint8_t Rand8(void) { uint8_t Rand8(void) {
const uint32_t value = const uint32_t value =
random_.Generate(testing::internal::Random::kMaxRange); random_.Generate(testing::internal::Random::kMaxRange);
// There's a bit more entropy in the upper bits of this implementation. // There's a bit more entropy in the upper bits of this implementation.
return (value >> 23) & 0xff; return (value >> 24) & 0xff;
} }
uint8_t Rand8Extremes(void) { uint8_t Rand8Extremes(void) {

View File

@@ -40,13 +40,7 @@ include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm LOCAL_ARM_MODE := arm
LOCAL_MODULE := libvpx_test LOCAL_MODULE := libvpx_test
LOCAL_STATIC_LIBRARIES := gtest libwebm LOCAL_STATIC_LIBRARIES := gtest libwebm
LOCAL_SHARED_LIBRARIES := vpx
ifeq ($(ENABLE_SHARED),1)
LOCAL_SHARED_LIBRARIES := vpx
else
LOCAL_STATIC_LIBRARIES += vpx
endif
include $(LOCAL_PATH)/test/test.mk include $(LOCAL_PATH)/test/test.mk
LOCAL_C_INCLUDES := $(BINDINGS_DIR) LOCAL_C_INCLUDES := $(BINDINGS_DIR)
FILTERED_SRC := $(sort $(filter %.cc %.c, $(LIBVPX_TEST_SRCS-yes))) FILTERED_SRC := $(sort $(filter %.cc %.c, $(LIBVPX_TEST_SRCS-yes)))

View File

@@ -1,229 +0,0 @@
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 <string.h>
#include <limits.h>
#include <stdio.h>
#include "./vpx_config.h"
#if CONFIG_VP9_ENCODER
#include "./vp9_rtcd.h"
#endif
#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h"
#include "test/util.h"
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "vpx_mem/vpx_mem.h"
extern "C"
double vp9_get_blockiness(const unsigned char *img1, int img1_pitch,
const unsigned char *img2, int img2_pitch,
int width, int height);
using libvpx_test::ACMRandom;
namespace {
class BlockinessTestBase : public ::testing::Test {
public:
BlockinessTestBase(int width, int height) : width_(width), height_(height) {}
static void SetUpTestCase() {
source_data_ = reinterpret_cast<uint8_t*>(
vpx_memalign(kDataAlignment, kDataBufferSize));
reference_data_ = reinterpret_cast<uint8_t*>(
vpx_memalign(kDataAlignment, kDataBufferSize));
}
static void TearDownTestCase() {
vpx_free(source_data_);
source_data_ = NULL;
vpx_free(reference_data_);
reference_data_ = NULL;
}
virtual void TearDown() {
libvpx_test::ClearSystemState();
}
protected:
// Handle frames up to 640x480
static const int kDataAlignment = 16;
static const int kDataBufferSize = 640*480;
virtual void SetUp() {
source_stride_ = (width_ + 31) & ~31;
reference_stride_ = width_ * 2;
rnd_.Reset(ACMRandom::DeterministicSeed());
}
void FillConstant(uint8_t *data, int stride, uint8_t fill_constant,
int width, int height) {
for (int h = 0; h < height; ++h) {
for (int w = 0; w < width; ++w) {
data[h * stride + w] = fill_constant;
}
}
}
void FillConstant(uint8_t *data, int stride, uint8_t fill_constant) {
FillConstant(data, stride, fill_constant, width_, height_);
}
void FillRandom(uint8_t *data, int stride, int width, int height) {
for (int h = 0; h < height; ++h) {
for (int w = 0; w < width; ++w) {
data[h * stride + w] = rnd_.Rand8();
}
}
}
void FillRandom(uint8_t *data, int stride) {
FillRandom(data, stride, width_, height_);
}
void FillRandomBlocky(uint8_t *data, int stride) {
for (int h = 0; h < height_; h += 4) {
for (int w = 0; w < width_; w += 4) {
FillRandom(data + h * stride + w, stride, 4, 4);
}
}
}
void FillCheckerboard(uint8_t *data, int stride) {
for (int h = 0; h < height_; h += 4) {
for (int w = 0; w < width_; w += 4) {
if (((h/4) ^ (w/4)) & 1)
FillConstant(data + h * stride + w, stride, 255, 4, 4);
else
FillConstant(data + h * stride + w, stride, 0, 4, 4);
}
}
}
void Blur(uint8_t *data, int stride, int taps) {
int sum = 0;
int half_taps = taps / 2;
for (int h = 0; h < height_; ++h) {
for (int w = 0; w < taps; ++w) {
sum += data[w + h * stride];
}
for (int w = taps; w < width_; ++w) {
sum += data[w + h * stride] - data[w - taps + h * stride];
data[w - half_taps + h * stride] = (sum + half_taps) / taps;
}
}
for (int w = 0; w < width_; ++w) {
for (int h = 0; h < taps; ++h) {
sum += data[h + w * stride];
}
for (int h = taps; h < height_; ++h) {
sum += data[w + h * stride] - data[(h - taps) * stride + w];
data[(h - half_taps) * stride + w] = (sum + half_taps) / taps;
}
}
}
int width_, height_;
static uint8_t* source_data_;
int source_stride_;
static uint8_t* reference_data_;
int reference_stride_;
ACMRandom rnd_;
};
#if CONFIG_VP9_ENCODER
typedef std::tr1::tuple<int, int> BlockinessParam;
class BlockinessVP9Test
: public BlockinessTestBase,
public ::testing::WithParamInterface<BlockinessParam> {
public:
BlockinessVP9Test() : BlockinessTestBase(GET_PARAM(0), GET_PARAM(1)) {}
protected:
int CheckBlockiness() {
return vp9_get_blockiness(source_data_, source_stride_,
reference_data_, reference_stride_,
width_, height_);
}
};
#endif // CONFIG_VP9_ENCODER
uint8_t* BlockinessTestBase::source_data_ = NULL;
uint8_t* BlockinessTestBase::reference_data_ = NULL;
#if CONFIG_VP9_ENCODER
TEST_P(BlockinessVP9Test, SourceBlockierThanReference) {
// Source is blockier than reference.
FillRandomBlocky(source_data_, source_stride_);
FillConstant(reference_data_, reference_stride_, 128);
int super_blocky = CheckBlockiness();
EXPECT_EQ(0, super_blocky) << "Blocky source should produce 0 blockiness.";
}
TEST_P(BlockinessVP9Test, ReferenceBlockierThanSource) {
// Source is blockier than reference.
FillConstant(source_data_, source_stride_, 128);
FillRandomBlocky(reference_data_, reference_stride_);
int super_blocky = CheckBlockiness();
EXPECT_GT(super_blocky, 0.0)
<< "Blocky reference should score high for blockiness.";
}
TEST_P(BlockinessVP9Test, BlurringDecreasesBlockiness) {
// Source is blockier than reference.
FillConstant(source_data_, source_stride_, 128);
FillRandomBlocky(reference_data_, reference_stride_);
int super_blocky = CheckBlockiness();
Blur(reference_data_, reference_stride_, 4);
int less_blocky = CheckBlockiness();
EXPECT_GT(super_blocky, less_blocky)
<< "A straight blur should decrease blockiness.";
}
TEST_P(BlockinessVP9Test, WorstCaseBlockiness) {
// Source is blockier than reference.
FillConstant(source_data_, source_stride_, 128);
FillCheckerboard(reference_data_, reference_stride_);
int super_blocky = CheckBlockiness();
Blur(reference_data_, reference_stride_, 4);
int less_blocky = CheckBlockiness();
EXPECT_GT(super_blocky, less_blocky)
<< "A straight blur should decrease blockiness.";
}
#endif // CONFIG_VP9_ENCODER
using std::tr1::make_tuple;
//------------------------------------------------------------------------------
// C functions
#if CONFIG_VP9_ENCODER
const BlockinessParam c_vp9_tests[] = {
make_tuple(320, 240),
make_tuple(318, 242),
make_tuple(318, 238),
};
INSTANTIATE_TEST_CASE_P(C, BlockinessVP9Test, ::testing::ValuesIn(c_vp9_tests));
#endif
} // namespace

View File

@@ -1,189 +0,0 @@
/*
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 <string>
#include "./vpx_config.h"
#include "test/codec_factory.h"
#include "test/decode_test_driver.h"
#include "test/md5_helper.h"
#include "test/util.h"
#if CONFIG_WEBM_IO
#include "test/webm_video_source.h"
#endif
namespace {
const int kLegacyByteAlignment = 0;
const int kLegacyYPlaneByteAlignment = 32;
const int kNumPlanesToCheck = 3;
const char kVP9TestFile[] = "vp90-2-02-size-lf-1920x1080.webm";
const char kVP9Md5File[] = "vp90-2-02-size-lf-1920x1080.webm.md5";
#if CONFIG_WEBM_IO
struct ByteAlignmentTestParam {
int byte_alignment;
vpx_codec_err_t expected_value;
bool decode_remaining;
};
const ByteAlignmentTestParam kBaTestParams[] = {
{kLegacyByteAlignment, VPX_CODEC_OK, true},
{32, VPX_CODEC_OK, true},
{64, VPX_CODEC_OK, true},
{128, VPX_CODEC_OK, true},
{256, VPX_CODEC_OK, true},
{512, VPX_CODEC_OK, true},
{1024, VPX_CODEC_OK, true},
{1, VPX_CODEC_INVALID_PARAM, false},
{-2, VPX_CODEC_INVALID_PARAM, false},
{4, VPX_CODEC_INVALID_PARAM, false},
{16, VPX_CODEC_INVALID_PARAM, false},
{255, VPX_CODEC_INVALID_PARAM, false},
{2048, VPX_CODEC_INVALID_PARAM, false},
};
// Class for testing byte alignment of reference buffers.
class ByteAlignmentTest
: public ::testing::TestWithParam<ByteAlignmentTestParam> {
protected:
ByteAlignmentTest()
: video_(NULL),
decoder_(NULL),
md5_file_(NULL) {}
virtual void SetUp() {
video_ = new libvpx_test::WebMVideoSource(kVP9TestFile);
ASSERT_TRUE(video_ != NULL);
video_->Init();
video_->Begin();
const vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
decoder_ = new libvpx_test::VP9Decoder(cfg, 0);
ASSERT_TRUE(decoder_ != NULL);
OpenMd5File(kVP9Md5File);
}
virtual void TearDown() {
if (md5_file_ != NULL)
fclose(md5_file_);
delete decoder_;
delete video_;
}
void SetByteAlignment(int byte_alignment, vpx_codec_err_t expected_value) {
decoder_->Control(VP9_SET_BYTE_ALIGNMENT, byte_alignment, expected_value);
}
vpx_codec_err_t DecodeOneFrame(int byte_alignment_to_check) {
const vpx_codec_err_t res =
decoder_->DecodeFrame(video_->cxdata(), video_->frame_size());
CheckDecodedFrames(byte_alignment_to_check);
if (res == VPX_CODEC_OK)
video_->Next();
return res;
}
vpx_codec_err_t DecodeRemainingFrames(int byte_alignment_to_check) {
for (; video_->cxdata() != NULL; video_->Next()) {
const vpx_codec_err_t res =
decoder_->DecodeFrame(video_->cxdata(), video_->frame_size());
if (res != VPX_CODEC_OK)
return res;
CheckDecodedFrames(byte_alignment_to_check);
}
return VPX_CODEC_OK;
}
private:
// Check if |data| is aligned to |byte_alignment_to_check|.
// |byte_alignment_to_check| must be a power of 2.
void CheckByteAlignment(const uint8_t *data, int byte_alignment_to_check) {
ASSERT_EQ(0u, reinterpret_cast<size_t>(data) % byte_alignment_to_check);
}
// Iterate through the planes of the decoded frames and check for
// alignment based off |byte_alignment_to_check|.
void CheckDecodedFrames(int byte_alignment_to_check) {
libvpx_test::DxDataIterator dec_iter = decoder_->GetDxData();
const vpx_image_t *img;
// Get decompressed data
while ((img = dec_iter.Next()) != NULL) {
if (byte_alignment_to_check == kLegacyByteAlignment) {
CheckByteAlignment(img->planes[0], kLegacyYPlaneByteAlignment);
} else {
for (int i = 0; i < kNumPlanesToCheck; ++i) {
CheckByteAlignment(img->planes[i], byte_alignment_to_check);
}
}
CheckMd5(*img);
}
}
// TODO(fgalligan): Move the MD5 testing code into another class.
void OpenMd5File(const std::string &md5_file_name_) {
md5_file_ = libvpx_test::OpenTestDataFile(md5_file_name_);
ASSERT_TRUE(md5_file_ != NULL) << "MD5 file open failed. Filename: "
<< md5_file_name_;
}
void CheckMd5(const vpx_image_t &img) {
ASSERT_TRUE(md5_file_ != NULL);
char expected_md5[33];
char junk[128];
// Read correct md5 checksums.
const int res = fscanf(md5_file_, "%s %s", expected_md5, junk);
ASSERT_NE(EOF, res) << "Read md5 data failed";
expected_md5[32] = '\0';
::libvpx_test::MD5 md5_res;
md5_res.Add(&img);
const char *const actual_md5 = md5_res.Get();
// Check md5 match.
ASSERT_STREQ(expected_md5, actual_md5) << "MD5 checksums don't match";
}
libvpx_test::WebMVideoSource *video_;
libvpx_test::VP9Decoder *decoder_;
FILE *md5_file_;
};
TEST_F(ByteAlignmentTest, SwitchByteAlignment) {
const int num_elements = 14;
const int byte_alignments[] = { 0, 32, 64, 128, 256, 512, 1024,
0, 1024, 32, 512, 64, 256, 128 };
for (int i = 0; i < num_elements; ++i) {
SetByteAlignment(byte_alignments[i], VPX_CODEC_OK);
ASSERT_EQ(VPX_CODEC_OK, DecodeOneFrame(byte_alignments[i]));
}
SetByteAlignment(byte_alignments[0], VPX_CODEC_OK);
ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames(byte_alignments[0]));
}
TEST_P(ByteAlignmentTest, TestAlignment) {
const ByteAlignmentTestParam t = GetParam();
SetByteAlignment(t.byte_alignment, t.expected_value);
if (t.decode_remaining)
ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames(t.byte_alignment));
}
INSTANTIATE_TEST_CASE_P(Alignments, ByteAlignmentTest,
::testing::ValuesIn(kBaTestParams));
#endif // CONFIG_WEBM_IO
} // namespace

View File

@@ -35,11 +35,6 @@ class CodecFactory {
virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg, virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
unsigned long deadline) const = 0; unsigned long deadline) const = 0;
virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
const vpx_codec_flags_t flags,
unsigned long deadline) // NOLINT(runtime/int)
const = 0;
virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg, virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
unsigned long deadline, unsigned long deadline,
const unsigned long init_flags, const unsigned long init_flags,
@@ -77,10 +72,6 @@ class VP8Decoder : public Decoder {
VP8Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline) VP8Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
: Decoder(cfg, deadline) {} : Decoder(cfg, deadline) {}
VP8Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
unsigned long deadline) // NOLINT
: Decoder(cfg, flag, deadline) {}
protected: protected:
virtual vpx_codec_iface_t* CodecInterface() const { virtual vpx_codec_iface_t* CodecInterface() const {
#if CONFIG_VP8_DECODER #if CONFIG_VP8_DECODER
@@ -113,14 +104,8 @@ class VP8CodecFactory : public CodecFactory {
virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg, virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
unsigned long deadline) const { unsigned long deadline) const {
return CreateDecoder(cfg, 0, deadline);
}
virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
const vpx_codec_flags_t flags,
unsigned long deadline) const { // NOLINT
#if CONFIG_VP8_DECODER #if CONFIG_VP8_DECODER
return new VP8Decoder(cfg, flags, deadline); return new VP8Decoder(cfg, deadline);
#else #else
return NULL; return NULL;
#endif #endif
@@ -169,10 +154,6 @@ class VP9Decoder : public Decoder {
VP9Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline) VP9Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
: Decoder(cfg, deadline) {} : Decoder(cfg, deadline) {}
VP9Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
unsigned long deadline) // NOLINT
: Decoder(cfg, flag, deadline) {}
protected: protected:
virtual vpx_codec_iface_t* CodecInterface() const { virtual vpx_codec_iface_t* CodecInterface() const {
#if CONFIG_VP9_DECODER #if CONFIG_VP9_DECODER
@@ -205,14 +186,8 @@ class VP9CodecFactory : public CodecFactory {
virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg, virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
unsigned long deadline) const { unsigned long deadline) const {
return CreateDecoder(cfg, 0, deadline);
}
virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
const vpx_codec_flags_t flags,
unsigned long deadline) const { // NOLINT
#if CONFIG_VP9_DECODER #if CONFIG_VP9_DECODER
return new VP9Decoder(cfg, flags, deadline); return new VP9Decoder(cfg, deadline);
#else #else
return NULL; return NULL;
#endif #endif

View File

@@ -1,224 +0,0 @@
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 <string.h>
#include <limits.h>
#include <stdio.h>
#include "./vpx_config.h"
#if CONFIG_VP9_ENCODER
#include "./vp9_rtcd.h"
#endif
#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h"
#include "test/util.h"
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "vp9/encoder/vp9_ssim.h"
#include "vpx_mem/vpx_mem.h"
extern "C"
double vp9_get_ssim_metrics(uint8_t *img1, int img1_pitch,
uint8_t *img2, int img2_pitch,
int width, int height,
Ssimv *sv2, Metrics *m,
int do_inconsistency);
using libvpx_test::ACMRandom;
namespace {
class ConsistencyTestBase : public ::testing::Test {
public:
ConsistencyTestBase(int width, int height) : width_(width), height_(height) {}
static void SetUpTestCase() {
source_data_[0] = reinterpret_cast<uint8_t*>(
vpx_memalign(kDataAlignment, kDataBufferSize));
reference_data_[0] = reinterpret_cast<uint8_t*>(
vpx_memalign(kDataAlignment, kDataBufferSize));
source_data_[1] = reinterpret_cast<uint8_t*>(
vpx_memalign(kDataAlignment, kDataBufferSize));
reference_data_[1] = reinterpret_cast<uint8_t*>(
vpx_memalign(kDataAlignment, kDataBufferSize));
ssim_array_ = new Ssimv[kDataBufferSize / 16];
}
static void ClearSsim() {
memset(ssim_array_, 0, kDataBufferSize / 16);
}
static void TearDownTestCase() {
vpx_free(source_data_[0]);
source_data_[0] = NULL;
vpx_free(reference_data_[0]);
reference_data_[0] = NULL;
vpx_free(source_data_[1]);
source_data_[1] = NULL;
vpx_free(reference_data_[1]);
reference_data_[1] = NULL;
delete ssim_array_;
}
virtual void TearDown() {
libvpx_test::ClearSystemState();
}
protected:
// Handle frames up to 640x480
static const int kDataAlignment = 16;
static const int kDataBufferSize = 640*480;
virtual void SetUp() {
source_stride_ = (width_ + 31) & ~31;
reference_stride_ = width_ * 2;
rnd_.Reset(ACMRandom::DeterministicSeed());
}
void FillRandom(uint8_t *data, int stride, int width, int height) {
for (int h = 0; h < height; ++h) {
for (int w = 0; w < width; ++w) {
data[h * stride + w] = rnd_.Rand8();
}
}
}
void FillRandom(uint8_t *data, int stride) {
FillRandom(data, stride, width_, height_);
}
void Copy(uint8_t *reference, uint8_t *source) {
memcpy(reference, source, kDataBufferSize);
}
void Blur(uint8_t *data, int stride, int taps) {
int sum = 0;
int half_taps = taps / 2;
for (int h = 0; h < height_; ++h) {
for (int w = 0; w < taps; ++w) {
sum += data[w + h * stride];
}
for (int w = taps; w < width_; ++w) {
sum += data[w + h * stride] - data[w - taps + h * stride];
data[w - half_taps + h * stride] = (sum + half_taps) / taps;
}
}
for (int w = 0; w < width_; ++w) {
for (int h = 0; h < taps; ++h) {
sum += data[h + w * stride];
}
for (int h = taps; h < height_; ++h) {
sum += data[w + h * stride] - data[(h - taps) * stride + w];
data[(h - half_taps) * stride + w] = (sum + half_taps) / taps;
}
}
}
int width_, height_;
static uint8_t* source_data_[2];
int source_stride_;
static uint8_t* reference_data_[2];
int reference_stride_;
static Ssimv *ssim_array_;
Metrics metrics_;
ACMRandom rnd_;
};
#if CONFIG_VP9_ENCODER
typedef std::tr1::tuple<int, int> ConsistencyParam;
class ConsistencyVP9Test
: public ConsistencyTestBase,
public ::testing::WithParamInterface<ConsistencyParam> {
public:
ConsistencyVP9Test() : ConsistencyTestBase(GET_PARAM(0), GET_PARAM(1)) {}
protected:
double CheckConsistency(int frame) {
EXPECT_LT(frame, 2)<< "Frame to check has to be less than 2.";
return
vp9_get_ssim_metrics(source_data_[frame], source_stride_,
reference_data_[frame], reference_stride_,
width_, height_, ssim_array_, &metrics_, 1);
}
};
#endif // CONFIG_VP9_ENCODER
uint8_t* ConsistencyTestBase::source_data_[2] = {NULL, NULL};
uint8_t* ConsistencyTestBase::reference_data_[2] = {NULL, NULL};
Ssimv* ConsistencyTestBase::ssim_array_ = NULL;
#if CONFIG_VP9_ENCODER
TEST_P(ConsistencyVP9Test, ConsistencyIsZero) {
FillRandom(source_data_[0], source_stride_);
Copy(source_data_[1], source_data_[0]);
Copy(reference_data_[0], source_data_[0]);
Blur(reference_data_[0], reference_stride_, 3);
Copy(reference_data_[1], source_data_[0]);
Blur(reference_data_[1], reference_stride_, 3);
double inconsistency = CheckConsistency(1);
inconsistency = CheckConsistency(0);
EXPECT_EQ(inconsistency, 0.0)
<< "Should have 0 inconsistency if they are exactly the same.";
// If sources are not consistent reference frames inconsistency should
// be less than if the source is consistent.
FillRandom(source_data_[0], source_stride_);
FillRandom(source_data_[1], source_stride_);
FillRandom(reference_data_[0], reference_stride_);
FillRandom(reference_data_[1], reference_stride_);
CheckConsistency(0);
inconsistency = CheckConsistency(1);
Copy(source_data_[1], source_data_[0]);
CheckConsistency(0);
double inconsistency2 = CheckConsistency(1);
EXPECT_LT(inconsistency, inconsistency2)
<< "Should have less inconsistency if source itself is inconsistent.";
// Less of a blur should be less inconsistent than more blur coming off a
// a frame with no blur.
ClearSsim();
FillRandom(source_data_[0], source_stride_);
Copy(source_data_[1], source_data_[0]);
Copy(reference_data_[0], source_data_[0]);
Copy(reference_data_[1], source_data_[0]);
Blur(reference_data_[1], reference_stride_, 4);
CheckConsistency(0);
inconsistency = CheckConsistency(1);
ClearSsim();
Copy(reference_data_[1], source_data_[0]);
Blur(reference_data_[1], reference_stride_, 8);
CheckConsistency(0);
inconsistency2 = CheckConsistency(1);
EXPECT_LT(inconsistency, inconsistency2)
<< "Stronger Blur should produce more inconsistency.";
}
#endif // CONFIG_VP9_ENCODER
using std::tr1::make_tuple;
//------------------------------------------------------------------------------
// C functions
#if CONFIG_VP9_ENCODER
const ConsistencyParam c_vp9_tests[] = {
make_tuple(320, 240),
make_tuple(318, 242),
make_tuple(318, 238),
};
INSTANTIATE_TEST_CASE_P(C, ConsistencyVP9Test,
::testing::ValuesIn(c_vp9_tests));
#endif
} // namespace

View File

@@ -10,14 +10,12 @@
#include <string.h> #include <string.h>
#include "test/acm_random.h" #include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h" #include "test/register_state_check.h"
#include "test/util.h" #include "test/util.h"
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
#include "./vpx_config.h" #include "./vpx_config.h"
#include "./vp9_rtcd.h" #include "./vp9_rtcd.h"
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_filter.h" #include "vp9/common/vp9_filter.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "vpx_ports/mem.h" #include "vpx_ports/mem.h"
@@ -33,16 +31,13 @@ typedef void (*ConvolveFunc)(const uint8_t *src, ptrdiff_t src_stride,
int w, int h); int w, int h);
struct ConvolveFunctions { struct ConvolveFunctions {
ConvolveFunctions(ConvolveFunc copy, ConvolveFunc avg, ConvolveFunctions(ConvolveFunc h8, ConvolveFunc h8_avg,
ConvolveFunc h8, ConvolveFunc h8_avg,
ConvolveFunc v8, ConvolveFunc v8_avg, ConvolveFunc v8, ConvolveFunc v8_avg,
ConvolveFunc hv8, ConvolveFunc hv8_avg, ConvolveFunc hv8, ConvolveFunc hv8_avg,
int bd) int bd)
: copy_(copy), avg_(avg), h8_(h8), v8_(v8), hv8_(hv8), h8_avg_(h8_avg), : h8_(h8), v8_(v8), hv8_(hv8), h8_avg_(h8_avg), v8_avg_(v8_avg),
v8_avg_(v8_avg), hv8_avg_(hv8_avg), use_highbd_(bd) {} hv8_avg_(hv8_avg), use_highbd_(bd) {}
ConvolveFunc copy_;
ConvolveFunc avg_;
ConvolveFunc h8_; ConvolveFunc h8_;
ConvolveFunc v8_; ConvolveFunc v8_;
ConvolveFunc hv8_; ConvolveFunc hv8_;
@@ -303,35 +298,25 @@ class ConvolveTest : public ::testing::TestWithParam<ConvolveParam> {
vpx_memalign(kDataAlignment, kInputBufferSize + 1)) + 1; vpx_memalign(kDataAlignment, kInputBufferSize + 1)) + 1;
output_ = reinterpret_cast<uint8_t*>( output_ = reinterpret_cast<uint8_t*>(
vpx_memalign(kDataAlignment, kOutputBufferSize)); vpx_memalign(kDataAlignment, kOutputBufferSize));
output_ref_ = reinterpret_cast<uint8_t*>(
vpx_memalign(kDataAlignment, kOutputBufferSize));
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
input16_ = reinterpret_cast<uint16_t*>( input16_ = reinterpret_cast<uint16_t*>(
vpx_memalign(kDataAlignment, vpx_memalign(kDataAlignment,
(kInputBufferSize + 1) * sizeof(uint16_t))) + 1; (kInputBufferSize + 1) * sizeof(uint16_t))) + 1;
output16_ = reinterpret_cast<uint16_t*>( output16_ = reinterpret_cast<uint16_t*>(
vpx_memalign(kDataAlignment, (kOutputBufferSize) * sizeof(uint16_t))); vpx_memalign(kDataAlignment, (kOutputBufferSize) * sizeof(uint16_t)));
output16_ref_ = reinterpret_cast<uint16_t*>(
vpx_memalign(kDataAlignment, (kOutputBufferSize) * sizeof(uint16_t)));
#endif #endif
} }
virtual void TearDown() { libvpx_test::ClearSystemState(); }
static void TearDownTestCase() { static void TearDownTestCase() {
vpx_free(input_ - 1); vpx_free(input_ - 1);
input_ = NULL; input_ = NULL;
vpx_free(output_); vpx_free(output_);
output_ = NULL; output_ = NULL;
vpx_free(output_ref_);
output_ref_ = NULL;
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
vpx_free(input16_ - 1); vpx_free(input16_ - 1);
input16_ = NULL; input16_ = NULL;
vpx_free(output16_); vpx_free(output16_);
output16_ = NULL; output16_ = NULL;
vpx_free(output16_ref_);
output16_ref_ = NULL;
#endif #endif
} }
@@ -397,13 +382,6 @@ class ConvolveTest : public ::testing::TestWithParam<ConvolveParam> {
#endif #endif
} }
void CopyOutputToRef() {
memcpy(output_ref_, output_, kOutputBufferSize);
#if CONFIG_VP9_HIGHBITDEPTH
memcpy(output16_ref_, output16_, kOutputBufferSize);
#endif
}
void CheckGuardBlocks() { void CheckGuardBlocks() {
for (int i = 0; i < kOutputBufferSize; ++i) { for (int i = 0; i < kOutputBufferSize; ++i) {
if (IsIndexInBorder(i)) if (IsIndexInBorder(i))
@@ -437,19 +415,6 @@ class ConvolveTest : public ::testing::TestWithParam<ConvolveParam> {
#endif #endif
} }
uint8_t *output_ref() const {
#if CONFIG_VP9_HIGHBITDEPTH
if (UUT_->use_highbd_ == 0) {
return output_ref_ + BorderTop() * kOuterBlockSize + BorderLeft();
} else {
return CONVERT_TO_BYTEPTR(output16_ref_ + BorderTop() * kOuterBlockSize +
BorderLeft());
}
#else
return output_ref_ + BorderTop() * kOuterBlockSize + BorderLeft();
#endif
}
uint16_t lookup(uint8_t *list, int index) const { uint16_t lookup(uint8_t *list, int index) const {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (UUT_->use_highbd_ == 0) { if (UUT_->use_highbd_ == 0) {
@@ -528,65 +493,24 @@ class ConvolveTest : public ::testing::TestWithParam<ConvolveParam> {
const ConvolveFunctions* UUT_; const ConvolveFunctions* UUT_;
static uint8_t* input_; static uint8_t* input_;
static uint8_t* output_; static uint8_t* output_;
static uint8_t* output_ref_;
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
static uint16_t* input16_; static uint16_t* input16_;
static uint16_t* output16_; static uint16_t* output16_;
static uint16_t* output16_ref_;
int mask_; int mask_;
#endif #endif
}; };
uint8_t* ConvolveTest::input_ = NULL; uint8_t* ConvolveTest::input_ = NULL;
uint8_t* ConvolveTest::output_ = NULL; uint8_t* ConvolveTest::output_ = NULL;
uint8_t* ConvolveTest::output_ref_ = NULL;
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
uint16_t* ConvolveTest::input16_ = NULL; uint16_t* ConvolveTest::input16_ = NULL;
uint16_t* ConvolveTest::output16_ = NULL; uint16_t* ConvolveTest::output16_ = NULL;
uint16_t* ConvolveTest::output16_ref_ = NULL;
#endif #endif
TEST_P(ConvolveTest, GuardBlocks) { TEST_P(ConvolveTest, GuardBlocks) {
CheckGuardBlocks(); CheckGuardBlocks();
} }
TEST_P(ConvolveTest, Copy) {
uint8_t* const in = input();
uint8_t* const out = output();
ASM_REGISTER_STATE_CHECK(
UUT_->copy_(in, kInputStride, out, kOutputStride, NULL, 0, NULL, 0,
Width(), Height()));
CheckGuardBlocks();
for (int y = 0; y < Height(); ++y)
for (int x = 0; x < Width(); ++x)
ASSERT_EQ(lookup(out, y * kOutputStride + x),
lookup(in, y * kInputStride + x))
<< "(" << x << "," << y << ")";
}
TEST_P(ConvolveTest, Avg) {
uint8_t* const in = input();
uint8_t* const out = output();
uint8_t* const out_ref = output_ref();
CopyOutputToRef();
ASM_REGISTER_STATE_CHECK(
UUT_->avg_(in, kInputStride, out, kOutputStride, NULL, 0, NULL, 0,
Width(), Height()));
CheckGuardBlocks();
for (int y = 0; y < Height(); ++y)
for (int x = 0; x < Width(); ++x)
ASSERT_EQ(lookup(out, y * kOutputStride + x),
ROUND_POWER_OF_TWO(lookup(in, y * kInputStride + x) +
lookup(out_ref, y * kOutputStride + x), 1))
<< "(" << x << "," << y << ")";
}
TEST_P(ConvolveTest, CopyHoriz) { TEST_P(ConvolveTest, CopyHoriz) {
uint8_t* const in = input(); uint8_t* const in = input();
uint8_t* const out = output(); uint8_t* const out = output();
@@ -1264,30 +1188,6 @@ void wrap_convolve8_avg_sse2_12(const uint8_t *src, ptrdiff_t src_stride,
} }
#endif // HAVE_SSE2 && ARCH_X86_64 #endif // HAVE_SSE2 && ARCH_X86_64
void wrap_convolve_copy_c_8(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x,
int filter_x_stride,
const int16_t *filter_y,
int filter_y_stride,
int w, int h) {
vp9_highbd_convolve_copy_c(src, src_stride, dst, dst_stride,
filter_x, filter_x_stride,
filter_y, filter_y_stride, w, h, 8);
}
void wrap_convolve_avg_c_8(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x,
int filter_x_stride,
const int16_t *filter_y,
int filter_y_stride,
int w, int h) {
vp9_highbd_convolve_avg_c(src, src_stride, dst, dst_stride,
filter_x, filter_x_stride,
filter_y, filter_y_stride, w, h, 8);
}
void wrap_convolve8_horiz_c_8(const uint8_t *src, ptrdiff_t src_stride, void wrap_convolve8_horiz_c_8(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride, uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x, const int16_t *filter_x,
@@ -1360,30 +1260,6 @@ void wrap_convolve8_avg_c_8(const uint8_t *src, ptrdiff_t src_stride,
filter_y, filter_y_stride, w, h, 8); filter_y, filter_y_stride, w, h, 8);
} }
void wrap_convolve_copy_c_10(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x,
int filter_x_stride,
const int16_t *filter_y,
int filter_y_stride,
int w, int h) {
vp9_highbd_convolve_copy_c(src, src_stride, dst, dst_stride,
filter_x, filter_x_stride,
filter_y, filter_y_stride, w, h, 10);
}
void wrap_convolve_avg_c_10(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x,
int filter_x_stride,
const int16_t *filter_y,
int filter_y_stride,
int w, int h) {
vp9_highbd_convolve_avg_c(src, src_stride, dst, dst_stride,
filter_x, filter_x_stride,
filter_y, filter_y_stride, w, h, 10);
}
void wrap_convolve8_horiz_c_10(const uint8_t *src, ptrdiff_t src_stride, void wrap_convolve8_horiz_c_10(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride, uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x, const int16_t *filter_x,
@@ -1456,30 +1332,6 @@ void wrap_convolve8_avg_c_10(const uint8_t *src, ptrdiff_t src_stride,
filter_y, filter_y_stride, w, h, 10); filter_y, filter_y_stride, w, h, 10);
} }
void wrap_convolve_copy_c_12(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x,
int filter_x_stride,
const int16_t *filter_y,
int filter_y_stride,
int w, int h) {
vp9_highbd_convolve_copy_c(src, src_stride, dst, dst_stride,
filter_x, filter_x_stride,
filter_y, filter_y_stride, w, h, 12);
}
void wrap_convolve_avg_c_12(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x,
int filter_x_stride,
const int16_t *filter_y,
int filter_y_stride,
int w, int h) {
vp9_highbd_convolve_avg_c(src, src_stride, dst, dst_stride,
filter_x, filter_x_stride,
filter_y, filter_y_stride, w, h, 12);
}
void wrap_convolve8_horiz_c_12(const uint8_t *src, ptrdiff_t src_stride, void wrap_convolve8_horiz_c_12(const uint8_t *src, ptrdiff_t src_stride,
uint8_t *dst, ptrdiff_t dst_stride, uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *filter_x, const int16_t *filter_x,
@@ -1553,7 +1405,6 @@ void wrap_convolve8_avg_c_12(const uint8_t *src, ptrdiff_t src_stride,
} }
const ConvolveFunctions convolve8_c( const ConvolveFunctions convolve8_c(
wrap_convolve_copy_c_8, wrap_convolve_avg_c_8,
wrap_convolve8_horiz_c_8, wrap_convolve8_avg_horiz_c_8, wrap_convolve8_horiz_c_8, wrap_convolve8_avg_horiz_c_8,
wrap_convolve8_vert_c_8, wrap_convolve8_avg_vert_c_8, wrap_convolve8_vert_c_8, wrap_convolve8_avg_vert_c_8,
wrap_convolve8_c_8, wrap_convolve8_avg_c_8, 8); wrap_convolve8_c_8, wrap_convolve8_avg_c_8, 8);
@@ -1572,7 +1423,6 @@ INSTANTIATE_TEST_CASE_P(C_8, ConvolveTest, ::testing::Values(
make_tuple(32, 64, &convolve8_c), make_tuple(32, 64, &convolve8_c),
make_tuple(64, 64, &convolve8_c))); make_tuple(64, 64, &convolve8_c)));
const ConvolveFunctions convolve10_c( const ConvolveFunctions convolve10_c(
wrap_convolve_copy_c_10, wrap_convolve_avg_c_10,
wrap_convolve8_horiz_c_10, wrap_convolve8_avg_horiz_c_10, wrap_convolve8_horiz_c_10, wrap_convolve8_avg_horiz_c_10,
wrap_convolve8_vert_c_10, wrap_convolve8_avg_vert_c_10, wrap_convolve8_vert_c_10, wrap_convolve8_avg_vert_c_10,
wrap_convolve8_c_10, wrap_convolve8_avg_c_10, 10); wrap_convolve8_c_10, wrap_convolve8_avg_c_10, 10);
@@ -1591,7 +1441,6 @@ INSTANTIATE_TEST_CASE_P(C_10, ConvolveTest, ::testing::Values(
make_tuple(32, 64, &convolve10_c), make_tuple(32, 64, &convolve10_c),
make_tuple(64, 64, &convolve10_c))); make_tuple(64, 64, &convolve10_c)));
const ConvolveFunctions convolve12_c( const ConvolveFunctions convolve12_c(
wrap_convolve_copy_c_12, wrap_convolve_avg_c_12,
wrap_convolve8_horiz_c_12, wrap_convolve8_avg_horiz_c_12, wrap_convolve8_horiz_c_12, wrap_convolve8_avg_horiz_c_12,
wrap_convolve8_vert_c_12, wrap_convolve8_avg_vert_c_12, wrap_convolve8_vert_c_12, wrap_convolve8_avg_vert_c_12,
wrap_convolve8_c_12, wrap_convolve8_avg_c_12, 12); wrap_convolve8_c_12, wrap_convolve8_avg_c_12, 12);
@@ -1613,7 +1462,6 @@ INSTANTIATE_TEST_CASE_P(C_12, ConvolveTest, ::testing::Values(
#else #else
const ConvolveFunctions convolve8_c( const ConvolveFunctions convolve8_c(
vp9_convolve_copy_c, vp9_convolve_avg_c,
vp9_convolve8_horiz_c, vp9_convolve8_avg_horiz_c, vp9_convolve8_horiz_c, vp9_convolve8_avg_horiz_c,
vp9_convolve8_vert_c, vp9_convolve8_avg_vert_c, vp9_convolve8_vert_c, vp9_convolve8_avg_vert_c,
vp9_convolve8_c, vp9_convolve8_avg_c, 0); vp9_convolve8_c, vp9_convolve8_avg_c, 0);
@@ -1637,21 +1485,10 @@ INSTANTIATE_TEST_CASE_P(C, ConvolveTest, ::testing::Values(
#if HAVE_SSE2 && ARCH_X86_64 #if HAVE_SSE2 && ARCH_X86_64
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
const ConvolveFunctions convolve8_sse2( const ConvolveFunctions convolve8_sse2(
wrap_convolve_copy_c_8, wrap_convolve_avg_c_8,
wrap_convolve8_horiz_sse2_8, wrap_convolve8_avg_horiz_sse2_8, wrap_convolve8_horiz_sse2_8, wrap_convolve8_avg_horiz_sse2_8,
wrap_convolve8_vert_sse2_8, wrap_convolve8_avg_vert_sse2_8, wrap_convolve8_vert_sse2_8, wrap_convolve8_avg_vert_sse2_8,
wrap_convolve8_sse2_8, wrap_convolve8_avg_sse2_8, 8); wrap_convolve8_sse2_8, wrap_convolve8_avg_sse2_8, 8);
const ConvolveFunctions convolve10_sse2( INSTANTIATE_TEST_CASE_P(SSE2_8, ConvolveTest, ::testing::Values(
wrap_convolve_copy_c_10, wrap_convolve_avg_c_10,
wrap_convolve8_horiz_sse2_10, wrap_convolve8_avg_horiz_sse2_10,
wrap_convolve8_vert_sse2_10, wrap_convolve8_avg_vert_sse2_10,
wrap_convolve8_sse2_10, wrap_convolve8_avg_sse2_10, 10);
const ConvolveFunctions convolve12_sse2(
wrap_convolve_copy_c_12, wrap_convolve_avg_c_12,
wrap_convolve8_horiz_sse2_12, wrap_convolve8_avg_horiz_sse2_12,
wrap_convolve8_vert_sse2_12, wrap_convolve8_avg_vert_sse2_12,
wrap_convolve8_sse2_12, wrap_convolve8_avg_sse2_12, 12);
INSTANTIATE_TEST_CASE_P(SSE2, ConvolveTest, ::testing::Values(
make_tuple(4, 4, &convolve8_sse2), make_tuple(4, 4, &convolve8_sse2),
make_tuple(8, 4, &convolve8_sse2), make_tuple(8, 4, &convolve8_sse2),
make_tuple(4, 8, &convolve8_sse2), make_tuple(4, 8, &convolve8_sse2),
@@ -1664,7 +1501,12 @@ INSTANTIATE_TEST_CASE_P(SSE2, ConvolveTest, ::testing::Values(
make_tuple(32, 32, &convolve8_sse2), make_tuple(32, 32, &convolve8_sse2),
make_tuple(64, 32, &convolve8_sse2), make_tuple(64, 32, &convolve8_sse2),
make_tuple(32, 64, &convolve8_sse2), make_tuple(32, 64, &convolve8_sse2),
make_tuple(64, 64, &convolve8_sse2), make_tuple(64, 64, &convolve8_sse2)));
const ConvolveFunctions convolve10_sse2(
wrap_convolve8_horiz_sse2_10, wrap_convolve8_avg_horiz_sse2_10,
wrap_convolve8_vert_sse2_10, wrap_convolve8_avg_vert_sse2_10,
wrap_convolve8_sse2_10, wrap_convolve8_avg_sse2_10, 10);
INSTANTIATE_TEST_CASE_P(SSE2_10, ConvolveTest, ::testing::Values(
make_tuple(4, 4, &convolve10_sse2), make_tuple(4, 4, &convolve10_sse2),
make_tuple(8, 4, &convolve10_sse2), make_tuple(8, 4, &convolve10_sse2),
make_tuple(4, 8, &convolve10_sse2), make_tuple(4, 8, &convolve10_sse2),
@@ -1677,7 +1519,12 @@ INSTANTIATE_TEST_CASE_P(SSE2, ConvolveTest, ::testing::Values(
make_tuple(32, 32, &convolve10_sse2), make_tuple(32, 32, &convolve10_sse2),
make_tuple(64, 32, &convolve10_sse2), make_tuple(64, 32, &convolve10_sse2),
make_tuple(32, 64, &convolve10_sse2), make_tuple(32, 64, &convolve10_sse2),
make_tuple(64, 64, &convolve10_sse2), make_tuple(64, 64, &convolve10_sse2)));
const ConvolveFunctions convolve12_sse2(
wrap_convolve8_horiz_sse2_12, wrap_convolve8_avg_horiz_sse2_12,
wrap_convolve8_vert_sse2_12, wrap_convolve8_avg_vert_sse2_12,
wrap_convolve8_sse2_12, wrap_convolve8_avg_sse2_12, 12);
INSTANTIATE_TEST_CASE_P(SSE2_12, ConvolveTest, ::testing::Values(
make_tuple(4, 4, &convolve12_sse2), make_tuple(4, 4, &convolve12_sse2),
make_tuple(8, 4, &convolve12_sse2), make_tuple(8, 4, &convolve12_sse2),
make_tuple(4, 8, &convolve12_sse2), make_tuple(4, 8, &convolve12_sse2),
@@ -1693,7 +1540,6 @@ INSTANTIATE_TEST_CASE_P(SSE2, ConvolveTest, ::testing::Values(
make_tuple(64, 64, &convolve12_sse2))); make_tuple(64, 64, &convolve12_sse2)));
#else #else
const ConvolveFunctions convolve8_sse2( const ConvolveFunctions convolve8_sse2(
vp9_convolve_copy_sse2, vp9_convolve_avg_sse2,
vp9_convolve8_horiz_sse2, vp9_convolve8_avg_horiz_sse2, vp9_convolve8_horiz_sse2, vp9_convolve8_avg_horiz_sse2,
vp9_convolve8_vert_sse2, vp9_convolve8_avg_vert_sse2, vp9_convolve8_vert_sse2, vp9_convolve8_avg_vert_sse2,
vp9_convolve8_sse2, vp9_convolve8_avg_sse2, 0); vp9_convolve8_sse2, vp9_convolve8_avg_sse2, 0);
@@ -1717,7 +1563,6 @@ INSTANTIATE_TEST_CASE_P(SSE2, ConvolveTest, ::testing::Values(
#if HAVE_SSSE3 #if HAVE_SSSE3
const ConvolveFunctions convolve8_ssse3( const ConvolveFunctions convolve8_ssse3(
vp9_convolve_copy_c, vp9_convolve_avg_c,
vp9_convolve8_horiz_ssse3, vp9_convolve8_avg_horiz_ssse3, vp9_convolve8_horiz_ssse3, vp9_convolve8_avg_horiz_ssse3,
vp9_convolve8_vert_ssse3, vp9_convolve8_avg_vert_ssse3, vp9_convolve8_vert_ssse3, vp9_convolve8_avg_vert_ssse3,
vp9_convolve8_ssse3, vp9_convolve8_avg_ssse3, 0); vp9_convolve8_ssse3, vp9_convolve8_avg_ssse3, 0);
@@ -1740,7 +1585,6 @@ INSTANTIATE_TEST_CASE_P(SSSE3, ConvolveTest, ::testing::Values(
#if HAVE_AVX2 && HAVE_SSSE3 #if HAVE_AVX2 && HAVE_SSSE3
const ConvolveFunctions convolve8_avx2( const ConvolveFunctions convolve8_avx2(
vp9_convolve_copy_c, vp9_convolve_avg_c,
vp9_convolve8_horiz_avx2, vp9_convolve8_avg_horiz_ssse3, vp9_convolve8_horiz_avx2, vp9_convolve8_avg_horiz_ssse3,
vp9_convolve8_vert_avx2, vp9_convolve8_avg_vert_ssse3, vp9_convolve8_vert_avx2, vp9_convolve8_avg_vert_ssse3,
vp9_convolve8_avx2, vp9_convolve8_avg_ssse3, 0); vp9_convolve8_avx2, vp9_convolve8_avg_ssse3, 0);
@@ -1761,20 +1605,11 @@ INSTANTIATE_TEST_CASE_P(AVX2, ConvolveTest, ::testing::Values(
make_tuple(64, 64, &convolve8_avx2))); make_tuple(64, 64, &convolve8_avx2)));
#endif // HAVE_AVX2 && HAVE_SSSE3 #endif // HAVE_AVX2 && HAVE_SSSE3
#if HAVE_NEON
#if HAVE_NEON_ASM #if HAVE_NEON_ASM
const ConvolveFunctions convolve8_neon( const ConvolveFunctions convolve8_neon(
vp9_convolve_copy_neon, vp9_convolve_avg_neon,
vp9_convolve8_horiz_neon, vp9_convolve8_avg_horiz_neon, vp9_convolve8_horiz_neon, vp9_convolve8_avg_horiz_neon,
vp9_convolve8_vert_neon, vp9_convolve8_avg_vert_neon, vp9_convolve8_vert_neon, vp9_convolve8_avg_vert_neon,
vp9_convolve8_neon, vp9_convolve8_avg_neon, 0); vp9_convolve8_neon, vp9_convolve8_avg_neon, 0);
#else // HAVE_NEON
const ConvolveFunctions convolve8_neon(
vp9_convolve_copy_neon, vp9_convolve_avg_neon,
vp9_convolve8_horiz_neon, vp9_convolve8_avg_horiz_neon,
vp9_convolve8_vert_neon, vp9_convolve8_avg_vert_neon,
vp9_convolve8_neon, vp9_convolve8_avg_neon, 0);
#endif // HAVE_NEON_ASM
INSTANTIATE_TEST_CASE_P(NEON, ConvolveTest, ::testing::Values( INSTANTIATE_TEST_CASE_P(NEON, ConvolveTest, ::testing::Values(
make_tuple(4, 4, &convolve8_neon), make_tuple(4, 4, &convolve8_neon),
@@ -1790,11 +1625,10 @@ INSTANTIATE_TEST_CASE_P(NEON, ConvolveTest, ::testing::Values(
make_tuple(64, 32, &convolve8_neon), make_tuple(64, 32, &convolve8_neon),
make_tuple(32, 64, &convolve8_neon), make_tuple(32, 64, &convolve8_neon),
make_tuple(64, 64, &convolve8_neon))); make_tuple(64, 64, &convolve8_neon)));
#endif // HAVE_NEON #endif
#if HAVE_DSPR2 #if HAVE_DSPR2
const ConvolveFunctions convolve8_dspr2( const ConvolveFunctions convolve8_dspr2(
vp9_convolve_copy_dspr2, vp9_convolve_avg_dspr2,
vp9_convolve8_horiz_dspr2, vp9_convolve8_avg_horiz_dspr2, vp9_convolve8_horiz_dspr2, vp9_convolve8_avg_horiz_dspr2,
vp9_convolve8_vert_dspr2, vp9_convolve8_avg_vert_dspr2, vp9_convolve8_vert_dspr2, vp9_convolve8_avg_vert_dspr2,
vp9_convolve8_dspr2, vp9_convolve8_avg_dspr2, 0); vp9_convolve8_dspr2, vp9_convolve8_avg_dspr2, 0);
@@ -1814,27 +1648,4 @@ INSTANTIATE_TEST_CASE_P(DSPR2, ConvolveTest, ::testing::Values(
make_tuple(32, 64, &convolve8_dspr2), make_tuple(32, 64, &convolve8_dspr2),
make_tuple(64, 64, &convolve8_dspr2))); make_tuple(64, 64, &convolve8_dspr2)));
#endif #endif
#if HAVE_MSA
const ConvolveFunctions convolve8_msa(
vp9_convolve_copy_msa, vp9_convolve_avg_msa,
vp9_convolve8_horiz_msa, vp9_convolve8_avg_horiz_c,
vp9_convolve8_vert_msa, vp9_convolve8_avg_vert_c,
vp9_convolve8_msa, vp9_convolve8_avg_c, 0);
INSTANTIATE_TEST_CASE_P(MSA, ConvolveTest, ::testing::Values(
make_tuple(4, 4, &convolve8_msa),
make_tuple(8, 4, &convolve8_msa),
make_tuple(4, 8, &convolve8_msa),
make_tuple(8, 8, &convolve8_msa),
make_tuple(16, 8, &convolve8_msa),
make_tuple(8, 16, &convolve8_msa),
make_tuple(16, 16, &convolve8_msa),
make_tuple(32, 16, &convolve8_msa),
make_tuple(16, 32, &convolve8_msa),
make_tuple(32, 32, &convolve8_msa),
make_tuple(64, 32, &convolve8_msa),
make_tuple(32, 64, &convolve8_msa),
make_tuple(64, 64, &convolve8_msa)));
#endif // HAVE_MSA
} // namespace } // namespace

View File

@@ -8,30 +8,27 @@
## in the file PATENTS. All contributing project authors may ## in the file PATENTS. All contributing project authors may
## be found in the AUTHORS file in the root of the source tree. ## be found in the AUTHORS file in the root of the source tree.
## ##
## This file tests the libvpx vp8cx_set_ref example. To add new tests to this ## This file tests the libvpx cx_set_ref example. To add new tests to this
## file, do the following: ## file, do the following:
## 1. Write a shell function (this is your test). ## 1. Write a shell function (this is your test).
## 2. Add the function to vp8cx_set_ref_tests (on a new line). ## 2. Add the function to cx_set_ref_tests (on a new line).
## ##
. $(dirname $0)/tools_common.sh . $(dirname $0)/tools_common.sh
# Environment check: $YUV_RAW_INPUT is required. # Environment check: $YUV_RAW_INPUT is required.
vp8cx_set_ref_verify_environment() { cx_set_ref_verify_environment() {
if [ ! -e "${YUV_RAW_INPUT}" ]; then if [ ! -e "${YUV_RAW_INPUT}" ]; then
echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH." echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
return 1 return 1
fi fi
} }
# Runs vp8cx_set_ref and updates the reference frame before encoding frame 90. # Runs cx_set_ref and updates the reference frame before encoding frame 90.
# $1 is the codec name, which vp8cx_set_ref does not support at present: It's # $1 is the codec name.
# currently used only to name the output file.
# TODO(tomfinegan): Pass the codec param once the example is updated to support
# VP9.
vpx_set_ref() { vpx_set_ref() {
local encoder="${LIBVPX_BIN_PATH}/vp8cx_set_ref${VPX_TEST_EXE_SUFFIX}"
local codec="$1" local codec="$1"
local output_file="${VPX_TEST_OUTPUT_DIR}/vp8cx_set_ref_${codec}.ivf" local encoder="${LIBVPX_BIN_PATH}/${codec}cx_set_ref${VPX_TEST_EXE_SUFFIX}"
local output_file="${VPX_TEST_OUTPUT_DIR}/${codec}cx_set_ref_${codec}.ivf"
local ref_frame_num=90 local ref_frame_num=90
if [ ! -x "${encoder}" ]; then if [ ! -x "${encoder}" ]; then
@@ -46,12 +43,18 @@ vpx_set_ref() {
[ -e "${output_file}" ] || return 1 [ -e "${output_file}" ] || return 1
} }
vp8cx_set_ref_vp8() { cx_set_ref_vp8() {
if [ "$(vp8_encode_available)" = "yes" ]; then if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_set_ref vp8 || return 1 vpx_set_ref vp8 || return 1
fi fi
} }
vp8cx_set_ref_tests="vp8cx_set_ref_vp8" cx_set_ref_vp9() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_set_ref vp9 || return 1
fi
}
run_tests vp8cx_set_ref_verify_environment "${vp8cx_set_ref_tests}" cx_set_ref_tests="cx_set_ref_vp8 cx_set_ref_vp9"
run_tests cx_set_ref_verify_environment "${cx_set_ref_tests}"

View File

@@ -38,25 +38,13 @@ class DatarateTestLarge : public ::libvpx_test::EncoderTest,
first_drop_ = 0; first_drop_ = 0;
bits_total_ = 0; bits_total_ = 0;
duration_ = 0.0; duration_ = 0.0;
denoiser_offon_test_ = 0;
denoiser_offon_period_ = -1;
} }
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) { ::libvpx_test::Encoder *encoder) {
if (video->frame() == 0) if (video->frame() == 1) {
encoder->Control(VP8E_SET_NOISE_SENSITIVITY, denoiser_on_);
if (denoiser_offon_test_) {
ASSERT_GT(denoiser_offon_period_, 0)
<< "denoiser_offon_period_ is not positive.";
if ((video->frame() + 1) % denoiser_offon_period_ == 0) {
// Flip denoiser_on_ periodically
denoiser_on_ ^= 1;
}
encoder->Control(VP8E_SET_NOISE_SENSITIVITY, denoiser_on_); encoder->Control(VP8E_SET_NOISE_SENSITIVITY, denoiser_on_);
} }
const vpx_rational_t tb = video->timebase(); const vpx_rational_t tb = video->timebase();
timebase_ = static_cast<double>(tb.num) / tb.den; timebase_ = static_cast<double>(tb.num) / tb.den;
duration_ = 0; duration_ = 0;
@@ -136,8 +124,6 @@ class DatarateTestLarge : public ::libvpx_test::EncoderTest,
double effective_datarate_; double effective_datarate_;
size_t bits_in_last_frame_; size_t bits_in_last_frame_;
int denoiser_on_; int denoiser_on_;
int denoiser_offon_test_;
int denoiser_offon_period_;
}; };
#if CONFIG_TEMPORAL_DENOISING #if CONFIG_TEMPORAL_DENOISING
@@ -169,29 +155,6 @@ TEST_P(DatarateTestLarge, DenoiserLevels) {
<< " The datarate for the file missed the target!"; << " The datarate for the file missed the target!";
} }
} }
// Check basic datarate targeting, for a single bitrate, when denoiser is off
// and on.
TEST_P(DatarateTestLarge, DenoiserOffOn) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_dropframe_thresh = 1;
cfg_.rc_max_quantizer = 56;
cfg_.rc_end_usage = VPX_CBR;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 299);
cfg_.rc_target_bitrate = 300;
ResetModel();
// The denoiser is off by default.
denoiser_on_ = 0;
// Set the offon test flag.
denoiser_offon_test_ = 1;
denoiser_offon_period_ = 100;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
<< " The datarate for the file exceeds the target!";
ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3)
<< " The datarate for the file missed the target!";
}
#endif // CONFIG_TEMPORAL_DENOISING #endif // CONFIG_TEMPORAL_DENOISING
TEST_P(DatarateTestLarge, BasicBufferModel) { TEST_P(DatarateTestLarge, BasicBufferModel) {
@@ -255,491 +218,5 @@ TEST_P(DatarateTestLarge, ChangingDropFrameThresh) {
} }
} }
class DatarateTestVP9Large : public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
public:
DatarateTestVP9Large() : EncoderTest(GET_PARAM(0)) {}
protected:
virtual ~DatarateTestVP9Large() {}
virtual void SetUp() {
InitializeConfig();
SetMode(GET_PARAM(1));
set_cpu_used_ = GET_PARAM(2);
ResetModel();
}
virtual void ResetModel() {
last_pts_ = 0;
bits_in_buffer_model_ = cfg_.rc_target_bitrate * cfg_.rc_buf_initial_sz;
frame_number_ = 0;
tot_frame_number_ = 0;
first_drop_ = 0;
num_drops_ = 0;
// Denoiser is off by default.
denoiser_on_ = 0;
// For testing up to 3 layers.
for (int i = 0; i < 3; ++i) {
bits_total_[i] = 0;
}
denoiser_offon_test_ = 0;
denoiser_offon_period_ = -1;
}
//
// Frame flags and layer id for temporal layers.
//
// For two layers, test pattern is:
// 1 3
// 0 2 .....
// For three layers, test pattern is:
// 1 3 5 7
// 2 6
// 0 4 ....
// LAST is always update on base/layer 0, GOLDEN is updated on layer 1.
// For this 3 layer example, the 2nd enhancement layer (layer 2) does not
// update any reference frames.
int SetFrameFlags(int frame_num, int num_temp_layers) {
int frame_flags = 0;
if (num_temp_layers == 2) {
if (frame_num % 2 == 0) {
// Layer 0: predict from L and ARF, update L.
frame_flags = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF;
} else {
// Layer 1: predict from L, G and ARF, and update G.
frame_flags = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ENTROPY;
}
} else if (num_temp_layers == 3) {
if (frame_num % 4 == 0) {
// Layer 0: predict from L and ARF; update L.
frame_flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF;
} else if ((frame_num - 2) % 4 == 0) {
// Layer 1: predict from L, G, ARF; update G.
frame_flags = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
} else if ((frame_num - 1) % 2 == 0) {
// Layer 2: predict from L, G, ARF; update none.
frame_flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST;
}
}
return frame_flags;
}
int SetLayerId(int frame_num, int num_temp_layers) {
int layer_id = 0;
if (num_temp_layers == 2) {
if (frame_num % 2 == 0) {
layer_id = 0;
} else {
layer_id = 1;
}
} else if (num_temp_layers == 3) {
if (frame_num % 4 == 0) {
layer_id = 0;
} else if ((frame_num - 2) % 4 == 0) {
layer_id = 1;
} else if ((frame_num - 1) % 2 == 0) {
layer_id = 2;
}
}
return layer_id;
}
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) {
if (video->frame() == 0)
encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
if (denoiser_offon_test_) {
ASSERT_GT(denoiser_offon_period_, 0)
<< "denoiser_offon_period_ is not positive.";
if ((video->frame() + 1) % denoiser_offon_period_ == 0) {
// Flip denoiser_on_ periodically
denoiser_on_ ^= 1;
}
}
encoder->Control(VP9E_SET_NOISE_SENSITIVITY, denoiser_on_);
if (cfg_.ts_number_layers > 1) {
if (video->frame() == 0) {
encoder->Control(VP9E_SET_SVC, 1);
}
vpx_svc_layer_id_t layer_id;
#if VPX_ENCODER_ABI_VERSION > (4 + VPX_CODEC_ABI_VERSION)
layer_id.spatial_layer_id = 0;
#endif
frame_flags_ = SetFrameFlags(video->frame(), cfg_.ts_number_layers);
layer_id.temporal_layer_id = SetLayerId(video->frame(),
cfg_.ts_number_layers);
encoder->Control(VP9E_SET_SVC_LAYER_ID, &layer_id);
}
const vpx_rational_t tb = video->timebase();
timebase_ = static_cast<double>(tb.num) / tb.den;
duration_ = 0;
}
virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
// Time since last timestamp = duration.
vpx_codec_pts_t duration = pkt->data.frame.pts - last_pts_;
if (duration > 1) {
// If first drop not set and we have a drop set it to this time.
if (!first_drop_)
first_drop_ = last_pts_ + 1;
// Update the number of frame drops.
num_drops_ += static_cast<int>(duration - 1);
// Update counter for total number of frames (#frames input to encoder).
// Needed for setting the proper layer_id below.
tot_frame_number_ += static_cast<int>(duration - 1);
}
int layer = SetLayerId(tot_frame_number_, cfg_.ts_number_layers);
// Add to the buffer the bits we'd expect from a constant bitrate server.
bits_in_buffer_model_ += static_cast<int64_t>(
duration * timebase_ * cfg_.rc_target_bitrate * 1000);
// Buffer should not go negative.
ASSERT_GE(bits_in_buffer_model_, 0) << "Buffer Underrun at frame "
<< pkt->data.frame.pts;
const size_t frame_size_in_bits = pkt->data.frame.sz * 8;
// Update the total encoded bits. For temporal layers, update the cumulative
// encoded bits per layer.
for (int i = layer; i < static_cast<int>(cfg_.ts_number_layers); ++i) {
bits_total_[i] += frame_size_in_bits;
}
// Update the most recent pts.
last_pts_ = pkt->data.frame.pts;
++frame_number_;
++tot_frame_number_;
}
virtual void EndPassHook(void) {
for (int layer = 0; layer < static_cast<int>(cfg_.ts_number_layers);
++layer) {
duration_ = (last_pts_ + 1) * timebase_;
if (bits_total_[layer]) {
// Effective file datarate:
effective_datarate_[layer] = (bits_total_[layer] / 1000.0) / duration_;
}
}
}
vpx_codec_pts_t last_pts_;
double timebase_;
int frame_number_; // Counter for number of non-dropped/encoded frames.
int tot_frame_number_; // Counter for total number of input frames.
int64_t bits_total_[3];
double duration_;
double effective_datarate_[3];
int set_cpu_used_;
int64_t bits_in_buffer_model_;
vpx_codec_pts_t first_drop_;
int num_drops_;
int denoiser_on_;
int denoiser_offon_test_;
int denoiser_offon_period_;
};
// Check basic rate targeting,
TEST_P(DatarateTestVP9Large, BasicRateTargeting) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_dropframe_thresh = 1;
cfg_.rc_min_quantizer = 0;
cfg_.rc_max_quantizer = 63;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_lag_in_frames = 0;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 140);
for (int i = 150; i < 800; i += 200) {
cfg_.rc_target_bitrate = i;
ResetModel();
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
ASSERT_GE(effective_datarate_[0], cfg_.rc_target_bitrate * 0.85)
<< " The datarate for the file is lower than target by too much!";
ASSERT_LE(effective_datarate_[0], cfg_.rc_target_bitrate * 1.15)
<< " The datarate for the file is greater than target by too much!";
}
}
// Check basic rate targeting,
TEST_P(DatarateTestVP9Large, BasicRateTargeting444) {
::libvpx_test::Y4mVideoSource video("rush_hour_444.y4m", 0, 140);
cfg_.g_profile = 1;
cfg_.g_timebase = video.timebase();
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_dropframe_thresh = 1;
cfg_.rc_min_quantizer = 0;
cfg_.rc_max_quantizer = 63;
cfg_.rc_end_usage = VPX_CBR;
for (int i = 250; i < 900; i += 200) {
cfg_.rc_target_bitrate = i;
ResetModel();
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
ASSERT_GE(static_cast<double>(cfg_.rc_target_bitrate),
effective_datarate_[0] * 0.85)
<< " The datarate for the file exceeds the target by too much!";
ASSERT_LE(static_cast<double>(cfg_.rc_target_bitrate),
effective_datarate_[0] * 1.15)
<< " The datarate for the file missed the target!"
<< cfg_.rc_target_bitrate << " "<< effective_datarate_;
}
}
// Check that (1) the first dropped frame gets earlier and earlier
// as the drop frame threshold is increased, and (2) that the total number of
// frame drops does not decrease as we increase frame drop threshold.
// Use a lower qp-max to force some frame drops.
TEST_P(DatarateTestVP9Large, ChangingDropFrameThresh) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_undershoot_pct = 20;
cfg_.rc_undershoot_pct = 20;
cfg_.rc_dropframe_thresh = 10;
cfg_.rc_min_quantizer = 0;
cfg_.rc_max_quantizer = 50;
cfg_.rc_end_usage = VPX_CBR;
cfg_.rc_target_bitrate = 200;
cfg_.g_lag_in_frames = 0;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 140);
const int kDropFrameThreshTestStep = 30;
vpx_codec_pts_t last_drop = 140;
int last_num_drops = 0;
for (int i = 10; i < 100; i += kDropFrameThreshTestStep) {
cfg_.rc_dropframe_thresh = i;
ResetModel();
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
ASSERT_GE(effective_datarate_[0], cfg_.rc_target_bitrate * 0.85)
<< " The datarate for the file is lower than target by too much!";
ASSERT_LE(effective_datarate_[0], cfg_.rc_target_bitrate * 1.15)
<< " The datarate for the file is greater than target by too much!";
ASSERT_LE(first_drop_, last_drop)
<< " The first dropped frame for drop_thresh " << i
<< " > first dropped frame for drop_thresh "
<< i - kDropFrameThreshTestStep;
ASSERT_GE(num_drops_, last_num_drops * 0.90)
<< " The number of dropped frames for drop_thresh " << i
<< " < number of dropped frames for drop_thresh "
<< i - kDropFrameThreshTestStep;
last_drop = first_drop_;
last_num_drops = num_drops_;
}
}
// Check basic rate targeting for 2 temporal layers.
TEST_P(DatarateTestVP9Large, BasicRateTargeting2TemporalLayers) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_dropframe_thresh = 1;
cfg_.rc_min_quantizer = 0;
cfg_.rc_max_quantizer = 63;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_lag_in_frames = 0;
// 2 Temporal layers, no spatial layers: Framerate decimation (2, 1).
cfg_.ss_number_layers = 1;
cfg_.ts_number_layers = 2;
cfg_.ts_rate_decimator[0] = 2;
cfg_.ts_rate_decimator[1] = 1;
if (deadline_ == VPX_DL_REALTIME)
cfg_.g_error_resilient = 1;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 200);
for (int i = 200; i <= 800; i += 200) {
cfg_.rc_target_bitrate = i;
ResetModel();
// 60-40 bitrate allocation for 2 temporal layers.
cfg_.ts_target_bitrate[0] = 60 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[1] = cfg_.rc_target_bitrate;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
for (int j = 0; j < static_cast<int>(cfg_.ts_number_layers); ++j) {
ASSERT_GE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 0.85)
<< " The datarate for the file is lower than target by too much, "
"for layer: " << j;
ASSERT_LE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 1.15)
<< " The datarate for the file is greater than target by too much, "
"for layer: " << j;
}
}
}
// Check basic rate targeting for 3 temporal layers.
TEST_P(DatarateTestVP9Large, BasicRateTargeting3TemporalLayers) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_dropframe_thresh = 1;
cfg_.rc_min_quantizer = 0;
cfg_.rc_max_quantizer = 63;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_lag_in_frames = 0;
// 3 Temporal layers, no spatial layers: Framerate decimation (4, 2, 1).
cfg_.ss_number_layers = 1;
cfg_.ts_number_layers = 3;
cfg_.ts_rate_decimator[0] = 4;
cfg_.ts_rate_decimator[1] = 2;
cfg_.ts_rate_decimator[2] = 1;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 200);
for (int i = 200; i <= 800; i += 200) {
cfg_.rc_target_bitrate = i;
ResetModel();
// 40-20-40 bitrate allocation for 3 temporal layers.
cfg_.ts_target_bitrate[0] = 40 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[1] = 60 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[2] = cfg_.rc_target_bitrate;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
for (int j = 0; j < static_cast<int>(cfg_.ts_number_layers); ++j) {
// TODO(yaowu): Work out more stable rc control strategy and
// Adjust the thresholds to be tighter than .75.
ASSERT_GE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 0.75)
<< " The datarate for the file is lower than target by too much, "
"for layer: " << j;
// TODO(yaowu): Work out more stable rc control strategy and
// Adjust the thresholds to be tighter than 1.25.
ASSERT_LE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 1.25)
<< " The datarate for the file is greater than target by too much, "
"for layer: " << j;
}
}
}
// Check basic rate targeting for 3 temporal layers, with frame dropping.
// Only for one (low) bitrate with lower max_quantizer, and somewhat higher
// frame drop threshold, to force frame dropping.
TEST_P(DatarateTestVP9Large, BasicRateTargeting3TemporalLayersFrameDropping) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
// Set frame drop threshold and rc_max_quantizer to force some frame drops.
cfg_.rc_dropframe_thresh = 20;
cfg_.rc_max_quantizer = 45;
cfg_.rc_min_quantizer = 0;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_lag_in_frames = 0;
// 3 Temporal layers, no spatial layers: Framerate decimation (4, 2, 1).
cfg_.ss_number_layers = 1;
cfg_.ts_number_layers = 3;
cfg_.ts_rate_decimator[0] = 4;
cfg_.ts_rate_decimator[1] = 2;
cfg_.ts_rate_decimator[2] = 1;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 200);
cfg_.rc_target_bitrate = 200;
ResetModel();
// 40-20-40 bitrate allocation for 3 temporal layers.
cfg_.ts_target_bitrate[0] = 40 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[1] = 60 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[2] = cfg_.rc_target_bitrate;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
for (int j = 0; j < static_cast<int>(cfg_.ts_number_layers); ++j) {
ASSERT_GE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 0.85)
<< " The datarate for the file is lower than target by too much, "
"for layer: " << j;
ASSERT_LE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 1.15)
<< " The datarate for the file is greater than target by too much, "
"for layer: " << j;
// Expect some frame drops in this test: for this 200 frames test,
// expect at least 10% and not more than 60% drops.
ASSERT_GE(num_drops_, 20);
ASSERT_LE(num_drops_, 130);
}
}
#if CONFIG_VP9_TEMPORAL_DENOISING
// Check basic datarate targeting, for a single bitrate, when denoiser is on.
TEST_P(DatarateTestVP9Large, DenoiserLevels) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_dropframe_thresh = 1;
cfg_.rc_min_quantizer = 2;
cfg_.rc_max_quantizer = 56;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_lag_in_frames = 0;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 140);
// For the temporal denoiser (#if CONFIG_VP9_TEMPORAL_DENOISING),
// there is only one denoiser mode: denoiserYonly(which is 1),
// but may add more modes in the future.
cfg_.rc_target_bitrate = 300;
ResetModel();
// Turn on the denoiser.
denoiser_on_ = 1;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
ASSERT_GE(effective_datarate_[0], cfg_.rc_target_bitrate * 0.85)
<< " The datarate for the file is lower than target by too much!";
ASSERT_LE(effective_datarate_[0], cfg_.rc_target_bitrate * 1.15)
<< " The datarate for the file is greater than target by too much!";
}
// Check basic datarate targeting, for a single bitrate, when denoiser is off
// and on.
TEST_P(DatarateTestVP9Large, DenoiserOffOn) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_dropframe_thresh = 1;
cfg_.rc_min_quantizer = 2;
cfg_.rc_max_quantizer = 56;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_lag_in_frames = 0;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 299);
// For the temporal denoiser (#if CONFIG_VP9_TEMPORAL_DENOISING),
// there is only one denoiser mode: denoiserYonly(which is 1),
// but may add more modes in the future.
cfg_.rc_target_bitrate = 300;
ResetModel();
// The denoiser is off by default.
denoiser_on_ = 0;
// Set the offon test flag.
denoiser_offon_test_ = 1;
denoiser_offon_period_ = 100;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
ASSERT_GE(effective_datarate_[0], cfg_.rc_target_bitrate * 0.85)
<< " The datarate for the file is lower than target by too much!";
ASSERT_LE(effective_datarate_[0], cfg_.rc_target_bitrate * 1.15)
<< " The datarate for the file is greater than target by too much!";
}
#endif // CONFIG_VP9_TEMPORAL_DENOISING
VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES); VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES);
VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large,
::testing::Values(::libvpx_test::kOnePassGood,
::libvpx_test::kRealTime),
::testing::Range(2, 7));
} // namespace } // namespace

View File

@@ -338,8 +338,8 @@ void idct16x16_10_add_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
void idct16x16_10_add_12_sse2(const tran_low_t *in, uint8_t *out, int stride) { void idct16x16_10_add_12_sse2(const tran_low_t *in, uint8_t *out, int stride) {
vp9_highbd_idct16x16_10_add_sse2(in, out, stride, 12); vp9_highbd_idct16x16_10_add_sse2(in, out, stride, 12);
} }
#endif // HAVE_SSE2 #endif
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
class Trans16x16TestBase { class Trans16x16TestBase {
public: public:
@@ -502,11 +502,11 @@ class Trans16x16TestBase {
fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_, tx_type_); fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_, tx_type_);
// clear reconstructed pixel buffers // clear reconstructed pixel buffers
memset(dst, 0, kNumCoeffs * sizeof(uint8_t)); vpx_memset(dst, 0, kNumCoeffs * sizeof(uint8_t));
memset(ref, 0, kNumCoeffs * sizeof(uint8_t)); vpx_memset(ref, 0, kNumCoeffs * sizeof(uint8_t));
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
memset(dst16, 0, kNumCoeffs * sizeof(uint16_t)); vpx_memset(dst16, 0, kNumCoeffs * sizeof(uint16_t));
memset(ref16, 0, kNumCoeffs * sizeof(uint16_t)); vpx_memset(ref16, 0, kNumCoeffs * sizeof(uint16_t));
#endif #endif
// quantization with maximum allowed step sizes // quantization with maximum allowed step sizes
@@ -546,7 +546,7 @@ class Trans16x16TestBase {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, kNumCoeffs); DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, kNumCoeffs);
DECLARE_ALIGNED_ARRAY(16, uint16_t, src16, kNumCoeffs); DECLARE_ALIGNED_ARRAY(16, uint16_t, src16, kNumCoeffs);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
for (int i = 0; i < count_test_block; ++i) { for (int i = 0; i < count_test_block; ++i) {
double out_r[kNumCoeffs]; double out_r[kNumCoeffs];
@@ -562,7 +562,7 @@ class Trans16x16TestBase {
src16[j] = rnd.Rand16() & mask_; src16[j] = rnd.Rand16() & mask_;
dst16[j] = rnd.Rand16() & mask_; dst16[j] = rnd.Rand16() & mask_;
in[j] = src16[j] - dst16[j]; in[j] = src16[j] - dst16[j];
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
} }
} }
@@ -576,7 +576,7 @@ class Trans16x16TestBase {
} else { } else {
ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, CONVERT_TO_BYTEPTR(dst16), ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, CONVERT_TO_BYTEPTR(dst16),
16)); 16));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
} }
for (int j = 0; j < kNumCoeffs; ++j) { for (int j = 0; j < kNumCoeffs; ++j) {
@@ -585,7 +585,7 @@ class Trans16x16TestBase {
bit_depth_ == VPX_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j]; bit_depth_ == VPX_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j];
#else #else
const uint32_t diff = dst[j] - src[j]; const uint32_t diff = dst[j] - src[j];
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
const uint32_t error = diff * diff; const uint32_t error = diff * diff;
EXPECT_GE(1u, error) EXPECT_GE(1u, error)
<< "Error: 16x16 IDCT has error " << error << "Error: 16x16 IDCT has error " << error
@@ -593,7 +593,6 @@ class Trans16x16TestBase {
} }
} }
} }
void CompareInvReference(IdctFunc ref_txfm, int thresh) { void CompareInvReference(IdctFunc ref_txfm, int thresh) {
ACMRandom rnd(ACMRandom::DeterministicSeed()); ACMRandom rnd(ACMRandom::DeterministicSeed());
const int count_test_block = 10000; const int count_test_block = 10000;
@@ -605,13 +604,13 @@ class Trans16x16TestBase {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, kNumCoeffs); DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, kNumCoeffs);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref16, kNumCoeffs); DECLARE_ALIGNED_ARRAY(16, uint16_t, ref16, kNumCoeffs);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
for (int i = 0; i < count_test_block; ++i) { for (int i = 0; i < count_test_block; ++i) {
for (int j = 0; j < kNumCoeffs; ++j) { for (int j = 0; j < kNumCoeffs; ++j) {
if (j < eob) { if (j < eob) {
// Random values less than the threshold, either positive or negative // Random values less than the threshold, either positive or negative
coeff[scan[j]] = rnd(thresh) * (1 - 2 * (i % 2)); coeff[scan[j]] = rnd(thresh) * (1-2*(i%2));
} else { } else {
coeff[scan[j]] = 0; coeff[scan[j]] = 0;
} }
@@ -622,7 +621,7 @@ class Trans16x16TestBase {
} else { } else {
dst16[j] = 0; dst16[j] = 0;
ref16[j] = 0; ref16[j] = 0;
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
} }
} }
if (bit_depth_ == VPX_BITS_8) { if (bit_depth_ == VPX_BITS_8) {
@@ -633,7 +632,7 @@ class Trans16x16TestBase {
ref_txfm(coeff, CONVERT_TO_BYTEPTR(ref16), pitch_); ref_txfm(coeff, CONVERT_TO_BYTEPTR(ref16), pitch_);
ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, CONVERT_TO_BYTEPTR(dst16), ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, CONVERT_TO_BYTEPTR(dst16),
pitch_)); pitch_));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
} }
for (int j = 0; j < kNumCoeffs; ++j) { for (int j = 0; j < kNumCoeffs; ++j) {
@@ -642,7 +641,7 @@ class Trans16x16TestBase {
bit_depth_ == VPX_BITS_8 ? dst[j] - ref[j] : dst16[j] - ref16[j]; bit_depth_ == VPX_BITS_8 ? dst[j] - ref[j] : dst16[j] - ref16[j];
#else #else
const uint32_t diff = dst[j] - ref[j]; const uint32_t diff = dst[j] - ref[j];
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
const uint32_t error = diff * diff; const uint32_t error = diff * diff;
EXPECT_EQ(0u, error) EXPECT_EQ(0u, error)
<< "Error: 16x16 IDCT Comparison has error " << error << "Error: 16x16 IDCT Comparison has error " << error
@@ -650,7 +649,6 @@ class Trans16x16TestBase {
} }
} }
} }
int pitch_; int pitch_;
int tx_type_; int tx_type_;
vpx_bit_depth_t bit_depth_; vpx_bit_depth_t bit_depth_;
@@ -798,9 +796,9 @@ class InvTrans16x16DCT
virtual void SetUp() { virtual void SetUp() {
ref_txfm_ = GET_PARAM(0); ref_txfm_ = GET_PARAM(0);
inv_txfm_ = GET_PARAM(1); inv_txfm_ = GET_PARAM(1);
thresh_ = GET_PARAM(2); thresh_ = GET_PARAM(2);
bit_depth_ = GET_PARAM(3); bit_depth_ = GET_PARAM(3);
pitch_ = 16; pitch_ = 16;
mask_ = (1 << bit_depth_) - 1; mask_ = (1 << bit_depth_) - 1;
} }
virtual void TearDown() { libvpx_test::ClearSystemState(); } virtual void TearDown() { libvpx_test::ClearSystemState(); }
@@ -834,7 +832,7 @@ INSTANTIATE_TEST_CASE_P(
C, Trans16x16DCT, C, Trans16x16DCT,
::testing::Values( ::testing::Values(
make_tuple(&vp9_fdct16x16_c, &vp9_idct16x16_256_add_c, 0, VPX_BITS_8))); make_tuple(&vp9_fdct16x16_c, &vp9_idct16x16_256_add_c, 0, VPX_BITS_8)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -860,7 +858,7 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 1, VPX_BITS_8), make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 1, VPX_BITS_8),
make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 2, VPX_BITS_8), make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 2, VPX_BITS_8),
make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 3, VPX_BITS_8))); make_tuple(&vp9_fht16x16_c, &vp9_iht16x16_256_add_c, 3, VPX_BITS_8)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
#if HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -887,7 +885,7 @@ INSTANTIATE_TEST_CASE_P(
VPX_BITS_8), VPX_BITS_8),
make_tuple(&vp9_fht16x16_sse2, &vp9_iht16x16_256_add_sse2, 3, make_tuple(&vp9_fht16x16_sse2, &vp9_iht16x16_256_add_sse2, 3,
VPX_BITS_8))); VPX_BITS_8)));
#endif // HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -932,5 +930,13 @@ INSTANTIATE_TEST_CASE_P(
&idct16x16_10_add_12_sse2, 3167, VPX_BITS_12), &idct16x16_10_add_12_sse2, 3167, VPX_BITS_12),
make_tuple(&idct16x16_12, make_tuple(&idct16x16_12,
&idct16x16_256_add_12_sse2, 3167, VPX_BITS_12))); &idct16x16_256_add_12_sse2, 3167, VPX_BITS_12)));
#endif // HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if HAVE_SSSE3 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P(
SSSE3, Trans16x16DCT,
::testing::Values(
make_tuple(&vp9_fdct16x16_c, &vp9_idct16x16_256_add_ssse3, 0,
VPX_BITS_8)));
#endif
} // namespace } // namespace

View File

@@ -90,7 +90,7 @@ void idct32x32_10(const tran_low_t *in, uint8_t *out, int stride) {
void idct32x32_12(const tran_low_t *in, uint8_t *out, int stride) { void idct32x32_12(const tran_low_t *in, uint8_t *out, int stride) {
vp9_highbd_idct32x32_1024_add_c(in, out, stride, 12); vp9_highbd_idct32x32_1024_add_c(in, out, stride, 12);
} }
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
class Trans32x32Test : public ::testing::TestWithParam<Trans32x32Param> { class Trans32x32Test : public ::testing::TestWithParam<Trans32x32Param> {
public: public:
@@ -335,7 +335,7 @@ INSTANTIATE_TEST_CASE_P(
&vp9_idct32x32_1024_add_c, 0, VPX_BITS_8), &vp9_idct32x32_1024_add_c, 0, VPX_BITS_8),
make_tuple(&vp9_fdct32x32_rd_c, make_tuple(&vp9_fdct32x32_rd_c,
&vp9_idct32x32_1024_add_c, 1, VPX_BITS_8))); &vp9_idct32x32_1024_add_c, 1, VPX_BITS_8)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
#if HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -345,7 +345,7 @@ INSTANTIATE_TEST_CASE_P(
&vp9_idct32x32_1024_add_neon, 0, VPX_BITS_8), &vp9_idct32x32_1024_add_neon, 0, VPX_BITS_8),
make_tuple(&vp9_fdct32x32_rd_c, make_tuple(&vp9_fdct32x32_rd_c,
&vp9_idct32x32_1024_add_neon, 1, VPX_BITS_8))); &vp9_idct32x32_1024_add_neon, 1, VPX_BITS_8)));
#endif // HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -355,7 +355,7 @@ INSTANTIATE_TEST_CASE_P(
&vp9_idct32x32_1024_add_sse2, 0, VPX_BITS_8), &vp9_idct32x32_1024_add_sse2, 0, VPX_BITS_8),
make_tuple(&vp9_fdct32x32_rd_sse2, make_tuple(&vp9_fdct32x32_rd_sse2,
&vp9_idct32x32_1024_add_sse2, 1, VPX_BITS_8))); &vp9_idct32x32_1024_add_sse2, 1, VPX_BITS_8)));
#endif // HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -371,7 +371,7 @@ INSTANTIATE_TEST_CASE_P(
VPX_BITS_8), VPX_BITS_8),
make_tuple(&vp9_fdct32x32_rd_sse2, &vp9_idct32x32_1024_add_c, 1, make_tuple(&vp9_fdct32x32_rd_sse2, &vp9_idct32x32_1024_add_c, 1,
VPX_BITS_8))); VPX_BITS_8)));
#endif // HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -381,5 +381,5 @@ INSTANTIATE_TEST_CASE_P(
&vp9_idct32x32_1024_add_sse2, 0, VPX_BITS_8), &vp9_idct32x32_1024_add_sse2, 0, VPX_BITS_8),
make_tuple(&vp9_fdct32x32_rd_avx2, make_tuple(&vp9_fdct32x32_rd_avx2,
&vp9_idct32x32_1024_add_sse2, 1, VPX_BITS_8))); &vp9_idct32x32_1024_add_sse2, 1, VPX_BITS_8)));
#endif // HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
} // namespace } // namespace

View File

@@ -57,21 +57,6 @@ TEST(DecodeAPI, InvalidParams) {
} }
} }
#if CONFIG_VP8_DECODER
TEST(DecodeAPI, OptionalParams) {
vpx_codec_ctx_t dec;
#if CONFIG_ERROR_CONCEALMENT
EXPECT_EQ(VPX_CODEC_OK, vpx_codec_dec_init(&dec, &vpx_codec_vp8_dx_algo, NULL,
VPX_CODEC_USE_ERROR_CONCEALMENT));
#else
EXPECT_EQ(VPX_CODEC_INCAPABLE,
vpx_codec_dec_init(&dec, &vpx_codec_vp8_dx_algo, NULL,
VPX_CODEC_USE_ERROR_CONCEALMENT));
#endif // CONFIG_ERROR_CONCEALMENT
}
#endif // CONFIG_VP8_DECODER
#if CONFIG_VP9_DECODER #if CONFIG_VP9_DECODER
// Test VP9 codec controls after a decode error to ensure the code doesn't // Test VP9 codec controls after a decode error to ensure the code doesn't
// misbehave. // misbehave.
@@ -80,7 +65,6 @@ void TestVp9Controls(vpx_codec_ctx_t *dec) {
VP8D_GET_LAST_REF_UPDATES, VP8D_GET_LAST_REF_UPDATES,
VP8D_GET_FRAME_CORRUPTED, VP8D_GET_FRAME_CORRUPTED,
VP9D_GET_DISPLAY_SIZE, VP9D_GET_DISPLAY_SIZE,
VP9D_GET_FRAME_SIZE
}; };
int val[2]; int val[2];

View File

@@ -8,17 +8,13 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <string>
#include "test/codec_factory.h" #include "test/codec_factory.h"
#include "test/decode_test_driver.h" #include "test/decode_test_driver.h"
#include "test/encode_test_driver.h"
#include "test/i420_video_source.h"
#include "test/ivf_video_source.h" #include "test/ivf_video_source.h"
#include "test/md5_helper.h" #include "test/md5_helper.h"
#include "test/util.h" #include "test/util.h"
#include "test/webm_video_source.h" #include "test/webm_video_source.h"
#include "vpx_ports/vpx_timer.h" #include "vpx_ports/vpx_timer.h"
#include "./ivfenc.h"
#include "./vpx_version.h" #include "./vpx_version.h"
using std::tr1::make_tuple; using std::tr1::make_tuple;
@@ -28,9 +24,7 @@ namespace {
#define VIDEO_NAME 0 #define VIDEO_NAME 0
#define THREADS 1 #define THREADS 1
const int kMaxPsnr = 100;
const double kUsecsInSec = 1000000.0; const double kUsecsInSec = 1000000.0;
const char kNewEncodeOutputFile[] = "new_encode.ivf";
/* /*
DecodePerfTest takes a tuple of filename + number of threads to decode with DecodePerfTest takes a tuple of filename + number of threads to decode with
@@ -111,163 +105,4 @@ TEST_P(DecodePerfTest, PerfTest) {
INSTANTIATE_TEST_CASE_P(VP9, DecodePerfTest, INSTANTIATE_TEST_CASE_P(VP9, DecodePerfTest,
::testing::ValuesIn(kVP9DecodePerfVectors)); ::testing::ValuesIn(kVP9DecodePerfVectors));
class VP9NewEncodeDecodePerfTest :
public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
protected:
VP9NewEncodeDecodePerfTest()
: EncoderTest(GET_PARAM(0)),
encoding_mode_(GET_PARAM(1)),
speed_(0),
outfile_(0),
out_frames_(0) {
}
virtual ~VP9NewEncodeDecodePerfTest() {}
virtual void SetUp() {
InitializeConfig();
SetMode(encoding_mode_);
cfg_.g_lag_in_frames = 25;
cfg_.rc_min_quantizer = 2;
cfg_.rc_max_quantizer = 56;
cfg_.rc_dropframe_thresh = 0;
cfg_.rc_undershoot_pct = 50;
cfg_.rc_overshoot_pct = 50;
cfg_.rc_buf_sz = 1000;
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 600;
cfg_.rc_resize_allowed = 0;
cfg_.rc_end_usage = VPX_VBR;
}
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) {
if (video->frame() == 1) {
encoder->Control(VP8E_SET_CPUUSED, speed_);
encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 1);
encoder->Control(VP9E_SET_TILE_COLUMNS, 2);
}
}
virtual void BeginPassHook(unsigned int /*pass*/) {
const std::string data_path = getenv("LIBVPX_TEST_DATA_PATH");
const std::string path_to_source = data_path + "/" + kNewEncodeOutputFile;
outfile_ = fopen(path_to_source.c_str(), "wb");
ASSERT_TRUE(outfile_ != NULL);
}
virtual void EndPassHook() {
if (outfile_ != NULL) {
if (!fseek(outfile_, 0, SEEK_SET))
ivf_write_file_header(outfile_, &cfg_, VP9_FOURCC, out_frames_);
fclose(outfile_);
outfile_ = NULL;
}
}
virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
++out_frames_;
// Write initial file header if first frame.
if (pkt->data.frame.pts == 0)
ivf_write_file_header(outfile_, &cfg_, VP9_FOURCC, out_frames_);
// Write frame header and data.
ivf_write_frame_header(outfile_, out_frames_, pkt->data.frame.sz);
ASSERT_EQ(fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz, outfile_),
pkt->data.frame.sz);
}
virtual bool DoDecode() { return false; }
void set_speed(unsigned int speed) {
speed_ = speed;
}
private:
libvpx_test::TestMode encoding_mode_;
uint32_t speed_;
FILE *outfile_;
uint32_t out_frames_;
};
struct EncodePerfTestVideo {
EncodePerfTestVideo(const char *name_, uint32_t width_, uint32_t height_,
uint32_t bitrate_, int frames_)
: name(name_),
width(width_),
height(height_),
bitrate(bitrate_),
frames(frames_) {}
const char *name;
uint32_t width;
uint32_t height;
uint32_t bitrate;
int frames;
};
const EncodePerfTestVideo kVP9EncodePerfTestVectors[] = {
EncodePerfTestVideo("niklas_1280_720_30.yuv", 1280, 720, 600, 470),
};
TEST_P(VP9NewEncodeDecodePerfTest, PerfTest) {
SetUp();
// TODO(JBB): Make this work by going through the set of given files.
const int i = 0;
const vpx_rational timebase = { 33333333, 1000000000 };
cfg_.g_timebase = timebase;
cfg_.rc_target_bitrate = kVP9EncodePerfTestVectors[i].bitrate;
init_flags_ = VPX_CODEC_USE_PSNR;
const char *video_name = kVP9EncodePerfTestVectors[i].name;
libvpx_test::I420VideoSource video(
video_name,
kVP9EncodePerfTestVectors[i].width,
kVP9EncodePerfTestVectors[i].height,
timebase.den, timebase.num, 0,
kVP9EncodePerfTestVectors[i].frames);
set_speed(2);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
const uint32_t threads = 4;
libvpx_test::IVFVideoSource decode_video(kNewEncodeOutputFile);
decode_video.Init();
vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
cfg.threads = threads;
libvpx_test::VP9Decoder decoder(cfg, 0);
vpx_usec_timer t;
vpx_usec_timer_start(&t);
for (decode_video.Begin(); decode_video.cxdata() != NULL;
decode_video.Next()) {
decoder.DecodeFrame(decode_video.cxdata(), decode_video.frame_size());
}
vpx_usec_timer_mark(&t);
const double elapsed_secs =
static_cast<double>(vpx_usec_timer_elapsed(&t)) / kUsecsInSec;
const unsigned decode_frames = decode_video.frame_number();
const double fps = static_cast<double>(decode_frames) / elapsed_secs;
printf("{\n");
printf("\t\"type\" : \"decode_perf_test\",\n");
printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP);
printf("\t\"videoName\" : \"%s\",\n", kNewEncodeOutputFile);
printf("\t\"threadCount\" : %u,\n", threads);
printf("\t\"decodeTimeSecs\" : %f,\n", elapsed_secs);
printf("\t\"totalFrames\" : %u,\n", decode_frames);
printf("\t\"framesPerSecond\" : %f\n", fps);
printf("}\n");
}
VP9_INSTANTIATE_TEST_CASE(
VP9NewEncodeDecodePerfTest, ::testing::Values(::libvpx_test::kTwoPassGood));
} // namespace } // namespace

View File

@@ -65,7 +65,7 @@ void DecoderTest::HandlePeekResult(Decoder *const decoder,
void DecoderTest::RunLoop(CompressedVideoSource *video, void DecoderTest::RunLoop(CompressedVideoSource *video,
const vpx_codec_dec_cfg_t &dec_cfg) { const vpx_codec_dec_cfg_t &dec_cfg) {
Decoder* const decoder = codec_->CreateDecoder(dec_cfg, flags_, 0); Decoder* const decoder = codec_->CreateDecoder(dec_cfg, 0);
ASSERT_TRUE(decoder != NULL); ASSERT_TRUE(decoder != NULL);
bool end_of_file = false; bool end_of_file = false;
@@ -110,12 +110,4 @@ void DecoderTest::RunLoop(CompressedVideoSource *video) {
RunLoop(video, dec_cfg); RunLoop(video, dec_cfg);
} }
void DecoderTest::set_cfg(const vpx_codec_dec_cfg_t &dec_cfg) {
memcpy(&cfg_, &dec_cfg, sizeof(cfg_));
}
void DecoderTest::set_flags(const vpx_codec_flags_t flags) {
flags_ = flags;
}
} // namespace libvpx_test } // namespace libvpx_test

View File

@@ -41,13 +41,7 @@ class DxDataIterator {
class Decoder { class Decoder {
public: public:
Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline) Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
: cfg_(cfg), flags_(0), deadline_(deadline), init_done_(false) { : cfg_(cfg), deadline_(deadline), init_done_(false) {
memset(&decoder_, 0, sizeof(decoder_));
}
Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
unsigned long deadline) // NOLINT
: cfg_(cfg), flags_(flag), deadline_(deadline), init_done_(false) {
memset(&decoder_, 0, sizeof(decoder_)); memset(&decoder_, 0, sizeof(decoder_));
} }
@@ -72,7 +66,9 @@ class Decoder {
} }
void Control(int ctrl_id, int arg) { void Control(int ctrl_id, int arg) {
Control(ctrl_id, arg, VPX_CODEC_OK); InitOnce();
const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
} }
void Control(int ctrl_id, const void *arg) { void Control(int ctrl_id, const void *arg) {
@@ -81,12 +77,6 @@ class Decoder {
ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
} }
void Control(int ctrl_id, int arg, vpx_codec_err_t expected_value) {
InitOnce();
const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
ASSERT_EQ(expected_value, res) << DecodeError();
}
const char* DecodeError() { const char* DecodeError() {
const char *detail = vpx_codec_error_detail(&decoder_); const char *detail = vpx_codec_error_detail(&decoder_);
return detail ? detail : vpx_codec_error(&decoder_); return detail ? detail : vpx_codec_error(&decoder_);
@@ -107,10 +97,6 @@ class Decoder {
bool IsVP8() const; bool IsVP8() const;
vpx_codec_ctx_t * GetDecoder() {
return &decoder_;
}
protected: protected:
virtual vpx_codec_iface_t* CodecInterface() const = 0; virtual vpx_codec_iface_t* CodecInterface() const = 0;
@@ -118,7 +104,7 @@ class Decoder {
if (!init_done_) { if (!init_done_) {
const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_, const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_,
CodecInterface(), CodecInterface(),
&cfg_, flags_); &cfg_, 0);
ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
init_done_ = true; init_done_ = true;
} }
@@ -126,7 +112,6 @@ class Decoder {
vpx_codec_ctx_t decoder_; vpx_codec_ctx_t decoder_;
vpx_codec_dec_cfg_t cfg_; vpx_codec_dec_cfg_t cfg_;
vpx_codec_flags_t flags_;
unsigned int deadline_; unsigned int deadline_;
bool init_done_; bool init_done_;
}; };
@@ -139,9 +124,6 @@ class DecoderTest {
virtual void RunLoop(CompressedVideoSource *video, virtual void RunLoop(CompressedVideoSource *video,
const vpx_codec_dec_cfg_t &dec_cfg); const vpx_codec_dec_cfg_t &dec_cfg);
virtual void set_cfg(const vpx_codec_dec_cfg_t &dec_cfg);
virtual void set_flags(const vpx_codec_flags_t flags);
// Hook to be called before decompressing every frame. // Hook to be called before decompressing every frame.
virtual void PreDecodeFrameHook(const CompressedVideoSource& /*video*/, virtual void PreDecodeFrameHook(const CompressedVideoSource& /*video*/,
Decoder* /*decoder*/) {} Decoder* /*decoder*/) {}
@@ -164,16 +146,11 @@ class DecoderTest {
const vpx_codec_err_t res_peek); const vpx_codec_err_t res_peek);
protected: protected:
explicit DecoderTest(const CodecFactory *codec) explicit DecoderTest(const CodecFactory *codec) : codec_(codec) {}
: codec_(codec),
cfg_(),
flags_(0) {}
virtual ~DecoderTest() {} virtual ~DecoderTest() {}
const CodecFactory *codec_; const CodecFactory *codec_;
vpx_codec_dec_cfg_t cfg_;
vpx_codec_flags_t flags_;
}; };
} // namespace libvpx_test } // namespace libvpx_test

View File

@@ -7,7 +7,6 @@
* in the file PATENTS. All contributing project authors may * in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <string>
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
#include "./vpx_config.h" #include "./vpx_config.h"
#include "./vpx_version.h" #include "./vpx_version.h"
@@ -51,8 +50,7 @@ const EncodePerfTestVideo kVP9EncodePerfTestVectors[] = {
EncodePerfTestVideo("niklas_1280_720_30.yuv", 1280, 720, 600, 470), EncodePerfTestVideo("niklas_1280_720_30.yuv", 1280, 720, 600, 470),
}; };
const int kEncodePerfTestSpeeds[] = { 5, 6, 7, 8 }; const int kEncodePerfTestSpeeds[] = { 5, 6, 7, 12 };
const int kEncodePerfTestThreads[] = { 1, 2, 4 };
#define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0])) #define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
@@ -65,8 +63,7 @@ class VP9EncodePerfTest
min_psnr_(kMaxPsnr), min_psnr_(kMaxPsnr),
nframes_(0), nframes_(0),
encoding_mode_(GET_PARAM(1)), encoding_mode_(GET_PARAM(1)),
speed_(0), speed_(0) {}
threads_(1) {}
virtual ~VP9EncodePerfTest() {} virtual ~VP9EncodePerfTest() {}
@@ -85,18 +82,12 @@ class VP9EncodePerfTest
cfg_.rc_buf_optimal_sz = 600; cfg_.rc_buf_optimal_sz = 600;
cfg_.rc_resize_allowed = 0; cfg_.rc_resize_allowed = 0;
cfg_.rc_end_usage = VPX_CBR; cfg_.rc_end_usage = VPX_CBR;
cfg_.g_error_resilient = 1;
cfg_.g_threads = threads_;
} }
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) { ::libvpx_test::Encoder *encoder) {
if (video->frame() == 0) { if (video->frame() == 1) {
const int log2_tile_columns = 3;
encoder->Control(VP8E_SET_CPUUSED, speed_); encoder->Control(VP8E_SET_CPUUSED, speed_);
encoder->Control(VP9E_SET_TILE_COLUMNS, log2_tile_columns);
encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 1);
encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 0);
} }
} }
@@ -122,77 +113,54 @@ class VP9EncodePerfTest
speed_ = speed; speed_ = speed;
} }
void set_threads(unsigned int threads) {
threads_ = threads;
}
private: private:
double min_psnr_; double min_psnr_;
unsigned int nframes_; unsigned int nframes_;
libvpx_test::TestMode encoding_mode_; libvpx_test::TestMode encoding_mode_;
unsigned speed_; unsigned speed_;
unsigned int threads_;
}; };
TEST_P(VP9EncodePerfTest, PerfTest) { TEST_P(VP9EncodePerfTest, PerfTest) {
for (size_t i = 0; i < NELEMENTS(kVP9EncodePerfTestVectors); ++i) { for (size_t i = 0; i < NELEMENTS(kVP9EncodePerfTestVectors); ++i) {
for (size_t j = 0; j < NELEMENTS(kEncodePerfTestSpeeds); ++j) { for (size_t j = 0; j < NELEMENTS(kEncodePerfTestSpeeds); ++j) {
for (size_t k = 0; k < NELEMENTS(kEncodePerfTestThreads); ++k) { SetUp();
if (kVP9EncodePerfTestVectors[i].width < 512 &&
kEncodePerfTestThreads[k] > 1)
continue;
else if (kVP9EncodePerfTestVectors[i].width < 1024 &&
kEncodePerfTestThreads[k] > 2)
continue;
set_threads(kEncodePerfTestThreads[k]); const vpx_rational timebase = { 33333333, 1000000000 };
SetUp(); cfg_.g_timebase = timebase;
cfg_.rc_target_bitrate = kVP9EncodePerfTestVectors[i].bitrate;
const vpx_rational timebase = { 33333333, 1000000000 }; init_flags_ = VPX_CODEC_USE_PSNR;
cfg_.g_timebase = timebase;
cfg_.rc_target_bitrate = kVP9EncodePerfTestVectors[i].bitrate;
init_flags_ = VPX_CODEC_USE_PSNR; const unsigned frames = kVP9EncodePerfTestVectors[i].frames;
const char *video_name = kVP9EncodePerfTestVectors[i].name;
libvpx_test::I420VideoSource video(
video_name,
kVP9EncodePerfTestVectors[i].width,
kVP9EncodePerfTestVectors[i].height,
timebase.den, timebase.num, 0,
kVP9EncodePerfTestVectors[i].frames);
set_speed(kEncodePerfTestSpeeds[j]);
const unsigned frames = kVP9EncodePerfTestVectors[i].frames; vpx_usec_timer t;
const char *video_name = kVP9EncodePerfTestVectors[i].name; vpx_usec_timer_start(&t);
libvpx_test::I420VideoSource video(
video_name,
kVP9EncodePerfTestVectors[i].width,
kVP9EncodePerfTestVectors[i].height,
timebase.den, timebase.num, 0,
kVP9EncodePerfTestVectors[i].frames);
set_speed(kEncodePerfTestSpeeds[j]);
vpx_usec_timer t; ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
vpx_usec_timer_start(&t);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); vpx_usec_timer_mark(&t);
const double elapsed_secs = vpx_usec_timer_elapsed(&t) / kUsecsInSec;
const double fps = frames / elapsed_secs;
const double minimum_psnr = min_psnr();
vpx_usec_timer_mark(&t); printf("{\n");
const double elapsed_secs = vpx_usec_timer_elapsed(&t) / kUsecsInSec; printf("\t\"type\" : \"encode_perf_test\",\n");
const double fps = frames / elapsed_secs; printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP);
const double minimum_psnr = min_psnr(); printf("\t\"videoName\" : \"%s\",\n", video_name);
std::string display_name(video_name); printf("\t\"encodeTimeSecs\" : %f,\n", elapsed_secs);
if (kEncodePerfTestThreads[k] > 1) { printf("\t\"totalFrames\" : %u,\n", frames);
char thread_count[32]; printf("\t\"framesPerSecond\" : %f,\n", fps);
snprintf(thread_count, sizeof(thread_count), "_t-%d", printf("\t\"minPsnr\" : %f,\n", minimum_psnr);
kEncodePerfTestThreads[k]); printf("\t\"speed\" : %d\n", kEncodePerfTestSpeeds[j]);
display_name += thread_count; printf("}\n");
}
printf("{\n");
printf("\t\"type\" : \"encode_perf_test\",\n");
printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP);
printf("\t\"videoName\" : \"%s\",\n", display_name.c_str());
printf("\t\"encodeTimeSecs\" : %f,\n", elapsed_secs);
printf("\t\"totalFrames\" : %u,\n", frames);
printf("\t\"framesPerSecond\" : %f,\n", fps);
printf("\t\"minPsnr\" : %f,\n", minimum_psnr);
printf("\t\"speed\" : %d,\n", kEncodePerfTestSpeeds[j]);
printf("\t\"threads\" : %d\n", kEncodePerfTestThreads[k]);
printf("}\n");
}
} }
} }
} }

View File

@@ -8,8 +8,6 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <string>
#include "./vpx_config.h" #include "./vpx_config.h"
#include "test/codec_factory.h" #include "test/codec_factory.h"
#include "test/encode_test_driver.h" #include "test/encode_test_driver.h"
@@ -19,38 +17,6 @@
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
namespace libvpx_test { namespace libvpx_test {
void Encoder::InitEncoder(VideoSource *video) {
vpx_codec_err_t res;
const vpx_image_t *img = video->img();
if (video->img() && !encoder_.priv) {
cfg_.g_w = img->d_w;
cfg_.g_h = img->d_h;
cfg_.g_timebase = video->timebase();
cfg_.rc_twopass_stats_in = stats_->buf();
res = vpx_codec_enc_init(&encoder_, CodecInterface(), &cfg_,
init_flags_);
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
#if CONFIG_VP9_ENCODER
if (CodecInterface() == &vpx_codec_vp9_cx_algo) {
// Default to 1 tile column for VP9.
const int log2_tile_columns = 0;
res = vpx_codec_control_(&encoder_, VP9E_SET_TILE_COLUMNS,
log2_tile_columns);
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
} else
#endif
{
#if CONFIG_VP8_ENCODER
ASSERT_EQ(&vpx_codec_vp8_cx_algo, CodecInterface())
<< "Unknown Codec Interface";
#endif
}
}
}
void Encoder::EncodeFrame(VideoSource *video, const unsigned long frame_flags) { void Encoder::EncodeFrame(VideoSource *video, const unsigned long frame_flags) {
if (video->img()) if (video->img())
EncodeFrameInternal(*video, frame_flags); EncodeFrameInternal(*video, frame_flags);
@@ -73,6 +39,17 @@ void Encoder::EncodeFrameInternal(const VideoSource &video,
vpx_codec_err_t res; vpx_codec_err_t res;
const vpx_image_t *img = video.img(); const vpx_image_t *img = video.img();
// Handle first frame initialization
if (!encoder_.priv) {
cfg_.g_w = img->d_w;
cfg_.g_h = img->d_h;
cfg_.g_timebase = video.timebase();
cfg_.rc_twopass_stats_in = stats_->buf();
res = vpx_codec_enc_init(&encoder_, CodecInterface(), &cfg_,
init_flags_);
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
}
// Handle frame resizing // Handle frame resizing
if (cfg_.g_w != img->d_w || cfg_.g_h != img->d_h) { if (cfg_.g_w != img->d_w || cfg_.g_h != img->d_h) {
cfg_.g_w = img->d_w; cfg_.g_w = img->d_w;
@@ -83,7 +60,8 @@ void Encoder::EncodeFrameInternal(const VideoSource &video,
// Encode the frame // Encode the frame
API_REGISTER_STATE_CHECK( API_REGISTER_STATE_CHECK(
res = vpx_codec_encode(&encoder_, img, video.pts(), video.duration(), res = vpx_codec_encode(&encoder_,
video.img(), video.pts(), video.duration(),
frame_flags, deadline_)); frame_flags, deadline_));
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError(); ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
} }
@@ -99,7 +77,6 @@ void Encoder::Flush() {
void EncoderTest::InitializeConfig() { void EncoderTest::InitializeConfig() {
const vpx_codec_err_t res = codec_->DefaultEncoderConfig(&cfg_, 0); const vpx_codec_err_t res = codec_->DefaultEncoderConfig(&cfg_, 0);
dec_cfg_ = vpx_codec_dec_cfg_t();
ASSERT_EQ(VPX_CODEC_OK, res); ASSERT_EQ(VPX_CODEC_OK, res);
} }
@@ -165,6 +142,12 @@ void EncoderTest::MismatchHook(const vpx_image_t* /*img1*/,
void EncoderTest::RunLoop(VideoSource *video) { void EncoderTest::RunLoop(VideoSource *video) {
vpx_codec_dec_cfg_t dec_cfg = vpx_codec_dec_cfg_t(); vpx_codec_dec_cfg_t dec_cfg = vpx_codec_dec_cfg_t();
#if CONFIG_ROW_TILE
// Decode all tiles.
dec_cfg.tile_col = -1;
dec_cfg.tile_row = -1;
#endif // CONFIG_ROW_TILE
stats_.Reset(); stats_.Reset();
ASSERT_TRUE(passes_ == 1 || passes_ == 2); ASSERT_TRUE(passes_ == 1 || passes_ == 2);
@@ -182,18 +165,9 @@ void EncoderTest::RunLoop(VideoSource *video) {
Encoder* const encoder = codec_->CreateEncoder(cfg_, deadline_, init_flags_, Encoder* const encoder = codec_->CreateEncoder(cfg_, deadline_, init_flags_,
&stats_); &stats_);
ASSERT_TRUE(encoder != NULL); ASSERT_TRUE(encoder != NULL);
Decoder* const decoder = codec_->CreateDecoder(dec_cfg, 0);
video->Begin();
encoder->InitEncoder(video);
unsigned long dec_init_flags = 0; // NOLINT
// Use fragment decoder if encoder outputs partitions.
// NOTE: fragment decoder and partition encoder are only supported by VP8.
if (init_flags_ & VPX_CODEC_USE_OUTPUT_PARTITION)
dec_init_flags |= VPX_CODEC_USE_INPUT_FRAGMENTS;
Decoder* const decoder = codec_->CreateDecoder(dec_cfg, dec_init_flags, 0);
bool again; bool again;
for (again = true; again; video->Next()) { for (again = true, video->Begin(); again; video->Next()) {
again = (video->img() != NULL); again = (video->img() != NULL);
PreEncodeFrameHook(video); PreEncodeFrameHook(video);
@@ -233,13 +207,6 @@ void EncoderTest::RunLoop(VideoSource *video) {
} }
} }
// Flush the decoder when there are no more fragments.
if ((init_flags_ & VPX_CODEC_USE_OUTPUT_PARTITION) && has_dxdata) {
const vpx_codec_err_t res_dec = decoder->DecodeFrame(NULL, 0);
if (!HandleDecodeResult(res_dec, *video, decoder))
break;
}
if (has_dxdata && has_cxdata) { if (has_dxdata && has_cxdata) {
const vpx_image_t *img_enc = encoder->GetPreviewFrame(); const vpx_image_t *img_enc = encoder->GetPreviewFrame();
DxDataIterator dec_iter = decoder->GetDxData(); DxDataIterator dec_iter = decoder->GetDxData();

View File

@@ -104,8 +104,6 @@ class Encoder {
return CxDataIterator(&encoder_); return CxDataIterator(&encoder_);
} }
void InitEncoder(VideoSource *video);
const vpx_image_t *GetPreviewFrame() { const vpx_image_t *GetPreviewFrame() {
return vpx_codec_get_preview_frame(&encoder_); return vpx_codec_get_preview_frame(&encoder_);
} }
@@ -128,11 +126,6 @@ class Encoder {
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError(); ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
} }
void Control(int ctrl_id, struct vpx_svc_layer_id *arg) {
const vpx_codec_err_t res = vpx_codec_control_(&encoder_, ctrl_id, arg);
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
}
#if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER
void Control(int ctrl_id, vpx_active_map_t *arg) { void Control(int ctrl_id, vpx_active_map_t *arg) {
const vpx_codec_err_t res = vpx_codec_control_(&encoder_, ctrl_id, arg); const vpx_codec_err_t res = vpx_codec_control_(&encoder_, ctrl_id, arg);
@@ -140,12 +133,6 @@ class Encoder {
} }
#endif #endif
void Config(const vpx_codec_enc_cfg_t *cfg) {
const vpx_codec_err_t res = vpx_codec_enc_config_set(&encoder_, cfg);
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
cfg_ = *cfg;
}
void set_deadline(unsigned long deadline) { void set_deadline(unsigned long deadline) {
deadline_ = deadline; deadline_ = deadline;
} }
@@ -183,10 +170,7 @@ class EncoderTest {
protected: protected:
explicit EncoderTest(const CodecFactory *codec) explicit EncoderTest(const CodecFactory *codec)
: codec_(codec), abort_(false), init_flags_(0), frame_flags_(0), : codec_(codec), abort_(false), init_flags_(0), frame_flags_(0),
last_pts_(0) { last_pts_(0) {}
// Default to 1 thread.
cfg_.g_threads = 1;
}
virtual ~EncoderTest() {} virtual ~EncoderTest() {}
@@ -196,11 +180,6 @@ class EncoderTest {
// Map the TestMode enum to the deadline_ and passes_ variables. // Map the TestMode enum to the deadline_ and passes_ variables.
void SetMode(TestMode mode); void SetMode(TestMode mode);
// Set encoder flag.
void set_init_flags(unsigned long flag) { // NOLINT(runtime/int)
init_flags_ = flag;
}
// Main loop // Main loop
virtual void RunLoop(VideoSource *video); virtual void RunLoop(VideoSource *video);
@@ -254,7 +233,6 @@ class EncoderTest {
bool abort_; bool abort_;
vpx_codec_enc_cfg_t cfg_; vpx_codec_enc_cfg_t cfg_;
vpx_codec_dec_cfg_t dec_cfg_;
unsigned int passes_; unsigned int passes_;
unsigned long deadline_; unsigned long deadline_;
TwopassStatsStore stats_; TwopassStatsStore stats_;

View File

@@ -13,11 +13,11 @@
#include <string> #include <string>
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
#include "test/acm_random.h" #include "test/acm_random.h"
#include "test/clear_system_state.h" #include "test/clear_system_state.h"
#include "test/register_state_check.h" #include "test/register_state_check.h"
#include "test/util.h" #include "test/util.h"
#include "./vpx_config.h" #include "./vpx_config.h"
#include "./vp9_rtcd.h" #include "./vp9_rtcd.h"
#include "vp9/common/vp9_entropy.h" #include "vp9/common/vp9_entropy.h"
@@ -27,16 +27,13 @@ using libvpx_test::ACMRandom;
namespace { namespace {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
const int kNumIterations = 1000; const int number_of_iterations = 1000;
typedef int64_t (*ErrorBlockFunc)(const tran_low_t *coeff, typedef int64_t (*ErrorBlockFunc)(const tran_low_t *coeff,
const tran_low_t *dqcoeff, const tran_low_t *dqcoeff, intptr_t block_size,
intptr_t block_size, int64_t *ssz, int bps);
int64_t *ssz, int bps);
typedef std::tr1::tuple<ErrorBlockFunc, ErrorBlockFunc, vpx_bit_depth_t> typedef std::tr1::tuple<ErrorBlockFunc, ErrorBlockFunc, vpx_bit_depth_t>
ErrorBlockParam; ErrorBlockParam;
class ErrorBlockTest class ErrorBlockTest
: public ::testing::TestWithParam<ErrorBlockParam> { : public ::testing::TestWithParam<ErrorBlockParam> {
public: public:
@@ -66,12 +63,12 @@ TEST_P(ErrorBlockTest, OperationCheck) {
int64_t ret; int64_t ret;
int64_t ref_ssz; int64_t ref_ssz;
int64_t ref_ret; int64_t ref_ret;
for (int i = 0; i < kNumIterations; ++i) { for (int i = 0; i < number_of_iterations; ++i) {
int err_count = 0; int err_count = 0;
block_size = 16 << (i % 9); // All block sizes from 4x4, 8x4 ..64x64 block_size = 16 << (i % 9); // All block sizes from 4x4, 8x4 ..64x64
for (int j = 0; j < block_size; j++) { for (int j = 0; j < block_size; j++) {
coeff[j] = rnd(2 << 20) - (1 << 20); coeff[j] = rnd(2<<20)-(1<<20);
dqcoeff[j] = rnd(2 << 20) - (1 << 20); dqcoeff[j] = rnd(2<<20)-(1<<20);
} }
ref_ret = ref_error_block_op_(coeff, dqcoeff, block_size, &ref_ssz, ref_ret = ref_error_block_op_(coeff, dqcoeff, block_size, &ref_ssz,
bit_depth_); bit_depth_);
@@ -84,8 +81,8 @@ TEST_P(ErrorBlockTest, OperationCheck) {
err_count_total += err_count; err_count_total += err_count;
} }
EXPECT_EQ(0, err_count_total) EXPECT_EQ(0, err_count_total)
<< "Error: Error Block Test, C output doesn't match SSE2 output. " << "Error: Error Block Test, C output doesn't match SSE2 output. "
<< "First failed at test case " << first_failure; << "First failed at test case " << first_failure;
} }
TEST_P(ErrorBlockTest, ExtremeValues) { TEST_P(ErrorBlockTest, ExtremeValues) {
@@ -99,8 +96,8 @@ TEST_P(ErrorBlockTest, ExtremeValues) {
int64_t ret; int64_t ret;
int64_t ref_ssz; int64_t ref_ssz;
int64_t ref_ret; int64_t ref_ret;
int max_val = ((1 << 20) - 1); int max_val = ((1<<20)-1);
for (int i = 0; i < kNumIterations; ++i) { for (int i = 0; i < number_of_iterations; ++i) {
int err_count = 0; int err_count = 0;
int k = (i / 9) % 5; int k = (i / 9) % 5;
@@ -129,22 +126,21 @@ TEST_P(ErrorBlockTest, ExtremeValues) {
err_count_total += err_count; err_count_total += err_count;
} }
EXPECT_EQ(0, err_count_total) EXPECT_EQ(0, err_count_total)
<< "Error: Error Block Test, C output doesn't match SSE2 output. " << "Error: Error Block Test, C output doesn't match SSE2 output. "
<< "First failed at test case " << first_failure; << "First failed at test case " << first_failure;
} }
using std::tr1::make_tuple; using std::tr1::make_tuple;
#if HAVE_SSE2 #if HAVE_SSE2
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, ErrorBlockTest, SSE2_C_COMPARE, ErrorBlockTest,
::testing::Values( ::testing::Values(
make_tuple(&vp9_highbd_block_error_sse2, make_tuple(&vp9_highbd_block_error_sse2,
&vp9_highbd_block_error_c, VPX_BITS_10), &vp9_highbd_block_error_c, VPX_BITS_10),
make_tuple(&vp9_highbd_block_error_sse2, make_tuple(&vp9_highbd_block_error_sse2,
&vp9_highbd_block_error_c, VPX_BITS_12), &vp9_highbd_block_error_c, VPX_BITS_12),
make_tuple(&vp9_highbd_block_error_sse2, make_tuple(&vp9_highbd_block_error_sse2,
&vp9_highbd_block_error_c, VPX_BITS_8))); &vp9_highbd_block_error_c, VPX_BITS_8)));
#endif // HAVE_SSE2 #endif // HAVE_SSE2
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
} // namespace } // namespace

View File

@@ -37,7 +37,6 @@ class ErrorResilienceTestLarge : public ::libvpx_test::EncoderTest,
void Reset() { void Reset() {
error_nframes_ = 0; error_nframes_ = 0;
droppable_nframes_ = 0; droppable_nframes_ = 0;
pattern_switch_ = 0;
} }
virtual void SetUp() { virtual void SetUp() {
@@ -57,77 +56,22 @@ class ErrorResilienceTestLarge : public ::libvpx_test::EncoderTest,
nframes_++; nframes_++;
} }
// virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video) {
// Frame flags and layer id for temporal layers.
// For two layers, test pattern is:
// 1 3
// 0 2 .....
// LAST is updated on base/layer 0, GOLDEN updated on layer 1.
// Non-zero pattern_switch parameter means pattern will switch to
// not using LAST for frame_num >= pattern_switch.
int SetFrameFlags(int frame_num,
int num_temp_layers,
int pattern_switch) {
int frame_flags = 0;
if (num_temp_layers == 2) {
if (frame_num % 2 == 0) {
if (frame_num < pattern_switch || pattern_switch == 0) {
// Layer 0: predict from LAST and ARF, update LAST.
frame_flags = VP8_EFLAG_NO_REF_GF |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF;
} else {
// Layer 0: predict from GF and ARF, update GF.
frame_flags = VP8_EFLAG_NO_REF_LAST |
VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ARF;
}
} else {
if (frame_num < pattern_switch || pattern_switch == 0) {
// Layer 1: predict from L, GF, and ARF, update GF.
frame_flags = VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST;
} else {
// Layer 1: predict from GF and ARF, update GF.
frame_flags = VP8_EFLAG_NO_REF_LAST |
VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ARF;
}
}
}
return frame_flags;
}
virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) {
frame_flags_ &= ~(VP8_EFLAG_NO_UPD_LAST | frame_flags_ &= ~(VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF); VP8_EFLAG_NO_UPD_ARF);
// For temporal layer case. if (droppable_nframes_ > 0 &&
if (cfg_.ts_number_layers > 1) { (cfg_.g_pass == VPX_RC_LAST_PASS || cfg_.g_pass == VPX_RC_ONE_PASS)) {
frame_flags_ = SetFrameFlags(video->frame(),
cfg_.ts_number_layers,
pattern_switch_);
for (unsigned int i = 0; i < droppable_nframes_; ++i) { for (unsigned int i = 0; i < droppable_nframes_; ++i) {
if (droppable_frames_[i] == video->frame()) { if (droppable_frames_[i] == video->frame()) {
std::cout << "Encoding droppable frame: " std::cout << " Encoding droppable frame: "
<< droppable_frames_[i] << "\n"; << droppable_frames_[i] << "\n";
frame_flags_ |= (VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF);
return;
} }
} }
} else {
if (droppable_nframes_ > 0 &&
(cfg_.g_pass == VPX_RC_LAST_PASS || cfg_.g_pass == VPX_RC_ONE_PASS)) {
for (unsigned int i = 0; i < droppable_nframes_; ++i) {
if (droppable_frames_[i] == video->frame()) {
std::cout << "Encoding droppable frame: "
<< droppable_frames_[i] << "\n";
frame_flags_ |= (VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF);
return;
}
}
}
} }
} }
@@ -189,16 +133,11 @@ class ErrorResilienceTestLarge : public ::libvpx_test::EncoderTest,
return mismatch_nframes_; return mismatch_nframes_;
} }
void SetPatternSwitch(int frame_switch) {
pattern_switch_ = frame_switch;
}
private: private:
double psnr_; double psnr_;
unsigned int nframes_; unsigned int nframes_;
unsigned int error_nframes_; unsigned int error_nframes_;
unsigned int droppable_nframes_; unsigned int droppable_nframes_;
unsigned int pattern_switch_;
double mismatch_psnr_; double mismatch_psnr_;
unsigned int mismatch_nframes_; unsigned int mismatch_nframes_;
unsigned int error_frames_[kMaxErrorFrames]; unsigned int error_frames_[kMaxErrorFrames];
@@ -297,290 +236,7 @@ TEST_P(ErrorResilienceTestLarge, DropFramesWithoutRecovery) {
#endif #endif
} }
// Check for successful decoding and no encoder/decoder mismatch
// if we lose (i.e., drop before decoding) the enhancement layer frames for a
// two layer temporal pattern. The base layer does not predict from the top
// layer, so successful decoding is expected.
TEST_P(ErrorResilienceTestLarge, 2LayersDropEnhancement) {
const vpx_rational timebase = { 33333333, 1000000000 };
cfg_.g_timebase = timebase;
cfg_.rc_target_bitrate = 500;
cfg_.g_lag_in_frames = 0;
cfg_.rc_end_usage = VPX_CBR;
// 2 Temporal layers, no spatial layers, CBR mode.
cfg_.ss_number_layers = 1;
cfg_.ts_number_layers = 2;
cfg_.ts_rate_decimator[0] = 2;
cfg_.ts_rate_decimator[1] = 1;
cfg_.ts_periodicity = 2;
cfg_.ts_target_bitrate[0] = 60 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[1] = cfg_.rc_target_bitrate;
init_flags_ = VPX_CODEC_USE_PSNR;
libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
timebase.den, timebase.num, 0, 40);
// Error resilient mode ON.
cfg_.g_error_resilient = 1;
cfg_.kf_mode = VPX_KF_DISABLED;
SetPatternSwitch(0);
// The odd frames are the enhancement layer for 2 layer pattern, so set
// those frames as droppable. Drop the last 7 frames.
unsigned int num_droppable_frames = 7;
unsigned int droppable_frame_list[] = {27, 29, 31, 33, 35, 37, 39};
SetDroppableFrames(num_droppable_frames, droppable_frame_list);
SetErrorFrames(num_droppable_frames, droppable_frame_list);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
// Test that no mismatches have been found
std::cout << " Mismatch frames: "
<< GetMismatchFrames() << "\n";
EXPECT_EQ(GetMismatchFrames(), (unsigned int) 0);
// Reset previously set of error/droppable frames.
Reset();
}
// Check for successful decoding and no encoder/decoder mismatch
// for a two layer temporal pattern, where at some point in the
// sequence, the LAST ref is not used anymore.
TEST_P(ErrorResilienceTestLarge, 2LayersNoRefLast) {
const vpx_rational timebase = { 33333333, 1000000000 };
cfg_.g_timebase = timebase;
cfg_.rc_target_bitrate = 500;
cfg_.g_lag_in_frames = 0;
cfg_.rc_end_usage = VPX_CBR;
// 2 Temporal layers, no spatial layers, CBR mode.
cfg_.ss_number_layers = 1;
cfg_.ts_number_layers = 2;
cfg_.ts_rate_decimator[0] = 2;
cfg_.ts_rate_decimator[1] = 1;
cfg_.ts_periodicity = 2;
cfg_.ts_target_bitrate[0] = 60 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[1] = cfg_.rc_target_bitrate;
init_flags_ = VPX_CODEC_USE_PSNR;
libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
timebase.den, timebase.num, 0, 100);
// Error resilient mode ON.
cfg_.g_error_resilient = 1;
cfg_.kf_mode = VPX_KF_DISABLED;
SetPatternSwitch(60);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
// Test that no mismatches have been found
std::cout << " Mismatch frames: "
<< GetMismatchFrames() << "\n";
EXPECT_EQ(GetMismatchFrames(), (unsigned int) 0);
// Reset previously set of error/droppable frames.
Reset();
}
class ErrorResilienceTestLargeCodecControls : public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
protected:
ErrorResilienceTestLargeCodecControls()
: EncoderTest(GET_PARAM(0)),
encoding_mode_(GET_PARAM(1)) {
Reset();
}
virtual ~ErrorResilienceTestLargeCodecControls() {}
void Reset() {
last_pts_ = 0;
tot_frame_number_ = 0;
// For testing up to 3 layers.
for (int i = 0; i < 3; ++i) {
bits_total_[i] = 0;
}
duration_ = 0.0;
}
virtual void SetUp() {
InitializeConfig();
SetMode(encoding_mode_);
}
//
// Frame flags and layer id for temporal layers.
//
// For two layers, test pattern is:
// 1 3
// 0 2 .....
// For three layers, test pattern is:
// 1 3 5 7
// 2 6
// 0 4 ....
// LAST is always update on base/layer 0, GOLDEN is updated on layer 1,
// and ALTREF is updated on top layer for 3 layer pattern.
int SetFrameFlags(int frame_num, int num_temp_layers) {
int frame_flags = 0;
if (num_temp_layers == 2) {
if (frame_num % 2 == 0) {
// Layer 0: predict from L and ARF, update L.
frame_flags = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF;
} else {
// Layer 1: predict from L, G and ARF, and update G.
frame_flags = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ENTROPY;
}
} else if (num_temp_layers == 3) {
if (frame_num % 4 == 0) {
// Layer 0: predict from L, update L.
frame_flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF;
} else if ((frame_num - 2) % 4 == 0) {
// Layer 1: predict from L, G, update G.
frame_flags = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_REF_ARF;
} else if ((frame_num - 1) % 2 == 0) {
// Layer 2: predict from L, G, ARF; update ARG.
frame_flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_LAST;
}
}
return frame_flags;
}
int SetLayerId(int frame_num, int num_temp_layers) {
int layer_id = 0;
if (num_temp_layers == 2) {
if (frame_num % 2 == 0) {
layer_id = 0;
} else {
layer_id = 1;
}
} else if (num_temp_layers == 3) {
if (frame_num % 4 == 0) {
layer_id = 0;
} else if ((frame_num - 2) % 4 == 0) {
layer_id = 1;
} else if ((frame_num - 1) % 2 == 0) {
layer_id = 2;
}
}
return layer_id;
}
virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video,
libvpx_test::Encoder *encoder) {
if (cfg_.ts_number_layers > 1) {
int layer_id = SetLayerId(video->frame(), cfg_.ts_number_layers);
int frame_flags = SetFrameFlags(video->frame(), cfg_.ts_number_layers);
if (video->frame() > 0) {
encoder->Control(VP8E_SET_TEMPORAL_LAYER_ID, layer_id);
encoder->Control(VP8E_SET_FRAME_FLAGS, frame_flags);
}
const vpx_rational_t tb = video->timebase();
timebase_ = static_cast<double>(tb.num) / tb.den;
duration_ = 0;
return;
}
}
virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
// Time since last timestamp = duration.
vpx_codec_pts_t duration = pkt->data.frame.pts - last_pts_;
if (duration > 1) {
// Update counter for total number of frames (#frames input to encoder).
// Needed for setting the proper layer_id below.
tot_frame_number_ += static_cast<int>(duration - 1);
}
int layer = SetLayerId(tot_frame_number_, cfg_.ts_number_layers);
const size_t frame_size_in_bits = pkt->data.frame.sz * 8;
// Update the total encoded bits. For temporal layers, update the cumulative
// encoded bits per layer.
for (int i = layer; i < static_cast<int>(cfg_.ts_number_layers); ++i) {
bits_total_[i] += frame_size_in_bits;
}
// Update the most recent pts.
last_pts_ = pkt->data.frame.pts;
++tot_frame_number_;
}
virtual void EndPassHook(void) {
duration_ = (last_pts_ + 1) * timebase_;
if (cfg_.ts_number_layers > 1) {
for (int layer = 0; layer < static_cast<int>(cfg_.ts_number_layers);
++layer) {
if (bits_total_[layer]) {
// Effective file datarate:
effective_datarate_[layer] = (bits_total_[layer] / 1000.0) / duration_;
}
}
}
}
double effective_datarate_[3];
private:
libvpx_test::TestMode encoding_mode_;
vpx_codec_pts_t last_pts_;
double timebase_;
int64_t bits_total_[3];
double duration_;
int tot_frame_number_;
};
// Check two codec controls used for:
// (1) for setting temporal layer id, and (2) for settings encoder flags.
// This test invokes those controls for each frame, and verifies encoder/decoder
// mismatch and basic rate control response.
// TODO(marpan): Maybe move this test to datarate_test.cc.
TEST_P(ErrorResilienceTestLargeCodecControls, CodecControl3TemporalLayers) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_dropframe_thresh = 1;
cfg_.rc_min_quantizer = 2;
cfg_.rc_max_quantizer = 56;
cfg_.rc_end_usage = VPX_CBR;
cfg_.rc_dropframe_thresh = 1;
cfg_.g_lag_in_frames = 0;
cfg_.kf_mode = VPX_KF_DISABLED;
cfg_.g_error_resilient = 1;
// 3 Temporal layers. Framerate decimation (4, 2, 1).
cfg_.ts_number_layers = 3;
cfg_.ts_rate_decimator[0] = 4;
cfg_.ts_rate_decimator[1] = 2;
cfg_.ts_rate_decimator[2] = 1;
cfg_.ts_periodicity = 4;
cfg_.ts_layer_id[0] = 0;
cfg_.ts_layer_id[1] = 2;
cfg_.ts_layer_id[2] = 1;
cfg_.ts_layer_id[3] = 2;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 200);
for (int i = 200; i <= 800; i += 200) {
cfg_.rc_target_bitrate = i;
Reset();
// 40-20-40 bitrate allocation for 3 temporal layers.
cfg_.ts_target_bitrate[0] = 40 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[1] = 60 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[2] = cfg_.rc_target_bitrate;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
for (int j = 0; j < static_cast<int>(cfg_.ts_number_layers); ++j) {
ASSERT_GE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 0.75)
<< " The datarate for the file is lower than target by too much, "
"for layer: " << j;
ASSERT_LE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 1.25)
<< " The datarate for the file is greater than target by too much, "
"for layer: " << j;
}
}
}
VP8_INSTANTIATE_TEST_CASE(ErrorResilienceTestLarge, ONE_PASS_TEST_MODES); VP8_INSTANTIATE_TEST_CASE(ErrorResilienceTestLarge, ONE_PASS_TEST_MODES);
VP8_INSTANTIATE_TEST_CASE(ErrorResilienceTestLargeCodecControls,
ONE_PASS_TEST_MODES);
VP9_INSTANTIATE_TEST_CASE(ErrorResilienceTestLarge, ONE_PASS_TEST_MODES); VP9_INSTANTIATE_TEST_CASE(ErrorResilienceTestLarge, ONE_PASS_TEST_MODES);
} // namespace } // namespace

View File

@@ -97,19 +97,13 @@ class ExternalFrameBufferList {
return 0; return 0;
} }
// Marks the external frame buffer that |fb| is pointing to as free. // Marks the external frame buffer that |fb| is pointing too as free.
// Returns < 0 on an error. // Returns < 0 on an error.
int ReturnFrameBuffer(vpx_codec_frame_buffer_t *fb) { int ReturnFrameBuffer(vpx_codec_frame_buffer_t *fb) {
if (fb == NULL) { EXPECT_TRUE(fb != NULL);
EXPECT_TRUE(fb != NULL);
return -1;
}
ExternalFrameBuffer *const ext_fb = ExternalFrameBuffer *const ext_fb =
reinterpret_cast<ExternalFrameBuffer*>(fb->priv); reinterpret_cast<ExternalFrameBuffer*>(fb->priv);
if (ext_fb == NULL) { EXPECT_TRUE(ext_fb != NULL);
EXPECT_TRUE(ext_fb != NULL);
return -1;
}
EXPECT_EQ(1, ext_fb->in_use); EXPECT_EQ(1, ext_fb->in_use);
ext_fb->in_use = 0; ext_fb->in_use = 0;
return 0; return 0;

View File

@@ -84,8 +84,8 @@ void idct4x4_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
void idct4x4_12_sse2(const tran_low_t *in, uint8_t *out, int stride) { void idct4x4_12_sse2(const tran_low_t *in, uint8_t *out, int stride) {
vp9_highbd_idct4x4_16_add_sse2(in, out, stride, 12); vp9_highbd_idct4x4_16_add_sse2(in, out, stride, 12);
} }
#endif // HAVE_SSE2 #endif
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
class Trans4x4TestBase { class Trans4x4TestBase {
public: public:
@@ -426,7 +426,7 @@ INSTANTIATE_TEST_CASE_P(
C, Trans4x4DCT, C, Trans4x4DCT,
::testing::Values( ::testing::Values(
make_tuple(&vp9_fdct4x4_c, &vp9_idct4x4_16_add_c, 0, VPX_BITS_8))); make_tuple(&vp9_fdct4x4_c, &vp9_idct4x4_16_add_c, 0, VPX_BITS_8)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -452,7 +452,7 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_c, 1, VPX_BITS_8), make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_c, 1, VPX_BITS_8),
make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_c, 2, VPX_BITS_8), make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_c, 2, VPX_BITS_8),
make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_c, 3, VPX_BITS_8))); make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_c, 3, VPX_BITS_8)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -466,7 +466,7 @@ INSTANTIATE_TEST_CASE_P(
C, Trans4x4WHT, C, Trans4x4WHT,
::testing::Values( ::testing::Values(
make_tuple(&vp9_fwht4x4_c, &vp9_iwht4x4_16_add_c, 0, VPX_BITS_8))); make_tuple(&vp9_fwht4x4_c, &vp9_iwht4x4_16_add_c, 0, VPX_BITS_8)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
#if HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -474,17 +474,14 @@ INSTANTIATE_TEST_CASE_P(
::testing::Values( ::testing::Values(
make_tuple(&vp9_fdct4x4_c, make_tuple(&vp9_fdct4x4_c,
&vp9_idct4x4_16_add_neon, 0, VPX_BITS_8))); &vp9_idct4x4_16_add_neon, 0, VPX_BITS_8)));
#endif // HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
#if HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
NEON, Trans4x4HT, DISABLED_NEON, Trans4x4HT,
::testing::Values( ::testing::Values(
make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_neon, 0, VPX_BITS_8), make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_neon, 0, VPX_BITS_8),
make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_neon, 1, VPX_BITS_8), make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_neon, 1, VPX_BITS_8),
make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_neon, 2, VPX_BITS_8), make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_neon, 2, VPX_BITS_8),
make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_neon, 3, VPX_BITS_8))); make_tuple(&vp9_fht4x4_c, &vp9_iht4x4_16_add_neon, 3, VPX_BITS_8)));
#endif // HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if CONFIG_USE_X86INC && HAVE_MMX && !CONFIG_VP9_HIGHBITDEPTH && \ #if CONFIG_USE_X86INC && HAVE_MMX && !CONFIG_VP9_HIGHBITDEPTH && \
!CONFIG_EMULATE_HARDWARE !CONFIG_EMULATE_HARDWARE
@@ -507,7 +504,7 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_sse2, 1, VPX_BITS_8), make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_sse2, 1, VPX_BITS_8),
make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_sse2, 2, VPX_BITS_8), make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_sse2, 2, VPX_BITS_8),
make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_sse2, 3, VPX_BITS_8))); make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_sse2, 3, VPX_BITS_8)));
#endif // HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -535,5 +532,5 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 1, VPX_BITS_8), make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 1, VPX_BITS_8),
make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 2, VPX_BITS_8), make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 2, VPX_BITS_8),
make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 3, VPX_BITS_8))); make_tuple(&vp9_fht4x4_sse2, &vp9_iht4x4_16_add_c, 3, VPX_BITS_8)));
#endif // HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
} // namespace } // namespace

View File

@@ -62,10 +62,6 @@ void reference_8x8_dct_2d(const int16_t input[kNumCoeffs],
using libvpx_test::ACMRandom; using libvpx_test::ACMRandom;
namespace { namespace {
const int kSignBiasMaxDiff255 = 1500;
const int kSignBiasMaxDiff15 = 10000;
typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride); typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride); typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
typedef void (*FhtFunc)(const int16_t *in, tran_low_t *out, int stride, typedef void (*FhtFunc)(const int16_t *in, tran_low_t *out, int stride,
@@ -126,8 +122,8 @@ void idct8x8_64_add_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
void idct8x8_64_add_12_sse2(const tran_low_t *in, uint8_t *out, int stride) { void idct8x8_64_add_12_sse2(const tran_low_t *in, uint8_t *out, int stride) {
vp9_highbd_idct8x8_64_add_sse2(in, out, stride, 12); vp9_highbd_idct8x8_64_add_sse2(in, out, stride, 12);
} }
#endif // HAVE_SSE2 #endif
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
class FwdTrans8x8TestBase { class FwdTrans8x8TestBase {
public: public:
@@ -164,7 +160,7 @@ class FwdTrans8x8TestBase {
for (int j = 0; j < 64; ++j) { for (int j = 0; j < 64; ++j) {
const int diff = abs(count_sign_block[j][0] - count_sign_block[j][1]); const int diff = abs(count_sign_block[j][0] - count_sign_block[j][1]);
const int max_diff = kSignBiasMaxDiff255; const int max_diff = 1125;
EXPECT_LT(diff, max_diff << (bit_depth_ - 8)) EXPECT_LT(diff, max_diff << (bit_depth_ - 8))
<< "Error: 8x8 FDCT/FHT has a sign bias > " << "Error: 8x8 FDCT/FHT has a sign bias > "
<< 1. * max_diff / count_test_block * 100 << "%" << 1. * max_diff / count_test_block * 100 << "%"
@@ -177,7 +173,7 @@ class FwdTrans8x8TestBase {
memset(count_sign_block, 0, sizeof(count_sign_block)); memset(count_sign_block, 0, sizeof(count_sign_block));
for (int i = 0; i < count_test_block; ++i) { for (int i = 0; i < count_test_block; ++i) {
// Initialize a test block with input range [-mask_ / 16, mask_ / 16]. // Initialize a test block with input range [-mask_/16, mask_/16].
for (int j = 0; j < 64; ++j) for (int j = 0; j < 64; ++j)
test_input_block[j] = ((rnd.Rand16() & mask_) >> 4) - test_input_block[j] = ((rnd.Rand16() & mask_) >> 4) -
((rnd.Rand16() & mask_) >> 4); ((rnd.Rand16() & mask_) >> 4);
@@ -194,9 +190,9 @@ class FwdTrans8x8TestBase {
for (int j = 0; j < 64; ++j) { for (int j = 0; j < 64; ++j) {
const int diff = abs(count_sign_block[j][0] - count_sign_block[j][1]); const int diff = abs(count_sign_block[j][0] - count_sign_block[j][1]);
const int max_diff = kSignBiasMaxDiff15; const int max_diff = 10000;
EXPECT_LT(diff, max_diff << (bit_depth_ - 8)) EXPECT_LT(diff, max_diff << (bit_depth_ - 8))
<< "Error: 8x8 FDCT/FHT has a sign bias > " << "Error: 4x4 FDCT/FHT has a sign bias > "
<< 1. * max_diff / count_test_block * 100 << "%" << 1. * max_diff / count_test_block * 100 << "%"
<< " for input range [-15, 15] at index " << j << " for input range [-15, 15] at index " << j
<< " count0: " << count_sign_block[j][0] << " count0: " << count_sign_block[j][0]
@@ -624,8 +620,8 @@ class InvTrans8x8DCT
virtual void SetUp() { virtual void SetUp() {
ref_txfm_ = GET_PARAM(0); ref_txfm_ = GET_PARAM(0);
inv_txfm_ = GET_PARAM(1); inv_txfm_ = GET_PARAM(1);
thresh_ = GET_PARAM(2); thresh_ = GET_PARAM(2);
pitch_ = 8; pitch_ = 8;
bit_depth_ = GET_PARAM(3); bit_depth_ = GET_PARAM(3);
mask_ = (1 << bit_depth_) - 1; mask_ = (1 << bit_depth_) - 1;
} }
@@ -653,21 +649,20 @@ using std::tr1::make_tuple;
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
C, FwdTrans8x8DCT, C, FwdTrans8x8DCT,
::testing::Values( ::testing::Values(
make_tuple(&vp9_fdct8x8_c, &vp9_idct8x8_64_add_c, 0, VPX_BITS_8),
make_tuple(&vp9_highbd_fdct8x8_c, &idct8x8_10, 0, VPX_BITS_10), make_tuple(&vp9_highbd_fdct8x8_c, &idct8x8_10, 0, VPX_BITS_10),
make_tuple(&vp9_highbd_fdct8x8_c, &idct8x8_12, 0, VPX_BITS_12))); make_tuple(&vp9_highbd_fdct8x8_c, &idct8x8_12, 0, VPX_BITS_12),
make_tuple(&vp9_fdct8x8_c, &vp9_idct8x8_64_add_c, 0, VPX_BITS_8)));
#else #else
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
C, FwdTrans8x8DCT, C, FwdTrans8x8DCT,
::testing::Values( ::testing::Values(
make_tuple(&vp9_fdct8x8_c, &vp9_idct8x8_64_add_c, 0, VPX_BITS_8))); make_tuple(&vp9_fdct8x8_c, &vp9_idct8x8_64_add_c, 0, VPX_BITS_8)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
C, FwdTrans8x8HT, C, FwdTrans8x8HT,
::testing::Values( ::testing::Values(
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 0, VPX_BITS_8),
make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_10, 0, VPX_BITS_10), make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_10, 0, VPX_BITS_10),
make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_10, 1, VPX_BITS_10), make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_10, 1, VPX_BITS_10),
make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_10, 2, VPX_BITS_10), make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_10, 2, VPX_BITS_10),
@@ -676,12 +671,11 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_12, 1, VPX_BITS_12), make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_12, 1, VPX_BITS_12),
make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_12, 2, VPX_BITS_12), make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_12, 2, VPX_BITS_12),
make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_12, 3, VPX_BITS_12), make_tuple(&vp9_highbd_fht8x8_c, &iht8x8_12, 3, VPX_BITS_12),
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 0, VPX_BITS_8),
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 1, VPX_BITS_8), make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 1, VPX_BITS_8),
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 2, VPX_BITS_8), make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 2, VPX_BITS_8),
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 3, VPX_BITS_8))); make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 3, VPX_BITS_8)));
#else #else
// TODO(jingning): re-enable after this handles the expanded range [0, 65535]
// returned from Rand16().
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
C, FwdTrans8x8HT, C, FwdTrans8x8HT,
::testing::Values( ::testing::Values(
@@ -689,31 +683,24 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 1, VPX_BITS_8), make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 1, VPX_BITS_8),
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 2, VPX_BITS_8), make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 2, VPX_BITS_8),
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 3, VPX_BITS_8))); make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_c, 3, VPX_BITS_8)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
#if HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
// TODO(jingning): re-enable after this handles the expanded range [0, 65535]
// returned from Rand16().
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
NEON, FwdTrans8x8DCT, NEON, FwdTrans8x8DCT,
::testing::Values( ::testing::Values(
make_tuple(&vp9_fdct8x8_neon, &vp9_idct8x8_64_add_neon, 0, make_tuple(&vp9_fdct8x8_neon, &vp9_idct8x8_64_add_neon, 0,
VPX_BITS_8))); VPX_BITS_8)));
#endif // HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
#if HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
NEON, FwdTrans8x8HT, DISABLED_NEON, FwdTrans8x8HT,
::testing::Values( ::testing::Values(
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_neon, 0, VPX_BITS_8), make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_neon, 0, VPX_BITS_8),
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_neon, 1, VPX_BITS_8), make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_neon, 1, VPX_BITS_8),
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_neon, 2, VPX_BITS_8), make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_neon, 2, VPX_BITS_8),
make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_neon, 3, VPX_BITS_8))); make_tuple(&vp9_fht8x8_c, &vp9_iht8x8_64_add_neon, 3, VPX_BITS_8)));
#endif // HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
// TODO(jingning): re-enable after these handle the expanded range [0, 65535]
// returned from Rand16().
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, FwdTrans8x8DCT, SSE2, FwdTrans8x8DCT,
::testing::Values( ::testing::Values(
@@ -726,13 +713,12 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(&vp9_fht8x8_sse2, &vp9_iht8x8_64_add_sse2, 1, VPX_BITS_8), make_tuple(&vp9_fht8x8_sse2, &vp9_iht8x8_64_add_sse2, 1, VPX_BITS_8),
make_tuple(&vp9_fht8x8_sse2, &vp9_iht8x8_64_add_sse2, 2, VPX_BITS_8), make_tuple(&vp9_fht8x8_sse2, &vp9_iht8x8_64_add_sse2, 2, VPX_BITS_8),
make_tuple(&vp9_fht8x8_sse2, &vp9_iht8x8_64_add_sse2, 3, VPX_BITS_8))); make_tuple(&vp9_fht8x8_sse2, &vp9_iht8x8_64_add_sse2, 3, VPX_BITS_8)));
#endif // HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, FwdTrans8x8DCT, SSE2, FwdTrans8x8DCT,
::testing::Values( ::testing::Values(
make_tuple(&vp9_fdct8x8_sse2, &vp9_idct8x8_64_add_c, 0, VPX_BITS_8),
make_tuple(&vp9_highbd_fdct8x8_c, make_tuple(&vp9_highbd_fdct8x8_c,
&idct8x8_64_add_10_sse2, 12, VPX_BITS_10), &idct8x8_64_add_10_sse2, 12, VPX_BITS_10),
make_tuple(&vp9_highbd_fdct8x8_sse2, make_tuple(&vp9_highbd_fdct8x8_sse2,
@@ -740,10 +726,10 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(&vp9_highbd_fdct8x8_c, make_tuple(&vp9_highbd_fdct8x8_c,
&idct8x8_64_add_12_sse2, 12, VPX_BITS_12), &idct8x8_64_add_12_sse2, 12, VPX_BITS_12),
make_tuple(&vp9_highbd_fdct8x8_sse2, make_tuple(&vp9_highbd_fdct8x8_sse2,
&idct8x8_64_add_12_sse2, 12, VPX_BITS_12))); &idct8x8_64_add_12_sse2, 12, VPX_BITS_12),
make_tuple(&vp9_fdct8x8_sse2, &vp9_idct8x8_64_add_c, 0, VPX_BITS_8)));
// TODO(jingning): re-enable after these handle the expanded range [0, 65535]
// returned from Rand16().
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, FwdTrans8x8HT, SSE2, FwdTrans8x8HT,
::testing::Values( ::testing::Values(
@@ -765,12 +751,11 @@ INSTANTIATE_TEST_CASE_P(
&idct8x8_10_add_12_sse2, 6225, VPX_BITS_12), &idct8x8_10_add_12_sse2, 6225, VPX_BITS_12),
make_tuple(&idct8x8_12, make_tuple(&idct8x8_12,
&idct8x8_64_add_12_sse2, 6225, VPX_BITS_12))); &idct8x8_64_add_12_sse2, 6225, VPX_BITS_12)));
#endif // HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if HAVE_SSSE3 && ARCH_X86_64 && !CONFIG_VP9_HIGHBITDEPTH && \ #if HAVE_SSSE3 && ARCH_X86_64 && !CONFIG_VP9_HIGHBITDEPTH && \
!CONFIG_EMULATE_HARDWARE !CONFIG_EMULATE_HARDWARE
// TODO(jingning): re-enable after this handles the expanded range [0, 65535]
// returned from Rand16().
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSSE3, FwdTrans8x8DCT, SSSE3, FwdTrans8x8DCT,
::testing::Values( ::testing::Values(

View File

@@ -121,8 +121,6 @@ const DecodeParam kVP9InvalidFileTests[] = {
{1, "invalid-vp90-2-09-subpixel-00.ivf.s20492_r01-05_b6-.v2.ivf"}, {1, "invalid-vp90-2-09-subpixel-00.ivf.s20492_r01-05_b6-.v2.ivf"},
{1, "invalid-vp91-2-mixedrefcsp-444to420.ivf"}, {1, "invalid-vp91-2-mixedrefcsp-444to420.ivf"},
{1, "invalid-vp90-2-12-droppable_1.ivf.s73804_r01-05_b6-.ivf"}, {1, "invalid-vp90-2-12-droppable_1.ivf.s73804_r01-05_b6-.ivf"},
{1, "invalid-vp90-2-03-size-224x196.webm.ivf.s44156_r01-05_b6-.ivf"},
{1, "invalid-vp90-2-03-size-202x210.webm.ivf.s113306_r01-05_b6-.ivf"},
}; };
VP9_INSTANTIATE_TEST_CASE(InvalidFileTest, VP9_INSTANTIATE_TEST_CASE(InvalidFileTest,
@@ -153,7 +151,6 @@ const DecodeParam kMultiThreadedVP9InvalidFileTests[] = {
{4, "invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm"}, {4, "invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm"},
{4, "invalid-" {4, "invalid-"
"vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf"}, "vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf"},
{4, "invalid-vp90-2-08-tile_1x8_frame_parallel.webm.ivf.s288_r01-05_b6-.ivf"},
{2, "invalid-vp90-2-09-aq2.webm.ivf.s3984_r01-05_b6-.v2.ivf"}, {2, "invalid-vp90-2-09-aq2.webm.ivf.s3984_r01-05_b6-.v2.ivf"},
{4, "invalid-vp90-2-09-subpixel-00.ivf.s19552_r01-05_b6-.v2.ivf"}, {4, "invalid-vp90-2-09-subpixel-00.ivf.s19552_r01-05_b6-.v2.ivf"},
}; };

View File

@@ -21,9 +21,10 @@
#include "./vpx_config.h" #include "./vpx_config.h"
#include "./vp9_rtcd.h" #include "./vp9_rtcd.h"
#include "vp9/common/vp9_entropy.h" #include "vp9/common/vp9_entropy.h"
#include "vp9/common/vp9_loopfilter.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
#define MAX_LOOP_FILTER 63
using libvpx_test::ACMRandom; using libvpx_test::ACMRandom;
namespace { namespace {
@@ -52,7 +53,7 @@ typedef void (*dual_loop_op_t)(uint8_t *s, int p, const uint8_t *blimit0,
const uint8_t *thresh1); const uint8_t *thresh1);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
typedef std::tr1::tuple<loop_op_t, loop_op_t, int, int> loop8_param_t; typedef std::tr1::tuple<loop_op_t, loop_op_t, int> loop8_param_t;
typedef std::tr1::tuple<dual_loop_op_t, dual_loop_op_t, int> dualloop8_param_t; typedef std::tr1::tuple<dual_loop_op_t, dual_loop_op_t, int> dualloop8_param_t;
#if HAVE_SSE2 #if HAVE_SSE2
@@ -107,36 +108,6 @@ void wrapper_vertical_16_dual_c(uint8_t *s, int p, const uint8_t *blimit,
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
#endif // HAVE_SSE2 #endif // HAVE_SSE2
#if HAVE_NEON_ASM
#if CONFIG_VP9_HIGHBITDEPTH
// No neon high bitdepth functions.
#else
void wrapper_vertical_16_neon(uint8_t *s, int p, const uint8_t *blimit,
const uint8_t *limit, const uint8_t *thresh,
int count) {
vp9_lpf_vertical_16_neon(s, p, blimit, limit, thresh);
}
void wrapper_vertical_16_c(uint8_t *s, int p, const uint8_t *blimit,
const uint8_t *limit, const uint8_t *thresh,
int count) {
vp9_lpf_vertical_16_c(s, p, blimit, limit, thresh);
}
void wrapper_vertical_16_dual_neon(uint8_t *s, int p, const uint8_t *blimit,
const uint8_t *limit, const uint8_t *thresh,
int count) {
vp9_lpf_vertical_16_dual_neon(s, p, blimit, limit, thresh);
}
void wrapper_vertical_16_dual_c(uint8_t *s, int p, const uint8_t *blimit,
const uint8_t *limit, const uint8_t *thresh,
int count) {
vp9_lpf_vertical_16_dual_c(s, p, blimit, limit, thresh);
}
#endif // CONFIG_VP9_HIGHBITDEPTH
#endif // HAVE_NEON_ASM
class Loop8Test6Param : public ::testing::TestWithParam<loop8_param_t> { class Loop8Test6Param : public ::testing::TestWithParam<loop8_param_t> {
public: public:
virtual ~Loop8Test6Param() {} virtual ~Loop8Test6Param() {}
@@ -144,7 +115,6 @@ class Loop8Test6Param : public ::testing::TestWithParam<loop8_param_t> {
loopfilter_op_ = GET_PARAM(0); loopfilter_op_ = GET_PARAM(0);
ref_loopfilter_op_ = GET_PARAM(1); ref_loopfilter_op_ = GET_PARAM(1);
bit_depth_ = GET_PARAM(2); bit_depth_ = GET_PARAM(2);
count_ = GET_PARAM(3);
mask_ = (1 << bit_depth_) - 1; mask_ = (1 << bit_depth_) - 1;
} }
@@ -152,7 +122,6 @@ class Loop8Test6Param : public ::testing::TestWithParam<loop8_param_t> {
protected: protected:
int bit_depth_; int bit_depth_;
int count_;
int mask_; int mask_;
loop_op_t loopfilter_op_; loop_op_t loopfilter_op_;
loop_op_t ref_loopfilter_op_; loop_op_t ref_loopfilter_op_;
@@ -192,12 +161,19 @@ TEST_P(Loop8Test6Param, OperationCheck) {
int first_failure = -1; int first_failure = -1;
for (int i = 0; i < count_test_block; ++i) { for (int i = 0; i < count_test_block; ++i) {
int err_count = 0; int err_count = 0;
uint8_t tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4)); uint8_t tmp = rnd.Rand8();
// mblim <= 3 * MAX_LOOP_FILTER + 4
while (tmp > 3 * MAX_LOOP_FILTER + 4) {
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, blimit[16]) = { DECLARE_ALIGNED(16, const uint8_t, blimit[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
}; };
tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER)); tmp = rnd.Rand8();
while (tmp > MAX_LOOP_FILTER) { // lim <= MAX_LOOP_FILTER
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, limit[16]) = { DECLARE_ALIGNED(16, const uint8_t, limit[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
@@ -208,6 +184,7 @@ TEST_P(Loop8Test6Param, OperationCheck) {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
}; };
int32_t p = kNumCoeffs/32; int32_t p = kNumCoeffs/32;
int count = 1;
uint16_t tmp_s[kNumCoeffs]; uint16_t tmp_s[kNumCoeffs];
int j = 0; int j = 0;
@@ -239,13 +216,13 @@ TEST_P(Loop8Test6Param, OperationCheck) {
ref_s[j] = s[j]; ref_s[j] = s[j];
} }
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
ref_loopfilter_op_(ref_s + 8 + p * 8, p, blimit, limit, thresh, count_, bd); ref_loopfilter_op_(ref_s + 8 + p * 8, p, blimit, limit, thresh, count, bd);
ASM_REGISTER_STATE_CHECK( ASM_REGISTER_STATE_CHECK(
loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh, count_, bd)); loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh, count, bd));
#else #else
ref_loopfilter_op_(ref_s+8+p*8, p, blimit, limit, thresh, count_); ref_loopfilter_op_(ref_s+8+p*8, p, blimit, limit, thresh, count);
ASM_REGISTER_STATE_CHECK( ASM_REGISTER_STATE_CHECK(
loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh, count_)); loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh, count));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
for (int j = 0; j < kNumCoeffs; ++j) { for (int j = 0; j < kNumCoeffs; ++j) {
@@ -275,27 +252,21 @@ TEST_P(Loop8Test6Param, ValueCheck) {
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
int err_count_total = 0; int err_count_total = 0;
int first_failure = -1; int first_failure = -1;
// NOTE: The code in vp9_loopfilter.c:update_sharpness computes mblim as a
// function of sharpness_lvl and the loopfilter lvl as:
// block_inside_limit = lvl >> ((sharpness_lvl > 0) + (sharpness_lvl > 4));
// ...
// memset(lfi->lfthr[lvl].mblim, (2 * (lvl + 2) + block_inside_limit),
// SIMD_WIDTH);
// This means that the largest value for mblim will occur when sharpness_lvl
// is equal to 0, and lvl is equal to its greatest value (MAX_LOOP_FILTER).
// In this case block_inside_limit will be equal to MAX_LOOP_FILTER and
// therefore mblim will be equal to (2 * (lvl + 2) + block_inside_limit) =
// 2 * (MAX_LOOP_FILTER + 2) + MAX_LOOP_FILTER = 3 * MAX_LOOP_FILTER + 4
for (int i = 0; i < count_test_block; ++i) { for (int i = 0; i < count_test_block; ++i) {
int err_count = 0; int err_count = 0;
uint8_t tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4)); uint8_t tmp = rnd.Rand8();
// mblim <= 3 * MAX_LOOP_FILTER + 4
while (tmp > 3 * MAX_LOOP_FILTER + 4) {
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, blimit[16]) = { DECLARE_ALIGNED(16, const uint8_t, blimit[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
}; };
tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER)); tmp = rnd.Rand8();
while (tmp > MAX_LOOP_FILTER) { // lim <= MAX_LOOP_FILTER
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, limit[16]) = { DECLARE_ALIGNED(16, const uint8_t, limit[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
@@ -306,18 +277,19 @@ TEST_P(Loop8Test6Param, ValueCheck) {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
}; };
int32_t p = kNumCoeffs / 32; int32_t p = kNumCoeffs / 32;
int count = 1;
for (int j = 0; j < kNumCoeffs; ++j) { for (int j = 0; j < kNumCoeffs; ++j) {
s[j] = rnd.Rand16() & mask_; s[j] = rnd.Rand16() & mask_;
ref_s[j] = s[j]; ref_s[j] = s[j];
} }
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
ref_loopfilter_op_(ref_s + 8 + p * 8, p, blimit, limit, thresh, count_, bd); ref_loopfilter_op_(ref_s + 8 + p * 8, p, blimit, limit, thresh, count, bd);
ASM_REGISTER_STATE_CHECK( ASM_REGISTER_STATE_CHECK(
loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh, count_, bd)); loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh, count, bd));
#else #else
ref_loopfilter_op_(ref_s+8+p*8, p, blimit, limit, thresh, count_); ref_loopfilter_op_(ref_s+8+p*8, p, blimit, limit, thresh, count);
ASM_REGISTER_STATE_CHECK( ASM_REGISTER_STATE_CHECK(
loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh, count_)); loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh, count));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
for (int j = 0; j < kNumCoeffs; ++j) { for (int j = 0; j < kNumCoeffs; ++j) {
err_count += ref_s[j] != s[j]; err_count += ref_s[j] != s[j];
@@ -348,12 +320,20 @@ TEST_P(Loop8Test9Param, OperationCheck) {
int first_failure = -1; int first_failure = -1;
for (int i = 0; i < count_test_block; ++i) { for (int i = 0; i < count_test_block; ++i) {
int err_count = 0; int err_count = 0;
uint8_t tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4)); uint8_t tmp = rnd.Rand8();
// mblim <= 3 * MAX_LOOP_FILTER + 4
while (tmp > 3 * MAX_LOOP_FILTER + 4) {
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, blimit0[16]) = { DECLARE_ALIGNED(16, const uint8_t, blimit0[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
}; };
tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER)); tmp = rnd.Rand8();
// lim <= MAX_LOOP_FILTER
while (tmp > MAX_LOOP_FILTER) {
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, limit0[16]) = { DECLARE_ALIGNED(16, const uint8_t, limit0[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
@@ -363,12 +343,19 @@ TEST_P(Loop8Test9Param, OperationCheck) {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
}; };
tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4)); tmp = rnd.Rand8();
// mblim <= 3 * MAX_LOOP_FILTER + 4
while (tmp > 3 * MAX_LOOP_FILTER + 4) {
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, blimit1[16]) = { DECLARE_ALIGNED(16, const uint8_t, blimit1[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
}; };
tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER)); tmp = rnd.Rand8();
while (tmp > MAX_LOOP_FILTER) { // lim <= MAX_LOOP_FILTER
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, limit1[16]) = { DECLARE_ALIGNED(16, const uint8_t, limit1[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
@@ -450,12 +437,19 @@ TEST_P(Loop8Test9Param, ValueCheck) {
int first_failure = -1; int first_failure = -1;
for (int i = 0; i < count_test_block; ++i) { for (int i = 0; i < count_test_block; ++i) {
int err_count = 0; int err_count = 0;
uint8_t tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4)); uint8_t tmp = rnd.Rand8();
// mblim <= 3 * MAX_LOOP_FILTER + 4
while (tmp > 3 * MAX_LOOP_FILTER + 4) {
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, blimit0[16]) = { DECLARE_ALIGNED(16, const uint8_t, blimit0[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
}; };
tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER)); tmp = rnd.Rand8();
while (tmp > MAX_LOOP_FILTER) { // lim <= MAX_LOOP_FILTER
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, limit0[16]) = { DECLARE_ALIGNED(16, const uint8_t, limit0[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
@@ -465,12 +459,19 @@ TEST_P(Loop8Test9Param, ValueCheck) {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
}; };
tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4)); tmp = rnd.Rand8();
// mblim <= 3 * MAX_LOOP_FILTER + 4
while (tmp > 3 * MAX_LOOP_FILTER + 4) {
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, blimit1[16]) = { DECLARE_ALIGNED(16, const uint8_t, blimit1[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
}; };
tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER)); tmp = rnd.Rand8();
while (tmp > MAX_LOOP_FILTER) { // lim <= MAX_LOOP_FILTER
tmp = rnd.Rand8();
}
DECLARE_ALIGNED(16, const uint8_t, limit1[16]) = { DECLARE_ALIGNED(16, const uint8_t, limit1[16]) = {
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
@@ -518,81 +519,77 @@ using std::tr1::make_tuple;
#if HAVE_SSE2 #if HAVE_SSE2
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, Loop8Test6Param, SSE2_C_COMPARE_SINGLE, Loop8Test6Param,
::testing::Values( ::testing::Values(
make_tuple(&vp9_highbd_lpf_horizontal_4_sse2, make_tuple(&vp9_highbd_lpf_horizontal_4_sse2,
&vp9_highbd_lpf_horizontal_4_c, 8, 1), &vp9_highbd_lpf_horizontal_4_c, 8),
make_tuple(&vp9_highbd_lpf_vertical_4_sse2, make_tuple(&vp9_highbd_lpf_vertical_4_sse2,
&vp9_highbd_lpf_vertical_4_c, 8, 1), &vp9_highbd_lpf_vertical_4_c, 8),
make_tuple(&vp9_highbd_lpf_horizontal_8_sse2, make_tuple(&vp9_highbd_lpf_horizontal_8_sse2,
&vp9_highbd_lpf_horizontal_8_c, 8, 1), &vp9_highbd_lpf_horizontal_8_c, 8),
make_tuple(&vp9_highbd_lpf_horizontal_16_sse2, make_tuple(&vp9_highbd_lpf_horizontal_16_sse2,
&vp9_highbd_lpf_horizontal_16_c, 8, 1), &vp9_highbd_lpf_horizontal_16_c, 8),
make_tuple(&vp9_highbd_lpf_horizontal_16_sse2,
&vp9_highbd_lpf_horizontal_16_c, 8, 2),
make_tuple(&vp9_highbd_lpf_vertical_8_sse2, make_tuple(&vp9_highbd_lpf_vertical_8_sse2,
&vp9_highbd_lpf_vertical_8_c, 8, 1), &vp9_highbd_lpf_vertical_8_c, 8),
make_tuple(&wrapper_vertical_16_sse2, make_tuple(&wrapper_vertical_16_sse2,
&wrapper_vertical_16_c, 8, 1), &wrapper_vertical_16_c, 8),
make_tuple(&vp9_highbd_lpf_horizontal_4_sse2, make_tuple(&vp9_highbd_lpf_horizontal_4_sse2,
&vp9_highbd_lpf_horizontal_4_c, 10, 1), &vp9_highbd_lpf_horizontal_4_c, 10),
make_tuple(&vp9_highbd_lpf_vertical_4_sse2, make_tuple(&vp9_highbd_lpf_vertical_4_sse2,
&vp9_highbd_lpf_vertical_4_c, 10, 1), &vp9_highbd_lpf_vertical_4_c, 10),
make_tuple(&vp9_highbd_lpf_horizontal_8_sse2, make_tuple(&vp9_highbd_lpf_horizontal_8_sse2,
&vp9_highbd_lpf_horizontal_8_c, 10, 1), &vp9_highbd_lpf_horizontal_8_c, 10),
make_tuple(&vp9_highbd_lpf_horizontal_16_sse2, make_tuple(&vp9_highbd_lpf_horizontal_16_sse2,
&vp9_highbd_lpf_horizontal_16_c, 10, 1), &vp9_highbd_lpf_horizontal_16_c, 10),
make_tuple(&vp9_highbd_lpf_horizontal_16_sse2,
&vp9_highbd_lpf_horizontal_16_c, 10, 2),
make_tuple(&vp9_highbd_lpf_vertical_8_sse2, make_tuple(&vp9_highbd_lpf_vertical_8_sse2,
&vp9_highbd_lpf_vertical_8_c, 10, 1), &vp9_highbd_lpf_vertical_8_c, 10),
make_tuple(&wrapper_vertical_16_sse2, make_tuple(&wrapper_vertical_16_sse2,
&wrapper_vertical_16_c, 10, 1), &wrapper_vertical_16_c, 10),
make_tuple(&vp9_highbd_lpf_horizontal_4_sse2, make_tuple(&vp9_highbd_lpf_horizontal_4_sse2,
&vp9_highbd_lpf_horizontal_4_c, 12, 1), &vp9_highbd_lpf_horizontal_4_c, 12),
make_tuple(&vp9_highbd_lpf_vertical_4_sse2, make_tuple(&vp9_highbd_lpf_vertical_4_sse2,
&vp9_highbd_lpf_vertical_4_c, 12, 1), &vp9_highbd_lpf_vertical_4_c, 12),
make_tuple(&vp9_highbd_lpf_horizontal_8_sse2, make_tuple(&vp9_highbd_lpf_horizontal_8_sse2,
&vp9_highbd_lpf_horizontal_8_c, 12, 1), &vp9_highbd_lpf_horizontal_8_c, 12),
make_tuple(&vp9_highbd_lpf_horizontal_16_sse2, make_tuple(&vp9_highbd_lpf_horizontal_16_sse2,
&vp9_highbd_lpf_horizontal_16_c, 12, 1), &vp9_highbd_lpf_horizontal_16_c, 12),
make_tuple(&vp9_highbd_lpf_horizontal_16_sse2,
&vp9_highbd_lpf_horizontal_16_c, 12, 2),
make_tuple(&vp9_highbd_lpf_vertical_8_sse2, make_tuple(&vp9_highbd_lpf_vertical_8_sse2,
&vp9_highbd_lpf_vertical_8_c, 12, 1), &vp9_highbd_lpf_vertical_8_c, 12),
make_tuple(&wrapper_vertical_16_sse2, make_tuple(&wrapper_vertical_16_sse2,
&wrapper_vertical_16_c, 12, 1), &wrapper_vertical_16_c, 12)));
make_tuple(&wrapper_vertical_16_dual_sse2,
&wrapper_vertical_16_dual_c, 8, 1),
make_tuple(&wrapper_vertical_16_dual_sse2,
&wrapper_vertical_16_dual_c, 10, 1),
make_tuple(&wrapper_vertical_16_dual_sse2,
&wrapper_vertical_16_dual_c, 12, 1)));
#else #else
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, Loop8Test6Param, SSE2_C_COMPARE_SINGLE, Loop8Test6Param,
::testing::Values( ::testing::Values(
make_tuple(&vp9_lpf_horizontal_8_sse2, &vp9_lpf_horizontal_8_c, 8, 1), make_tuple(&vp9_lpf_horizontal_8_sse2, &vp9_lpf_horizontal_8_c, 8),
make_tuple(&vp9_lpf_horizontal_16_sse2, &vp9_lpf_horizontal_16_c, 8, 1), make_tuple(&vp9_lpf_horizontal_16_sse2, &vp9_lpf_horizontal_16_c, 8),
make_tuple(&vp9_lpf_horizontal_16_sse2, &vp9_lpf_horizontal_16_c, 8, 2), make_tuple(&vp9_lpf_vertical_8_sse2, &vp9_lpf_vertical_8_c, 8)));
make_tuple(&vp9_lpf_vertical_8_sse2, &vp9_lpf_vertical_8_c, 8, 1),
make_tuple(&wrapper_vertical_16_sse2, &wrapper_vertical_16_c, 8, 1)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
#endif #endif
#if HAVE_AVX2 && (!CONFIG_VP9_HIGHBITDEPTH)
INSTANTIATE_TEST_CASE_P(
AVX2, Loop8Test6Param,
::testing::Values(
make_tuple(&vp9_lpf_horizontal_16_avx2, &vp9_lpf_horizontal_16_c, 8, 1),
make_tuple(&vp9_lpf_horizontal_16_avx2, &vp9_lpf_horizontal_16_c, 8,
2)));
#endif
#if HAVE_SSE2 #if HAVE_SSE2
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, Loop8Test9Param, SSE2_C_COMPARE_DUAL, Loop8Test6Param,
::testing::Values(
make_tuple(&wrapper_vertical_16_dual_sse2,
&wrapper_vertical_16_dual_c, 8),
make_tuple(&wrapper_vertical_16_dual_sse2,
&wrapper_vertical_16_dual_c, 10),
make_tuple(&wrapper_vertical_16_dual_sse2,
&wrapper_vertical_16_dual_c, 12)));
#else
INSTANTIATE_TEST_CASE_P(
SSE2_C_COMPARE_DUAL, Loop8Test6Param,
::testing::Values(
make_tuple(&wrapper_vertical_16_sse2, &wrapper_vertical_16_c, 8)));
#endif // CONFIG_VP9_HIGHBITDEPTH
#endif // HAVE_SSE2
#if HAVE_SSE2
#if CONFIG_VP9_HIGHBITDEPTH
INSTANTIATE_TEST_CASE_P(
SSE_C_COMPARE_DUAL, Loop8Test9Param,
::testing::Values( ::testing::Values(
make_tuple(&vp9_highbd_lpf_horizontal_4_dual_sse2, make_tuple(&vp9_highbd_lpf_horizontal_4_dual_sse2,
&vp9_highbd_lpf_horizontal_4_dual_c, 8), &vp9_highbd_lpf_horizontal_4_dual_c, 8),
@@ -620,7 +617,7 @@ INSTANTIATE_TEST_CASE_P(
&vp9_highbd_lpf_vertical_8_dual_c, 12))); &vp9_highbd_lpf_vertical_8_dual_c, 12)));
#else #else
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, Loop8Test9Param, SSE_C_COMPARE_DUAL, Loop8Test9Param,
::testing::Values( ::testing::Values(
make_tuple(&vp9_lpf_horizontal_4_dual_sse2, make_tuple(&vp9_lpf_horizontal_4_dual_sse2,
&vp9_lpf_horizontal_4_dual_c, 8), &vp9_lpf_horizontal_4_dual_c, 8),
@@ -632,48 +629,4 @@ INSTANTIATE_TEST_CASE_P(
&vp9_lpf_vertical_8_dual_c, 8))); &vp9_lpf_vertical_8_dual_c, 8)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
#endif #endif
#if HAVE_NEON
#if CONFIG_VP9_HIGHBITDEPTH
// No neon high bitdepth functions.
#else
INSTANTIATE_TEST_CASE_P(
NEON, Loop8Test6Param,
::testing::Values(
#if HAVE_NEON_ASM
// Using #if inside the macro is unsupported on MSVS but the tests are not
// currently built for MSVS with ARM and NEON.
make_tuple(&vp9_lpf_horizontal_16_neon,
&vp9_lpf_horizontal_16_c, 8, 1),
make_tuple(&vp9_lpf_horizontal_16_neon,
&vp9_lpf_horizontal_16_c, 8, 2),
make_tuple(&wrapper_vertical_16_neon,
&wrapper_vertical_16_c, 8, 1),
make_tuple(&wrapper_vertical_16_dual_neon,
&wrapper_vertical_16_dual_c, 8, 1),
make_tuple(&vp9_lpf_horizontal_8_neon,
&vp9_lpf_horizontal_8_c, 8, 1),
make_tuple(&vp9_lpf_vertical_8_neon,
&vp9_lpf_vertical_8_c, 8, 1),
#endif // HAVE_NEON_ASM
make_tuple(&vp9_lpf_horizontal_4_neon,
&vp9_lpf_horizontal_4_c, 8, 1),
make_tuple(&vp9_lpf_vertical_4_neon,
&vp9_lpf_vertical_4_c, 8, 1)));
INSTANTIATE_TEST_CASE_P(
NEON, Loop8Test9Param,
::testing::Values(
#if HAVE_NEON_ASM
make_tuple(&vp9_lpf_horizontal_8_dual_neon,
&vp9_lpf_horizontal_8_dual_c, 8),
make_tuple(&vp9_lpf_vertical_8_dual_neon,
&vp9_lpf_vertical_8_dual_c, 8),
#endif // HAVE_NEON_ASM
make_tuple(&vp9_lpf_horizontal_4_dual_neon,
&vp9_lpf_horizontal_4_dual_c, 8),
make_tuple(&vp9_lpf_vertical_4_dual_neon,
&vp9_lpf_vertical_4_dual_c, 8)));
#endif // CONFIG_VP9_HIGHBITDEPTH
#endif // HAVE_NEON
} // namespace } // namespace

209
test/masked_sad_test.cc Normal file
View File

@@ -0,0 +1,209 @@
/*
* Copyright (c) 2015 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 <math.h>
#include <stdlib.h>
#include <string.h>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h"
#include "test/util.h"
#include "./vpx_config.h"
#include "./vp9_rtcd.h"
#include "vp9/common/vp9_entropy.h"
#include "vpx/vpx_integer.h"
using libvpx_test::ACMRandom;
namespace {
const int number_of_iterations = 500;
typedef unsigned int (*MaskedSADFunc)(const uint8_t *a, int a_stride,
const uint8_t *b, int b_stride,
const uint8_t *m, int m_stride);
typedef std::tr1::tuple<MaskedSADFunc, MaskedSADFunc> MaskedSADParam;
class MaskedSADTest : public ::testing::TestWithParam<MaskedSADParam> {
public:
virtual ~MaskedSADTest() {}
virtual void SetUp() {
maskedSAD_op_ = GET_PARAM(0);
ref_maskedSAD_op_ = GET_PARAM(1);
}
virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected:
MaskedSADFunc maskedSAD_op_;
MaskedSADFunc ref_maskedSAD_op_;
};
TEST_P(MaskedSADTest, OperationCheck) {
unsigned int ref_ret, ret;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, uint8_t, src_ptr, 4096);
DECLARE_ALIGNED_ARRAY(16, uint8_t, ref_ptr, 4096);
DECLARE_ALIGNED_ARRAY(16, uint8_t, msk_ptr, 4096);
int err_count = 0;
int first_failure = -1;
int src_stride = 64;
int ref_stride = 64;
int msk_stride = 64;
for (int i = 0; i < number_of_iterations; ++i) {
for (int j = 0; j < 4096; j++) {
src_ptr[j] = rnd.Rand8();
ref_ptr[j] = rnd.Rand8();
msk_ptr[j] = ((rnd.Rand8()&0x7f) > 64) ? rnd.Rand8()&0x3f : 64;
}
ref_ret = ref_maskedSAD_op_(src_ptr, src_stride, ref_ptr, ref_stride,
msk_ptr, msk_stride);
ASM_REGISTER_STATE_CHECK(ret = maskedSAD_op_(src_ptr, src_stride,
ref_ptr, ref_stride,
msk_ptr, msk_stride));
if (ret != ref_ret) {
err_count++;
if (first_failure == -1)
first_failure = i;
}
}
EXPECT_EQ(0, err_count)
<< "Error: Masked SAD Test, C output doesn't match SSSE3 output. "
<< "First failed at test case " << first_failure;
}
#if CONFIG_VP9_HIGHBITDEPTH
typedef unsigned int (*HighbdMaskedSADFunc)(const uint8_t *a, int a_stride,
const uint8_t *b, int b_stride,
const uint8_t *m, int m_stride);
typedef std::tr1::tuple<HighbdMaskedSADFunc, HighbdMaskedSADFunc>
HighbdMaskedSADParam;
class HighbdMaskedSADTest : public ::testing::
TestWithParam<HighbdMaskedSADParam> {
public:
virtual ~HighbdMaskedSADTest() {}
virtual void SetUp() {
maskedSAD_op_ = GET_PARAM(0);
ref_maskedSAD_op_ = GET_PARAM(1);
}
virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected:
HighbdMaskedSADFunc maskedSAD_op_;
HighbdMaskedSADFunc ref_maskedSAD_op_;
};
TEST_P(HighbdMaskedSADTest, OperationCheck) {
unsigned int ref_ret, ret;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, uint16_t, src_ptr, 4096);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_ptr, 4096);
DECLARE_ALIGNED_ARRAY(16, uint8_t, msk_ptr, 4096);
uint8_t* src8_ptr = CONVERT_TO_BYTEPTR(src_ptr);
uint8_t* ref8_ptr = CONVERT_TO_BYTEPTR(ref_ptr);
int err_count = 0;
int first_failure = -1;
int src_stride = 64;
int ref_stride = 64;
int msk_stride = 64;
for (int i = 0; i < number_of_iterations; ++i) {
for (int j = 0; j < 4096; j++) {
src_ptr[j] = rnd.Rand16()&0xfff;
ref_ptr[j] = rnd.Rand16()&0xfff;
msk_ptr[j] = ((rnd.Rand8()&0x7f) > 64) ? rnd.Rand8()&0x3f : 64;
}
ref_ret = ref_maskedSAD_op_(src8_ptr, src_stride, ref8_ptr, ref_stride,
msk_ptr, msk_stride);
ASM_REGISTER_STATE_CHECK(ret = maskedSAD_op_(src8_ptr, src_stride,
ref8_ptr, ref_stride,
msk_ptr, msk_stride));
if (ret != ref_ret) {
err_count++;
if (first_failure == -1)
first_failure = i;
}
}
EXPECT_EQ(0, err_count)
<< "Error: High BD Masked SAD Test, C output doesn't match SSSE3 output. "
<< "First failed at test case " << first_failure;
}
#endif // CONFIG_VP9_HIGHBITDEPTH
using std::tr1::make_tuple;
#if HAVE_SSSE3
INSTANTIATE_TEST_CASE_P(
SSSE3_C_COMPARE, MaskedSADTest,
::testing::Values(
make_tuple(&vp9_masked_sad64x64_ssse3,
&vp9_masked_sad64x64_c),
make_tuple(&vp9_masked_sad64x32_ssse3,
&vp9_masked_sad64x32_c),
make_tuple(&vp9_masked_sad32x64_ssse3,
&vp9_masked_sad32x64_c),
make_tuple(&vp9_masked_sad32x32_ssse3,
&vp9_masked_sad32x32_c),
make_tuple(&vp9_masked_sad32x16_ssse3,
&vp9_masked_sad32x16_c),
make_tuple(&vp9_masked_sad16x32_ssse3,
&vp9_masked_sad16x32_c),
make_tuple(&vp9_masked_sad16x16_ssse3,
&vp9_masked_sad16x16_c),
make_tuple(&vp9_masked_sad16x8_ssse3,
&vp9_masked_sad16x8_c),
make_tuple(&vp9_masked_sad8x16_ssse3,
&vp9_masked_sad8x16_c),
make_tuple(&vp9_masked_sad8x8_ssse3,
&vp9_masked_sad8x8_c),
make_tuple(&vp9_masked_sad8x4_ssse3,
&vp9_masked_sad8x4_c),
make_tuple(&vp9_masked_sad4x8_ssse3,
&vp9_masked_sad4x8_c),
make_tuple(&vp9_masked_sad4x4_ssse3,
&vp9_masked_sad4x4_c)));
#if CONFIG_VP9_HIGHBITDEPTH
INSTANTIATE_TEST_CASE_P(
SSSE3_C_COMPARE, HighbdMaskedSADTest,
::testing::Values(
make_tuple(&vp9_highbd_masked_sad64x64_ssse3,
&vp9_highbd_masked_sad64x64_c),
make_tuple(&vp9_highbd_masked_sad64x32_ssse3,
&vp9_highbd_masked_sad64x32_c),
make_tuple(&vp9_highbd_masked_sad32x64_ssse3,
&vp9_highbd_masked_sad32x64_c),
make_tuple(&vp9_highbd_masked_sad32x32_ssse3,
&vp9_highbd_masked_sad32x32_c),
make_tuple(&vp9_highbd_masked_sad32x16_ssse3,
&vp9_highbd_masked_sad32x16_c),
make_tuple(&vp9_highbd_masked_sad16x32_ssse3,
&vp9_highbd_masked_sad16x32_c),
make_tuple(&vp9_highbd_masked_sad16x16_ssse3,
&vp9_highbd_masked_sad16x16_c),
make_tuple(&vp9_highbd_masked_sad16x8_ssse3,
&vp9_highbd_masked_sad16x8_c),
make_tuple(&vp9_highbd_masked_sad8x16_ssse3,
&vp9_highbd_masked_sad8x16_c),
make_tuple(&vp9_highbd_masked_sad8x8_ssse3,
&vp9_highbd_masked_sad8x8_c),
make_tuple(&vp9_highbd_masked_sad8x4_ssse3,
&vp9_highbd_masked_sad8x4_c),
make_tuple(&vp9_highbd_masked_sad4x8_ssse3,
&vp9_highbd_masked_sad4x8_c),
make_tuple(&vp9_highbd_masked_sad4x4_ssse3,
&vp9_highbd_masked_sad4x4_c)));
#endif // CONFIG_VP9_HIGHBITDEPTH
#endif // HAVE_SSSE3
} // namespace

View File

@@ -0,0 +1,753 @@
/*
* Copyright (c) 2015 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 <math.h>
#include <stdlib.h>
#include <string.h>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h"
#include "test/util.h"
#include "./vpx_config.h"
#include "./vp9_rtcd.h"
#include "vp9/common/vp9_entropy.h"
#include "vpx/vpx_integer.h"
#include "vp9/common/vp9_filter.h"
#define MAX_SIZE 64
using libvpx_test::ACMRandom;
namespace {
const int number_of_iterations = 500;
typedef unsigned int (*MaskedVarianceFunc)(const uint8_t *a, int a_stride,
const uint8_t *b, int b_stride,
const uint8_t *m, int m_stride,
unsigned int *sse);
typedef std::tr1::tuple<MaskedVarianceFunc,
MaskedVarianceFunc> MaskedVarianceParam;
class MaskedVarianceTest :
public ::testing::TestWithParam<MaskedVarianceParam> {
public:
virtual ~MaskedVarianceTest() {}
virtual void SetUp() {
opt_func_ = GET_PARAM(0);
ref_func_ = GET_PARAM(1);
}
virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected:
MaskedVarianceFunc opt_func_;
MaskedVarianceFunc ref_func_;
};
TEST_P(MaskedVarianceTest, OperationCheck) {
unsigned int ref_ret, opt_ret;
unsigned int ref_sse, opt_sse;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, uint8_t, src_ptr, MAX_SIZE*MAX_SIZE);
DECLARE_ALIGNED_ARRAY(16, uint8_t, ref_ptr, MAX_SIZE*MAX_SIZE);
DECLARE_ALIGNED_ARRAY(16, uint8_t, msk_ptr, MAX_SIZE*MAX_SIZE);
int err_count = 0;
int first_failure = -1;
int src_stride = MAX_SIZE;
int ref_stride = MAX_SIZE;
int msk_stride = MAX_SIZE;
for (int i = 0; i < number_of_iterations; ++i) {
for (int j = 0; j < MAX_SIZE*MAX_SIZE; j++) {
src_ptr[j] = rnd.Rand8();
ref_ptr[j] = rnd.Rand8();
msk_ptr[j] = rnd(65);
}
ref_ret = ref_func_(src_ptr, src_stride,
ref_ptr, ref_stride,
msk_ptr, msk_stride,
&ref_sse);
ASM_REGISTER_STATE_CHECK(opt_ret = opt_func_(src_ptr, src_stride,
ref_ptr, ref_stride,
msk_ptr, msk_stride,
&opt_sse));
if (opt_ret != ref_ret || opt_sse != ref_sse) {
err_count++;
if (first_failure == -1)
first_failure = i;
}
}
EXPECT_EQ(0, err_count)
<< "Error: Masked Variance Test OperationCheck,"
<< "C output doesn't match SSSE3 output. "
<< "First failed at test case " << first_failure;
}
TEST_P(MaskedVarianceTest, ExtremeValues) {
unsigned int ref_ret, opt_ret;
unsigned int ref_sse, opt_sse;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, uint8_t, src_ptr, MAX_SIZE*MAX_SIZE);
DECLARE_ALIGNED_ARRAY(16, uint8_t, ref_ptr, MAX_SIZE*MAX_SIZE);
DECLARE_ALIGNED_ARRAY(16, uint8_t, msk_ptr, MAX_SIZE*MAX_SIZE);
int err_count = 0;
int first_failure = -1;
int src_stride = MAX_SIZE;
int ref_stride = MAX_SIZE;
int msk_stride = MAX_SIZE;
for (int i = 0; i < 8; ++i) {
memset(src_ptr, (i & 0x1) ? 255 : 0, MAX_SIZE*MAX_SIZE);
memset(ref_ptr, (i & 0x2) ? 255 : 0, MAX_SIZE*MAX_SIZE);
memset(msk_ptr, (i & 0x4) ? 64 : 0, MAX_SIZE*MAX_SIZE);
ref_ret = ref_func_(src_ptr, src_stride,
ref_ptr, ref_stride,
msk_ptr, msk_stride,
&ref_sse);
ASM_REGISTER_STATE_CHECK(opt_ret = opt_func_(src_ptr, src_stride,
ref_ptr, ref_stride,
msk_ptr, msk_stride,
&opt_sse));
if (opt_ret != ref_ret || opt_sse != ref_sse) {
err_count++;
if (first_failure == -1)
first_failure = i;
}
}
EXPECT_EQ(0, err_count)
<< "Error: Masked Variance Test ExtremeValues,"
<< "C output doesn't match SSSE3 output. "
<< "First failed at test case " << first_failure;
}
typedef unsigned int (*MaskedSubPixelVarianceFunc)(
const uint8_t *a, int a_stride,
int xoffset, int yoffset,
const uint8_t *b, int b_stride,
const uint8_t *m, int m_stride,
unsigned int *sse);
typedef std::tr1::tuple<MaskedSubPixelVarianceFunc,
MaskedSubPixelVarianceFunc> MaskedSubPixelVarianceParam;
class MaskedSubPixelVarianceTest :
public ::testing::TestWithParam<MaskedSubPixelVarianceParam> {
public:
virtual ~MaskedSubPixelVarianceTest() {}
virtual void SetUp() {
opt_func_ = GET_PARAM(0);
ref_func_ = GET_PARAM(1);
}
virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected:
MaskedSubPixelVarianceFunc opt_func_;
MaskedSubPixelVarianceFunc ref_func_;
};
TEST_P(MaskedSubPixelVarianceTest, OperationCheck) {
unsigned int ref_ret, opt_ret;
unsigned int ref_sse, opt_sse;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, uint8_t, src_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
DECLARE_ALIGNED_ARRAY(16, uint8_t, ref_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
DECLARE_ALIGNED_ARRAY(16, uint8_t, msk_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
int err_count = 0;
int first_failure = -1;
int src_stride = (MAX_SIZE+1);
int ref_stride = (MAX_SIZE+1);
int msk_stride = (MAX_SIZE+1);
int xoffset;
int yoffset;
for (int i = 0; i < number_of_iterations; ++i) {
int xoffsets[] = {0, 8, rnd(SUBPEL_SHIFTS)};
int yoffsets[] = {0, 8, rnd(SUBPEL_SHIFTS)};
for (int j = 0; j < (MAX_SIZE+1)*(MAX_SIZE+1); j++) {
src_ptr[j] = rnd.Rand8();
ref_ptr[j] = rnd.Rand8();
msk_ptr[j] = rnd(65);
}
for (int k = 0; k < 3; k++) {
xoffset = xoffsets[k];
for (int l = 0; l < 3; l++) {
xoffset = xoffsets[k];
yoffset = yoffsets[l];
ref_ret = ref_func_(src_ptr, src_stride,
xoffset, yoffset,
ref_ptr, ref_stride,
msk_ptr, msk_stride,
&ref_sse);
ASM_REGISTER_STATE_CHECK(opt_ret = opt_func_(src_ptr, src_stride,
xoffset, yoffset,
ref_ptr, ref_stride,
msk_ptr, msk_stride,
&opt_sse));
if (opt_ret != ref_ret || opt_sse != ref_sse) {
err_count++;
if (first_failure == -1)
first_failure = i;
}
}
}
}
EXPECT_EQ(0, err_count)
<< "Error: Masked Sub Pixel Variance Test OperationCheck,"
<< "C output doesn't match SSSE3 output. "
<< "First failed at test case " << first_failure;
}
TEST_P(MaskedSubPixelVarianceTest, ExtremeValues) {
unsigned int ref_ret, opt_ret;
unsigned int ref_sse, opt_sse;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, uint8_t, src_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
DECLARE_ALIGNED_ARRAY(16, uint8_t, ref_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
DECLARE_ALIGNED_ARRAY(16, uint8_t, msk_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
int first_failure_x = -1;
int first_failure_y = -1;
int err_count = 0;
int first_failure = -1;
int src_stride = (MAX_SIZE+1);
int ref_stride = (MAX_SIZE+1);
int msk_stride = (MAX_SIZE+1);
for (int xoffset = 0 ; xoffset < SUBPEL_SHIFTS ; xoffset++) {
for (int yoffset = 0 ; yoffset < SUBPEL_SHIFTS ; yoffset++) {
for (int i = 0; i < 8; ++i) {
memset(src_ptr, (i & 0x1) ? 255 : 0, (MAX_SIZE+1)*(MAX_SIZE+1));
memset(ref_ptr, (i & 0x2) ? 255 : 0, (MAX_SIZE+1)*(MAX_SIZE+1));
memset(msk_ptr, (i & 0x4) ? 64 : 0, (MAX_SIZE+1)*(MAX_SIZE+1));
ref_ret = ref_func_(src_ptr, src_stride,
xoffset, yoffset,
ref_ptr, ref_stride,
msk_ptr, msk_stride,
&ref_sse);
ASM_REGISTER_STATE_CHECK(opt_ret = opt_func_(src_ptr, src_stride,
xoffset, yoffset,
ref_ptr, ref_stride,
msk_ptr, msk_stride,
&opt_sse));
if (opt_ret != ref_ret || opt_sse != ref_sse) {
err_count++;
if (first_failure == -1) {
first_failure = i;
first_failure_x = xoffset;
first_failure_y = yoffset;
}
}
}
}
}
EXPECT_EQ(0, err_count)
<< "Error: Masked Variance Test ExtremeValues,"
<< "C output doesn't match SSSE3 output. "
<< "First failed at test case " << first_failure
<< " x_offset = " << first_failure_x
<< " y_offset = " << first_failure_y;
}
#if CONFIG_VP9_HIGHBITDEPTH
typedef std::tr1::tuple<MaskedVarianceFunc,
MaskedVarianceFunc,
vpx_bit_depth_t> HighbdMaskedVarianceParam;
class HighbdMaskedVarianceTest :
public ::testing::TestWithParam<HighbdMaskedVarianceParam> {
public:
virtual ~HighbdMaskedVarianceTest() {}
virtual void SetUp() {
opt_func_ = GET_PARAM(0);
ref_func_ = GET_PARAM(1);
bit_depth_ = GET_PARAM(2);
}
virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected:
MaskedVarianceFunc opt_func_;
MaskedVarianceFunc ref_func_;
vpx_bit_depth_t bit_depth_;
};
TEST_P(HighbdMaskedVarianceTest, OperationCheck) {
unsigned int ref_ret, opt_ret;
unsigned int ref_sse, opt_sse;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, uint16_t, src_ptr, MAX_SIZE*MAX_SIZE);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_ptr, MAX_SIZE*MAX_SIZE);
DECLARE_ALIGNED_ARRAY(16, uint8_t, msk_ptr, MAX_SIZE*MAX_SIZE);
uint8_t* src8_ptr = CONVERT_TO_BYTEPTR(src_ptr);
uint8_t* ref8_ptr = CONVERT_TO_BYTEPTR(ref_ptr);
int err_count = 0;
int first_failure = -1;
int src_stride = MAX_SIZE;
int ref_stride = MAX_SIZE;
int msk_stride = MAX_SIZE;
for (int i = 0; i < number_of_iterations; ++i) {
for (int j = 0; j < MAX_SIZE*MAX_SIZE; j++) {
src_ptr[j] = rnd.Rand16() & ((1 << bit_depth_) - 1);
ref_ptr[j] = rnd.Rand16() & ((1 << bit_depth_) - 1);
msk_ptr[j] = rnd(65);
}
ref_ret = ref_func_(src8_ptr, src_stride,
ref8_ptr, ref_stride,
msk_ptr, msk_stride,
&ref_sse);
ASM_REGISTER_STATE_CHECK(opt_ret = opt_func_(src8_ptr, src_stride,
ref8_ptr, ref_stride,
msk_ptr, msk_stride,
&opt_sse));
if (opt_ret != ref_ret || opt_sse != ref_sse) {
err_count++;
if (first_failure == -1)
first_failure = i;
}
}
EXPECT_EQ(0, err_count)
<< "Error: Masked Variance Test OperationCheck,"
<< "C output doesn't match SSSE3 output. "
<< "First failed at test case " << first_failure;
}
TEST_P(HighbdMaskedVarianceTest, ExtremeValues) {
unsigned int ref_ret, opt_ret;
unsigned int ref_sse, opt_sse;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, uint16_t, src_ptr, MAX_SIZE*MAX_SIZE);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_ptr, MAX_SIZE*MAX_SIZE);
DECLARE_ALIGNED_ARRAY(16, uint8_t, msk_ptr, MAX_SIZE*MAX_SIZE);
uint8_t* src8_ptr = CONVERT_TO_BYTEPTR(src_ptr);
uint8_t* ref8_ptr = CONVERT_TO_BYTEPTR(ref_ptr);
int err_count = 0;
int first_failure = -1;
int src_stride = MAX_SIZE;
int ref_stride = MAX_SIZE;
int msk_stride = MAX_SIZE;
for (int i = 0; i < 8; ++i) {
vpx_memset16(src_ptr, (i & 0x1) ? ((1 << bit_depth_) - 1) : 0,
MAX_SIZE*MAX_SIZE);
vpx_memset16(ref_ptr, (i & 0x2) ? ((1 << bit_depth_) - 1) : 0,
MAX_SIZE*MAX_SIZE);
memset(msk_ptr, (i & 0x4) ? 64 : 0, MAX_SIZE*MAX_SIZE);
ref_ret = ref_func_(src8_ptr, src_stride,
ref8_ptr, ref_stride,
msk_ptr, msk_stride,
&ref_sse);
ASM_REGISTER_STATE_CHECK(opt_ret = opt_func_(src8_ptr, src_stride,
ref8_ptr, ref_stride,
msk_ptr, msk_stride,
&opt_sse));
if (opt_ret != ref_ret || opt_sse != ref_sse) {
err_count++;
if (first_failure == -1)
first_failure = i;
}
}
EXPECT_EQ(0, err_count)
<< "Error: Masked Variance Test ExtremeValues,"
<< "C output doesn't match SSSE3 output. "
<< "First failed at test case " << first_failure;
}
typedef std::tr1::tuple<MaskedSubPixelVarianceFunc,
MaskedSubPixelVarianceFunc,
vpx_bit_depth_t> HighbdMaskedSubPixelVarianceParam;
class HighbdMaskedSubPixelVarianceTest :
public ::testing::TestWithParam<HighbdMaskedSubPixelVarianceParam> {
public:
virtual ~HighbdMaskedSubPixelVarianceTest() {}
virtual void SetUp() {
opt_func_ = GET_PARAM(0);
ref_func_ = GET_PARAM(1);
bit_depth_ = GET_PARAM(2);
}
virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected:
MaskedSubPixelVarianceFunc opt_func_;
MaskedSubPixelVarianceFunc ref_func_;
vpx_bit_depth_t bit_depth_;
};
TEST_P(HighbdMaskedSubPixelVarianceTest, OperationCheck) {
unsigned int ref_ret, opt_ret;
unsigned int ref_sse, opt_sse;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, uint16_t, src_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
DECLARE_ALIGNED_ARRAY(16, uint8_t, msk_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
uint8_t* src8_ptr = CONVERT_TO_BYTEPTR(src_ptr);
uint8_t* ref8_ptr = CONVERT_TO_BYTEPTR(ref_ptr);
int err_count = 0;
int first_failure = -1;
int first_failure_x = -1;
int first_failure_y = -1;
int src_stride = (MAX_SIZE+1);
int ref_stride = (MAX_SIZE+1);
int msk_stride = (MAX_SIZE+1);
int xoffset, yoffset;
for (int i = 0; i < number_of_iterations; ++i) {
for (xoffset = 0; xoffset < SUBPEL_SHIFTS; xoffset++) {
for (yoffset = 0; yoffset < SUBPEL_SHIFTS; yoffset++) {
for (int j = 0; j < (MAX_SIZE+1)*(MAX_SIZE+1); j++) {
src_ptr[j] = rnd.Rand16() & ((1 << bit_depth_) - 1);
ref_ptr[j] = rnd.Rand16() & ((1 << bit_depth_) - 1);
msk_ptr[j] = rnd(65);
}
ref_ret = ref_func_(src8_ptr, src_stride,
xoffset, yoffset,
ref8_ptr, ref_stride,
msk_ptr, msk_stride,
&ref_sse);
ASM_REGISTER_STATE_CHECK(opt_ret = opt_func_(src8_ptr, src_stride,
xoffset, yoffset,
ref8_ptr, ref_stride,
msk_ptr, msk_stride,
&opt_sse));
if (opt_ret != ref_ret || opt_sse != ref_sse) {
err_count++;
if (first_failure == -1) {
first_failure = i;
first_failure_x = xoffset;
first_failure_y = yoffset;
}
}
}
}
}
EXPECT_EQ(0, err_count)
<< "Error: Masked Sub Pixel Variance Test OperationCheck,"
<< "C output doesn't match SSSE3 output. "
<< "First failed at test case " << first_failure
<< " x_offset = " << first_failure_x
<< " y_offset = " << first_failure_y;
}
TEST_P(HighbdMaskedSubPixelVarianceTest, ExtremeValues) {
unsigned int ref_ret, opt_ret;
unsigned int ref_sse, opt_sse;
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, uint16_t, src_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
DECLARE_ALIGNED_ARRAY(16, uint8_t, msk_ptr, (MAX_SIZE+1)*(MAX_SIZE+1));
uint8_t* src8_ptr = CONVERT_TO_BYTEPTR(src_ptr);
uint8_t* ref8_ptr = CONVERT_TO_BYTEPTR(ref_ptr);
int first_failure_x = -1;
int first_failure_y = -1;
int err_count = 0;
int first_failure = -1;
int src_stride = (MAX_SIZE+1);
int ref_stride = (MAX_SIZE+1);
int msk_stride = (MAX_SIZE+1);
for (int xoffset = 0 ; xoffset < SUBPEL_SHIFTS ; xoffset++) {
for (int yoffset = 0 ; yoffset < SUBPEL_SHIFTS ; yoffset++) {
for (int i = 0; i < 8; ++i) {
vpx_memset16(src_ptr, (i & 0x1) ? ((1 << bit_depth_) - 1) : 0,
(MAX_SIZE+1)*(MAX_SIZE+1));
vpx_memset16(ref_ptr, (i & 0x2) ? ((1 << bit_depth_) - 1) : 0,
(MAX_SIZE+1)*(MAX_SIZE+1));
memset(msk_ptr, (i & 0x4) ? 64 : 0, (MAX_SIZE+1)*(MAX_SIZE+1));
ref_ret = ref_func_(src8_ptr, src_stride,
xoffset, yoffset,
ref8_ptr, ref_stride,
msk_ptr, msk_stride,
&ref_sse);
ASM_REGISTER_STATE_CHECK(opt_ret = opt_func_(src8_ptr, src_stride,
xoffset, yoffset,
ref8_ptr, ref_stride,
msk_ptr, msk_stride,
&opt_sse));
if (opt_ret != ref_ret || opt_sse != ref_sse) {
err_count++;
if (first_failure == -1) {
first_failure = i;
first_failure_x = xoffset;
first_failure_y = yoffset;
}
}
}
}
}
EXPECT_EQ(0, err_count)
<< "Error: Masked Variance Test ExtremeValues,"
<< "C output doesn't match SSSE3 output. "
<< "First failed at test case " << first_failure
<< " x_offset = " << first_failure_x
<< " y_offset = " << first_failure_y;
}
#endif // CONFIG_VP9_HIGHBITDEPTH
using std::tr1::make_tuple;
#if HAVE_SSSE3
INSTANTIATE_TEST_CASE_P(
SSSE3_C_COMPARE, MaskedVarianceTest,
::testing::Values(
make_tuple(&vp9_masked_variance64x64_ssse3,
&vp9_masked_variance64x64_c),
make_tuple(&vp9_masked_variance64x32_ssse3,
&vp9_masked_variance64x32_c),
make_tuple(&vp9_masked_variance32x64_ssse3,
&vp9_masked_variance32x64_c),
make_tuple(&vp9_masked_variance32x32_ssse3,
&vp9_masked_variance32x32_c),
make_tuple(&vp9_masked_variance32x16_ssse3,
&vp9_masked_variance32x16_c),
make_tuple(&vp9_masked_variance16x32_ssse3,
&vp9_masked_variance16x32_c),
make_tuple(&vp9_masked_variance16x16_ssse3,
&vp9_masked_variance16x16_c),
make_tuple(&vp9_masked_variance16x8_ssse3,
&vp9_masked_variance16x8_c),
make_tuple(&vp9_masked_variance8x16_ssse3,
&vp9_masked_variance8x16_c),
make_tuple(&vp9_masked_variance8x8_ssse3,
&vp9_masked_variance8x8_c),
make_tuple(&vp9_masked_variance8x4_ssse3,
&vp9_masked_variance8x4_c),
make_tuple(&vp9_masked_variance4x8_ssse3,
&vp9_masked_variance4x8_c),
make_tuple(&vp9_masked_variance4x4_ssse3,
&vp9_masked_variance4x4_c)));
INSTANTIATE_TEST_CASE_P(
SSSE3_C_COMPARE, MaskedSubPixelVarianceTest,
::testing::Values(
make_tuple(&vp9_masked_sub_pixel_variance64x64_ssse3,
&vp9_masked_sub_pixel_variance64x64_c),
make_tuple(&vp9_masked_sub_pixel_variance64x32_ssse3,
&vp9_masked_sub_pixel_variance64x32_c),
make_tuple(&vp9_masked_sub_pixel_variance32x64_ssse3,
&vp9_masked_sub_pixel_variance32x64_c),
make_tuple(&vp9_masked_sub_pixel_variance32x32_ssse3,
&vp9_masked_sub_pixel_variance32x32_c),
make_tuple(&vp9_masked_sub_pixel_variance32x16_ssse3,
&vp9_masked_sub_pixel_variance32x16_c),
make_tuple(&vp9_masked_sub_pixel_variance16x32_ssse3,
&vp9_masked_sub_pixel_variance16x32_c),
make_tuple(&vp9_masked_sub_pixel_variance16x16_ssse3,
&vp9_masked_sub_pixel_variance16x16_c),
make_tuple(&vp9_masked_sub_pixel_variance16x8_ssse3,
&vp9_masked_sub_pixel_variance16x8_c),
make_tuple(&vp9_masked_sub_pixel_variance8x16_ssse3,
&vp9_masked_sub_pixel_variance8x16_c),
make_tuple(&vp9_masked_sub_pixel_variance8x8_ssse3,
&vp9_masked_sub_pixel_variance8x8_c),
make_tuple(&vp9_masked_sub_pixel_variance8x4_ssse3,
&vp9_masked_sub_pixel_variance8x4_c),
make_tuple(&vp9_masked_sub_pixel_variance4x8_ssse3,
&vp9_masked_sub_pixel_variance4x8_c),
make_tuple(&vp9_masked_sub_pixel_variance4x4_ssse3,
&vp9_masked_sub_pixel_variance4x4_c)));
#if CONFIG_VP9_HIGHBITDEPTH
INSTANTIATE_TEST_CASE_P(
SSSE3_C_COMPARE, HighbdMaskedVarianceTest,
::testing::Values(
make_tuple(&vp9_highbd_masked_variance64x64_ssse3,
&vp9_highbd_masked_variance64x64_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance64x32_ssse3,
&vp9_highbd_masked_variance64x32_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance32x64_ssse3,
&vp9_highbd_masked_variance32x64_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance32x32_ssse3,
&vp9_highbd_masked_variance32x32_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance32x16_ssse3,
&vp9_highbd_masked_variance32x16_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance16x32_ssse3,
&vp9_highbd_masked_variance16x32_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance16x16_ssse3,
&vp9_highbd_masked_variance16x16_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance16x8_ssse3,
&vp9_highbd_masked_variance16x8_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance8x16_ssse3,
&vp9_highbd_masked_variance8x16_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance8x8_ssse3,
&vp9_highbd_masked_variance8x8_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance8x4_ssse3,
&vp9_highbd_masked_variance8x4_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance4x8_ssse3,
&vp9_highbd_masked_variance4x8_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_variance4x4_ssse3,
&vp9_highbd_masked_variance4x4_c, VPX_BITS_8),
make_tuple(&vp9_highbd_10_masked_variance64x64_ssse3,
&vp9_highbd_10_masked_variance64x64_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance64x32_ssse3,
&vp9_highbd_10_masked_variance64x32_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance32x64_ssse3,
&vp9_highbd_10_masked_variance32x64_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance32x32_ssse3,
&vp9_highbd_10_masked_variance32x32_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance32x16_ssse3,
&vp9_highbd_10_masked_variance32x16_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance16x32_ssse3,
&vp9_highbd_10_masked_variance16x32_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance16x16_ssse3,
&vp9_highbd_10_masked_variance16x16_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance16x8_ssse3,
&vp9_highbd_10_masked_variance16x8_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance8x16_ssse3,
&vp9_highbd_10_masked_variance8x16_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance8x8_ssse3,
&vp9_highbd_10_masked_variance8x8_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance8x4_ssse3,
&vp9_highbd_10_masked_variance8x4_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance4x8_ssse3,
&vp9_highbd_10_masked_variance4x8_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_variance4x4_ssse3,
&vp9_highbd_10_masked_variance4x4_c, VPX_BITS_10),
make_tuple(&vp9_highbd_12_masked_variance64x64_ssse3,
&vp9_highbd_12_masked_variance64x64_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance64x32_ssse3,
&vp9_highbd_12_masked_variance64x32_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance32x64_ssse3,
&vp9_highbd_12_masked_variance32x64_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance32x32_ssse3,
&vp9_highbd_12_masked_variance32x32_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance32x16_ssse3,
&vp9_highbd_12_masked_variance32x16_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance16x32_ssse3,
&vp9_highbd_12_masked_variance16x32_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance16x16_ssse3,
&vp9_highbd_12_masked_variance16x16_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance16x8_ssse3,
&vp9_highbd_12_masked_variance16x8_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance8x16_ssse3,
&vp9_highbd_12_masked_variance8x16_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance8x8_ssse3,
&vp9_highbd_12_masked_variance8x8_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance8x4_ssse3,
&vp9_highbd_12_masked_variance8x4_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance4x8_ssse3,
&vp9_highbd_12_masked_variance4x8_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_variance4x4_ssse3,
&vp9_highbd_12_masked_variance4x4_c, VPX_BITS_12)));
INSTANTIATE_TEST_CASE_P(
SSSE3_C_COMPARE, HighbdMaskedSubPixelVarianceTest,
::testing::Values(
make_tuple(&vp9_highbd_masked_sub_pixel_variance64x64_ssse3,
&vp9_highbd_masked_sub_pixel_variance64x64_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance64x32_ssse3,
&vp9_highbd_masked_sub_pixel_variance64x32_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance32x64_ssse3,
&vp9_highbd_masked_sub_pixel_variance32x64_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance32x32_ssse3,
&vp9_highbd_masked_sub_pixel_variance32x32_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance32x16_ssse3,
&vp9_highbd_masked_sub_pixel_variance32x16_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance16x32_ssse3,
&vp9_highbd_masked_sub_pixel_variance16x32_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance16x16_ssse3,
&vp9_highbd_masked_sub_pixel_variance16x16_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance16x8_ssse3,
&vp9_highbd_masked_sub_pixel_variance16x8_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance8x16_ssse3,
&vp9_highbd_masked_sub_pixel_variance8x16_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance8x8_ssse3,
&vp9_highbd_masked_sub_pixel_variance8x8_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance8x4_ssse3,
&vp9_highbd_masked_sub_pixel_variance8x4_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance4x8_ssse3,
&vp9_highbd_masked_sub_pixel_variance4x8_c, VPX_BITS_8),
make_tuple(&vp9_highbd_masked_sub_pixel_variance4x4_ssse3,
&vp9_highbd_masked_sub_pixel_variance4x4_c, VPX_BITS_8),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance64x64_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance64x64_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance64x32_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance64x32_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance32x64_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance32x64_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance32x32_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance32x32_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance32x16_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance32x16_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance16x32_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance16x32_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance16x16_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance16x16_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance16x8_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance16x8_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance8x16_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance8x16_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance8x8_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance8x8_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance8x4_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance8x4_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance4x8_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance4x8_c, VPX_BITS_10),
make_tuple(&vp9_highbd_10_masked_sub_pixel_variance4x4_ssse3,
&vp9_highbd_10_masked_sub_pixel_variance4x4_c, VPX_BITS_10),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance64x64_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance64x64_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance64x32_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance64x32_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance32x64_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance32x64_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance32x32_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance32x32_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance32x16_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance32x16_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance16x32_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance16x32_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance16x16_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance16x16_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance16x8_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance16x8_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance8x16_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance8x16_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance8x8_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance8x8_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance8x4_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance8x4_c, VPX_BITS_12) ,
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance4x8_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance4x8_c, VPX_BITS_12),
make_tuple(&vp9_highbd_12_masked_sub_pixel_variance4x4_ssse3,
&vp9_highbd_12_masked_sub_pixel_variance4x4_c, VPX_BITS_12)));
#endif // CONFIG_VP9_HIGHBITDEPTH
#endif // HAVE_SSSE3
} // namespace

View File

@@ -230,7 +230,7 @@ INSTANTIATE_TEST_CASE_P(
&vp9_idct4x4_1_add_c, &vp9_idct4x4_1_add_c,
TX_4X4, 1))); TX_4X4, 1)));
#if HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_NEON_ASM
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
NEON, PartialIDctTest, NEON, PartialIDctTest,
::testing::Values( ::testing::Values(
@@ -258,7 +258,7 @@ INSTANTIATE_TEST_CASE_P(
&vp9_idct4x4_16_add_c, &vp9_idct4x4_16_add_c,
&vp9_idct4x4_1_add_neon, &vp9_idct4x4_1_add_neon,
TX_4X4, 1))); TX_4X4, 1)));
#endif // HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #endif
#if HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE #if HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
@@ -305,4 +305,13 @@ INSTANTIATE_TEST_CASE_P(
TX_8X8, 12))); TX_8X8, 12)));
#endif #endif
#if HAVE_SSSE3 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P(
SSSE3, PartialIDctTest,
::testing::Values(
make_tuple(&vp9_fdct16x16_c,
&vp9_idct16x16_256_add_c,
&vp9_idct16x16_10_add_ssse3,
TX_16X16, 10)));
#endif
} // namespace } // namespace

View File

@@ -63,12 +63,12 @@ TEST_P(VP8PostProcessingFilterTest, FilterOutputCheck) {
uint8_t *const dst_image_ptr = dst_image + 8; uint8_t *const dst_image_ptr = dst_image + 8;
uint8_t *const flimits = uint8_t *const flimits =
reinterpret_cast<uint8_t *>(vpx_memalign(16, block_width)); reinterpret_cast<uint8_t *>(vpx_memalign(16, block_width));
(void)memset(flimits, 255, block_width); (void)vpx_memset(flimits, 255, block_width);
// Initialize pixels in the input: // Initialize pixels in the input:
// block pixels to value 1, // block pixels to value 1,
// border pixels to value 10. // border pixels to value 10.
(void)memset(src_image, 10, input_size); (void)vpx_memset(src_image, 10, input_size);
uint8_t *pixel_ptr = src_image_ptr; uint8_t *pixel_ptr = src_image_ptr;
for (int i = 0; i < block_height; ++i) { for (int i = 0; i < block_height; ++i) {
for (int j = 0; j < block_width; ++j) { for (int j = 0; j < block_width; ++j) {
@@ -78,7 +78,7 @@ TEST_P(VP8PostProcessingFilterTest, FilterOutputCheck) {
} }
// Initialize pixels in the output to 99. // Initialize pixels in the output to 99.
(void)memset(dst_image, 99, output_size); (void)vpx_memset(dst_image, 99, output_size);
ASM_REGISTER_STATE_CHECK( ASM_REGISTER_STATE_CHECK(
GetParam()(src_image_ptr, dst_image_ptr, input_stride, GetParam()(src_image_ptr, dst_image_ptr, input_stride,

View File

@@ -8,6 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <math.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
@@ -17,179 +19,326 @@
#include "test/util.h" #include "test/util.h"
#include "./vpx_config.h" #include "./vpx_config.h"
#include "./vp8_rtcd.h" #include "./vp9_rtcd.h"
#include "vp8/common/blockd.h" #include "vp9/common/vp9_entropy.h"
#include "vp8/common/onyx.h"
#include "vp8/encoder/block.h"
#include "vp8/encoder/onyx_int.h"
#include "vp8/encoder/quantize.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
#include "vpx_mem/vpx_mem.h"
namespace {
const int kNumBlocks = 25;
const int kNumBlockEntries = 16;
typedef void (*VP8Quantize)(BLOCK *b, BLOCKD *d);
typedef std::tr1::tuple<VP8Quantize, VP8Quantize> VP8QuantizeParam;
using libvpx_test::ACMRandom; using libvpx_test::ACMRandom;
using std::tr1::make_tuple;
// Create and populate a VP8_COMP instance which has a complete set of namespace {
// quantization inputs as well as a second MACROBLOCKD for output. #if CONFIG_VP9_HIGHBITDEPTH
class QuantizeTestBase { const int number_of_iterations = 100;
typedef void (*QuantizeFunc)(const tran_low_t *coeff, intptr_t count,
int skip_block, const int16_t *zbin,
const int16_t *round, const int16_t *quant,
const int16_t *quant_shift,
tran_low_t *qcoeff, tran_low_t *dqcoeff,
const int16_t *dequant, uint16_t *eob,
const int16_t *scan, const int16_t *iscan);
typedef std::tr1::tuple<QuantizeFunc, QuantizeFunc, int>
QuantizeParam;
class QuantizeTest : public ::testing::TestWithParam<QuantizeParam> {
public: public:
virtual ~QuantizeTestBase() { virtual ~QuantizeTest() {}
vp8_remove_compressor(&vp8_comp_);
vp8_comp_ = NULL;
vpx_free(macroblockd_dst_);
macroblockd_dst_ = NULL;
libvpx_test::ClearSystemState();
}
protected:
void SetupCompressor() {
rnd_.Reset(ACMRandom::DeterministicSeed());
// The full configuration is necessary to generate the quantization tables.
VP8_CONFIG vp8_config;
memset(&vp8_config, 0, sizeof(vp8_config));
vp8_comp_ = vp8_create_compressor(&vp8_config);
// Set the tables based on a quantizer of 0.
vp8_set_quantizer(vp8_comp_, 0);
// Set up all the block/blockd pointers for the mb in vp8_comp_.
vp8cx_frame_init_quantizer(vp8_comp_);
// Copy macroblockd from the reference to get pre-set-up dequant values.
macroblockd_dst_ = reinterpret_cast<MACROBLOCKD *>(
vpx_memalign(32, sizeof(*macroblockd_dst_)));
memcpy(macroblockd_dst_, &vp8_comp_->mb.e_mbd, sizeof(*macroblockd_dst_));
// Fix block pointers - currently they point to the blocks in the reference
// structure.
vp8_setup_block_dptrs(macroblockd_dst_);
}
void UpdateQuantizer(int q) {
vp8_set_quantizer(vp8_comp_, q);
memcpy(macroblockd_dst_, &vp8_comp_->mb.e_mbd, sizeof(*macroblockd_dst_));
vp8_setup_block_dptrs(macroblockd_dst_);
}
void FillCoeffConstant(int16_t c) {
for (int i = 0; i < kNumBlocks * kNumBlockEntries; ++i) {
vp8_comp_->mb.coeff[i] = c;
}
}
void FillCoeffRandom() {
for (int i = 0; i < kNumBlocks * kNumBlockEntries; ++i) {
vp8_comp_->mb.coeff[i] = rnd_.Rand8();
}
}
void CheckOutput() {
EXPECT_EQ(0, memcmp(vp8_comp_->mb.e_mbd.qcoeff, macroblockd_dst_->qcoeff,
sizeof(*macroblockd_dst_->qcoeff) * kNumBlocks *
kNumBlockEntries))
<< "qcoeff mismatch";
EXPECT_EQ(0, memcmp(vp8_comp_->mb.e_mbd.dqcoeff, macroblockd_dst_->dqcoeff,
sizeof(*macroblockd_dst_->dqcoeff) * kNumBlocks *
kNumBlockEntries))
<< "dqcoeff mismatch";
EXPECT_EQ(0, memcmp(vp8_comp_->mb.e_mbd.eobs, macroblockd_dst_->eobs,
sizeof(*macroblockd_dst_->eobs) * kNumBlocks))
<< "eobs mismatch";
}
VP8_COMP *vp8_comp_;
MACROBLOCKD *macroblockd_dst_;
private:
ACMRandom rnd_;
};
class QuantizeTest : public QuantizeTestBase,
public ::testing::TestWithParam<VP8QuantizeParam> {
protected:
virtual void SetUp() { virtual void SetUp() {
SetupCompressor(); quantize_op_ = GET_PARAM(0);
asm_quant_ = GET_PARAM(0); ref_quantize_op_ = GET_PARAM(1);
c_quant_ = GET_PARAM(1); bit_depth_ = GET_PARAM(2);
mask_ = (1 << bit_depth_) - 1;
} }
void RunComparison() { virtual void TearDown() { libvpx_test::ClearSystemState(); }
for (int i = 0; i < kNumBlocks; ++i) {
ASM_REGISTER_STATE_CHECK(
c_quant_(&vp8_comp_->mb.block[i], &vp8_comp_->mb.e_mbd.block[i]));
ASM_REGISTER_STATE_CHECK(
asm_quant_(&vp8_comp_->mb.block[i], &macroblockd_dst_->block[i]));
}
CheckOutput(); protected:
int bit_depth_;
int mask_;
QuantizeFunc quantize_op_;
QuantizeFunc ref_quantize_op_;
};
class Quantize32Test : public ::testing::TestWithParam<QuantizeParam> {
public:
virtual ~Quantize32Test() {}
virtual void SetUp() {
quantize_op_ = GET_PARAM(0);
ref_quantize_op_ = GET_PARAM(1);
bit_depth_ = GET_PARAM(2);
mask_ = (1 << bit_depth_) - 1;
} }
private: virtual void TearDown() { libvpx_test::ClearSystemState(); }
VP8Quantize asm_quant_;
VP8Quantize c_quant_; protected:
int bit_depth_;
int mask_;
QuantizeFunc quantize_op_;
QuantizeFunc ref_quantize_op_;
}; };
TEST_P(QuantizeTest, TestZeroInput) { TEST_P(QuantizeTest, OperationCheck) {
FillCoeffConstant(0); ACMRandom rnd(ACMRandom::DeterministicSeed());
RunComparison(); DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff_ptr, 256);
} DECLARE_ALIGNED_ARRAY(16, int16_t, zbin_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, round_ptr, 2);
TEST_P(QuantizeTest, TestLargeNegativeInput) { DECLARE_ALIGNED_ARRAY(16, int16_t, quant_ptr, 2);
FillCoeffConstant(0); DECLARE_ALIGNED_ARRAY(16, int16_t, quant_shift_ptr, 2);
// Generate a qcoeff which contains 512/-512 (0x0100/0xFE00) to catch issues DECLARE_ALIGNED_ARRAY(16, tran_low_t, qcoeff_ptr, 256);
// like BUG=883 where the constant being compared was incorrectly initialized. DECLARE_ALIGNED_ARRAY(16, tran_low_t, dqcoeff_ptr, 256);
vp8_comp_->mb.coeff[0] = -8191; DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_qcoeff_ptr, 256);
RunComparison(); DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_dqcoeff_ptr, 256);
} DECLARE_ALIGNED_ARRAY(16, int16_t, dequant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, uint16_t, eob_ptr, 1);
TEST_P(QuantizeTest, TestRandomInput) { DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_eob_ptr, 1);
FillCoeffRandom(); int err_count_total = 0;
RunComparison(); int first_failure = -1;
} for (int i = 0; i < number_of_iterations; ++i) {
int skip_block = i == 0;
TEST_P(QuantizeTest, TestMultipleQ) { TX_SIZE sz = (TX_SIZE)(i % 3); // TX_4X4, TX_8X8 TX_16X16
for (int q = 0; q < QINDEX_RANGE; ++q) { TX_TYPE tx_type = (TX_TYPE)((i >> 2) % 3);
UpdateQuantizer(q); const scan_order *scan_order = &vp9_intra_scan_orders[sz][tx_type];
FillCoeffRandom(); int count = (4 << sz) * (4 << sz); // 16, 64, 256
RunComparison(); int err_count = 0;
*eob_ptr = rnd.Rand16();
*ref_eob_ptr = *eob_ptr;
for (int j = 0; j < count; j++) {
coeff_ptr[j] = rnd.Rand16()&mask_;
}
for (int j = 0; j < 2; j++) {
zbin_ptr[j] = rnd.Rand16()&mask_;
round_ptr[j] = rnd.Rand16();
quant_ptr[j] = rnd.Rand16();
quant_shift_ptr[j] = rnd.Rand16();
dequant_ptr[j] = rnd.Rand16();
}
ref_quantize_op_(coeff_ptr, count, skip_block, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, ref_qcoeff_ptr,
ref_dqcoeff_ptr, dequant_ptr,
ref_eob_ptr, scan_order->scan, scan_order->iscan);
ASM_REGISTER_STATE_CHECK(quantize_op_(coeff_ptr, count, skip_block,
zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr,
scan_order->scan, scan_order->iscan));
for (int j = 0; j < sz; ++j) {
err_count += (ref_qcoeff_ptr[j] != qcoeff_ptr[j]) |
(ref_dqcoeff_ptr[j] != dqcoeff_ptr[j]);
}
err_count += (*ref_eob_ptr != *eob_ptr);
if (err_count && !err_count_total) {
first_failure = i;
}
err_count_total += err_count;
} }
EXPECT_EQ(0, err_count_total)
<< "Error: Quantization Test, C output doesn't match SSE2 output. "
<< "First failed at test case " << first_failure;
} }
TEST_P(Quantize32Test, OperationCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, int16_t, zbin_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, round_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_shift_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, qcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, dqcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_qcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_dqcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, int16_t, dequant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, uint16_t, eob_ptr, 1);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_eob_ptr, 1);
int err_count_total = 0;
int first_failure = -1;
for (int i = 0; i < number_of_iterations; ++i) {
int skip_block = i == 0;
TX_SIZE sz = TX_32X32;
TX_TYPE tx_type = (TX_TYPE)(i % 4);
const scan_order *scan_order = &vp9_intra_scan_orders[sz][tx_type];
int count = (4 << sz) * (4 << sz); // 1024
int err_count = 0;
*eob_ptr = rnd.Rand16();
*ref_eob_ptr = *eob_ptr;
for (int j = 0; j < count; j++) {
coeff_ptr[j] = rnd.Rand16()&mask_;
}
for (int j = 0; j < 2; j++) {
zbin_ptr[j] = rnd.Rand16()&mask_;
round_ptr[j] = rnd.Rand16();
quant_ptr[j] = rnd.Rand16();
quant_shift_ptr[j] = rnd.Rand16();
dequant_ptr[j] = rnd.Rand16();
}
ref_quantize_op_(coeff_ptr, count, skip_block, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, ref_qcoeff_ptr,
ref_dqcoeff_ptr, dequant_ptr,
ref_eob_ptr, scan_order->scan, scan_order->iscan);
ASM_REGISTER_STATE_CHECK(quantize_op_(coeff_ptr, count, skip_block,
zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr,
scan_order->scan, scan_order->iscan));
for (int j = 0; j < sz; ++j) {
err_count += (ref_qcoeff_ptr[j] != qcoeff_ptr[j]) |
(ref_dqcoeff_ptr[j] != dqcoeff_ptr[j]);
}
err_count += (*ref_eob_ptr != *eob_ptr);
if (err_count && !err_count_total) {
first_failure = i;
}
err_count_total += err_count;
}
EXPECT_EQ(0, err_count_total)
<< "Error: Quantization Test, C output doesn't match SSE2 output. "
<< "First failed at test case " << first_failure;
}
TEST_P(QuantizeTest, EOBCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, int16_t, zbin_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, round_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_shift_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, qcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, dqcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_qcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_dqcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, int16_t, dequant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, uint16_t, eob_ptr, 1);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_eob_ptr, 1);
int err_count_total = 0;
int first_failure = -1;
for (int i = 0; i < number_of_iterations; ++i) {
int skip_block = i == 0;
TX_SIZE sz = (TX_SIZE)(i % 3); // TX_4X4, TX_8X8 TX_16X16
TX_TYPE tx_type = (TX_TYPE)((i >> 2) % 3);
const scan_order *scan_order = &vp9_intra_scan_orders[sz][tx_type];
int count = (4 << sz) * (4 << sz); // 16, 64, 256
int err_count = 0;
*eob_ptr = rnd.Rand16();
*ref_eob_ptr = *eob_ptr;
// Two random entries
for (int j = 0; j < count; j++) {
coeff_ptr[j] = 0;
}
coeff_ptr[rnd(count)] = rnd.Rand16()&mask_;
coeff_ptr[rnd(count)] = rnd.Rand16()&mask_;
for (int j = 0; j < 2; j++) {
zbin_ptr[j] = rnd.Rand16()&mask_;
round_ptr[j] = rnd.Rand16();
quant_ptr[j] = rnd.Rand16();
quant_shift_ptr[j] = rnd.Rand16();
dequant_ptr[j] = rnd.Rand16();
}
ref_quantize_op_(coeff_ptr, count, skip_block, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, ref_qcoeff_ptr,
ref_dqcoeff_ptr, dequant_ptr,
ref_eob_ptr, scan_order->scan, scan_order->iscan);
ASM_REGISTER_STATE_CHECK(quantize_op_(coeff_ptr, count, skip_block,
zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr,
scan_order->scan, scan_order->iscan));
for (int j = 0; j < sz; ++j) {
err_count += (ref_qcoeff_ptr[j] != qcoeff_ptr[j]) |
(ref_dqcoeff_ptr[j] != dqcoeff_ptr[j]);
}
err_count += (*ref_eob_ptr != *eob_ptr);
if (err_count && !err_count_total) {
first_failure = i;
}
err_count_total += err_count;
}
EXPECT_EQ(0, err_count_total)
<< "Error: Quantization Test, C output doesn't match SSE2 output. "
<< "First failed at test case " << first_failure;
}
TEST_P(Quantize32Test, EOBCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, int16_t, zbin_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, round_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_shift_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, qcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, dqcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_qcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_dqcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, int16_t, dequant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, uint16_t, eob_ptr, 1);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_eob_ptr, 1);
int err_count_total = 0;
int first_failure = -1;
for (int i = 0; i < number_of_iterations; ++i) {
int skip_block = i == 0;
TX_SIZE sz = TX_32X32;
TX_TYPE tx_type = (TX_TYPE)(i % 4);
const scan_order *scan_order = &vp9_intra_scan_orders[sz][tx_type];
int count = (4 << sz) * (4 << sz); // 1024
int err_count = 0;
*eob_ptr = rnd.Rand16();
*ref_eob_ptr = *eob_ptr;
for (int j = 0; j < count; j++) {
coeff_ptr[j] = 0;
}
// Two random entries
coeff_ptr[rnd(count)] = rnd.Rand16()&mask_;
coeff_ptr[rnd(count)] = rnd.Rand16()&mask_;
for (int j = 0; j < 2; j++) {
zbin_ptr[j] = rnd.Rand16()&mask_;
round_ptr[j] = rnd.Rand16();
quant_ptr[j] = rnd.Rand16();
quant_shift_ptr[j] = rnd.Rand16();
dequant_ptr[j] = rnd.Rand16();
}
ref_quantize_op_(coeff_ptr, count, skip_block, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, ref_qcoeff_ptr,
ref_dqcoeff_ptr, dequant_ptr,
ref_eob_ptr, scan_order->scan, scan_order->iscan);
ASM_REGISTER_STATE_CHECK(quantize_op_(coeff_ptr, count, skip_block,
zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr,
scan_order->scan, scan_order->iscan));
for (int j = 0; j < sz; ++j) {
err_count += (ref_qcoeff_ptr[j] != qcoeff_ptr[j]) |
(ref_dqcoeff_ptr[j] != dqcoeff_ptr[j]);
}
err_count += (*ref_eob_ptr != *eob_ptr);
if (err_count && !err_count_total) {
first_failure = i;
}
err_count_total += err_count;
}
EXPECT_EQ(0, err_count_total)
<< "Error: Quantization Test, C output doesn't match SSE2 output. "
<< "First failed at test case " << first_failure;
}
using std::tr1::make_tuple;
#if HAVE_SSE2 #if HAVE_SSE2
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, QuantizeTest, SSE2_C_COMPARE, QuantizeTest,
::testing::Values( ::testing::Values(
make_tuple(&vp8_fast_quantize_b_sse2, &vp8_fast_quantize_b_c), make_tuple(&vp9_highbd_quantize_b_sse2,
make_tuple(&vp8_regular_quantize_b_sse2, &vp8_regular_quantize_b_c))); &vp9_highbd_quantize_b_c, 8),
#endif // HAVE_SSE2 make_tuple(&vp9_highbd_quantize_b_sse2,
&vp9_highbd_quantize_b_c, 10),
#if HAVE_SSSE3 make_tuple(&vp9_highbd_quantize_b_sse2,
INSTANTIATE_TEST_CASE_P(SSSE3, QuantizeTest, &vp9_highbd_quantize_b_c, 12)));
::testing::Values(make_tuple(&vp8_fast_quantize_b_ssse3,
&vp8_fast_quantize_b_c)));
#endif // HAVE_SSSE3
#if HAVE_SSE4_1
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE4_1, QuantizeTest, SSE2_C_COMPARE, Quantize32Test,
::testing::Values(make_tuple(&vp8_regular_quantize_b_sse4_1, ::testing::Values(
&vp8_regular_quantize_b_c))); make_tuple(&vp9_highbd_quantize_b_32x32_sse2,
#endif // HAVE_SSE4_1 &vp9_highbd_quantize_b_32x32_c, 8),
make_tuple(&vp9_highbd_quantize_b_32x32_sse2,
#if HAVE_NEON &vp9_highbd_quantize_b_32x32_c, 10),
INSTANTIATE_TEST_CASE_P(NEON, QuantizeTest, make_tuple(&vp9_highbd_quantize_b_32x32_sse2,
::testing::Values(make_tuple(&vp8_fast_quantize_b_neon, &vp9_highbd_quantize_b_32x32_c, 12)));
&vp8_fast_quantize_b_c))); #endif // HAVE_SSE2
#endif // HAVE_NEON #endif // CONFIG_VP9_HIGHBITDEPTH
} // namespace } // namespace

View File

@@ -144,7 +144,6 @@ class ResizeTest : public ::libvpx_test::EncoderTest,
TEST_P(ResizeTest, TestExternalResizeWorks) { TEST_P(ResizeTest, TestExternalResizeWorks) {
ResizingVideoSource video; ResizingVideoSource video;
cfg_.g_lag_in_frames = 0;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
for (std::vector<FrameInfo>::const_iterator info = frame_info_list_.begin(); for (std::vector<FrameInfo>::const_iterator info = frame_info_list_.begin();
@@ -154,9 +153,9 @@ TEST_P(ResizeTest, TestExternalResizeWorks) {
const unsigned int expected_h = ScaleForFrameNumber(frame, kInitialHeight); const unsigned int expected_h = ScaleForFrameNumber(frame, kInitialHeight);
EXPECT_EQ(expected_w, info->w) EXPECT_EQ(expected_w, info->w)
<< "Frame " << frame << " had unexpected width"; << "Frame " << frame << "had unexpected width";
EXPECT_EQ(expected_h, info->h) EXPECT_EQ(expected_h, info->h)
<< "Frame " << frame << " had unexpected height"; << "Frame " << frame << "had unexpected height";
} }
} }
@@ -261,116 +260,7 @@ TEST_P(ResizeInternalTest, TestInternalResizeWorks) {
} }
} }
vpx_img_fmt_t CspForFrameNumber(int frame) {
if (frame < 10)
return VPX_IMG_FMT_I420;
if (frame < 20)
return VPX_IMG_FMT_I444;
return VPX_IMG_FMT_I420;
}
class ResizeCspTest : public ResizeTest {
protected:
#if WRITE_COMPRESSED_STREAM
ResizeCspTest()
: ResizeTest(),
frame0_psnr_(0.0),
outfile_(NULL),
out_frames_(0) {}
#else
ResizeCspTest() : ResizeTest(), frame0_psnr_(0.0) {}
#endif
virtual ~ResizeCspTest() {}
virtual void BeginPassHook(unsigned int /*pass*/) {
#if WRITE_COMPRESSED_STREAM
outfile_ = fopen("vp91-2-05-cspchape.ivf", "wb");
#endif
}
virtual void EndPassHook() {
#if WRITE_COMPRESSED_STREAM
if (outfile_) {
if (!fseek(outfile_, 0, SEEK_SET))
write_ivf_file_header(&cfg_, out_frames_, outfile_);
fclose(outfile_);
outfile_ = NULL;
}
#endif
}
virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video,
libvpx_test::Encoder *encoder) {
if (CspForFrameNumber(video->frame()) != VPX_IMG_FMT_I420 &&
cfg_.g_profile != 1) {
cfg_.g_profile = 1;
encoder->Config(&cfg_);
}
if (CspForFrameNumber(video->frame()) == VPX_IMG_FMT_I420 &&
cfg_.g_profile != 0) {
cfg_.g_profile = 0;
encoder->Config(&cfg_);
}
}
virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) {
if (!frame0_psnr_)
frame0_psnr_ = pkt->data.psnr.psnr[0];
EXPECT_NEAR(pkt->data.psnr.psnr[0], frame0_psnr_, 2.0);
}
#if WRITE_COMPRESSED_STREAM
virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
++out_frames_;
// Write initial file header if first frame.
if (pkt->data.frame.pts == 0)
write_ivf_file_header(&cfg_, 0, outfile_);
// Write frame header and data.
write_ivf_frame_header(pkt, outfile_);
(void)fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz, outfile_);
}
#endif
double frame0_psnr_;
#if WRITE_COMPRESSED_STREAM
FILE *outfile_;
unsigned int out_frames_;
#endif
};
class ResizingCspVideoSource : public ::libvpx_test::DummyVideoSource {
public:
ResizingCspVideoSource() {
SetSize(kInitialWidth, kInitialHeight);
limit_ = 30;
}
virtual ~ResizingCspVideoSource() {}
protected:
virtual void Next() {
++frame_;
SetImageFormat(CspForFrameNumber(frame_));
FillFrame();
}
};
TEST_P(ResizeCspTest, TestResizeCspWorks) {
ResizingCspVideoSource video;
init_flags_ = VPX_CODEC_USE_PSNR;
cfg_.rc_min_quantizer = cfg_.rc_max_quantizer = 48;
cfg_.g_lag_in_frames = 0;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
}
VP8_INSTANTIATE_TEST_CASE(ResizeTest, ONE_PASS_TEST_MODES); VP8_INSTANTIATE_TEST_CASE(ResizeTest, ONE_PASS_TEST_MODES);
VP9_INSTANTIATE_TEST_CASE(ResizeTest,
::testing::Values(::libvpx_test::kRealTime));
VP9_INSTANTIATE_TEST_CASE(ResizeInternalTest, VP9_INSTANTIATE_TEST_CASE(ResizeInternalTest,
::testing::Values(::libvpx_test::kOnePassBest)); ::testing::Values(::libvpx_test::kOnePassBest));
VP9_INSTANTIATE_TEST_CASE(ResizeCspTest,
::testing::Values(::libvpx_test::kRealTime));
} // namespace } // namespace

View File

@@ -20,14 +20,15 @@
#if CONFIG_VP9_ENCODER #if CONFIG_VP9_ENCODER
#include "./vp9_rtcd.h" #include "./vp9_rtcd.h"
#endif #endif
#include "vpx/vpx_codec.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "vpx_ports/mem.h"
#include "test/acm_random.h" #include "test/acm_random.h"
#include "test/clear_system_state.h" #include "test/clear_system_state.h"
#include "test/register_state_check.h" #include "test/register_state_check.h"
#include "test/util.h" #include "test/util.h"
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
#include "vpx/vpx_codec.h"
#if CONFIG_VP8_ENCODER #if CONFIG_VP8_ENCODER
@@ -43,21 +44,24 @@ typedef unsigned int (*SadMxNVp9Func)(const unsigned char *source_ptr,
int source_stride, int source_stride,
const unsigned char *reference_ptr, const unsigned char *reference_ptr,
int reference_stride); int reference_stride);
typedef std::tr1::tuple<int, int, SadMxNVp9Func, int> SadMxNVp9Param; typedef std::tr1::tuple<int, int, SadMxNVp9Func, int>
typedef uint32_t (*SadMxNAvgVp9Func)(const uint8_t *source_ptr, SadMxNVp9Param;
int source_stride, typedef unsigned int (*SadMxNAvgVp9Func)(const unsigned char *source_ptr,
const uint8_t *reference_ptr, int source_stride,
int reference_stride, const unsigned char *reference_ptr,
const uint8_t *second_pred); int reference_stride,
typedef std::tr1::tuple<int, int, SadMxNAvgVp9Func, int> SadMxNAvgVp9Param; const unsigned char *second_pred);
typedef std::tr1::tuple<int, int, SadMxNAvgVp9Func, int>
SadMxNAvgVp9Param;
#endif #endif
typedef void (*SadMxNx4Func)(const uint8_t *src_ptr, typedef void (*SadMxNx4Func)(const uint8_t *src_ptr,
int src_stride, int src_stride,
const uint8_t *const ref_ptr[], const unsigned char *const ref_ptr[],
int ref_stride, int ref_stride,
uint32_t *sad_array); unsigned int *sad_array);
typedef std::tr1::tuple<int, int, SadMxNx4Func, int> SadMxNx4Param; typedef std::tr1::tuple<int, int, SadMxNx4Func, int>
SadMxNx4Param;
using libvpx_test::ACMRandom; using libvpx_test::ACMRandom;
@@ -135,15 +139,13 @@ class SADTestBase : public ::testing::Test {
second_pred_ = second_pred8_; second_pred_ = second_pred8_;
} else { } else {
use_high_bit_depth_ = true; use_high_bit_depth_ = true;
bit_depth_ = static_cast<vpx_bit_depth_t>(bd_); bit_depth_ = (vpx_bit_depth_t) bd_;
source_data_ = CONVERT_TO_BYTEPTR(source_data16_); source_data_ = CONVERT_TO_BYTEPTR(source_data16_);
reference_data_ = CONVERT_TO_BYTEPTR(reference_data16_); reference_data_ = CONVERT_TO_BYTEPTR(reference_data16_);
second_pred_ = CONVERT_TO_BYTEPTR(second_pred16_); second_pred_ = CONVERT_TO_BYTEPTR(second_pred16_);
} }
#else
bit_depth_ = VPX_BITS_8;
#endif #endif
mask_ = (1 << bit_depth_) - 1; mask_ = (1 << bit_depth_)-1;
source_stride_ = (width_ + 31) & ~31; source_stride_ = (width_ + 31) & ~31;
reference_stride_ = width_ * 2; reference_stride_ = width_ * 2;
rnd_.Reset(ACMRandom::DeterministicSeed()); rnd_.Reset(ACMRandom::DeterministicSeed());
@@ -180,18 +182,15 @@ class SADTestBase : public ::testing::Test {
for (int w = 0; w < width_; ++w) { for (int w = 0; w < width_; ++w) {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (!use_high_bit_depth_) { if (!use_high_bit_depth_) {
sad += sad += abs(source8[h * source_stride_ + w]
abs(source8[h * source_stride_ + w] - - reference8[h * reference_stride_ + w]);
reference8[h * reference_stride_ + w]);
} else { } else {
sad += sad += abs(source16[h * source_stride_ + w]
abs(source16[h * source_stride_ + w] - - reference16[h * reference_stride_ + w]);
reference16[h * reference_stride_ + w]);
} }
#else #else
sad += sad += abs(source[h * source_stride_ + w]
abs(source[h * source_stride_ + w] - - reference[h * reference_stride_ + w]);
reference[h * reference_stride_ + w]);
#endif #endif
} }
if (sad > max_sad) { if (sad > max_sad) {
@@ -211,7 +210,7 @@ class SADTestBase : public ::testing::Test {
const uint8_t *const source8 = source_data_; const uint8_t *const source8 = source_data_;
const uint8_t *const second_pred8 = second_pred_; const uint8_t *const second_pred8 = second_pred_;
const uint16_t *const reference16 = const uint16_t *const reference16 =
CONVERT_TO_SHORTPTR(GetReference(block_idx)); CONVERT_TO_SHORTPTR(GetReference(block_idx));
const uint16_t *const source16 = CONVERT_TO_SHORTPTR(source_data_); const uint16_t *const source16 = CONVERT_TO_SHORTPTR(source_data_);
const uint16_t *const second_pred16 = CONVERT_TO_SHORTPTR(second_pred_); const uint16_t *const second_pred16 = CONVERT_TO_SHORTPTR(second_pred_);
#else #else
@@ -223,20 +222,20 @@ class SADTestBase : public ::testing::Test {
for (int w = 0; w < width_; ++w) { for (int w = 0; w < width_; ++w) {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (!use_high_bit_depth_) { if (!use_high_bit_depth_) {
const int tmp = second_pred8[h * width_ + w] + int tmp = second_pred8[h * width_ + w] +
reference8[h * reference_stride_ + w]; reference8[h * reference_stride_ + w];
const uint8_t comp_pred = ROUND_POWER_OF_TWO(tmp, 1); uint8_t comp_pred = ROUND_POWER_OF_TWO(tmp, 1);
sad += abs(source8[h * source_stride_ + w] - comp_pred); sad += abs(source8[h * source_stride_ + w] - comp_pred);
} else { } else {
const int tmp = second_pred16[h * width_ + w] + int tmp = second_pred16[h * width_ + w] +
reference16[h * reference_stride_ + w]; reference16[h * reference_stride_ + w];
const uint16_t comp_pred = ROUND_POWER_OF_TWO(tmp, 1); uint16_t comp_pred = ROUND_POWER_OF_TWO(tmp, 1);
sad += abs(source16[h * source_stride_ + w] - comp_pred); sad += abs(source16[h * source_stride_ + w] - comp_pred);
} }
#else #else
const int tmp = second_pred[h * width_ + w] + int tmp = second_pred[h * width_ + w] +
reference[h * reference_stride_ + w]; reference[h * reference_stride_ + w];
const uint8_t comp_pred = (tmp + 1) >> 1; uint8_t comp_pred = ROUND_POWER_OF_TWO(tmp, 1);
sad += abs(source[h * source_stride_ + w] - comp_pred); sad += abs(source[h * source_stride_ + w] - comp_pred);
#endif #endif
} }
@@ -256,12 +255,12 @@ class SADTestBase : public ::testing::Test {
for (int w = 0; w < width_; ++w) { for (int w = 0; w < width_; ++w) {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
if (!use_high_bit_depth_) { if (!use_high_bit_depth_) {
data8[h * stride + w] = static_cast<uint8_t>(fill_constant); data8[h * stride + w] = fill_constant;
} else { } else {
data16[h * stride + w] = fill_constant; data16[h * stride + w] = fill_constant;
} }
#else #else
data[h * stride + w] = static_cast<uint8_t>(fill_constant); data[h * stride + w] = (uint8_t)fill_constant;
#endif #endif
} }
} }
@@ -984,6 +983,20 @@ const SadMxNVp9Func sad_16x8_sse2_vp9 = vp9_sad16x8_sse2;
const SadMxNVp9Func sad_8x16_sse2_vp9 = vp9_sad8x16_sse2; const SadMxNVp9Func sad_8x16_sse2_vp9 = vp9_sad8x16_sse2;
const SadMxNVp9Func sad_8x8_sse2_vp9 = vp9_sad8x8_sse2; const SadMxNVp9Func sad_8x8_sse2_vp9 = vp9_sad8x8_sse2;
const SadMxNVp9Func sad_8x4_sse2_vp9 = vp9_sad8x4_sse2; const SadMxNVp9Func sad_8x4_sse2_vp9 = vp9_sad8x4_sse2;
const SadMxNVp9Param sse2_vp9_tests[] = {
make_tuple(64, 64, sad_64x64_sse2_vp9, -1),
make_tuple(64, 32, sad_64x32_sse2_vp9, -1),
make_tuple(32, 64, sad_32x64_sse2_vp9, -1),
make_tuple(32, 32, sad_32x32_sse2_vp9, -1),
make_tuple(32, 16, sad_32x16_sse2_vp9, -1),
make_tuple(16, 32, sad_16x32_sse2_vp9, -1),
make_tuple(16, 16, sad_16x16_sse2_vp9, -1),
make_tuple(16, 8, sad_16x8_sse2_vp9, -1),
make_tuple(8, 16, sad_8x16_sse2_vp9, -1),
make_tuple(8, 8, sad_8x8_sse2_vp9, -1),
make_tuple(8, 4, sad_8x4_sse2_vp9, -1),
};
INSTANTIATE_TEST_CASE_P(SSE2, SADVP9Test, ::testing::ValuesIn(sse2_vp9_tests));
const SadMxNx4Func sad_64x64x4d_sse2 = vp9_sad64x64x4d_sse2; const SadMxNx4Func sad_64x64x4d_sse2 = vp9_sad64x64x4d_sse2;
const SadMxNx4Func sad_64x32x4d_sse2 = vp9_sad64x32x4d_sse2; const SadMxNx4Func sad_64x32x4d_sse2 = vp9_sad64x32x4d_sse2;
@@ -996,7 +1009,18 @@ const SadMxNx4Func sad_16x8x4d_sse2 = vp9_sad16x8x4d_sse2;
const SadMxNx4Func sad_8x16x4d_sse2 = vp9_sad8x16x4d_sse2; const SadMxNx4Func sad_8x16x4d_sse2 = vp9_sad8x16x4d_sse2;
const SadMxNx4Func sad_8x8x4d_sse2 = vp9_sad8x8x4d_sse2; const SadMxNx4Func sad_8x8x4d_sse2 = vp9_sad8x8x4d_sse2;
const SadMxNx4Func sad_8x4x4d_sse2 = vp9_sad8x4x4d_sse2; const SadMxNx4Func sad_8x4x4d_sse2 = vp9_sad8x4x4d_sse2;
INSTANTIATE_TEST_CASE_P(SSE2, SADx4Test, ::testing::Values(
make_tuple(64, 64, sad_64x64x4d_sse2, -1),
make_tuple(64, 32, sad_64x32x4d_sse2, -1),
make_tuple(32, 64, sad_32x64x4d_sse2, -1),
make_tuple(32, 32, sad_32x32x4d_sse2, -1),
make_tuple(32, 16, sad_32x16x4d_sse2, -1),
make_tuple(16, 32, sad_16x32x4d_sse2, -1),
make_tuple(16, 16, sad_16x16x4d_sse2, -1),
make_tuple(16, 8, sad_16x8x4d_sse2, -1),
make_tuple(8, 16, sad_8x16x4d_sse2, -1),
make_tuple(8, 8, sad_8x8x4d_sse2, -1),
make_tuple(8, 4, sad_8x4x4d_sse2, -1)));
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
const SadMxNVp9Func highbd_sad8x4_sse2_vp9 = vp9_highbd_sad8x4_sse2; const SadMxNVp9Func highbd_sad8x4_sse2_vp9 = vp9_highbd_sad8x4_sse2;
const SadMxNVp9Func highbd_sad8x8_sse2_vp9 = vp9_highbd_sad8x8_sse2; const SadMxNVp9Func highbd_sad8x8_sse2_vp9 = vp9_highbd_sad8x8_sse2;
@@ -1009,55 +1033,53 @@ const SadMxNVp9Func highbd_sad32x32_sse2_vp9 = vp9_highbd_sad32x32_sse2;
const SadMxNVp9Func highbd_sad32x64_sse2_vp9 = vp9_highbd_sad32x64_sse2; const SadMxNVp9Func highbd_sad32x64_sse2_vp9 = vp9_highbd_sad32x64_sse2;
const SadMxNVp9Func highbd_sad64x32_sse2_vp9 = vp9_highbd_sad64x32_sse2; const SadMxNVp9Func highbd_sad64x32_sse2_vp9 = vp9_highbd_sad64x32_sse2;
const SadMxNVp9Func highbd_sad64x64_sse2_vp9 = vp9_highbd_sad64x64_sse2; const SadMxNVp9Func highbd_sad64x64_sse2_vp9 = vp9_highbd_sad64x64_sse2;
SadMxNVp9Param sse2_vp9_highbd_8_tests[] = {
make_tuple(8, 4, highbd_sad8x4_sse2_vp9, 8),
make_tuple(8, 8, highbd_sad8x8_sse2_vp9, 8),
make_tuple(8, 16, highbd_sad8x16_sse2_vp9, 8),
make_tuple(16, 8, highbd_sad16x8_sse2_vp9, 8),
make_tuple(16, 16, highbd_sad16x16_sse2_vp9, 8),
make_tuple(16, 32, highbd_sad16x32_sse2_vp9, 8),
make_tuple(32, 16, highbd_sad32x16_sse2_vp9, 8),
make_tuple(32, 32, highbd_sad32x32_sse2_vp9, 8),
make_tuple(32, 64, highbd_sad32x64_sse2_vp9, 8),
make_tuple(64, 32, highbd_sad64x32_sse2_vp9, 8),
make_tuple(64, 64, highbd_sad64x64_sse2_vp9, 8)};
INSTANTIATE_TEST_CASE_P(SSE2_8, SADVP9Test,
::testing::ValuesIn(sse2_vp9_highbd_8_tests));
SadMxNVp9Param sse2_vp9_highbd_10_tests[] = {
make_tuple(8, 4, highbd_sad8x4_sse2_vp9, 10),
make_tuple(8, 8, highbd_sad8x8_sse2_vp9, 10),
make_tuple(8, 16, highbd_sad8x16_sse2_vp9, 10),
make_tuple(16, 8, highbd_sad16x8_sse2_vp9, 10),
make_tuple(16, 16, highbd_sad16x16_sse2_vp9, 10),
make_tuple(16, 32, highbd_sad16x32_sse2_vp9, 10),
make_tuple(32, 16, highbd_sad32x16_sse2_vp9, 10),
make_tuple(32, 32, highbd_sad32x32_sse2_vp9, 10),
make_tuple(32, 64, highbd_sad32x64_sse2_vp9, 10),
make_tuple(64, 32, highbd_sad64x32_sse2_vp9, 10),
make_tuple(64, 64, highbd_sad64x64_sse2_vp9, 10)};
INSTANTIATE_TEST_CASE_P(SSE2_10, SADVP9Test,
::testing::ValuesIn(sse2_vp9_highbd_10_tests));
SadMxNVp9Param sse2_vp9_highbd_12_tests[] = {
make_tuple(8, 4, highbd_sad8x4_sse2_vp9, 12),
make_tuple(8, 8, highbd_sad8x8_sse2_vp9, 12),
make_tuple(8, 16, highbd_sad8x16_sse2_vp9, 12),
make_tuple(16, 8, highbd_sad16x8_sse2_vp9, 12),
make_tuple(16, 16, highbd_sad16x16_sse2_vp9, 12),
make_tuple(16, 32, highbd_sad16x32_sse2_vp9, 12),
make_tuple(32, 16, highbd_sad32x16_sse2_vp9, 12),
make_tuple(32, 32, highbd_sad32x32_sse2_vp9, 12),
make_tuple(32, 64, highbd_sad32x64_sse2_vp9, 12),
make_tuple(64, 32, highbd_sad64x32_sse2_vp9, 12),
make_tuple(64, 64, highbd_sad64x64_sse2_vp9, 12)};
INSTANTIATE_TEST_CASE_P(SSE2_12, SADVP9Test,
::testing::ValuesIn(sse2_vp9_highbd_12_tests));
INSTANTIATE_TEST_CASE_P(SSE2, SADVP9Test, ::testing::Values( const SadMxNAvgVp9Func highbd_sad8x4_avg_sse2_vp9 =
make_tuple(64, 64, sad_64x64_sse2_vp9, -1), vp9_highbd_sad8x4_avg_sse2;
make_tuple(64, 32, sad_64x32_sse2_vp9, -1), const SadMxNAvgVp9Func highbd_sad8x8_avg_sse2_vp9 =
make_tuple(32, 64, sad_32x64_sse2_vp9, -1), vp9_highbd_sad8x8_avg_sse2;
make_tuple(32, 32, sad_32x32_sse2_vp9, -1),
make_tuple(32, 16, sad_32x16_sse2_vp9, -1),
make_tuple(16, 32, sad_16x32_sse2_vp9, -1),
make_tuple(16, 16, sad_16x16_sse2_vp9, -1),
make_tuple(16, 8, sad_16x8_sse2_vp9, -1),
make_tuple(8, 16, sad_8x16_sse2_vp9, -1),
make_tuple(8, 8, sad_8x8_sse2_vp9, -1),
make_tuple(8, 4, sad_8x4_sse2_vp9, -1),
make_tuple(8, 4, highbd_sad8x4_sse2_vp9, 8),
make_tuple(8, 8, highbd_sad8x8_sse2_vp9, 8),
make_tuple(8, 16, highbd_sad8x16_sse2_vp9, 8),
make_tuple(16, 8, highbd_sad16x8_sse2_vp9, 8),
make_tuple(16, 16, highbd_sad16x16_sse2_vp9, 8),
make_tuple(16, 32, highbd_sad16x32_sse2_vp9, 8),
make_tuple(32, 16, highbd_sad32x16_sse2_vp9, 8),
make_tuple(32, 32, highbd_sad32x32_sse2_vp9, 8),
make_tuple(32, 64, highbd_sad32x64_sse2_vp9, 8),
make_tuple(64, 32, highbd_sad64x32_sse2_vp9, 8),
make_tuple(64, 64, highbd_sad64x64_sse2_vp9, 8),
make_tuple(8, 4, highbd_sad8x4_sse2_vp9, 10),
make_tuple(8, 8, highbd_sad8x8_sse2_vp9, 10),
make_tuple(8, 16, highbd_sad8x16_sse2_vp9, 10),
make_tuple(16, 8, highbd_sad16x8_sse2_vp9, 10),
make_tuple(16, 16, highbd_sad16x16_sse2_vp9, 10),
make_tuple(16, 32, highbd_sad16x32_sse2_vp9, 10),
make_tuple(32, 16, highbd_sad32x16_sse2_vp9, 10),
make_tuple(32, 32, highbd_sad32x32_sse2_vp9, 10),
make_tuple(32, 64, highbd_sad32x64_sse2_vp9, 10),
make_tuple(64, 32, highbd_sad64x32_sse2_vp9, 10),
make_tuple(64, 64, highbd_sad64x64_sse2_vp9, 10),
make_tuple(8, 4, highbd_sad8x4_sse2_vp9, 12),
make_tuple(8, 8, highbd_sad8x8_sse2_vp9, 12),
make_tuple(8, 16, highbd_sad8x16_sse2_vp9, 12),
make_tuple(16, 8, highbd_sad16x8_sse2_vp9, 12),
make_tuple(16, 16, highbd_sad16x16_sse2_vp9, 12),
make_tuple(16, 32, highbd_sad16x32_sse2_vp9, 12),
make_tuple(32, 16, highbd_sad32x16_sse2_vp9, 12),
make_tuple(32, 32, highbd_sad32x32_sse2_vp9, 12),
make_tuple(32, 64, highbd_sad32x64_sse2_vp9, 12),
make_tuple(64, 32, highbd_sad64x32_sse2_vp9, 12),
make_tuple(64, 64, highbd_sad64x64_sse2_vp9, 12)));
const SadMxNAvgVp9Func highbd_sad8x4_avg_sse2_vp9 = vp9_highbd_sad8x4_avg_sse2;
const SadMxNAvgVp9Func highbd_sad8x8_avg_sse2_vp9 = vp9_highbd_sad8x8_avg_sse2;
const SadMxNAvgVp9Func highbd_sad8x16_avg_sse2_vp9 = const SadMxNAvgVp9Func highbd_sad8x16_avg_sse2_vp9 =
vp9_highbd_sad8x16_avg_sse2; vp9_highbd_sad8x16_avg_sse2;
const SadMxNAvgVp9Func highbd_sad16x8_avg_sse2_vp9 = const SadMxNAvgVp9Func highbd_sad16x8_avg_sse2_vp9 =
@@ -1076,41 +1098,48 @@ const SadMxNAvgVp9Func highbd_sad64x32_avg_sse2_vp9 =
vp9_highbd_sad64x32_avg_sse2; vp9_highbd_sad64x32_avg_sse2;
const SadMxNAvgVp9Func highbd_sad64x64_avg_sse2_vp9 = const SadMxNAvgVp9Func highbd_sad64x64_avg_sse2_vp9 =
vp9_highbd_sad64x64_avg_sse2; vp9_highbd_sad64x64_avg_sse2;
SadMxNAvgVp9Param avg_sse2_vp9_highbd_8_tests[] = {
INSTANTIATE_TEST_CASE_P(SSE2, SADavgVP9Test, ::testing::Values( make_tuple(8, 4, highbd_sad8x4_avg_sse2_vp9, 8),
make_tuple(8, 4, highbd_sad8x4_avg_sse2_vp9, 8), make_tuple(8, 8, highbd_sad8x8_avg_sse2_vp9, 8),
make_tuple(8, 8, highbd_sad8x8_avg_sse2_vp9, 8), make_tuple(8, 16, highbd_sad8x16_avg_sse2_vp9, 8),
make_tuple(8, 16, highbd_sad8x16_avg_sse2_vp9, 8), make_tuple(16, 8, highbd_sad16x8_avg_sse2_vp9, 8),
make_tuple(16, 8, highbd_sad16x8_avg_sse2_vp9, 8), make_tuple(16, 16, highbd_sad16x16_avg_sse2_vp9, 8),
make_tuple(16, 16, highbd_sad16x16_avg_sse2_vp9, 8), make_tuple(16, 32, highbd_sad16x32_avg_sse2_vp9, 8),
make_tuple(16, 32, highbd_sad16x32_avg_sse2_vp9, 8), make_tuple(32, 16, highbd_sad32x16_avg_sse2_vp9, 8),
make_tuple(32, 16, highbd_sad32x16_avg_sse2_vp9, 8), make_tuple(32, 32, highbd_sad32x32_avg_sse2_vp9, 8),
make_tuple(32, 32, highbd_sad32x32_avg_sse2_vp9, 8), make_tuple(32, 64, highbd_sad32x64_avg_sse2_vp9, 8),
make_tuple(32, 64, highbd_sad32x64_avg_sse2_vp9, 8), make_tuple(64, 32, highbd_sad64x32_avg_sse2_vp9, 8),
make_tuple(64, 32, highbd_sad64x32_avg_sse2_vp9, 8), make_tuple(64, 64, highbd_sad64x64_avg_sse2_vp9, 8)};
make_tuple(64, 64, highbd_sad64x64_avg_sse2_vp9, 8), INSTANTIATE_TEST_CASE_P(SSE2_8, SADavgVP9Test,
make_tuple(8, 4, highbd_sad8x4_avg_sse2_vp9, 10), ::testing::ValuesIn(avg_sse2_vp9_highbd_8_tests));
make_tuple(8, 8, highbd_sad8x8_avg_sse2_vp9, 10), SadMxNAvgVp9Param avg_sse2_vp9_highbd_10_tests[] = {
make_tuple(8, 16, highbd_sad8x16_avg_sse2_vp9, 10), make_tuple(8, 4, highbd_sad8x4_avg_sse2_vp9, 10),
make_tuple(16, 8, highbd_sad16x8_avg_sse2_vp9, 10), make_tuple(8, 8, highbd_sad8x8_avg_sse2_vp9, 10),
make_tuple(16, 16, highbd_sad16x16_avg_sse2_vp9, 10), make_tuple(8, 16, highbd_sad8x16_avg_sse2_vp9, 10),
make_tuple(16, 32, highbd_sad16x32_avg_sse2_vp9, 10), make_tuple(16, 8, highbd_sad16x8_avg_sse2_vp9, 10),
make_tuple(32, 16, highbd_sad32x16_avg_sse2_vp9, 10), make_tuple(16, 16, highbd_sad16x16_avg_sse2_vp9, 10),
make_tuple(32, 32, highbd_sad32x32_avg_sse2_vp9, 10), make_tuple(16, 32, highbd_sad16x32_avg_sse2_vp9, 10),
make_tuple(32, 64, highbd_sad32x64_avg_sse2_vp9, 10), make_tuple(32, 16, highbd_sad32x16_avg_sse2_vp9, 10),
make_tuple(64, 32, highbd_sad64x32_avg_sse2_vp9, 10), make_tuple(32, 32, highbd_sad32x32_avg_sse2_vp9, 10),
make_tuple(64, 64, highbd_sad64x64_avg_sse2_vp9, 10), make_tuple(32, 64, highbd_sad32x64_avg_sse2_vp9, 10),
make_tuple(8, 4, highbd_sad8x4_avg_sse2_vp9, 12), make_tuple(64, 32, highbd_sad64x32_avg_sse2_vp9, 10),
make_tuple(8, 8, highbd_sad8x8_avg_sse2_vp9, 12), make_tuple(64, 64, highbd_sad64x64_avg_sse2_vp9, 10)};
make_tuple(8, 16, highbd_sad8x16_avg_sse2_vp9, 12), INSTANTIATE_TEST_CASE_P(SSE2_10, SADavgVP9Test,
make_tuple(16, 8, highbd_sad16x8_avg_sse2_vp9, 12), ::testing::ValuesIn(avg_sse2_vp9_highbd_10_tests));
make_tuple(16, 16, highbd_sad16x16_avg_sse2_vp9, 12), SadMxNAvgVp9Param avg_sse2_vp9_highbd_12_tests[] = {
make_tuple(16, 32, highbd_sad16x32_avg_sse2_vp9, 12), make_tuple(8, 4, highbd_sad8x4_avg_sse2_vp9, 12),
make_tuple(32, 16, highbd_sad32x16_avg_sse2_vp9, 12), make_tuple(8, 8, highbd_sad8x8_avg_sse2_vp9, 12),
make_tuple(32, 32, highbd_sad32x32_avg_sse2_vp9, 12), make_tuple(8, 16, highbd_sad8x16_avg_sse2_vp9, 12),
make_tuple(32, 64, highbd_sad32x64_avg_sse2_vp9, 12), make_tuple(16, 8, highbd_sad16x8_avg_sse2_vp9, 12),
make_tuple(64, 32, highbd_sad64x32_avg_sse2_vp9, 12), make_tuple(16, 16, highbd_sad16x16_avg_sse2_vp9, 12),
make_tuple(64, 64, highbd_sad64x64_avg_sse2_vp9, 12))); make_tuple(16, 32, highbd_sad16x32_avg_sse2_vp9, 12),
make_tuple(32, 16, highbd_sad32x16_avg_sse2_vp9, 12),
make_tuple(32, 32, highbd_sad32x32_avg_sse2_vp9, 12),
make_tuple(32, 64, highbd_sad32x64_avg_sse2_vp9, 12),
make_tuple(64, 32, highbd_sad64x32_avg_sse2_vp9, 12),
make_tuple(64, 64, highbd_sad64x64_avg_sse2_vp9, 12)};
INSTANTIATE_TEST_CASE_P(SSE2_12, SADavgVP9Test,
::testing::ValuesIn(avg_sse2_vp9_highbd_12_tests));
const SadMxNx4Func highbd_sad_64x64x4d_sse2 = vp9_highbd_sad64x64x4d_sse2; const SadMxNx4Func highbd_sad_64x64x4d_sse2 = vp9_highbd_sad64x64x4d_sse2;
const SadMxNx4Func highbd_sad_64x32x4d_sse2 = vp9_highbd_sad64x32x4d_sse2; const SadMxNx4Func highbd_sad_64x32x4d_sse2 = vp9_highbd_sad64x32x4d_sse2;
@@ -1119,25 +1148,14 @@ const SadMxNx4Func highbd_sad_32x32x4d_sse2 = vp9_highbd_sad32x32x4d_sse2;
const SadMxNx4Func highbd_sad_32x16x4d_sse2 = vp9_highbd_sad32x16x4d_sse2; const SadMxNx4Func highbd_sad_32x16x4d_sse2 = vp9_highbd_sad32x16x4d_sse2;
const SadMxNx4Func highbd_sad_16x32x4d_sse2 = vp9_highbd_sad16x32x4d_sse2; const SadMxNx4Func highbd_sad_16x32x4d_sse2 = vp9_highbd_sad16x32x4d_sse2;
const SadMxNx4Func highbd_sad_16x16x4d_sse2 = vp9_highbd_sad16x16x4d_sse2; const SadMxNx4Func highbd_sad_16x16x4d_sse2 = vp9_highbd_sad16x16x4d_sse2;
const SadMxNx4Func highbd_sad_16x8x4d_sse2 = vp9_highbd_sad16x8x4d_sse2; const SadMxNx4Func highbd_sad_16x8x4d_sse2 = vp9_highbd_sad16x8x4d_sse2;
const SadMxNx4Func highbd_sad_8x16x4d_sse2 = vp9_highbd_sad8x16x4d_sse2; const SadMxNx4Func highbd_sad_8x16x4d_sse2 = vp9_highbd_sad8x16x4d_sse2;
const SadMxNx4Func highbd_sad_8x8x4d_sse2 = vp9_highbd_sad8x8x4d_sse2; const SadMxNx4Func highbd_sad_8x8x4d_sse2 = vp9_highbd_sad8x8x4d_sse2;
const SadMxNx4Func highbd_sad_8x4x4d_sse2 = vp9_highbd_sad8x4x4d_sse2; const SadMxNx4Func highbd_sad_8x4x4d_sse2 = vp9_highbd_sad8x4x4d_sse2;
const SadMxNx4Func highbd_sad_4x8x4d_sse2 = vp9_highbd_sad4x8x4d_sse2; const SadMxNx4Func highbd_sad_4x8x4d_sse2 = vp9_highbd_sad4x8x4d_sse2;
const SadMxNx4Func highbd_sad_4x4x4d_sse2 = vp9_highbd_sad4x4x4d_sse2; const SadMxNx4Func highbd_sad_4x4x4d_sse2 = vp9_highbd_sad4x4x4d_sse2;
INSTANTIATE_TEST_CASE_P(SSE2, SADx4Test, ::testing::Values( INSTANTIATE_TEST_CASE_P(SSE2_8, SADx4Test, ::testing::Values(
make_tuple(64, 64, sad_64x64x4d_sse2, -1),
make_tuple(64, 32, sad_64x32x4d_sse2, -1),
make_tuple(32, 64, sad_32x64x4d_sse2, -1),
make_tuple(32, 32, sad_32x32x4d_sse2, -1),
make_tuple(32, 16, sad_32x16x4d_sse2, -1),
make_tuple(16, 32, sad_16x32x4d_sse2, -1),
make_tuple(16, 16, sad_16x16x4d_sse2, -1),
make_tuple(16, 8, sad_16x8x4d_sse2, -1),
make_tuple(8, 16, sad_8x16x4d_sse2, -1),
make_tuple(8, 8, sad_8x8x4d_sse2, -1),
make_tuple(8, 4, sad_8x4x4d_sse2, -1),
make_tuple(64, 64, highbd_sad_64x64x4d_sse2, 8), make_tuple(64, 64, highbd_sad_64x64x4d_sse2, 8),
make_tuple(64, 32, highbd_sad_64x32x4d_sse2, 8), make_tuple(64, 32, highbd_sad_64x32x4d_sse2, 8),
make_tuple(32, 64, highbd_sad_32x64x4d_sse2, 8), make_tuple(32, 64, highbd_sad_32x64x4d_sse2, 8),
@@ -1145,12 +1163,13 @@ INSTANTIATE_TEST_CASE_P(SSE2, SADx4Test, ::testing::Values(
make_tuple(32, 16, highbd_sad_32x16x4d_sse2, 8), make_tuple(32, 16, highbd_sad_32x16x4d_sse2, 8),
make_tuple(16, 32, highbd_sad_16x32x4d_sse2, 8), make_tuple(16, 32, highbd_sad_16x32x4d_sse2, 8),
make_tuple(16, 16, highbd_sad_16x16x4d_sse2, 8), make_tuple(16, 16, highbd_sad_16x16x4d_sse2, 8),
make_tuple(16, 8, highbd_sad_16x8x4d_sse2, 8), make_tuple(16, 8, highbd_sad_16x8x4d_sse2, 8),
make_tuple(8, 16, highbd_sad_8x16x4d_sse2, 8), make_tuple(8, 16, highbd_sad_8x16x4d_sse2, 8),
make_tuple(8, 8, highbd_sad_8x8x4d_sse2, 8), make_tuple(8, 8, highbd_sad_8x8x4d_sse2, 8),
make_tuple(8, 4, highbd_sad_8x4x4d_sse2, 8), make_tuple(8, 4, highbd_sad_8x4x4d_sse2, 8),
make_tuple(4, 8, highbd_sad_4x8x4d_sse2, 8), make_tuple(4, 8, highbd_sad_4x8x4d_sse2, 8),
make_tuple(4, 4, highbd_sad_4x4x4d_sse2, 8), make_tuple(4, 4, highbd_sad_4x4x4d_sse2, 8)));
INSTANTIATE_TEST_CASE_P(SSE2_10, SADx4Test, ::testing::Values(
make_tuple(64, 64, highbd_sad_64x64x4d_sse2, 10), make_tuple(64, 64, highbd_sad_64x64x4d_sse2, 10),
make_tuple(64, 32, highbd_sad_64x32x4d_sse2, 10), make_tuple(64, 32, highbd_sad_64x32x4d_sse2, 10),
make_tuple(32, 64, highbd_sad_32x64x4d_sse2, 10), make_tuple(32, 64, highbd_sad_32x64x4d_sse2, 10),
@@ -1158,12 +1177,13 @@ INSTANTIATE_TEST_CASE_P(SSE2, SADx4Test, ::testing::Values(
make_tuple(32, 16, highbd_sad_32x16x4d_sse2, 10), make_tuple(32, 16, highbd_sad_32x16x4d_sse2, 10),
make_tuple(16, 32, highbd_sad_16x32x4d_sse2, 10), make_tuple(16, 32, highbd_sad_16x32x4d_sse2, 10),
make_tuple(16, 16, highbd_sad_16x16x4d_sse2, 10), make_tuple(16, 16, highbd_sad_16x16x4d_sse2, 10),
make_tuple(16, 8, highbd_sad_16x8x4d_sse2, 10), make_tuple(16, 8, highbd_sad_16x8x4d_sse2, 10),
make_tuple(8, 16, highbd_sad_8x16x4d_sse2, 10), make_tuple(8, 16, highbd_sad_8x16x4d_sse2, 10),
make_tuple(8, 8, highbd_sad_8x8x4d_sse2, 10), make_tuple(8, 8, highbd_sad_8x8x4d_sse2, 10),
make_tuple(8, 4, highbd_sad_8x4x4d_sse2, 10), make_tuple(8, 4, highbd_sad_8x4x4d_sse2, 10),
make_tuple(4, 8, highbd_sad_4x8x4d_sse2, 10), make_tuple(4, 8, highbd_sad_4x8x4d_sse2, 10),
make_tuple(4, 4, highbd_sad_4x4x4d_sse2, 10), make_tuple(4, 4, highbd_sad_4x4x4d_sse2, 10)));
INSTANTIATE_TEST_CASE_P(SSE2_12, SADx4Test, ::testing::Values(
make_tuple(64, 64, highbd_sad_64x64x4d_sse2, 12), make_tuple(64, 64, highbd_sad_64x64x4d_sse2, 12),
make_tuple(64, 32, highbd_sad_64x32x4d_sse2, 12), make_tuple(64, 32, highbd_sad_64x32x4d_sse2, 12),
make_tuple(32, 64, highbd_sad_32x64x4d_sse2, 12), make_tuple(32, 64, highbd_sad_32x64x4d_sse2, 12),
@@ -1171,38 +1191,12 @@ INSTANTIATE_TEST_CASE_P(SSE2, SADx4Test, ::testing::Values(
make_tuple(32, 16, highbd_sad_32x16x4d_sse2, 12), make_tuple(32, 16, highbd_sad_32x16x4d_sse2, 12),
make_tuple(16, 32, highbd_sad_16x32x4d_sse2, 12), make_tuple(16, 32, highbd_sad_16x32x4d_sse2, 12),
make_tuple(16, 16, highbd_sad_16x16x4d_sse2, 12), make_tuple(16, 16, highbd_sad_16x16x4d_sse2, 12),
make_tuple(16, 8, highbd_sad_16x8x4d_sse2, 12), make_tuple(16, 8, highbd_sad_16x8x4d_sse2, 12),
make_tuple(8, 16, highbd_sad_8x16x4d_sse2, 12), make_tuple(8, 16, highbd_sad_8x16x4d_sse2, 12),
make_tuple(8, 8, highbd_sad_8x8x4d_sse2, 12), make_tuple(8, 8, highbd_sad_8x8x4d_sse2, 12),
make_tuple(8, 4, highbd_sad_8x4x4d_sse2, 12), make_tuple(8, 4, highbd_sad_8x4x4d_sse2, 12),
make_tuple(4, 8, highbd_sad_4x8x4d_sse2, 12), make_tuple(4, 8, highbd_sad_4x8x4d_sse2, 12),
make_tuple(4, 4, highbd_sad_4x4x4d_sse2, 12))); make_tuple(4, 4, highbd_sad_4x4x4d_sse2, 12)));
#else
INSTANTIATE_TEST_CASE_P(SSE2, SADVP9Test, ::testing::Values(
make_tuple(64, 64, sad_64x64_sse2_vp9, -1),
make_tuple(64, 32, sad_64x32_sse2_vp9, -1),
make_tuple(32, 64, sad_32x64_sse2_vp9, -1),
make_tuple(32, 32, sad_32x32_sse2_vp9, -1),
make_tuple(32, 16, sad_32x16_sse2_vp9, -1),
make_tuple(16, 32, sad_16x32_sse2_vp9, -1),
make_tuple(16, 16, sad_16x16_sse2_vp9, -1),
make_tuple(16, 8, sad_16x8_sse2_vp9, -1),
make_tuple(8, 16, sad_8x16_sse2_vp9, -1),
make_tuple(8, 8, sad_8x8_sse2_vp9, -1),
make_tuple(8, 4, sad_8x4_sse2_vp9, -1)));
INSTANTIATE_TEST_CASE_P(SSE2, SADx4Test, ::testing::Values(
make_tuple(64, 64, sad_64x64x4d_sse2, -1),
make_tuple(64, 32, sad_64x32x4d_sse2, -1),
make_tuple(32, 64, sad_32x64x4d_sse2, -1),
make_tuple(32, 32, sad_32x32x4d_sse2, -1),
make_tuple(32, 16, sad_32x16x4d_sse2, -1),
make_tuple(16, 32, sad_16x32x4d_sse2, -1),
make_tuple(16, 16, sad_16x16x4d_sse2, -1),
make_tuple(16, 8, sad_16x8x4d_sse2, -1),
make_tuple(8, 16, sad_8x16x4d_sse2, -1),
make_tuple(8, 8, sad_8x8x4d_sse2, -1),
make_tuple(8, 4, sad_8x4x4d_sse2, -1)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
#endif // CONFIG_USE_X86INC #endif // CONFIG_USE_X86INC
#endif // CONFIG_VP9_ENCODER #endif // CONFIG_VP9_ENCODER
@@ -1234,24 +1228,28 @@ INSTANTIATE_TEST_CASE_P(SSE3, SADTest, ::testing::Values(
#endif // CONFIG_USE_X86INC #endif // CONFIG_USE_X86INC
#endif // HAVE_SSSE3 #endif // HAVE_SSSE3
#if CONFIG_VP9_ENCODER
#if HAVE_AVX2 #if HAVE_AVX2
#if CONFIG_VP9_ENCODER
const SadMxNVp9Func sad_64x64_avx2_vp9 = vp9_sad64x64_avx2;
const SadMxNVp9Func sad_64x32_avx2_vp9 = vp9_sad64x32_avx2;
const SadMxNVp9Func sad_32x64_avx2_vp9 = vp9_sad32x64_avx2;
const SadMxNVp9Func sad_32x32_avx2_vp9 = vp9_sad32x32_avx2;
const SadMxNVp9Func sad_32x16_avx2_vp9 = vp9_sad32x16_avx2;
const SadMxNVp9Param avx2_vp9_tests[] = {
make_tuple(64, 64, sad_64x64_avx2_vp9, -1),
make_tuple(64, 32, sad_64x32_avx2_vp9, -1),
make_tuple(32, 64, sad_32x64_avx2_vp9, -1),
make_tuple(32, 32, sad_32x32_avx2_vp9, -1),
make_tuple(32, 16, sad_32x16_avx2_vp9, -1),
};
INSTANTIATE_TEST_CASE_P(AVX2, SADVP9Test, ::testing::ValuesIn(avx2_vp9_tests));
const SadMxNx4Func sad_64x64x4d_avx2 = vp9_sad64x64x4d_avx2; const SadMxNx4Func sad_64x64x4d_avx2 = vp9_sad64x64x4d_avx2;
const SadMxNx4Func sad_32x32x4d_avx2 = vp9_sad32x32x4d_avx2; const SadMxNx4Func sad_32x32x4d_avx2 = vp9_sad32x32x4d_avx2;
INSTANTIATE_TEST_CASE_P(AVX2, SADx4Test, ::testing::Values( INSTANTIATE_TEST_CASE_P(AVX2, SADx4Test, ::testing::Values(
make_tuple(32, 32, sad_32x32x4d_avx2, -1), make_tuple(32, 32, sad_32x32x4d_avx2, -1),
make_tuple(64, 64, sad_64x64x4d_avx2, -1))); make_tuple(64, 64, sad_64x64x4d_avx2, -1)));
#endif // CONFIG_VP9_ENCODER
#endif // HAVE_AVX2 #endif // HAVE_AVX2
#if HAVE_NEON
const SadMxNx4Func sad_16x16x4d_neon = vp9_sad16x16x4d_neon;
const SadMxNx4Func sad_32x32x4d_neon = vp9_sad32x32x4d_neon;
const SadMxNx4Func sad_64x64x4d_neon = vp9_sad64x64x4d_neon;
INSTANTIATE_TEST_CASE_P(NEON, SADx4Test, ::testing::Values(
make_tuple(16, 16, sad_16x16x4d_neon, -1),
make_tuple(32, 32, sad_32x32x4d_neon, -1),
make_tuple(64, 64, sad_64x64x4d_neon, -1)));
#endif // HAVE_NEON
#endif // CONFIG_VP9_ENCODER
} // namespace } // namespace

View File

@@ -53,7 +53,7 @@ TEST(VP8RoiMapTest, ParameterCheck) {
cpi.common.mb_rows = 240 >> 4; cpi.common.mb_rows = 240 >> 4;
cpi.common.mb_cols = 320 >> 4; cpi.common.mb_cols = 320 >> 4;
const int mbs = (cpi.common.mb_rows * cpi.common.mb_cols); const int mbs = (cpi.common.mb_rows * cpi.common.mb_cols);
memset(cpi.segment_feature_data, 0, sizeof(cpi.segment_feature_data)); vpx_memset(cpi.segment_feature_data, 0, sizeof(cpi.segment_feature_data));
// Segment map // Segment map
cpi.segmentation_map = reinterpret_cast<unsigned char *>(vpx_calloc(mbs, 1)); cpi.segmentation_map = reinterpret_cast<unsigned char *>(vpx_calloc(mbs, 1));
@@ -61,9 +61,9 @@ TEST(VP8RoiMapTest, ParameterCheck) {
// Allocate memory for the source memory map. // Allocate memory for the source memory map.
unsigned char *roi_map = unsigned char *roi_map =
reinterpret_cast<unsigned char *>(vpx_calloc(mbs, 1)); reinterpret_cast<unsigned char *>(vpx_calloc(mbs, 1));
memset(&roi_map[mbs >> 2], 1, (mbs >> 2)); vpx_memset(&roi_map[mbs >> 2], 1, (mbs >> 2));
memset(&roi_map[mbs >> 1], 2, (mbs >> 2)); vpx_memset(&roi_map[mbs >> 1], 2, (mbs >> 2));
memset(&roi_map[mbs -(mbs >> 2)], 3, (mbs >> 2)); vpx_memset(&roi_map[mbs -(mbs >> 2)], 3, (mbs >> 2));
// Do a test call with valid parameters. // Do a test call with valid parameters.
int roi_retval = vp8_set_roimap(&cpi, roi_map, cpi.common.mb_rows, int roi_retval = vp8_set_roimap(&cpi, roi_map, cpi.common.mb_rows,

View File

@@ -1,796 +0,0 @@
/*
* Copyright (c) 2013 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 <string>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "test/codec_factory.h"
#include "test/decode_test_driver.h"
#include "test/i420_video_source.h"
#include "vp9/decoder/vp9_decoder.h"
#include "vpx/svc_context.h"
#include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h"
namespace {
using libvpx_test::CodecFactory;
using libvpx_test::Decoder;
using libvpx_test::DxDataIterator;
using libvpx_test::VP9CodecFactory;
class SvcTest : public ::testing::Test {
protected:
static const uint32_t kWidth = 352;
static const uint32_t kHeight = 288;
SvcTest()
: codec_iface_(0),
test_file_name_("hantro_collage_w352h288.yuv"),
codec_initialized_(false),
decoder_(0) {
memset(&svc_, 0, sizeof(svc_));
memset(&codec_, 0, sizeof(codec_));
memset(&codec_enc_, 0, sizeof(codec_enc_));
}
virtual ~SvcTest() {}
virtual void SetUp() {
svc_.log_level = SVC_LOG_DEBUG;
svc_.log_print = 0;
codec_iface_ = vpx_codec_vp9_cx();
const vpx_codec_err_t res =
vpx_codec_enc_config_default(codec_iface_, &codec_enc_, 0);
EXPECT_EQ(VPX_CODEC_OK, res);
codec_enc_.g_w = kWidth;
codec_enc_.g_h = kHeight;
codec_enc_.g_timebase.num = 1;
codec_enc_.g_timebase.den = 60;
codec_enc_.kf_min_dist = 100;
codec_enc_.kf_max_dist = 100;
vpx_codec_dec_cfg_t dec_cfg = vpx_codec_dec_cfg_t();
VP9CodecFactory codec_factory;
decoder_ = codec_factory.CreateDecoder(dec_cfg, 0);
tile_columns_ = 0;
tile_rows_ = 0;
}
virtual void TearDown() {
ReleaseEncoder();
delete(decoder_);
}
void InitializeEncoder() {
const vpx_codec_err_t res =
vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_OK, res);
vpx_codec_control(&codec_, VP8E_SET_CPUUSED, 4); // Make the test faster
vpx_codec_control(&codec_, VP9E_SET_TILE_COLUMNS, tile_columns_);
vpx_codec_control(&codec_, VP9E_SET_TILE_ROWS, tile_rows_);
codec_initialized_ = true;
}
void ReleaseEncoder() {
vpx_svc_release(&svc_);
if (codec_initialized_) vpx_codec_destroy(&codec_);
codec_initialized_ = false;
}
void GetStatsData(std::string *const stats_buf) {
vpx_codec_iter_t iter = NULL;
const vpx_codec_cx_pkt_t *cx_pkt;
while ((cx_pkt = vpx_codec_get_cx_data(&codec_, &iter)) != NULL) {
if (cx_pkt->kind == VPX_CODEC_STATS_PKT) {
EXPECT_GT(cx_pkt->data.twopass_stats.sz, 0U);
ASSERT_TRUE(cx_pkt->data.twopass_stats.buf != NULL);
stats_buf->append(static_cast<char*>(cx_pkt->data.twopass_stats.buf),
cx_pkt->data.twopass_stats.sz);
}
}
}
void Pass1EncodeNFrames(const int n, const int layers,
std::string *const stats_buf) {
vpx_codec_err_t res;
ASSERT_GT(n, 0);
ASSERT_GT(layers, 0);
svc_.spatial_layers = layers;
codec_enc_.g_pass = VPX_RC_FIRST_PASS;
InitializeEncoder();
libvpx_test::I420VideoSource video(test_file_name_,
codec_enc_.g_w, codec_enc_.g_h,
codec_enc_.g_timebase.den,
codec_enc_.g_timebase.num, 0, 30);
video.Begin();
for (int i = 0; i < n; ++i) {
res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(),
video.duration(), VPX_DL_GOOD_QUALITY);
ASSERT_EQ(VPX_CODEC_OK, res);
GetStatsData(stats_buf);
video.Next();
}
// Flush encoder and test EOS packet.
res = vpx_svc_encode(&svc_, &codec_, NULL, video.pts(),
video.duration(), VPX_DL_GOOD_QUALITY);
ASSERT_EQ(VPX_CODEC_OK, res);
GetStatsData(stats_buf);
ReleaseEncoder();
}
void StoreFrames(const size_t max_frame_received,
struct vpx_fixed_buf *const outputs,
size_t *const frame_received) {
vpx_codec_iter_t iter = NULL;
const vpx_codec_cx_pkt_t *cx_pkt;
while ((cx_pkt = vpx_codec_get_cx_data(&codec_, &iter)) != NULL) {
if (cx_pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
const size_t frame_size = cx_pkt->data.frame.sz;
EXPECT_GT(frame_size, 0U);
ASSERT_TRUE(cx_pkt->data.frame.buf != NULL);
ASSERT_LT(*frame_received, max_frame_received);
if (*frame_received == 0)
EXPECT_EQ(1, !!(cx_pkt->data.frame.flags & VPX_FRAME_IS_KEY));
outputs[*frame_received].buf = malloc(frame_size + 16);
ASSERT_TRUE(outputs[*frame_received].buf != NULL);
memcpy(outputs[*frame_received].buf, cx_pkt->data.frame.buf,
frame_size);
outputs[*frame_received].sz = frame_size;
++(*frame_received);
}
}
}
void Pass2EncodeNFrames(std::string *const stats_buf,
const int n, const int layers,
struct vpx_fixed_buf *const outputs) {
vpx_codec_err_t res;
size_t frame_received = 0;
ASSERT_TRUE(outputs != NULL);
ASSERT_GT(n, 0);
ASSERT_GT(layers, 0);
svc_.spatial_layers = layers;
codec_enc_.rc_target_bitrate = 500;
if (codec_enc_.g_pass == VPX_RC_LAST_PASS) {
ASSERT_TRUE(stats_buf != NULL);
ASSERT_GT(stats_buf->size(), 0U);
codec_enc_.rc_twopass_stats_in.buf = &(*stats_buf)[0];
codec_enc_.rc_twopass_stats_in.sz = stats_buf->size();
}
InitializeEncoder();
libvpx_test::I420VideoSource video(test_file_name_,
codec_enc_.g_w, codec_enc_.g_h,
codec_enc_.g_timebase.den,
codec_enc_.g_timebase.num, 0, 30);
video.Begin();
for (int i = 0; i < n; ++i) {
res = vpx_svc_encode(&svc_, &codec_, video.img(), video.pts(),
video.duration(), VPX_DL_GOOD_QUALITY);
ASSERT_EQ(VPX_CODEC_OK, res);
StoreFrames(n, outputs, &frame_received);
video.Next();
}
// Flush encoder.
res = vpx_svc_encode(&svc_, &codec_, NULL, 0,
video.duration(), VPX_DL_GOOD_QUALITY);
EXPECT_EQ(VPX_CODEC_OK, res);
StoreFrames(n, outputs, &frame_received);
EXPECT_EQ(frame_received, static_cast<size_t>(n));
ReleaseEncoder();
}
void DecodeNFrames(const struct vpx_fixed_buf *const inputs, const int n) {
int decoded_frames = 0;
int received_frames = 0;
ASSERT_TRUE(inputs != NULL);
ASSERT_GT(n, 0);
for (int i = 0; i < n; ++i) {
ASSERT_TRUE(inputs[i].buf != NULL);
ASSERT_GT(inputs[i].sz, 0U);
const vpx_codec_err_t res_dec =
decoder_->DecodeFrame(static_cast<const uint8_t *>(inputs[i].buf),
inputs[i].sz);
ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder_->DecodeError();
++decoded_frames;
DxDataIterator dec_iter = decoder_->GetDxData();
while (dec_iter.Next() != NULL) {
++received_frames;
}
}
EXPECT_EQ(decoded_frames, n);
EXPECT_EQ(received_frames, n);
}
void DropEnhancementLayers(struct vpx_fixed_buf *const inputs,
const int num_super_frames,
const int remained_spatial_layers) {
ASSERT_TRUE(inputs != NULL);
ASSERT_GT(num_super_frames, 0);
ASSERT_GT(remained_spatial_layers, 0);
for (int i = 0; i < num_super_frames; ++i) {
uint32_t frame_sizes[8] = {0};
int frame_count = 0;
int frames_found = 0;
int frame;
ASSERT_TRUE(inputs[i].buf != NULL);
ASSERT_GT(inputs[i].sz, 0U);
vpx_codec_err_t res =
vp9_parse_superframe_index(static_cast<const uint8_t*>(inputs[i].buf),
inputs[i].sz, frame_sizes, &frame_count,
NULL, NULL);
ASSERT_EQ(VPX_CODEC_OK, res);
if (frame_count == 0) {
// There's no super frame but only a single frame.
ASSERT_EQ(1, remained_spatial_layers);
} else {
// Found a super frame.
uint8_t *frame_data = static_cast<uint8_t*>(inputs[i].buf);
uint8_t *frame_start = frame_data;
for (frame = 0; frame < frame_count; ++frame) {
// Looking for a visible frame.
if (frame_data[0] & 0x02) {
++frames_found;
if (frames_found == remained_spatial_layers)
break;
}
frame_data += frame_sizes[frame];
}
ASSERT_LT(frame, frame_count) << "Couldn't find a visible frame. "
<< "remained_spatial_layers: " << remained_spatial_layers
<< " super_frame: " << i;
if (frame == frame_count - 1)
continue;
frame_data += frame_sizes[frame];
// We need to add one more frame for multiple frame contexts.
uint8_t marker =
static_cast<const uint8_t*>(inputs[i].buf)[inputs[i].sz - 1];
const uint32_t mag = ((marker >> 3) & 0x3) + 1;
const size_t index_sz = 2 + mag * frame_count;
const size_t new_index_sz = 2 + mag * (frame + 1);
marker &= 0x0f8;
marker |= frame;
// Copy existing frame sizes.
memmove(frame_data + 1, frame_start + inputs[i].sz - index_sz + 1,
new_index_sz - 2);
// New marker.
frame_data[0] = marker;
frame_data += (mag * (frame + 1) + 1);
*frame_data++ = marker;
inputs[i].sz = frame_data - frame_start;
}
}
}
void FreeBitstreamBuffers(struct vpx_fixed_buf *const inputs, const int n) {
ASSERT_TRUE(inputs != NULL);
ASSERT_GT(n, 0);
for (int i = 0; i < n; ++i) {
free(inputs[i].buf);
inputs[i].buf = NULL;
inputs[i].sz = 0;
}
}
SvcContext svc_;
vpx_codec_ctx_t codec_;
struct vpx_codec_enc_cfg codec_enc_;
vpx_codec_iface_t *codec_iface_;
std::string test_file_name_;
bool codec_initialized_;
Decoder *decoder_;
int tile_columns_;
int tile_rows_;
};
TEST_F(SvcTest, SvcInit) {
// test missing parameters
vpx_codec_err_t res = vpx_svc_init(NULL, &codec_, codec_iface_, &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_init(&svc_, NULL, codec_iface_, &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_init(&svc_, &codec_, NULL, &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_init(&svc_, &codec_, codec_iface_, NULL);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
svc_.spatial_layers = 6; // too many layers
res = vpx_svc_init(&svc_, &codec_, codec_iface_, &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
svc_.spatial_layers = 0; // use default layers
InitializeEncoder();
EXPECT_EQ(VPX_SS_DEFAULT_LAYERS, svc_.spatial_layers);
}
TEST_F(SvcTest, InitTwoLayers) {
svc_.spatial_layers = 2;
InitializeEncoder();
}
TEST_F(SvcTest, InvalidOptions) {
vpx_codec_err_t res = vpx_svc_set_options(&svc_, NULL);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_set_options(&svc_, "not-an-option=1");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
}
TEST_F(SvcTest, SetLayersOption) {
vpx_codec_err_t res = vpx_svc_set_options(&svc_, "spatial-layers=3");
EXPECT_EQ(VPX_CODEC_OK, res);
InitializeEncoder();
EXPECT_EQ(3, svc_.spatial_layers);
}
TEST_F(SvcTest, SetMultipleOptions) {
vpx_codec_err_t res =
vpx_svc_set_options(&svc_, "spatial-layers=2 scale-factors=1/3,2/3");
EXPECT_EQ(VPX_CODEC_OK, res);
InitializeEncoder();
EXPECT_EQ(2, svc_.spatial_layers);
}
TEST_F(SvcTest, SetScaleFactorsOption) {
svc_.spatial_layers = 2;
vpx_codec_err_t res =
vpx_svc_set_options(&svc_, "scale-factors=not-scale-factors");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_set_options(&svc_, "scale-factors=1/3, 3*3");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_set_options(&svc_, "scale-factors=1/3");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_set_options(&svc_, "scale-factors=1/3,2/3");
EXPECT_EQ(VPX_CODEC_OK, res);
InitializeEncoder();
}
TEST_F(SvcTest, SetQuantizersOption) {
svc_.spatial_layers = 2;
vpx_codec_err_t res = vpx_svc_set_options(&svc_, "max-quantizers=nothing");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_set_options(&svc_, "min-quantizers=nothing");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_set_options(&svc_, "max-quantizers=40");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_set_options(&svc_, "min-quantizers=40");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_set_options(&svc_, "max-quantizers=30,30 min-quantizers=40,40");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_set_options(&svc_, "max-quantizers=40,40 min-quantizers=30,30");
InitializeEncoder();
}
TEST_F(SvcTest, SetAutoAltRefOption) {
svc_.spatial_layers = 5;
vpx_codec_err_t res = vpx_svc_set_options(&svc_, "auto-alt-refs=none");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
res = vpx_svc_set_options(&svc_, "auto-alt-refs=1,1,1,1,0");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
vpx_svc_set_options(&svc_, "auto-alt-refs=0,1,1,1,0");
InitializeEncoder();
}
// Test that decoder can handle an SVC frame as the first frame in a sequence.
TEST_F(SvcTest, OnePassEncodeOneFrame) {
codec_enc_.g_pass = VPX_RC_ONE_PASS;
vpx_fixed_buf output = {0};
Pass2EncodeNFrames(NULL, 1, 2, &output);
DecodeNFrames(&output, 1);
FreeBitstreamBuffers(&output, 1);
}
TEST_F(SvcTest, OnePassEncodeThreeFrames) {
codec_enc_.g_pass = VPX_RC_ONE_PASS;
vpx_fixed_buf outputs[3];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(NULL, 3, 2, &outputs[0]);
DecodeNFrames(&outputs[0], 3);
FreeBitstreamBuffers(&outputs[0], 3);
}
TEST_F(SvcTest, TwoPassEncode10Frames) {
// First pass encode
std::string stats_buf;
Pass1EncodeNFrames(10, 2, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest, TwoPassEncode20FramesWithAltRef) {
// First pass encode
std::string stats_buf;
Pass1EncodeNFrames(20, 2, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
vpx_svc_set_options(&svc_, "auto-alt-refs=1,1");
vpx_fixed_buf outputs[20];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 20, 2, &outputs[0]);
DecodeNFrames(&outputs[0], 20);
FreeBitstreamBuffers(&outputs[0], 20);
}
TEST_F(SvcTest, TwoPassEncode2SpatialLayersDecodeBaseLayerOnly) {
// First pass encode
std::string stats_buf;
Pass1EncodeNFrames(10, 2, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
vpx_svc_set_options(&svc_, "auto-alt-refs=1,1");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]);
DropEnhancementLayers(&outputs[0], 10, 1);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest, TwoPassEncode5SpatialLayersDecode54321Layers) {
// First pass encode
std::string stats_buf;
Pass1EncodeNFrames(10, 5, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
vpx_svc_set_options(&svc_, "auto-alt-refs=0,1,1,1,0");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 5, &outputs[0]);
DecodeNFrames(&outputs[0], 10);
DropEnhancementLayers(&outputs[0], 10, 4);
DecodeNFrames(&outputs[0], 10);
DropEnhancementLayers(&outputs[0], 10, 3);
DecodeNFrames(&outputs[0], 10);
DropEnhancementLayers(&outputs[0], 10, 2);
DecodeNFrames(&outputs[0], 10);
DropEnhancementLayers(&outputs[0], 10, 1);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest, TwoPassEncode2SNRLayers) {
// First pass encode
std::string stats_buf;
vpx_svc_set_options(&svc_, "scale-factors=1/1,1/1");
Pass1EncodeNFrames(20, 2, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
vpx_svc_set_options(&svc_,
"auto-alt-refs=1,1 scale-factors=1/1,1/1");
vpx_fixed_buf outputs[20];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 20, 2, &outputs[0]);
DecodeNFrames(&outputs[0], 20);
FreeBitstreamBuffers(&outputs[0], 20);
}
TEST_F(SvcTest, TwoPassEncode3SNRLayersDecode321Layers) {
// First pass encode
std::string stats_buf;
vpx_svc_set_options(&svc_, "scale-factors=1/1,1/1,1/1");
Pass1EncodeNFrames(20, 3, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
vpx_svc_set_options(&svc_,
"auto-alt-refs=1,1,1 scale-factors=1/1,1/1,1/1");
vpx_fixed_buf outputs[20];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 20, 3, &outputs[0]);
DecodeNFrames(&outputs[0], 20);
DropEnhancementLayers(&outputs[0], 20, 2);
DecodeNFrames(&outputs[0], 20);
DropEnhancementLayers(&outputs[0], 20, 1);
DecodeNFrames(&outputs[0], 20);
FreeBitstreamBuffers(&outputs[0], 20);
}
TEST_F(SvcTest, SetMultipleFrameContextsOption) {
svc_.spatial_layers = 5;
vpx_codec_err_t res =
vpx_svc_set_options(&svc_, "multi-frame-contexts=1");
EXPECT_EQ(VPX_CODEC_OK, res);
res = vpx_svc_init(&svc_, &codec_, vpx_codec_vp9_cx(), &codec_enc_);
EXPECT_EQ(VPX_CODEC_INVALID_PARAM, res);
svc_.spatial_layers = 2;
res = vpx_svc_set_options(&svc_, "multi-frame-contexts=1");
InitializeEncoder();
}
TEST_F(SvcTest, TwoPassEncode2SpatialLayersWithMultipleFrameContexts) {
// First pass encode
std::string stats_buf;
Pass1EncodeNFrames(10, 2, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
codec_enc_.g_error_resilient = 0;
vpx_svc_set_options(&svc_, "auto-alt-refs=1,1 multi-frame-contexts=1");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest,
TwoPassEncode2SpatialLayersWithMultipleFrameContextsDecodeBaselayer) {
// First pass encode
std::string stats_buf;
Pass1EncodeNFrames(10, 2, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
codec_enc_.g_error_resilient = 0;
vpx_svc_set_options(&svc_, "auto-alt-refs=1,1 multi-frame-contexts=1");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]);
DropEnhancementLayers(&outputs[0], 10, 1);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest, TwoPassEncode2SNRLayersWithMultipleFrameContexts) {
// First pass encode
std::string stats_buf;
vpx_svc_set_options(&svc_, "scale-factors=1/1,1/1");
Pass1EncodeNFrames(10, 2, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
codec_enc_.g_error_resilient = 0;
vpx_svc_set_options(&svc_, "auto-alt-refs=1,1 scale-factors=1/1,1/1 "
"multi-frame-contexts=1");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 2, &outputs[0]);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest,
TwoPassEncode3SNRLayersWithMultipleFrameContextsDecode321Layer) {
// First pass encode
std::string stats_buf;
vpx_svc_set_options(&svc_, "scale-factors=1/1,1/1,1/1");
Pass1EncodeNFrames(10, 3, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
codec_enc_.g_error_resilient = 0;
vpx_svc_set_options(&svc_, "auto-alt-refs=1,1,1 scale-factors=1/1,1/1,1/1 "
"multi-frame-contexts=1");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 3, &outputs[0]);
DecodeNFrames(&outputs[0], 10);
DropEnhancementLayers(&outputs[0], 10, 2);
DecodeNFrames(&outputs[0], 10);
DropEnhancementLayers(&outputs[0], 10, 1);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest, TwoPassEncode2TemporalLayers) {
// First pass encode
std::string stats_buf;
vpx_svc_set_options(&svc_, "scale-factors=1/1");
svc_.temporal_layers = 2;
Pass1EncodeNFrames(10, 1, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
svc_.temporal_layers = 2;
vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest, TwoPassEncode2TemporalLayersWithMultipleFrameContexts) {
// First pass encode
std::string stats_buf;
vpx_svc_set_options(&svc_, "scale-factors=1/1");
svc_.temporal_layers = 2;
Pass1EncodeNFrames(10, 1, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
svc_.temporal_layers = 2;
codec_enc_.g_error_resilient = 0;
vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1 "
"multi-frame-contexts=1");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest, TwoPassEncode2TemporalLayersDecodeBaseLayer) {
// First pass encode
std::string stats_buf;
vpx_svc_set_options(&svc_, "scale-factors=1/1");
svc_.temporal_layers = 2;
Pass1EncodeNFrames(10, 1, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
svc_.temporal_layers = 2;
vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]);
vpx_fixed_buf base_layer[5];
for (int i = 0; i < 5; ++i)
base_layer[i] = outputs[i * 2];
DecodeNFrames(&base_layer[0], 5);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest,
TwoPassEncode2TemporalLayersWithMultipleFrameContextsDecodeBaseLayer) {
// First pass encode
std::string stats_buf;
vpx_svc_set_options(&svc_, "scale-factors=1/1");
svc_.temporal_layers = 2;
Pass1EncodeNFrames(10, 1, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
svc_.temporal_layers = 2;
codec_enc_.g_error_resilient = 0;
vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1 "
"multi-frame-contexts=1");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]);
vpx_fixed_buf base_layer[5];
for (int i = 0; i < 5; ++i)
base_layer[i] = outputs[i * 2];
DecodeNFrames(&base_layer[0], 5);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest, TwoPassEncode2TemporalLayersWithTiles) {
// First pass encode
std::string stats_buf;
vpx_svc_set_options(&svc_, "scale-factors=1/1");
svc_.temporal_layers = 2;
Pass1EncodeNFrames(10, 1, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
svc_.temporal_layers = 2;
vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1");
codec_enc_.g_w = 704;
codec_enc_.g_h = 144;
tile_columns_ = 1;
tile_rows_ = 1;
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
TEST_F(SvcTest,
TwoPassEncode2TemporalLayersWithMultipleFrameContextsAndTiles) {
// First pass encode
std::string stats_buf;
vpx_svc_set_options(&svc_, "scale-factors=1/1");
svc_.temporal_layers = 2;
Pass1EncodeNFrames(10, 1, &stats_buf);
// Second pass encode
codec_enc_.g_pass = VPX_RC_LAST_PASS;
svc_.temporal_layers = 2;
codec_enc_.g_error_resilient = 0;
codec_enc_.g_w = 704;
codec_enc_.g_h = 144;
tile_columns_ = 1;
tile_rows_ = 1;
vpx_svc_set_options(&svc_, "auto-alt-refs=1 scale-factors=1/1 "
"multi-frame-contexts=1");
vpx_fixed_buf outputs[10];
memset(&outputs[0], 0, sizeof(outputs));
Pass2EncodeNFrames(&stats_buf, 10, 1, &outputs[0]);
DecodeNFrames(&outputs[0], 10);
FreeBitstreamBuffers(&outputs[0], 10);
}
} // namespace

View File

@@ -17,7 +17,6 @@ LIBVPX_TEST_DATA-$(CONFIG_ENCODERS) += park_joy_90p_8_422.y4m
LIBVPX_TEST_DATA-$(CONFIG_ENCODERS) += park_joy_90p_8_444.y4m LIBVPX_TEST_DATA-$(CONFIG_ENCODERS) += park_joy_90p_8_444.y4m
LIBVPX_TEST_DATA-$(CONFIG_ENCODERS) += park_joy_90p_8_440.yuv LIBVPX_TEST_DATA-$(CONFIG_ENCODERS) += park_joy_90p_8_440.yuv
LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += niklas_1280_720_30.y4m
LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += rush_hour_444.y4m LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += rush_hour_444.y4m
LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += screendata.y4m LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += screendata.y4m
@@ -554,8 +553,6 @@ LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-06-bilinear.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-06-bilinear.webm.md5 LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-06-bilinear.webm.md5
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-07-frame_parallel.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-07-frame_parallel.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-07-frame_parallel.webm.md5 LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-07-frame_parallel.webm.md5
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-07-frame_parallel-1.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-07-frame_parallel-1.webm.md5
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-08-tile-4x1.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-08-tile-4x1.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-08-tile-4x1.webm.md5 LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-08-tile-4x1.webm.md5
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-08-tile-4x4.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-08-tile-4x4.webm
@@ -662,10 +659,6 @@ LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv440.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv440.webm.md5 LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv440.webm.md5
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv444.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv444.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv444.webm.md5 LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv444.webm.md5
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-20-big_superframe-01.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-20-big_superframe-01.webm.md5
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-20-big_superframe-02.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-20-big_superframe-02.webm.md5
ifeq ($(CONFIG_VP9_HIGHBITDEPTH),yes) ifeq ($(CONFIG_VP9_HIGHBITDEPTH),yes)
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp92-2-20-10bit-yuv420.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp92-2-20-10bit-yuv420.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp92-2-20-10bit-yuv420.webm.md5 LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp92-2-20-10bit-yuv420.webm.md5
@@ -698,16 +691,10 @@ LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.iv
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-03-size-202x210.webm.ivf.s113306_r01-05_b6-.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-03-size-202x210.webm.ivf.s113306_r01-05_b6-.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-03-size-224x196.webm.ivf.s44156_r01-05_b6-.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-03-size-224x196.webm.ivf.s44156_r01-05_b6-.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-05-resize.ivf.s59293_r01-05_b6-.ivf LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-05-resize.ivf.s59293_r01-05_b6-.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-05-resize.ivf.s59293_r01-05_b6-.ivf.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-05-resize.ivf.s59293_r01-05_b6-.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x8_frame_parallel.webm.ivf.s288_r01-05_b6-.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x8_frame_parallel.webm.ivf.s288_r01-05_b6-.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-09-aq2.webm.ivf.s3984_r01-05_b6-.v2.ivf LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-09-aq2.webm.ivf.s3984_r01-05_b6-.v2.ivf
@@ -722,13 +709,8 @@ LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-12-droppable_1.ivf.s738
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-12-droppable_1.ivf.s73804_r01-05_b6-.ivf.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-12-droppable_1.ivf.s73804_r01-05_b6-.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp91-2-mixedrefcsp-444to420.ivf LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp91-2-mixedrefcsp-444to420.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp91-2-mixedrefcsp-444to420.ivf.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp91-2-mixedrefcsp-444to420.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-07-frame_parallel-1.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-07-frame_parallel-2.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-07-frame_parallel-3.webm
ifeq ($(CONFIG_DECODE_PERF_TESTS),yes) ifeq ($(CONFIG_DECODE_PERF_TESTS),yes)
# Encode / Decode test
LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += niklas_1280_720_30.yuv
# BBB VP9 streams # BBB VP9 streams
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-bbb_426x240_tile_1x1_180kbps.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-bbb_426x240_tile_1x1_180kbps.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-bbb_640x360_tile_1x2_337kbps.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp90-2-bbb_640x360_tile_1x2_337kbps.webm
@@ -764,6 +746,3 @@ LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += tacomanarrows_640_480_30.yuv
LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += tacomasmallcameramovement_640_480_30.yuv LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += tacomasmallcameramovement_640_480_30.yuv
LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += thaloundeskmtg_640_480_30.yuv LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += thaloundeskmtg_640_480_30.yuv
endif # CONFIG_ENCODE_PERF_TESTS endif # CONFIG_ENCODE_PERF_TESTS
# sort and remove duplicates
LIBVPX_TEST_DATA-yes := $(sort $(LIBVPX_TEST_DATA-yes))

View File

@@ -706,8 +706,6 @@ c12918cf0a716417fba2de35c3fc5ab90e52dfce vp90-2-18-resize.ivf.md5
717da707afcaa1f692ff1946f291054eb75a4f06 screendata.y4m 717da707afcaa1f692ff1946f291054eb75a4f06 screendata.y4m
b7c1296630cdf1a7ef493d15ff4f9eb2999202f6 invalid-vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf b7c1296630cdf1a7ef493d15ff4f9eb2999202f6 invalid-vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf
0a3884edb3fd8f9d9b500223e650f7de257b67d8 invalid-vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf.res 0a3884edb3fd8f9d9b500223e650f7de257b67d8 invalid-vp90-2-08-tile_1x2_frame_parallel.webm.ivf.s47039_r01-05_b6-.ivf.res
359e138dfb66863828397b77000ea7a83c844d02 invalid-vp90-2-08-tile_1x8_frame_parallel.webm.ivf.s288_r01-05_b6-.ivf
bbd33de01c17b165b4ce00308e8a19a942023ab8 invalid-vp90-2-08-tile_1x8_frame_parallel.webm.ivf.s288_r01-05_b6-.ivf.res
fac89b5735be8a86b0dc05159f996a5c3208ae32 invalid-vp90-2-09-aq2.webm.ivf.s3984_r01-05_b6-.v2.ivf fac89b5735be8a86b0dc05159f996a5c3208ae32 invalid-vp90-2-09-aq2.webm.ivf.s3984_r01-05_b6-.v2.ivf
0a3884edb3fd8f9d9b500223e650f7de257b67d8 invalid-vp90-2-09-aq2.webm.ivf.s3984_r01-05_b6-.v2.ivf.res 0a3884edb3fd8f9d9b500223e650f7de257b67d8 invalid-vp90-2-09-aq2.webm.ivf.s3984_r01-05_b6-.v2.ivf.res
4506dfdcdf8ee4250924b075a0dcf1f070f72e5a invalid-vp90-2-09-subpixel-00.ivf.s19552_r01-05_b6-.v2.ivf 4506dfdcdf8ee4250924b075a0dcf1f070f72e5a invalid-vp90-2-09-subpixel-00.ivf.s19552_r01-05_b6-.v2.ivf
@@ -728,17 +726,3 @@ b03c408cf23158638da18dbc3323b99a1635c68a invalid-vp90-2-12-droppable_1.ivf.s367
a61774cf03fc584bd9f0904fc145253bb8ea6c4c invalid-vp91-2-mixedrefcsp-444to420.ivf.res a61774cf03fc584bd9f0904fc145253bb8ea6c4c invalid-vp91-2-mixedrefcsp-444to420.ivf.res
812d05a64a0d83c1b504d0519927ddc5a2cdb273 invalid-vp90-2-12-droppable_1.ivf.s73804_r01-05_b6-.ivf 812d05a64a0d83c1b504d0519927ddc5a2cdb273 invalid-vp90-2-12-droppable_1.ivf.s73804_r01-05_b6-.ivf
1e472baaf5f6113459f0399a38a5a5e68d17799d invalid-vp90-2-12-droppable_1.ivf.s73804_r01-05_b6-.ivf.res 1e472baaf5f6113459f0399a38a5a5e68d17799d invalid-vp90-2-12-droppable_1.ivf.s73804_r01-05_b6-.ivf.res
f97088c7359fc8d3d5aa5eafe57bc7308b3ee124 vp90-2-20-big_superframe-01.webm
47d7d409785afa33b123376de0c907336e6c7bd7 vp90-2-20-big_superframe-01.webm.md5
65ade6d2786209582c50d34cfe22b3cdb033abaf vp90-2-20-big_superframe-02.webm
7c0ed8d04c4d06c5411dd2e5de2411d37f092db5 vp90-2-20-big_superframe-02.webm.md5
667ec8718c982aef6be07eb94f083c2efb9d2d16 vp90-2-07-frame_parallel-1.webm
bfc82bf848e9c05020d61e3ffc1e62f25df81d19 vp90-2-07-frame_parallel-1.webm.md5
efd5a51d175cfdacd169ed23477729dc558030dc invalid-vp90-2-07-frame_parallel-1.webm
9f912712ec418be69adb910e2ca886a63c4cec08 invalid-vp90-2-07-frame_parallel-2.webm
445f5a53ca9555341852997ccdd480a51540bd14 invalid-vp90-2-07-frame_parallel-3.webm
d18c90709a0d03c82beadf10898b27d88fff719c invalid-vp90-2-03-size-224x196.webm.ivf.s44156_r01-05_b6-.ivf
d06285d109ecbaef63b0cbcc44d70a129186f51c invalid-vp90-2-03-size-224x196.webm.ivf.s44156_r01-05_b6-.ivf.res
e60d859b0ef2b331b21740cf6cb83fabe469b079 invalid-vp90-2-03-size-202x210.webm.ivf.s113306_r01-05_b6-.ivf
0ae808dca4d3c1152a9576e14830b6faa39f1b4a invalid-vp90-2-03-size-202x210.webm.ivf.s113306_r01-05_b6-.ivf.res
9cfc855459e7549fd015c79e8eca512b2f2cb7e3 niklas_1280_720_30.y4m

View File

@@ -22,7 +22,6 @@ LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += aq_segment_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += datarate_test.cc LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += datarate_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += error_resilience_test.cc LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += error_resilience_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += i420_video_source.h LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += i420_video_source.h
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += resize_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += y4m_video_source.h LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += y4m_video_source.h
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += yuv_video_source.h LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += yuv_video_source.h
@@ -31,36 +30,31 @@ LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += config_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += cq_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += cq_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += keyframe_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += keyframe_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += byte_alignment_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += external_frame_buffer_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += external_frame_buffer_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += invalid_file_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += invalid_file_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += user_priv_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += user_priv_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += vp9_frame_parallel_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += active_map_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += active_map_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += borders_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += borders_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += cpu_speed_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += cpu_speed_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += frame_size_tests.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += frame_size_tests.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += resize_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_lossless_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_lossless_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_end_to_end_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_end_to_end_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_ethread_test.cc
LIBVPX_TEST_SRCS-yes += decode_test_driver.cc LIBVPX_TEST_SRCS-yes += decode_test_driver.cc
LIBVPX_TEST_SRCS-yes += decode_test_driver.h LIBVPX_TEST_SRCS-yes += decode_test_driver.h
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += encode_test_driver.cc LIBVPX_TEST_SRCS-yes += encode_test_driver.cc
LIBVPX_TEST_SRCS-yes += encode_test_driver.h LIBVPX_TEST_SRCS-yes += encode_test_driver.h
## IVF writing.
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += ../ivfenc.c ../ivfenc.h
## Y4m parsing. ## Y4m parsing.
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += y4m_test.cc ../y4menc.c ../y4menc.h LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += y4m_test.cc ../y4menc.c ../y4menc.h
## WebM Parsing ## WebM Parsing
ifeq ($(CONFIG_WEBM_IO), yes) ifeq ($(CONFIG_WEBM_IO), yes)
LIBWEBM_PARSER_SRCS += ../third_party/libwebm/mkvparser.cpp LIBWEBM_PARSER_SRCS += ../third_party/libwebm/mkvparser/mkvparser.cc
LIBWEBM_PARSER_SRCS += ../third_party/libwebm/mkvreader.cpp LIBWEBM_PARSER_SRCS += ../third_party/libwebm/mkvparser/mkvreader.cc
LIBWEBM_PARSER_SRCS += ../third_party/libwebm/mkvparser.hpp LIBWEBM_PARSER_SRCS += ../third_party/libwebm/mkvparser/mkvparser.h
LIBWEBM_PARSER_SRCS += ../third_party/libwebm/mkvreader.hpp LIBWEBM_PARSER_SRCS += ../third_party/libwebm/mkvparser/mkvreader.h
LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += $(LIBWEBM_PARSER_SRCS) LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += $(LIBWEBM_PARSER_SRCS)
LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ../tools_common.h LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ../tools_common.h
LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ../webmdec.cc LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ../webmdec.cc
@@ -92,12 +86,11 @@ endif
ifeq ($(CONFIG_SHARED),) ifeq ($(CONFIG_SHARED),)
## VP8 ## VP8
ifneq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),) ifeq ($(CONFIG_VP8),yes)
# These tests require both the encoder and decoder to be built. # These tests require both the encoder and decoder to be built.
ifeq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),yesyes) ifeq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),yesyes)
LIBVPX_TEST_SRCS-yes += vp8_boolcoder_test.cc LIBVPX_TEST_SRCS-yes += vp8_boolcoder_test.cc
LIBVPX_TEST_SRCS-yes += vp8_fragments_test.cc
endif endif
LIBVPX_TEST_SRCS-$(CONFIG_POSTPROC) += pp_filter_test.cc LIBVPX_TEST_SRCS-$(CONFIG_POSTPROC) += pp_filter_test.cc
@@ -106,7 +99,6 @@ LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += set_roi.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += subtract_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += subtract_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += variance_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += variance_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += vp8_fdct4x4_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += vp8_fdct4x4_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += quantize_test.cc
LIBVPX_TEST_SRCS-yes += idct_test.cc LIBVPX_TEST_SRCS-yes += idct_test.cc
LIBVPX_TEST_SRCS-yes += intrapred_test.cc LIBVPX_TEST_SRCS-yes += intrapred_test.cc
@@ -120,7 +112,7 @@ endif
endif # VP8 endif # VP8
## VP9 ## VP9
ifneq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),) ifeq ($(CONFIG_VP9),yes)
# These tests require both the encoder and decoder to be built. # These tests require both the encoder and decoder to be built.
ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),yesyes) ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),yesyes)
@@ -130,7 +122,7 @@ LIBVPX_TEST_SRCS-yes += partial_idct_test.cc
LIBVPX_TEST_SRCS-yes += superframe_test.cc LIBVPX_TEST_SRCS-yes += superframe_test.cc
LIBVPX_TEST_SRCS-yes += tile_independence_test.cc LIBVPX_TEST_SRCS-yes += tile_independence_test.cc
LIBVPX_TEST_SRCS-yes += vp9_boolcoder_test.cc LIBVPX_TEST_SRCS-yes += vp9_boolcoder_test.cc
LIBVPX_TEST_SRCS-yes += vp9_encoder_parms_get_to_decoder.cc
endif endif
LIBVPX_TEST_SRCS-$(CONFIG_VP9) += convolve_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9) += convolve_test.cc
@@ -144,21 +136,22 @@ LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += variance_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_subtract_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_subtract_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += lpf_8_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += lpf_8_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_avg_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_avg_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_error_block_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += quantize_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += vp9_quantize_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9_ENCODER) += error_block_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9) += vp9_intrapred_test.cc LIBVPX_TEST_SRCS-$(CONFIG_VP9) += vp9_intrapred_test.cc
ifeq ($(CONFIG_VP9_ENCODER),yes)
LIBVPX_TEST_SRCS-$(CONFIG_SPATIAL_SVC) += svc_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_INTERNAL_STATS) += blockiness_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_INTERNAL_STATS) += consistency_test.cc
endif
ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_TEMPORAL_DENOISING),yesyes) ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_TEMPORAL_DENOISING),yesyes)
LIBVPX_TEST_SRCS-$(HAVE_SSE2) += vp9_denoiser_sse2_test.cc LIBVPX_TEST_SRCS-$(HAVE_SSE2) += vp9_denoiser_sse2_test.cc
endif endif
ifeq ($(CONFIG_VP9)$(CONFIG_WEDGE_PARTITION),yesyes)
LIBVPX_TEST_SRCS-$(HAVE_SSSE3) += masked_variance_test.cc
endif
ifeq ($(CONFIG_VP9)$(CONFIG_WEDGE_PARTITION),yesyes)
LIBVPX_TEST_SRCS-$(HAVE_SSSE3) += masked_sad_test.cc
endif
endif # VP9 endif # VP9
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += sad_test.cc LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += sad_test.cc

View File

@@ -15,11 +15,10 @@
extern "C" { extern "C" {
#if CONFIG_VP8 #if CONFIG_VP8
extern void vp8_rtcd(); extern void vp8_rtcd();
#endif // CONFIG_VP8 #endif
#if CONFIG_VP9 #if CONFIG_VP9
extern void vp9_rtcd(); extern void vp9_rtcd();
#endif // CONFIG_VP9 #endif
extern void vpx_scale_rtcd();
} }
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
@@ -60,12 +59,11 @@ int main(int argc, char **argv) {
#if CONFIG_VP8 #if CONFIG_VP8
vp8_rtcd(); vp8_rtcd();
#endif // CONFIG_VP8 #endif
#if CONFIG_VP9 #if CONFIG_VP9
vp9_rtcd(); vp9_rtcd();
#endif // CONFIG_VP9 #endif
vpx_scale_rtcd(); #endif
#endif // !CONFIG_SHARED
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }

View File

@@ -12,7 +12,6 @@
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
#include "../tools_common.h"
#include "./vpx_config.h" #include "./vpx_config.h"
#include "test/codec_factory.h" #include "test/codec_factory.h"
#include "test/decode_test_driver.h" #include "test/decode_test_driver.h"
@@ -27,24 +26,10 @@
namespace { namespace {
enum DecodeMode {
kSerialMode,
kFrameParallelMode
};
const int kDecodeMode = 0;
const int kThreads = 1;
const int kFileName = 2;
typedef std::tr1::tuple<int, int, const char*> DecodeParam;
class TestVectorTest : public ::libvpx_test::DecoderTest, class TestVectorTest : public ::libvpx_test::DecoderTest,
public ::libvpx_test::CodecTestWithParam<DecodeParam> { public ::libvpx_test::CodecTestWithParam<const char*> {
protected: protected:
TestVectorTest() TestVectorTest() : DecoderTest(GET_PARAM(0)), md5_file_(NULL) {}
: DecoderTest(GET_PARAM(0)),
md5_file_(NULL) {
}
virtual ~TestVectorTest() { virtual ~TestVectorTest() {
if (md5_file_) if (md5_file_)
@@ -86,25 +71,8 @@ class TestVectorTest : public ::libvpx_test::DecoderTest,
// checksums match the correct md5 data, then the test is passed. Otherwise, // checksums match the correct md5 data, then the test is passed. Otherwise,
// the test failed. // the test failed.
TEST_P(TestVectorTest, MD5Match) { TEST_P(TestVectorTest, MD5Match) {
const DecodeParam input = GET_PARAM(1); const std::string filename = GET_PARAM(1);
const std::string filename = std::tr1::get<kFileName>(input);
const int threads = std::tr1::get<kThreads>(input);
const int mode = std::tr1::get<kDecodeMode>(input);
libvpx_test::CompressedVideoSource *video = NULL; libvpx_test::CompressedVideoSource *video = NULL;
vpx_codec_flags_t flags = 0;
vpx_codec_dec_cfg_t cfg = {0};
char str[256];
if (mode == kFrameParallelMode) {
flags |= VPX_CODEC_USE_FRAME_THREADING;
}
cfg.threads = threads;
snprintf(str, sizeof(str) / sizeof(str[0]) - 1,
"file: %s mode: %s threads: %d",
filename.c_str(), mode == 0 ? "Serial" : "Parallel", threads);
SCOPED_TRACE(str);
// Open compressed video file. // Open compressed video file.
if (filename.substr(filename.length() - 3, 3) == "ivf") { if (filename.substr(filename.length() - 3, 3) == "ivf") {
@@ -124,49 +92,23 @@ TEST_P(TestVectorTest, MD5Match) {
const std::string md5_filename = filename + ".md5"; const std::string md5_filename = filename + ".md5";
OpenMD5File(md5_filename); OpenMD5File(md5_filename);
// Set decode config and flags.
set_cfg(cfg);
set_flags(flags);
// Decode frame, and check the md5 matching. // Decode frame, and check the md5 matching.
ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg)); ASSERT_NO_FATAL_FAILURE(RunLoop(video));
delete video; delete video;
} }
// Test VP8 decode in serial mode with single thread. #if CONFIG_VP8_DECODER
// NOTE: VP8 only support serial mode. VP8_INSTANTIATE_TEST_CASE(TestVectorTest,
VP8_INSTANTIATE_TEST_CASE( ::testing::ValuesIn(libvpx_test::kVP8TestVectors,
TestVectorTest, libvpx_test::kVP8TestVectors +
::testing::Combine( libvpx_test::kNumVP8TestVectors));
::testing::Values(0), // Serial Mode. #endif // CONFIG_VP8_DECODER
::testing::Values(1), // Single thread.
::testing::ValuesIn(libvpx_test::kVP8TestVectors,
libvpx_test::kVP8TestVectors +
libvpx_test::kNumVP8TestVectors)));
// Test VP9 decode in serial mode with single thread.
VP9_INSTANTIATE_TEST_CASE(
TestVectorTest,
::testing::Combine(
::testing::Values(0), // Serial Mode.
::testing::Values(1), // Single thread.
::testing::ValuesIn(libvpx_test::kVP9TestVectors,
libvpx_test::kVP9TestVectors +
libvpx_test::kNumVP9TestVectors)));
#if CONFIG_VP9_DECODER #if CONFIG_VP9_DECODER
// Test VP9 decode in frame parallel mode with different number of threads. VP9_INSTANTIATE_TEST_CASE(TestVectorTest,
INSTANTIATE_TEST_CASE_P( ::testing::ValuesIn(libvpx_test::kVP9TestVectors,
VP9MultiThreadedFrameParallel, TestVectorTest, libvpx_test::kVP9TestVectors +
::testing::Combine( libvpx_test::kNumVP9TestVectors));
::testing::Values( #endif // CONFIG_VP9_DECODER
static_cast<const libvpx_test::CodecFactory *>(&libvpx_test::kVP9)),
::testing::Combine(
::testing::Values(1), // Frame Parallel mode.
::testing::Range(2, 9), // With 2 ~ 8 threads.
::testing::ValuesIn(libvpx_test::kVP9TestVectors,
libvpx_test::kVP9TestVectors +
libvpx_test::kNumVP9TestVectors))));
#endif
} // namespace } // namespace

View File

@@ -191,7 +191,6 @@ const char *const kVP9TestVectors[] = {
"vp93-2-20-10bit-yuv440.webm", "vp93-2-20-12bit-yuv440.webm", "vp93-2-20-10bit-yuv440.webm", "vp93-2-20-12bit-yuv440.webm",
"vp93-2-20-10bit-yuv444.webm", "vp93-2-20-12bit-yuv444.webm", "vp93-2-20-10bit-yuv444.webm", "vp93-2-20-12bit-yuv444.webm",
#endif // CONFIG_VP9_HIGHBITDEPTH` #endif // CONFIG_VP9_HIGHBITDEPTH`
"vp90-2-20-big_superframe-01.webm", "vp90-2-20-big_superframe-02.webm",
}; };
const int kNumVP9TestVectors = NELEMENTS(kVP9TestVectors); const int kNumVP9TestVectors = NELEMENTS(kVP9TestVectors);
#endif // CONFIG_VP9_DECODER #endif // CONFIG_VP9_DECODER

View File

@@ -106,24 +106,22 @@ check_git_hashes() {
fi fi
} }
# $1 is the name of an environment variable containing a directory name to
# test.
test_env_var_dir() {
local dir=$(eval echo "\${$1}")
if [ ! -d "${dir}" ]; then
elog "'${dir}': No such directory"
elog "The $1 environment variable must be set to a valid directory."
return 1
fi
}
# This script requires that the LIBVPX_BIN_PATH, LIBVPX_CONFIG_PATH, and # This script requires that the LIBVPX_BIN_PATH, LIBVPX_CONFIG_PATH, and
# LIBVPX_TEST_DATA_PATH variables are in the environment: Confirm that # LIBVPX_TEST_DATA_PATH variables are in the environment: Confirm that
# the variables are set and that they all evaluate to directory paths. # the variables are set and that they all evaluate to directory paths.
verify_vpx_test_environment() { verify_vpx_test_environment() {
test_env_var_dir "LIBVPX_BIN_PATH" \ if [ ! -d "${LIBVPX_BIN_PATH}" ]; then
&& test_env_var_dir "LIBVPX_CONFIG_PATH" \ echo "The LIBVPX_BIN_PATH environment variable must be set."
&& test_env_var_dir "LIBVPX_TEST_DATA_PATH" return 1
fi
if [ ! -d "${LIBVPX_CONFIG_PATH}" ]; then
echo "The LIBVPX_CONFIG_PATH environment variable must be set."
return 1
fi
if [ ! -d "${LIBVPX_TEST_DATA_PATH}" ]; then
echo "The LIBVPX_TEST_DATA_PATH environment variable must be set."
return 1
fi
} }
# Greps vpx_config.h in LIBVPX_CONFIG_PATH for positional parameter one, which # Greps vpx_config.h in LIBVPX_CONFIG_PATH for positional parameter one, which
@@ -263,9 +261,6 @@ run_tests() {
return return
fi fi
# Don't bother with the environment tests if everything else was disabled.
[ -z "${tests_to_filter}" ] && return
# Combine environment and actual tests. # Combine environment and actual tests.
local tests_to_run="${env_tests} ${tests_to_filter}" local tests_to_run="${env_tests} ${tests_to_filter}"
@@ -383,7 +378,8 @@ else
VPX_TEST_TEMP_ROOT=/tmp VPX_TEST_TEMP_ROOT=/tmp
fi fi
VPX_TEST_OUTPUT_DIR="${VPX_TEST_TEMP_ROOT}/vpx_test_$$" VPX_TEST_RAND=$(awk 'BEGIN { srand(); printf "%d\n",(rand() * 32768)}')
VPX_TEST_OUTPUT_DIR="${VPX_TEST_TEMP_ROOT}/vpx_test_${VPX_TEST_RAND}"
if ! mkdir -p "${VPX_TEST_OUTPUT_DIR}" || \ if ! mkdir -p "${VPX_TEST_OUTPUT_DIR}" || \
[ ! -d "${VPX_TEST_OUTPUT_DIR}" ]; then [ ! -d "${VPX_TEST_OUTPUT_DIR}" ]; then
@@ -401,8 +397,6 @@ VP8_IVF_FILE="${LIBVPX_TEST_DATA_PATH}/vp80-00-comprehensive-001.ivf"
VP9_IVF_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-09-subpixel-00.ivf" VP9_IVF_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-09-subpixel-00.ivf"
VP9_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-00-quantizer-00.webm" VP9_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-00-quantizer-00.webm"
VP9_FPM_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-07-frame_parallel-1.webm"
VP9_LT_50_FRAMES_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-02-size-32x08.webm"
YUV_RAW_INPUT="${LIBVPX_TEST_DATA_PATH}/hantro_collage_w352h288.yuv" YUV_RAW_INPUT="${LIBVPX_TEST_DATA_PATH}/hantro_collage_w352h288.yuv"
YUV_RAW_INPUT_WIDTH=352 YUV_RAW_INPUT_WIDTH=352
@@ -423,6 +417,7 @@ vlog "$(basename "${0%.*}") test configuration:
VPX_TEST_LIST_TESTS=${VPX_TEST_LIST_TESTS} VPX_TEST_LIST_TESTS=${VPX_TEST_LIST_TESTS}
VPX_TEST_OUTPUT_DIR=${VPX_TEST_OUTPUT_DIR} VPX_TEST_OUTPUT_DIR=${VPX_TEST_OUTPUT_DIR}
VPX_TEST_PREFIX=${VPX_TEST_PREFIX} VPX_TEST_PREFIX=${VPX_TEST_PREFIX}
VPX_TEST_RAND=${VPX_TEST_RAND}
VPX_TEST_RUN_DISABLED_TESTS=${VPX_TEST_RUN_DISABLED_TESTS} VPX_TEST_RUN_DISABLED_TESTS=${VPX_TEST_RUN_DISABLED_TESTS}
VPX_TEST_SHOW_PROGRAM_OUTPUT=${VPX_TEST_SHOW_PROGRAM_OUTPUT} VPX_TEST_SHOW_PROGRAM_OUTPUT=${VPX_TEST_SHOW_PROGRAM_OUTPUT}
VPX_TEST_TEMP_ROOT=${VPX_TEST_TEMP_ROOT} VPX_TEST_TEMP_ROOT=${VPX_TEST_TEMP_ROOT}

View File

@@ -7,19 +7,18 @@
* in the file PATENTS. All contributing project authors may * in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <stdlib.h>
#include <cstdlib>
#include <new> #include <new>
#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h"
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
#include "./vpx_config.h" #include "test/clear_system_state.h"
#include "vpx/vpx_codec.h" #include "test/register_state_check.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
#include "./vpx_config.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "vpx/vpx_codec.h"
#if CONFIG_VP8_ENCODER #if CONFIG_VP8_ENCODER
# include "./vp8_rtcd.h" # include "./vp8_rtcd.h"
# include "vp8/common/variance.h" # include "vp8/common/variance.h"
@@ -28,6 +27,7 @@
# include "./vp9_rtcd.h" # include "./vp9_rtcd.h"
# include "vp9/encoder/vp9_variance.h" # include "vp9/encoder/vp9_variance.h"
#endif #endif
#include "test/acm_random.h"
namespace { namespace {
@@ -46,14 +46,13 @@ static unsigned int mb_ss_ref(const int16_t *src) {
static unsigned int variance_ref(const uint8_t *src, const uint8_t *ref, static unsigned int variance_ref(const uint8_t *src, const uint8_t *ref,
int l2w, int l2h, int src_stride_coeff, int l2w, int l2h, int src_stride_coeff,
int ref_stride_coeff, uint32_t *sse_ptr, int ref_stride_coeff, unsigned int *sse_ptr,
bool use_high_bit_depth_, bool use_high_bit_depth_,
vpx_bit_depth_t bit_depth) { vpx_bit_depth_t bit_depth) {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
int64_t se = 0; int64_t se = 0;
uint64_t sse = 0; uint64_t sse = 0;
const int w = 1 << l2w; const int w = 1 << l2w, h = 1 << l2h;
const int h = 1 << l2h;
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) { for (int x = 0; x < w; x++) {
int diff; int diff;
@@ -71,14 +70,13 @@ static unsigned int variance_ref(const uint8_t *src, const uint8_t *ref,
} }
} }
if (bit_depth > VPX_BITS_8) { if (bit_depth > VPX_BITS_8) {
sse = ROUND_POWER_OF_TWO(sse, 2 * (bit_depth - 8)); sse = ROUND_POWER_OF_TWO(sse, 2*(bit_depth-8));
se = ROUND_POWER_OF_TWO(se, bit_depth - 8); se = ROUND_POWER_OF_TWO(se, bit_depth-8);
} }
#else #else
int se = 0; int se = 0;
unsigned int sse = 0; unsigned int sse = 0;
const int w = 1 << l2w; const int w = 1 << l2w, h = 1 << l2h;
const int h = 1 << l2h;
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) { for (int x = 0; x < w; x++) {
int diff = ref[w * y * ref_stride_coeff + x] - int diff = ref[w * y * ref_stride_coeff + x] -
@@ -87,7 +85,7 @@ static unsigned int variance_ref(const uint8_t *src, const uint8_t *ref,
sse += diff * diff; sse += diff * diff;
} }
} }
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
*sse_ptr = sse; *sse_ptr = sse;
return sse - (((int64_t) se * se) >> (l2w + l2h)); return sse - (((int64_t) se * se) >> (l2w + l2h));
} }
@@ -100,11 +98,11 @@ static unsigned int subpel_variance_ref(const uint8_t *ref, const uint8_t *src,
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
int64_t se = 0; int64_t se = 0;
uint64_t sse = 0; uint64_t sse = 0;
const int w = 1 << l2w; const int w = 1 << l2w, h = 1 << l2h;
const int h = 1 << l2h;
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) { for (int x = 0; x < w; x++) {
// Bilinear interpolation at a 16th pel step. // bilinear interpolation at a 16th pel step
if (!use_high_bit_depth_) { if (!use_high_bit_depth_) {
const int a1 = ref[(w + 1) * (y + 0) + x + 0]; const int a1 = ref[(w + 1) * (y + 0) + x + 0];
const int a2 = ref[(w + 1) * (y + 0) + x + 1]; const int a2 = ref[(w + 1) * (y + 0) + x + 1];
@@ -113,7 +111,7 @@ static unsigned int subpel_variance_ref(const uint8_t *ref, const uint8_t *src,
const int a = a1 + (((a2 - a1) * xoff + 8) >> 4); const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
const int b = b1 + (((b2 - b1) * xoff + 8) >> 4); const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
const int r = a + (((b - a) * yoff + 8) >> 4); const int r = a + (((b - a) * yoff + 8) >> 4);
const int diff = r - src[w * y + x]; int diff = r - src[w * y + x];
se += diff; se += diff;
sse += diff * diff; sse += diff * diff;
} else { } else {
@@ -126,7 +124,7 @@ static unsigned int subpel_variance_ref(const uint8_t *ref, const uint8_t *src,
const int a = a1 + (((a2 - a1) * xoff + 8) >> 4); const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
const int b = b1 + (((b2 - b1) * xoff + 8) >> 4); const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
const int r = a + (((b - a) * yoff + 8) >> 4); const int r = a + (((b - a) * yoff + 8) >> 4);
const int diff = r - src16[w * y + x]; int diff = r - src16[w * y + x];
se += diff; se += diff;
sse += diff * diff; sse += diff * diff;
} }
@@ -139,11 +137,10 @@ static unsigned int subpel_variance_ref(const uint8_t *ref, const uint8_t *src,
#else #else
int se = 0; int se = 0;
unsigned int sse = 0; unsigned int sse = 0;
const int w = 1 << l2w; const int w = 1 << l2w, h = 1 << l2h;
const int h = 1 << l2h;
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) { for (int x = 0; x < w; x++) {
// Bilinear interpolation at a 16th pel step. // bilinear interpolation at a 16th pel step
const int a1 = ref[(w + 1) * (y + 0) + x + 0]; const int a1 = ref[(w + 1) * (y + 0) + x + 0];
const int a2 = ref[(w + 1) * (y + 0) + x + 1]; const int a2 = ref[(w + 1) * (y + 0) + x + 1];
const int b1 = ref[(w + 1) * (y + 1) + x + 0]; const int b1 = ref[(w + 1) * (y + 1) + x + 0];
@@ -151,12 +148,12 @@ static unsigned int subpel_variance_ref(const uint8_t *ref, const uint8_t *src,
const int a = a1 + (((a2 - a1) * xoff + 8) >> 4); const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
const int b = b1 + (((b2 - b1) * xoff + 8) >> 4); const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
const int r = a + (((b - a) * yoff + 8) >> 4); const int r = a + (((b - a) * yoff + 8) >> 4);
const int diff = r - src[w * y + x]; int diff = r - src[w * y + x];
se += diff; se += diff;
sse += diff * diff; sse += diff * diff;
} }
} }
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
*sse_ptr = sse; *sse_ptr = sse;
return sse - (((int64_t) se * se) >> (l2w + l2h)); return sse - (((int64_t) se * se) >> (l2w + l2h));
} }
@@ -211,20 +208,21 @@ class VarianceTest
VarianceFunctionType, int> > { VarianceFunctionType, int> > {
public: public:
virtual void SetUp() { virtual void SetUp() {
const tuple<int, int, VarianceFunctionType, int>& params = this->GetParam(); const tuple<int, int, VarianceFunctionType, int>& params =
this->GetParam();
log2width_ = get<0>(params); log2width_ = get<0>(params);
width_ = 1 << log2width_; width_ = 1 << log2width_;
log2height_ = get<1>(params); log2height_ = get<1>(params);
height_ = 1 << log2height_; height_ = 1 << log2height_;
variance_ = get<2>(params); variance_ = get<2>(params);
if (get<3>(params)) { if (get<3>(params)) {
bit_depth_ = static_cast<vpx_bit_depth_t>(get<3>(params)); bit_depth_ = (vpx_bit_depth_t) get<3>(params);
use_high_bit_depth_ = true; use_high_bit_depth_ = true;
} else { } else {
bit_depth_ = VPX_BITS_8; bit_depth_ = VPX_BITS_8;
use_high_bit_depth_ = false; use_high_bit_depth_ = false;
} }
mask_ = (1 << bit_depth_) - 1; mask_ = (1 << bit_depth_)-1;
rnd_.Reset(ACMRandom::DeterministicSeed()); rnd_.Reset(ACMRandom::DeterministicSeed());
block_size_ = width_ * height_; block_size_ = width_ * height_;
@@ -367,9 +365,9 @@ void VarianceTest<VarianceFunctionType>::RefStrideTest() {
unsigned int sse1, sse2; unsigned int sse1, sse2;
unsigned int var1; unsigned int var1;
ASM_REGISTER_STATE_CHECK( ASM_REGISTER_STATE_CHECK(var1 = variance_(src_, width_ * src_stride_coeff,
var1 = variance_(src_, width_ * src_stride_coeff, ref_, width_ * ref_stride_coeff,
ref_, width_ * ref_stride_coeff, &sse1)); &sse1));
const unsigned int var2 = variance_ref(src_, ref_, log2width_, const unsigned int var2 = variance_ref(src_, ref_, log2width_,
log2height_, src_stride_coeff, log2height_, src_stride_coeff,
ref_stride_coeff, &sse2, ref_stride_coeff, &sse2,
@@ -378,7 +376,6 @@ void VarianceTest<VarianceFunctionType>::RefStrideTest() {
EXPECT_EQ(var1, var2); EXPECT_EQ(var1, var2);
} }
} }
template<typename VarianceFunctionType> template<typename VarianceFunctionType>
void VarianceTest<VarianceFunctionType>::OneQuarterTest() { void VarianceTest<VarianceFunctionType>::OneQuarterTest() {
const int half = block_size_ / 2; const int half = block_size_ / 2;
@@ -391,7 +388,7 @@ void VarianceTest<VarianceFunctionType>::OneQuarterTest() {
vpx_memset16(CONVERT_TO_SHORTPTR(src_), 255 << (bit_depth_ - 8), vpx_memset16(CONVERT_TO_SHORTPTR(src_), 255 << (bit_depth_ - 8),
block_size_); block_size_);
vpx_memset16(CONVERT_TO_SHORTPTR(ref_), 255 << (bit_depth_ - 8), half); vpx_memset16(CONVERT_TO_SHORTPTR(ref_), 255 << (bit_depth_ - 8), half);
vpx_memset16(CONVERT_TO_SHORTPTR(ref_) + half, 0, half); vpx_memset16(CONVERT_TO_SHORTPTR(ref_)+ half, 0, half);
} }
#else #else
memset(src_, 255, block_size_); memset(src_, 255, block_size_);
@@ -473,7 +470,8 @@ void MseTest<MseFunctionType>::RefTest_sse() {
unsigned int sse2; unsigned int sse2;
unsigned int var1; unsigned int var1;
const int stride_coeff = 1; const int stride_coeff = 1;
ASM_REGISTER_STATE_CHECK(var1 = mse_(src_, width_, ref_, width_)); ASM_REGISTER_STATE_CHECK(
var1 = mse_(src_, width_, ref_, width_));
variance_ref(src_, ref_, log2width_, log2height_, stride_coeff, variance_ref(src_, ref_, log2width_, log2height_, stride_coeff,
stride_coeff, &sse2, false, VPX_BITS_8); stride_coeff, &sse2, false, VPX_BITS_8);
EXPECT_EQ(var1, sse2); EXPECT_EQ(var1, sse2);
@@ -502,6 +500,7 @@ void MseTest<MseFunctionType>::MaxTest_sse() {
#endif #endif
#if CONFIG_VP9_ENCODER #if CONFIG_VP9_ENCODER
unsigned int subpel_avg_variance_ref(const uint8_t *ref, unsigned int subpel_avg_variance_ref(const uint8_t *ref,
const uint8_t *src, const uint8_t *src,
const uint8_t *second_pred, const uint8_t *second_pred,
@@ -513,8 +512,7 @@ unsigned int subpel_avg_variance_ref(const uint8_t *ref,
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
int64_t se = 0; int64_t se = 0;
uint64_t sse = 0; uint64_t sse = 0;
const int w = 1 << l2w; const int w = 1 << l2w, h = 1 << l2h;
const int h = 1 << l2h;
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) { for (int x = 0; x < w; x++) {
// bilinear interpolation at a 16th pel step // bilinear interpolation at a 16th pel step
@@ -526,7 +524,7 @@ unsigned int subpel_avg_variance_ref(const uint8_t *ref,
const int a = a1 + (((a2 - a1) * xoff + 8) >> 4); const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
const int b = b1 + (((b2 - b1) * xoff + 8) >> 4); const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
const int r = a + (((b - a) * yoff + 8) >> 4); const int r = a + (((b - a) * yoff + 8) >> 4);
const int diff = ((r + second_pred[w * y + x] + 1) >> 1) - src[w * y + x]; int diff = ((r + second_pred[w * y + x] + 1) >> 1) - src[w * y + x];
se += diff; se += diff;
sse += diff * diff; sse += diff * diff;
} else { } else {
@@ -540,7 +538,7 @@ unsigned int subpel_avg_variance_ref(const uint8_t *ref,
const int a = a1 + (((a2 - a1) * xoff + 8) >> 4); const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
const int b = b1 + (((b2 - b1) * xoff + 8) >> 4); const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
const int r = a + (((b - a) * yoff + 8) >> 4); const int r = a + (((b - a) * yoff + 8) >> 4);
const int diff = ((r + sec16[w * y + x] + 1) >> 1) - src16[w * y + x]; int diff = ((r + sec16[w * y + x] + 1) >> 1) - src16[w * y + x];
se += diff; se += diff;
sse += diff * diff; sse += diff * diff;
} }
@@ -553,8 +551,7 @@ unsigned int subpel_avg_variance_ref(const uint8_t *ref,
#else #else
int se = 0; int se = 0;
unsigned int sse = 0; unsigned int sse = 0;
const int w = 1 << l2w; const int w = 1 << l2w, h = 1 << l2h;
const int h = 1 << l2h;
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) { for (int x = 0; x < w; x++) {
// bilinear interpolation at a 16th pel step // bilinear interpolation at a 16th pel step
@@ -565,12 +562,12 @@ unsigned int subpel_avg_variance_ref(const uint8_t *ref,
const int a = a1 + (((a2 - a1) * xoff + 8) >> 4); const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
const int b = b1 + (((b2 - b1) * xoff + 8) >> 4); const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
const int r = a + (((b - a) * yoff + 8) >> 4); const int r = a + (((b - a) * yoff + 8) >> 4);
const int diff = ((r + second_pred[w * y + x] + 1) >> 1) - src[w * y + x]; int diff = ((r + second_pred[w * y + x] + 1) >> 1) - src[w * y + x];
se += diff; se += diff;
sse += diff * diff; sse += diff * diff;
} }
} }
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
*sse_ptr = sse; *sse_ptr = sse;
return sse - (((int64_t) se * se) >> (l2w + l2h)); return sse - (((int64_t) se * se) >> (l2w + l2h));
} }
@@ -605,20 +602,18 @@ class SubpelVarianceTest
sec_ = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_size_)); sec_ = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_size_));
ref_ = new uint8_t[block_size_ + width_ + height_ + 1]; ref_ = new uint8_t[block_size_ + width_ + height_ + 1];
} else { } else {
src_ = CONVERT_TO_BYTEPTR( src_ = CONVERT_TO_BYTEPTR(reinterpret_cast<uint16_t *>(vpx_memalign(16,
reinterpret_cast<uint16_t *>( block_size_*sizeof(uint16_t))));
vpx_memalign(16, block_size_*sizeof(uint16_t)))); sec_ = CONVERT_TO_BYTEPTR(reinterpret_cast<uint16_t *>(vpx_memalign(16,
sec_ = CONVERT_TO_BYTEPTR( block_size_*sizeof(uint16_t))));
reinterpret_cast<uint16_t *>( ref_ = CONVERT_TO_BYTEPTR(new uint16_t[block_size_ + width_ + height_
vpx_memalign(16, block_size_*sizeof(uint16_t)))); + 1]);
ref_ = CONVERT_TO_BYTEPTR(
new uint16_t[block_size_ + width_ + height_ + 1]);
} }
#else #else
src_ = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_size_)); src_ = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_size_));
sec_ = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_size_)); sec_ = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_size_));
ref_ = new uint8_t[block_size_ + width_ + height_ + 1]; ref_ = new uint8_t[block_size_ + width_ + height_ + 1];
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
ASSERT_TRUE(src_ != NULL); ASSERT_TRUE(src_ != NULL);
ASSERT_TRUE(sec_ != NULL); ASSERT_TRUE(sec_ != NULL);
ASSERT_TRUE(ref_ != NULL); ASSERT_TRUE(ref_ != NULL);
@@ -686,7 +681,7 @@ void SubpelVarianceTest<SubpelVarianceFunctionType>::RefTest() {
for (int j = 0; j < block_size_ + width_ + height_ + 1; j++) { for (int j = 0; j < block_size_ + width_ + height_ + 1; j++) {
ref_[j] = rnd_.Rand8(); ref_[j] = rnd_.Rand8();
} }
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
unsigned int sse1, sse2; unsigned int sse1, sse2;
unsigned int var1; unsigned int var1;
ASM_REGISTER_STATE_CHECK(var1 = subpel_variance_(ref_, width_ + 1, x, y, ASM_REGISTER_STATE_CHECK(var1 = subpel_variance_(ref_, width_ + 1, x, y,
@@ -703,9 +698,9 @@ void SubpelVarianceTest<SubpelVarianceFunctionType>::RefTest() {
template<typename SubpelVarianceFunctionType> template<typename SubpelVarianceFunctionType>
void SubpelVarianceTest<SubpelVarianceFunctionType>::ExtremeRefTest() { void SubpelVarianceTest<SubpelVarianceFunctionType>::ExtremeRefTest() {
// Compare against reference. // Compare against reference
// Src: Set the first half of values to 0, the second half to the maximum. // Src: Set the first half of values to 0, the second half to the maximum
// Ref: Set the first half of values to the maximum, the second half to 0. // Ref: Set the first half of values to the maximum, the second half to 0
for (int x = 0; x < 16; ++x) { for (int x = 0; x < 16; ++x) {
for (int y = 0; y < 16; ++y) { for (int y = 0; y < 16; ++y) {
const int half = block_size_ / 2; const int half = block_size_ / 2;
@@ -719,22 +714,23 @@ void SubpelVarianceTest<SubpelVarianceFunctionType>::ExtremeRefTest() {
vpx_memset16(CONVERT_TO_SHORTPTR(src_), mask_, half); vpx_memset16(CONVERT_TO_SHORTPTR(src_), mask_, half);
vpx_memset16(CONVERT_TO_SHORTPTR(src_) + half, 0, half); vpx_memset16(CONVERT_TO_SHORTPTR(src_) + half, 0, half);
vpx_memset16(CONVERT_TO_SHORTPTR(ref_), 0, half); vpx_memset16(CONVERT_TO_SHORTPTR(ref_), 0, half);
vpx_memset16(CONVERT_TO_SHORTPTR(ref_) + half, mask_, vpx_memset16(CONVERT_TO_SHORTPTR(ref_) + half, mask_, half + width_ +
half + width_ + height_ + 1); height_ + 1);
} }
#else #else
memset(src_, 0, half); memset(src_, 0, half);
memset(src_ + half, 255, half); memset(src_ + half, 255, half);
memset(ref_, 255, half); memset(ref_, 255, half);
memset(ref_ + half, 0, half + width_ + height_ + 1); memset(ref_ + half, 0, half + width_ + height_ + 1);
#endif // CONFIG_VP9_HIGHBITDEPTH #endif
unsigned int sse1, sse2; unsigned int sse1, sse2;
unsigned int var1; unsigned int var1;
ASM_REGISTER_STATE_CHECK( ASM_REGISTER_STATE_CHECK(var1 = subpel_variance_(ref_, width_ + 1, x, y,
var1 = subpel_variance_(ref_, width_ + 1, x, y, src_, width_, &sse1)); src_, width_, &sse1));
const unsigned int var2 = const unsigned int var2 = subpel_variance_ref(ref_, src_, log2width_,
subpel_variance_ref(ref_, src_, log2width_, log2height_, x, y, &sse2, log2height_, x, y, &sse2,
use_high_bit_depth_, bit_depth_); use_high_bit_depth_,
bit_depth_);
EXPECT_EQ(sse1, sse2) << "at position " << x << ", " << y; EXPECT_EQ(sse1, sse2) << "at position " << x << ", " << y;
EXPECT_EQ(var1, var2) << "at position " << x << ", " << y; EXPECT_EQ(var1, var2) << "at position " << x << ", " << y;
} }
@@ -1013,12 +1009,12 @@ const vp9_variance_fn_t highbd_variance64x32_c = vp9_highbd_variance64x32_c;
const vp9_variance_fn_t highbd_variance64x64_c = vp9_highbd_variance64x64_c; const vp9_variance_fn_t highbd_variance64x64_c = vp9_highbd_variance64x64_c;
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
C, VP9VarianceHighTest, C, VP9VarianceHighTest,
::testing::Values(make_tuple(2, 2, highbd_10_variance4x4_c, 10), ::testing::Values(make_tuple(2, 2, highbd_10_variance4x4_c, 10),
make_tuple(2, 3, highbd_10_variance4x8_c, 10), make_tuple(2, 3, highbd_10_variance4x8_c, 10),
make_tuple(3, 2, highbd_10_variance8x4_c, 10), make_tuple(3, 2, highbd_10_variance8x4_c, 10),
make_tuple(3, 3, highbd_10_variance8x8_c, 10), make_tuple(3, 3, highbd_10_variance8x8_c, 10),
make_tuple(3, 4, highbd_10_variance8x16_c, 10), make_tuple(3, 4, highbd_10_variance8x16_c, 10),
make_tuple(4, 3, highbd_10_variance16x8_c, 10), make_tuple(4, 3, highbd_10_variance16x8_c, 10),
make_tuple(4, 4, highbd_10_variance16x16_c, 10), make_tuple(4, 4, highbd_10_variance16x16_c, 10),
make_tuple(4, 5, highbd_10_variance16x32_c, 10), make_tuple(4, 5, highbd_10_variance16x32_c, 10),
make_tuple(5, 4, highbd_10_variance32x16_c, 10), make_tuple(5, 4, highbd_10_variance32x16_c, 10),
@@ -1026,12 +1022,12 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(5, 6, highbd_10_variance32x64_c, 10), make_tuple(5, 6, highbd_10_variance32x64_c, 10),
make_tuple(6, 5, highbd_10_variance64x32_c, 10), make_tuple(6, 5, highbd_10_variance64x32_c, 10),
make_tuple(6, 6, highbd_10_variance64x64_c, 10), make_tuple(6, 6, highbd_10_variance64x64_c, 10),
make_tuple(2, 2, highbd_12_variance4x4_c, 12), make_tuple(2, 2, highbd_12_variance4x4_c, 12),
make_tuple(2, 3, highbd_12_variance4x8_c, 12), make_tuple(2, 3, highbd_12_variance4x8_c, 12),
make_tuple(3, 2, highbd_12_variance8x4_c, 12), make_tuple(3, 2, highbd_12_variance8x4_c, 12),
make_tuple(3, 3, highbd_12_variance8x8_c, 12), make_tuple(3, 3, highbd_12_variance8x8_c, 12),
make_tuple(3, 4, highbd_12_variance8x16_c, 12), make_tuple(3, 4, highbd_12_variance8x16_c, 12),
make_tuple(4, 3, highbd_12_variance16x8_c, 12), make_tuple(4, 3, highbd_12_variance16x8_c, 12),
make_tuple(4, 4, highbd_12_variance16x16_c, 12), make_tuple(4, 4, highbd_12_variance16x16_c, 12),
make_tuple(4, 5, highbd_12_variance16x32_c, 12), make_tuple(4, 5, highbd_12_variance16x32_c, 12),
make_tuple(5, 4, highbd_12_variance32x16_c, 12), make_tuple(5, 4, highbd_12_variance32x16_c, 12),
@@ -1039,12 +1035,12 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(5, 6, highbd_12_variance32x64_c, 12), make_tuple(5, 6, highbd_12_variance32x64_c, 12),
make_tuple(6, 5, highbd_12_variance64x32_c, 12), make_tuple(6, 5, highbd_12_variance64x32_c, 12),
make_tuple(6, 6, highbd_12_variance64x64_c, 12), make_tuple(6, 6, highbd_12_variance64x64_c, 12),
make_tuple(2, 2, highbd_variance4x4_c, 8), make_tuple(2, 2, highbd_variance4x4_c, 8),
make_tuple(2, 3, highbd_variance4x8_c, 8), make_tuple(2, 3, highbd_variance4x8_c, 8),
make_tuple(3, 2, highbd_variance8x4_c, 8), make_tuple(3, 2, highbd_variance8x4_c, 8),
make_tuple(3, 3, highbd_variance8x8_c, 8), make_tuple(3, 3, highbd_variance8x8_c, 8),
make_tuple(3, 4, highbd_variance8x16_c, 8), make_tuple(3, 4, highbd_variance8x16_c, 8),
make_tuple(4, 3, highbd_variance16x8_c, 8), make_tuple(4, 3, highbd_variance16x8_c, 8),
make_tuple(4, 4, highbd_variance16x16_c, 8), make_tuple(4, 4, highbd_variance16x16_c, 8),
make_tuple(4, 5, highbd_variance16x32_c, 8), make_tuple(4, 5, highbd_variance16x32_c, 8),
make_tuple(5, 4, highbd_variance32x16_c, 8), make_tuple(5, 4, highbd_variance32x16_c, 8),
@@ -1216,12 +1212,12 @@ const vp9_subpixvariance_fn_t highbd_subpel_variance64x64_c =
vp9_highbd_sub_pixel_variance64x64_c; vp9_highbd_sub_pixel_variance64x64_c;
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
C, VP9SubpelVarianceHighTest, C, VP9SubpelVarianceHighTest,
::testing::Values(make_tuple(2, 2, highbd_10_subpel_variance4x4_c, 10), ::testing::Values(make_tuple(2, 2, highbd_10_subpel_variance4x4_c, 10),
make_tuple(2, 3, highbd_10_subpel_variance4x8_c, 10), make_tuple(2, 3, highbd_10_subpel_variance4x8_c, 10),
make_tuple(3, 2, highbd_10_subpel_variance8x4_c, 10), make_tuple(3, 2, highbd_10_subpel_variance8x4_c, 10),
make_tuple(3, 3, highbd_10_subpel_variance8x8_c, 10), make_tuple(3, 3, highbd_10_subpel_variance8x8_c, 10),
make_tuple(3, 4, highbd_10_subpel_variance8x16_c, 10), make_tuple(3, 4, highbd_10_subpel_variance8x16_c, 10),
make_tuple(4, 3, highbd_10_subpel_variance16x8_c, 10), make_tuple(4, 3, highbd_10_subpel_variance16x8_c, 10),
make_tuple(4, 4, highbd_10_subpel_variance16x16_c, 10), make_tuple(4, 4, highbd_10_subpel_variance16x16_c, 10),
make_tuple(4, 5, highbd_10_subpel_variance16x32_c, 10), make_tuple(4, 5, highbd_10_subpel_variance16x32_c, 10),
make_tuple(5, 4, highbd_10_subpel_variance32x16_c, 10), make_tuple(5, 4, highbd_10_subpel_variance32x16_c, 10),
@@ -1229,12 +1225,12 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(5, 6, highbd_10_subpel_variance32x64_c, 10), make_tuple(5, 6, highbd_10_subpel_variance32x64_c, 10),
make_tuple(6, 5, highbd_10_subpel_variance64x32_c, 10), make_tuple(6, 5, highbd_10_subpel_variance64x32_c, 10),
make_tuple(6, 6, highbd_10_subpel_variance64x64_c, 10), make_tuple(6, 6, highbd_10_subpel_variance64x64_c, 10),
make_tuple(2, 2, highbd_12_subpel_variance4x4_c, 12), make_tuple(2, 2, highbd_12_subpel_variance4x4_c, 12),
make_tuple(2, 3, highbd_12_subpel_variance4x8_c, 12), make_tuple(2, 3, highbd_12_subpel_variance4x8_c, 12),
make_tuple(3, 2, highbd_12_subpel_variance8x4_c, 12), make_tuple(3, 2, highbd_12_subpel_variance8x4_c, 12),
make_tuple(3, 3, highbd_12_subpel_variance8x8_c, 12), make_tuple(3, 3, highbd_12_subpel_variance8x8_c, 12),
make_tuple(3, 4, highbd_12_subpel_variance8x16_c, 12), make_tuple(3, 4, highbd_12_subpel_variance8x16_c, 12),
make_tuple(4, 3, highbd_12_subpel_variance16x8_c, 12), make_tuple(4, 3, highbd_12_subpel_variance16x8_c, 12),
make_tuple(4, 4, highbd_12_subpel_variance16x16_c, 12), make_tuple(4, 4, highbd_12_subpel_variance16x16_c, 12),
make_tuple(4, 5, highbd_12_subpel_variance16x32_c, 12), make_tuple(4, 5, highbd_12_subpel_variance16x32_c, 12),
make_tuple(5, 4, highbd_12_subpel_variance32x16_c, 12), make_tuple(5, 4, highbd_12_subpel_variance32x16_c, 12),
@@ -1242,12 +1238,12 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(5, 6, highbd_12_subpel_variance32x64_c, 12), make_tuple(5, 6, highbd_12_subpel_variance32x64_c, 12),
make_tuple(6, 5, highbd_12_subpel_variance64x32_c, 12), make_tuple(6, 5, highbd_12_subpel_variance64x32_c, 12),
make_tuple(6, 6, highbd_12_subpel_variance64x64_c, 12), make_tuple(6, 6, highbd_12_subpel_variance64x64_c, 12),
make_tuple(2, 2, highbd_subpel_variance4x4_c, 8), make_tuple(2, 2, highbd_subpel_variance4x4_c, 8),
make_tuple(2, 3, highbd_subpel_variance4x8_c, 8), make_tuple(2, 3, highbd_subpel_variance4x8_c, 8),
make_tuple(3, 2, highbd_subpel_variance8x4_c, 8), make_tuple(3, 2, highbd_subpel_variance8x4_c, 8),
make_tuple(3, 3, highbd_subpel_variance8x8_c, 8), make_tuple(3, 3, highbd_subpel_variance8x8_c, 8),
make_tuple(3, 4, highbd_subpel_variance8x16_c, 8), make_tuple(3, 4, highbd_subpel_variance8x16_c, 8),
make_tuple(4, 3, highbd_subpel_variance16x8_c, 8), make_tuple(4, 3, highbd_subpel_variance16x8_c, 8),
make_tuple(4, 4, highbd_subpel_variance16x16_c, 8), make_tuple(4, 4, highbd_subpel_variance16x16_c, 8),
make_tuple(4, 5, highbd_subpel_variance16x32_c, 8), make_tuple(4, 5, highbd_subpel_variance16x32_c, 8),
make_tuple(5, 4, highbd_subpel_variance32x16_c, 8), make_tuple(5, 4, highbd_subpel_variance32x16_c, 8),
@@ -1335,46 +1331,71 @@ const vp9_subp_avg_variance_fn_t highbd_subpel_avg_variance64x64_c =
vp9_highbd_sub_pixel_avg_variance64x64_c; vp9_highbd_sub_pixel_avg_variance64x64_c;
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
C, VP9SubpelAvgVarianceHighTest, C, VP9SubpelAvgVarianceHighTest,
::testing::Values( ::testing::Values(make_tuple(2, 2, highbd_10_subpel_avg_variance4x4_c,
make_tuple(2, 2, highbd_10_subpel_avg_variance4x4_c, 10), 10),
make_tuple(2, 3, highbd_10_subpel_avg_variance4x8_c, 10), make_tuple(2, 3, highbd_10_subpel_avg_variance4x8_c,
make_tuple(3, 2, highbd_10_subpel_avg_variance8x4_c, 10), 10),
make_tuple(3, 3, highbd_10_subpel_avg_variance8x8_c, 10), make_tuple(3, 2, highbd_10_subpel_avg_variance8x4_c,
make_tuple(3, 4, highbd_10_subpel_avg_variance8x16_c, 10), 10),
make_tuple(4, 3, highbd_10_subpel_avg_variance16x8_c, 10), make_tuple(3, 3, highbd_10_subpel_avg_variance8x8_c,
make_tuple(4, 4, highbd_10_subpel_avg_variance16x16_c, 10), 10),
make_tuple(4, 5, highbd_10_subpel_avg_variance16x32_c, 10), make_tuple(3, 4, highbd_10_subpel_avg_variance8x16_c,
make_tuple(5, 4, highbd_10_subpel_avg_variance32x16_c, 10), 10),
make_tuple(5, 5, highbd_10_subpel_avg_variance32x32_c, 10), make_tuple(4, 3, highbd_10_subpel_avg_variance16x8_c,
make_tuple(5, 6, highbd_10_subpel_avg_variance32x64_c, 10), 10),
make_tuple(6, 5, highbd_10_subpel_avg_variance64x32_c, 10), make_tuple(4, 4, highbd_10_subpel_avg_variance16x16_c,
make_tuple(6, 6, highbd_10_subpel_avg_variance64x64_c, 10), 10),
make_tuple(2, 2, highbd_12_subpel_avg_variance4x4_c, 12), make_tuple(4, 5, highbd_10_subpel_avg_variance16x32_c,
make_tuple(2, 3, highbd_12_subpel_avg_variance4x8_c, 12), 10),
make_tuple(3, 2, highbd_12_subpel_avg_variance8x4_c, 12), make_tuple(5, 4, highbd_10_subpel_avg_variance32x16_c,
make_tuple(3, 3, highbd_12_subpel_avg_variance8x8_c, 12), 10),
make_tuple(3, 4, highbd_12_subpel_avg_variance8x16_c, 12), make_tuple(5, 5, highbd_10_subpel_avg_variance32x32_c,
make_tuple(4, 3, highbd_12_subpel_avg_variance16x8_c, 12), 10),
make_tuple(4, 4, highbd_12_subpel_avg_variance16x16_c, 12), make_tuple(5, 6, highbd_10_subpel_avg_variance32x64_c,
make_tuple(4, 5, highbd_12_subpel_avg_variance16x32_c, 12), 10),
make_tuple(5, 4, highbd_12_subpel_avg_variance32x16_c, 12), make_tuple(6, 5, highbd_10_subpel_avg_variance64x32_c,
make_tuple(5, 5, highbd_12_subpel_avg_variance32x32_c, 12), 10),
make_tuple(5, 6, highbd_12_subpel_avg_variance32x64_c, 12), make_tuple(6, 6, highbd_10_subpel_avg_variance64x64_c,
make_tuple(6, 5, highbd_12_subpel_avg_variance64x32_c, 12), 10),
make_tuple(6, 6, highbd_12_subpel_avg_variance64x64_c, 12), make_tuple(2, 2, highbd_12_subpel_avg_variance4x4_c,
make_tuple(2, 2, highbd_subpel_avg_variance4x4_c, 8), 12),
make_tuple(2, 3, highbd_subpel_avg_variance4x8_c, 8), make_tuple(2, 3, highbd_12_subpel_avg_variance4x8_c,
make_tuple(3, 2, highbd_subpel_avg_variance8x4_c, 8), 12),
make_tuple(3, 3, highbd_subpel_avg_variance8x8_c, 8), make_tuple(3, 2, highbd_12_subpel_avg_variance8x4_c,
make_tuple(3, 4, highbd_subpel_avg_variance8x16_c, 8), 12),
make_tuple(4, 3, highbd_subpel_avg_variance16x8_c, 8), make_tuple(3, 3, highbd_12_subpel_avg_variance8x8_c,
make_tuple(4, 4, highbd_subpel_avg_variance16x16_c, 8), 12),
make_tuple(4, 5, highbd_subpel_avg_variance16x32_c, 8), make_tuple(3, 4, highbd_12_subpel_avg_variance8x16_c,
make_tuple(5, 4, highbd_subpel_avg_variance32x16_c, 8), 12),
make_tuple(5, 5, highbd_subpel_avg_variance32x32_c, 8), make_tuple(4, 3, highbd_12_subpel_avg_variance16x8_c,
make_tuple(5, 6, highbd_subpel_avg_variance32x64_c, 8), 12),
make_tuple(6, 5, highbd_subpel_avg_variance64x32_c, 8), make_tuple(4, 4, highbd_12_subpel_avg_variance16x16_c,
make_tuple(6, 6, highbd_subpel_avg_variance64x64_c, 8))); 12),
make_tuple(4, 5, highbd_12_subpel_avg_variance16x32_c,
12),
make_tuple(5, 4, highbd_12_subpel_avg_variance32x16_c,
12),
make_tuple(5, 5, highbd_12_subpel_avg_variance32x32_c,
12),
make_tuple(5, 6, highbd_12_subpel_avg_variance32x64_c,
12),
make_tuple(6, 5, highbd_12_subpel_avg_variance64x32_c,
12),
make_tuple(6, 6, highbd_12_subpel_avg_variance64x64_c,
12),
make_tuple(2, 2, highbd_subpel_avg_variance4x4_c, 8),
make_tuple(2, 3, highbd_subpel_avg_variance4x8_c, 8),
make_tuple(3, 2, highbd_subpel_avg_variance8x4_c, 8),
make_tuple(3, 3, highbd_subpel_avg_variance8x8_c, 8),
make_tuple(3, 4, highbd_subpel_avg_variance8x16_c, 8),
make_tuple(4, 3, highbd_subpel_avg_variance16x8_c, 8),
make_tuple(4, 4, highbd_subpel_avg_variance16x16_c, 8),
make_tuple(4, 5, highbd_subpel_avg_variance16x32_c, 8),
make_tuple(5, 4, highbd_subpel_avg_variance32x16_c, 8),
make_tuple(5, 5, highbd_subpel_avg_variance32x32_c, 8),
make_tuple(5, 6, highbd_subpel_avg_variance32x64_c, 8),
make_tuple(6, 5, highbd_subpel_avg_variance64x32_c, 8),
make_tuple(6, 6, highbd_subpel_avg_variance64x64_c, 8)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
#if HAVE_SSE2 #if HAVE_SSE2
@@ -1553,9 +1574,9 @@ const vp9_variance_fn_t highbd_12_variance64x64_sse2 =
vp9_highbd_12_variance64x64_sse2; vp9_highbd_12_variance64x64_sse2;
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, VP9VarianceHighTest, SSE2, VP9VarianceHighTest,
::testing::Values(make_tuple(3, 3, highbd_10_variance8x8_sse2, 10), ::testing::Values(make_tuple(3, 3, highbd_10_variance8x8_sse2, 10),
make_tuple(3, 4, highbd_10_variance8x16_sse2, 10), make_tuple(3, 4, highbd_10_variance8x16_sse2, 10),
make_tuple(4, 3, highbd_10_variance16x8_sse2, 10), make_tuple(4, 3, highbd_10_variance16x8_sse2, 10),
make_tuple(4, 4, highbd_10_variance16x16_sse2, 10), make_tuple(4, 4, highbd_10_variance16x16_sse2, 10),
make_tuple(4, 5, highbd_10_variance16x32_sse2, 10), make_tuple(4, 5, highbd_10_variance16x32_sse2, 10),
make_tuple(5, 4, highbd_10_variance32x16_sse2, 10), make_tuple(5, 4, highbd_10_variance32x16_sse2, 10),
@@ -1563,9 +1584,9 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(5, 6, highbd_10_variance32x64_sse2, 10), make_tuple(5, 6, highbd_10_variance32x64_sse2, 10),
make_tuple(6, 5, highbd_10_variance64x32_sse2, 10), make_tuple(6, 5, highbd_10_variance64x32_sse2, 10),
make_tuple(6, 6, highbd_10_variance64x64_sse2, 10), make_tuple(6, 6, highbd_10_variance64x64_sse2, 10),
make_tuple(3, 3, highbd_12_variance8x8_sse2, 12), make_tuple(3, 3, highbd_12_variance8x8_sse2, 12),
make_tuple(3, 4, highbd_12_variance8x16_sse2, 12), make_tuple(3, 4, highbd_12_variance8x16_sse2, 12),
make_tuple(4, 3, highbd_12_variance16x8_sse2, 12), make_tuple(4, 3, highbd_12_variance16x8_sse2, 12),
make_tuple(4, 4, highbd_12_variance16x16_sse2, 12), make_tuple(4, 4, highbd_12_variance16x16_sse2, 12),
make_tuple(4, 5, highbd_12_variance16x32_sse2, 12), make_tuple(4, 5, highbd_12_variance16x32_sse2, 12),
make_tuple(5, 4, highbd_12_variance32x16_sse2, 12), make_tuple(5, 4, highbd_12_variance32x16_sse2, 12),
@@ -1573,9 +1594,9 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(5, 6, highbd_12_variance32x64_sse2, 12), make_tuple(5, 6, highbd_12_variance32x64_sse2, 12),
make_tuple(6, 5, highbd_12_variance64x32_sse2, 12), make_tuple(6, 5, highbd_12_variance64x32_sse2, 12),
make_tuple(6, 6, highbd_12_variance64x64_sse2, 12), make_tuple(6, 6, highbd_12_variance64x64_sse2, 12),
make_tuple(3, 3, highbd_variance8x8_sse2, 8), make_tuple(3, 3, highbd_variance8x8_sse2, 8),
make_tuple(3, 4, highbd_variance8x16_sse2, 8), make_tuple(3, 4, highbd_variance8x16_sse2, 8),
make_tuple(4, 3, highbd_variance16x8_sse2, 8), make_tuple(4, 3, highbd_variance16x8_sse2, 8),
make_tuple(4, 4, highbd_variance16x16_sse2, 8), make_tuple(4, 4, highbd_variance16x16_sse2, 8),
make_tuple(4, 5, highbd_variance16x32_sse2, 8), make_tuple(4, 5, highbd_variance16x32_sse2, 8),
make_tuple(5, 4, highbd_variance32x16_sse2, 8), make_tuple(5, 4, highbd_variance32x16_sse2, 8),
@@ -1662,10 +1683,10 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(5, 6, highbd_10_subpel_variance32x64_sse2, 10), make_tuple(5, 6, highbd_10_subpel_variance32x64_sse2, 10),
make_tuple(6, 5, highbd_10_subpel_variance64x32_sse2, 10), make_tuple(6, 5, highbd_10_subpel_variance64x32_sse2, 10),
make_tuple(6, 6, highbd_10_subpel_variance64x64_sse2, 10), make_tuple(6, 6, highbd_10_subpel_variance64x64_sse2, 10),
make_tuple(3, 2, highbd_12_subpel_variance8x4_sse2, 12), make_tuple(3, 2, highbd_12_subpel_variance8x4_sse2, 12),
make_tuple(3, 3, highbd_12_subpel_variance8x8_sse2, 12), make_tuple(3, 3, highbd_12_subpel_variance8x8_sse2, 12),
make_tuple(3, 4, highbd_12_subpel_variance8x16_sse2, 12), make_tuple(3, 4, highbd_12_subpel_variance8x16_sse2, 12),
make_tuple(4, 3, highbd_12_subpel_variance16x8_sse2, 12), make_tuple(4, 3, highbd_12_subpel_variance16x8_sse2, 12),
make_tuple(4, 4, highbd_12_subpel_variance16x16_sse2, 12), make_tuple(4, 4, highbd_12_subpel_variance16x16_sse2, 12),
make_tuple(4, 5, highbd_12_subpel_variance16x32_sse2, 12), make_tuple(4, 5, highbd_12_subpel_variance16x32_sse2, 12),
make_tuple(5, 4, highbd_12_subpel_variance32x16_sse2, 12), make_tuple(5, 4, highbd_12_subpel_variance32x16_sse2, 12),
@@ -1753,10 +1774,10 @@ const vp9_subp_avg_variance_fn_t highbd_12_subpel_avg_variance64x64_sse2 =
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, VP9SubpelAvgVarianceHighTest, SSE2, VP9SubpelAvgVarianceHighTest,
::testing::Values( ::testing::Values(
make_tuple(3, 2, highbd_10_subpel_avg_variance8x4_sse2, 10), make_tuple(3, 2, highbd_10_subpel_avg_variance8x4_sse2, 10),
make_tuple(3, 3, highbd_10_subpel_avg_variance8x8_sse2, 10), make_tuple(3, 3, highbd_10_subpel_avg_variance8x8_sse2, 10),
make_tuple(3, 4, highbd_10_subpel_avg_variance8x16_sse2, 10), make_tuple(3, 4, highbd_10_subpel_avg_variance8x16_sse2, 10),
make_tuple(4, 3, highbd_10_subpel_avg_variance16x8_sse2, 10), make_tuple(4, 3, highbd_10_subpel_avg_variance16x8_sse2, 10),
make_tuple(4, 4, highbd_10_subpel_avg_variance16x16_sse2, 10), make_tuple(4, 4, highbd_10_subpel_avg_variance16x16_sse2, 10),
make_tuple(4, 5, highbd_10_subpel_avg_variance16x32_sse2, 10), make_tuple(4, 5, highbd_10_subpel_avg_variance16x32_sse2, 10),
make_tuple(5, 4, highbd_10_subpel_avg_variance32x16_sse2, 10), make_tuple(5, 4, highbd_10_subpel_avg_variance32x16_sse2, 10),
@@ -1764,10 +1785,10 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(5, 6, highbd_10_subpel_avg_variance32x64_sse2, 10), make_tuple(5, 6, highbd_10_subpel_avg_variance32x64_sse2, 10),
make_tuple(6, 5, highbd_10_subpel_avg_variance64x32_sse2, 10), make_tuple(6, 5, highbd_10_subpel_avg_variance64x32_sse2, 10),
make_tuple(6, 6, highbd_10_subpel_avg_variance64x64_sse2, 10), make_tuple(6, 6, highbd_10_subpel_avg_variance64x64_sse2, 10),
make_tuple(3, 2, highbd_12_subpel_avg_variance8x4_sse2, 12), make_tuple(3, 2, highbd_12_subpel_avg_variance8x4_sse2, 12),
make_tuple(3, 3, highbd_12_subpel_avg_variance8x8_sse2, 12), make_tuple(3, 3, highbd_12_subpel_avg_variance8x8_sse2, 12),
make_tuple(3, 4, highbd_12_subpel_avg_variance8x16_sse2, 12), make_tuple(3, 4, highbd_12_subpel_avg_variance8x16_sse2, 12),
make_tuple(4, 3, highbd_12_subpel_avg_variance16x8_sse2, 12), make_tuple(4, 3, highbd_12_subpel_avg_variance16x8_sse2, 12),
make_tuple(4, 4, highbd_12_subpel_avg_variance16x16_sse2, 12), make_tuple(4, 4, highbd_12_subpel_avg_variance16x16_sse2, 12),
make_tuple(4, 5, highbd_12_subpel_avg_variance16x32_sse2, 12), make_tuple(4, 5, highbd_12_subpel_avg_variance16x32_sse2, 12),
make_tuple(5, 4, highbd_12_subpel_avg_variance32x16_sse2, 12), make_tuple(5, 4, highbd_12_subpel_avg_variance32x16_sse2, 12),
@@ -1775,10 +1796,10 @@ INSTANTIATE_TEST_CASE_P(
make_tuple(5, 6, highbd_12_subpel_avg_variance32x64_sse2, 12), make_tuple(5, 6, highbd_12_subpel_avg_variance32x64_sse2, 12),
make_tuple(6, 5, highbd_12_subpel_avg_variance64x32_sse2, 12), make_tuple(6, 5, highbd_12_subpel_avg_variance64x32_sse2, 12),
make_tuple(6, 6, highbd_12_subpel_avg_variance64x64_sse2, 12), make_tuple(6, 6, highbd_12_subpel_avg_variance64x64_sse2, 12),
make_tuple(3, 2, highbd_subpel_avg_variance8x4_sse2, 8), make_tuple(3, 2, highbd_subpel_avg_variance8x4_sse2, 8),
make_tuple(3, 3, highbd_subpel_avg_variance8x8_sse2, 8), make_tuple(3, 3, highbd_subpel_avg_variance8x8_sse2, 8),
make_tuple(3, 4, highbd_subpel_avg_variance8x16_sse2, 8), make_tuple(3, 4, highbd_subpel_avg_variance8x16_sse2, 8),
make_tuple(4, 3, highbd_subpel_avg_variance16x8_sse2, 8), make_tuple(4, 3, highbd_subpel_avg_variance16x8_sse2, 8),
make_tuple(4, 4, highbd_subpel_avg_variance16x16_sse2, 8), make_tuple(4, 4, highbd_subpel_avg_variance16x16_sse2, 8),
make_tuple(4, 5, highbd_subpel_avg_variance16x32_sse2, 8), make_tuple(4, 5, highbd_subpel_avg_variance16x32_sse2, 8),
make_tuple(5, 4, highbd_subpel_avg_variance32x16_sse2, 8), make_tuple(5, 4, highbd_subpel_avg_variance32x16_sse2, 8),
@@ -1914,17 +1935,11 @@ INSTANTIATE_TEST_CASE_P(
const vp9_variance_fn_t variance8x8_neon = vp9_variance8x8_neon; const vp9_variance_fn_t variance8x8_neon = vp9_variance8x8_neon;
const vp9_variance_fn_t variance16x16_neon = vp9_variance16x16_neon; const vp9_variance_fn_t variance16x16_neon = vp9_variance16x16_neon;
const vp9_variance_fn_t variance32x32_neon = vp9_variance32x32_neon; const vp9_variance_fn_t variance32x32_neon = vp9_variance32x32_neon;
const vp9_variance_fn_t variance32x64_neon = vp9_variance32x64_neon;
const vp9_variance_fn_t variance64x32_neon = vp9_variance64x32_neon;
const vp9_variance_fn_t variance64x64_neon = vp9_variance64x64_neon;
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
NEON, VP9VarianceTest, NEON, VP9VarianceTest,
::testing::Values(make_tuple(3, 3, variance8x8_neon, 0), ::testing::Values(make_tuple(3, 3, variance8x8_neon, 0),
make_tuple(4, 4, variance16x16_neon, 0), make_tuple(4, 4, variance16x16_neon, 0),
make_tuple(5, 5, variance32x32_neon, 0), make_tuple(5, 5, variance32x32_neon, 0)));
make_tuple(5, 6, variance32x64_neon, 0),
make_tuple(6, 5, variance64x32_neon, 0),
make_tuple(6, 6, variance64x64_neon, 0)));
const vp9_subpixvariance_fn_t subpel_variance8x8_neon = const vp9_subpixvariance_fn_t subpel_variance8x8_neon =
vp9_sub_pixel_variance8x8_neon; vp9_sub_pixel_variance8x8_neon;
@@ -1932,14 +1947,11 @@ const vp9_subpixvariance_fn_t subpel_variance16x16_neon =
vp9_sub_pixel_variance16x16_neon; vp9_sub_pixel_variance16x16_neon;
const vp9_subpixvariance_fn_t subpel_variance32x32_neon = const vp9_subpixvariance_fn_t subpel_variance32x32_neon =
vp9_sub_pixel_variance32x32_neon; vp9_sub_pixel_variance32x32_neon;
const vp9_subpixvariance_fn_t subpel_variance64x64_neon =
vp9_sub_pixel_variance64x64_neon;
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
NEON, VP9SubpelVarianceTest, NEON, VP9SubpelVarianceTest,
::testing::Values(make_tuple(3, 3, subpel_variance8x8_neon, 0), ::testing::Values(make_tuple(3, 3, subpel_variance8x8_neon, 0),
make_tuple(4, 4, subpel_variance16x16_neon, 0), make_tuple(4, 4, subpel_variance16x16_neon, 0),
make_tuple(5, 5, subpel_variance32x32_neon, 0), make_tuple(5, 5, subpel_variance32x32_neon, 0)));
make_tuple(6, 6, subpel_variance64x64_neon, 0)));
#endif // HAVE_NEON #endif // HAVE_NEON
#endif // CONFIG_VP9_ENCODER #endif // CONFIG_VP9_ENCODER

View File

@@ -134,13 +134,8 @@ class VideoSource {
class DummyVideoSource : public VideoSource { class DummyVideoSource : public VideoSource {
public: public:
DummyVideoSource() DummyVideoSource() : img_(NULL), limit_(100), width_(0), height_(0) {
: img_(NULL), SetSize(80, 64);
limit_(100),
width_(80),
height_(64),
format_(VPX_IMG_FMT_I420) {
ReallocImage();
} }
virtual ~DummyVideoSource() { vpx_img_free(img_); } virtual ~DummyVideoSource() { vpx_img_free(img_); }
@@ -179,35 +174,23 @@ class DummyVideoSource : public VideoSource {
void SetSize(unsigned int width, unsigned int height) { void SetSize(unsigned int width, unsigned int height) {
if (width != width_ || height != height_) { if (width != width_ || height != height_) {
vpx_img_free(img_);
raw_sz_ = ((width + 31)&~31) * height * 3 / 2;
img_ = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, width, height, 32);
width_ = width; width_ = width;
height_ = height; height_ = height;
ReallocImage();
}
}
void SetImageFormat(vpx_img_fmt_t format) {
if (format_ != format) {
format_ = format;
ReallocImage();
} }
} }
protected: protected:
virtual void FillFrame() { if (img_) memset(img_->img_data, 0, raw_sz_); } virtual void FillFrame() { if (img_) memset(img_->img_data, 0, raw_sz_); }
void ReallocImage() {
vpx_img_free(img_);
img_ = vpx_img_alloc(NULL, format_, width_, height_, 32);
raw_sz_ = ((img_->w + 31) & ~31) * img_->h * img_->bps / 8;
}
vpx_image_t *img_; vpx_image_t *img_;
size_t raw_sz_; size_t raw_sz_;
unsigned int limit_; unsigned int limit_;
unsigned int frame_; unsigned int frame_;
unsigned int width_; unsigned int width_;
unsigned int height_; unsigned int height_;
vpx_img_fmt_t format_;
}; };

View File

@@ -1,37 +0,0 @@
/*
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 "third_party/googletest/src/include/gtest/gtest.h"
#include "test/codec_factory.h"
#include "test/video_source.h"
namespace {
class VP8FramgmentsTest
: public ::libvpx_test::EncoderTest,
public ::testing::Test {
protected:
VP8FramgmentsTest() : EncoderTest(&::libvpx_test::kVP8) {}
virtual ~VP8FramgmentsTest() {}
virtual void SetUp() {
const unsigned long init_flags = // NOLINT(runtime/int)
VPX_CODEC_USE_OUTPUT_PARTITION;
InitializeConfig();
SetMode(::libvpx_test::kRealTime);
set_init_flags(init_flags);
}
};
TEST_F(VP8FramgmentsTest, TestFragmentsEncodeDecode) {
::libvpx_test::RandomVideoSource video;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
}
} // namespace

View File

@@ -57,7 +57,7 @@ class AverageTestBase : public ::testing::Test {
} }
// Sum Pixels // Sum Pixels
unsigned int ReferenceAverage8x8(const uint8_t* source, int pitch ) { unsigned int ReferenceAverage(const uint8_t* source, int pitch ) {
unsigned int average = 0; unsigned int average = 0;
for (int h = 0; h < 8; ++h) for (int h = 0; h < 8; ++h)
for (int w = 0; w < 8; ++w) for (int w = 0; w < 8; ++w)
@@ -65,14 +65,6 @@ class AverageTestBase : public ::testing::Test {
return ((average + 32) >> 6); return ((average + 32) >> 6);
} }
unsigned int ReferenceAverage4x4(const uint8_t* source, int pitch ) {
unsigned int average = 0;
for (int h = 0; h < 4; ++h)
for (int w = 0; w < 4; ++w)
average += source[h * source_stride_ + w];
return ((average + 8) >> 4);
}
void FillConstant(uint8_t fill_constant) { void FillConstant(uint8_t fill_constant) {
for (int i = 0; i < width_ * height_; ++i) { for (int i = 0; i < width_ * height_; ++i) {
source_data_[i] = fill_constant; source_data_[i] = fill_constant;
@@ -93,7 +85,7 @@ class AverageTestBase : public ::testing::Test {
}; };
typedef unsigned int (*AverageFunction)(const uint8_t* s, int pitch); typedef unsigned int (*AverageFunction)(const uint8_t* s, int pitch);
typedef std::tr1::tuple<int, int, int, int, AverageFunction> AvgFunc; typedef std::tr1::tuple<int, int, int, AverageFunction> AvgFunc;
class AverageTest class AverageTest
: public AverageTestBase, : public AverageTestBase,
@@ -103,18 +95,12 @@ class AverageTest
protected: protected:
void CheckAverages() { void CheckAverages() {
unsigned int expected = 0; unsigned int expected = ReferenceAverage(source_data_+ GET_PARAM(2),
if (GET_PARAM(3) == 8) { source_stride_);
expected = ReferenceAverage8x8(source_data_+ GET_PARAM(2),
source_stride_);
} else if (GET_PARAM(3) == 4) {
expected = ReferenceAverage4x4(source_data_+ GET_PARAM(2),
source_stride_);
}
ASM_REGISTER_STATE_CHECK(GET_PARAM(4)(source_data_+ GET_PARAM(2), ASM_REGISTER_STATE_CHECK(GET_PARAM(3)(source_data_+ GET_PARAM(2),
source_stride_)); source_stride_));
unsigned int actual = GET_PARAM(4)(source_data_+ GET_PARAM(2), unsigned int actual = GET_PARAM(3)(source_data_+ GET_PARAM(2),
source_stride_); source_stride_);
EXPECT_EQ(expected, actual); EXPECT_EQ(expected, actual);
@@ -148,30 +134,16 @@ using std::tr1::make_tuple;
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
C, AverageTest, C, AverageTest,
::testing::Values( ::testing::Values(
make_tuple(16, 16, 1, 8, &vp9_avg_8x8_c), make_tuple(16, 16, 1, &vp9_avg_8x8_c)));
make_tuple(16, 16, 1, 4, &vp9_avg_4x4_c)));
#if HAVE_SSE2 #if HAVE_SSE2
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, AverageTest, SSE2, AverageTest,
::testing::Values( ::testing::Values(
make_tuple(16, 16, 0, 8, &vp9_avg_8x8_sse2), make_tuple(16, 16, 0, &vp9_avg_8x8_sse2),
make_tuple(16, 16, 5, 8, &vp9_avg_8x8_sse2), make_tuple(16, 16, 5, &vp9_avg_8x8_sse2),
make_tuple(32, 32, 15, 8, &vp9_avg_8x8_sse2), make_tuple(32, 32, 15, &vp9_avg_8x8_sse2)));
make_tuple(16, 16, 0, 4, &vp9_avg_4x4_sse2),
make_tuple(16, 16, 5, 4, &vp9_avg_4x4_sse2),
make_tuple(32, 32, 15, 4, &vp9_avg_4x4_sse2)));
#endif
#if HAVE_NEON
INSTANTIATE_TEST_CASE_P(
NEON, AverageTest,
::testing::Values(
make_tuple(16, 16, 0, 8, &vp9_avg_8x8_neon),
make_tuple(16, 16, 5, 8, &vp9_avg_8x8_neon),
make_tuple(32, 32, 15, 8, &vp9_avg_8x8_neon)));
#endif #endif

View File

@@ -1,193 +0,0 @@
/*
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 "test/codec_factory.h"
#include "test/encode_test_driver.h"
#include "test/y4m_video_source.h"
#include "test/yuv_video_source.h"
#include "test/util.h"
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "vp9/decoder/vp9_decoder.h"
typedef vpx_codec_stream_info_t vp9_stream_info_t;
struct vpx_codec_alg_priv {
vpx_codec_priv_t base;
vpx_codec_dec_cfg_t cfg;
vp9_stream_info_t si;
struct VP9Decoder *pbi;
int postproc_cfg_set;
vp8_postproc_cfg_t postproc_cfg;
vpx_decrypt_cb decrypt_cb;
void *decrypt_state;
vpx_image_t img;
int img_avail;
int flushed;
int invert_tile_order;
int frame_parallel_decode;
// External frame buffer info to save for VP9 common.
void *ext_priv; // Private data associated with the external frame buffers.
vpx_get_frame_buffer_cb_fn_t get_ext_fb_cb;
vpx_release_frame_buffer_cb_fn_t release_ext_fb_cb;
};
static vpx_codec_alg_priv_t *get_alg_priv(vpx_codec_ctx_t *ctx) {
return (vpx_codec_alg_priv_t *)ctx->priv;
}
namespace {
const unsigned int kFramerate = 50;
const int kCpuUsed = 2;
struct EncodePerfTestVideo {
const char *name;
uint32_t width;
uint32_t height;
uint32_t bitrate;
int frames;
};
const EncodePerfTestVideo kVP9EncodePerfTestVectors[] = {
{"niklas_1280_720_30.y4m", 1280, 720, 600, 10},
};
struct EncodeParameters {
int32_t tile_rows;
int32_t tile_cols;
int32_t lossless;
int32_t error_resilient;
int32_t frame_parallel;
vpx_color_space_t cs;
// TODO(JBB): quantizers / bitrate
};
const EncodeParameters kVP9EncodeParameterSet[] = {
{0, 0, 0, 1, 0, VPX_CS_BT_601},
{0, 0, 0, 0, 0, VPX_CS_BT_709},
{0, 0, 1, 0, 0, VPX_CS_BT_2020},
{0, 2, 0, 0, 1, VPX_CS_UNKNOWN},
// TODO(JBB): Test profiles (requires more work).
};
int is_extension_y4m(const char *filename) {
const char *dot = strrchr(filename, '.');
if (!dot || dot == filename)
return 0;
else
return !strcmp(dot, ".y4m");
}
class Vp9EncoderParmsGetToDecoder
: public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWith2Params<EncodeParameters, \
EncodePerfTestVideo> {
protected:
Vp9EncoderParmsGetToDecoder()
: EncoderTest(GET_PARAM(0)),
encode_parms(GET_PARAM(1)) {
}
virtual ~Vp9EncoderParmsGetToDecoder() {}
virtual void SetUp() {
InitializeConfig();
SetMode(::libvpx_test::kTwoPassGood);
cfg_.g_lag_in_frames = 25;
cfg_.g_error_resilient = encode_parms.error_resilient;
dec_cfg_.threads = 4;
test_video_ = GET_PARAM(2);
cfg_.rc_target_bitrate = test_video_.bitrate;
}
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) {
if (video->frame() == 1) {
encoder->Control(VP9E_SET_COLOR_SPACE, encode_parms.cs);
encoder->Control(VP9E_SET_LOSSLESS, encode_parms.lossless);
encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING,
encode_parms.frame_parallel);
encoder->Control(VP9E_SET_TILE_ROWS, encode_parms.tile_rows);
encoder->Control(VP9E_SET_TILE_COLUMNS, encode_parms.tile_cols);
encoder->Control(VP8E_SET_CPUUSED, kCpuUsed);
encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
encoder->Control(VP8E_SET_ARNR_TYPE, 3);
}
}
virtual bool HandleDecodeResult(const vpx_codec_err_t res_dec,
const libvpx_test::VideoSource& video,
libvpx_test::Decoder *decoder) {
vpx_codec_ctx_t* vp9_decoder = decoder->GetDecoder();
vpx_codec_alg_priv_t* priv =
(vpx_codec_alg_priv_t*) get_alg_priv(vp9_decoder);
VP9Decoder* pbi = priv->pbi;
VP9_COMMON* common = &pbi->common;
if (encode_parms.lossless) {
EXPECT_EQ(common->base_qindex, 0);
EXPECT_EQ(common->y_dc_delta_q, 0);
EXPECT_EQ(common->uv_dc_delta_q, 0);
EXPECT_EQ(common->uv_ac_delta_q, 0);
EXPECT_EQ(common->tx_mode, ONLY_4X4);
}
EXPECT_EQ(common->error_resilient_mode, encode_parms.error_resilient);
if (encode_parms.error_resilient) {
EXPECT_EQ(common->frame_parallel_decoding_mode, 1);
EXPECT_EQ(common->use_prev_frame_mvs, 0);
} else {
EXPECT_EQ(common->frame_parallel_decoding_mode,
encode_parms.frame_parallel);
}
EXPECT_EQ(common->color_space, encode_parms.cs);
EXPECT_EQ(common->log2_tile_cols, encode_parms.tile_cols);
EXPECT_EQ(common->log2_tile_rows, encode_parms.tile_rows);
EXPECT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError();
return VPX_CODEC_OK == res_dec;
}
EncodePerfTestVideo test_video_;
private:
EncodeParameters encode_parms;
};
// TODO(hkuang): This test conflicts with frame parallel decode. So disable it
// for now until fix.
TEST_P(Vp9EncoderParmsGetToDecoder, DISABLED_BitstreamParms) {
init_flags_ = VPX_CODEC_USE_PSNR;
libvpx_test::VideoSource *video;
if (is_extension_y4m(test_video_.name)) {
video = new libvpx_test::Y4mVideoSource(test_video_.name,
0, test_video_.frames);
} else {
video = new libvpx_test::YUVVideoSource(test_video_.name,
VPX_IMG_FMT_I420,
test_video_.width,
test_video_.height,
kFramerate, 1, 0,
test_video_.frames);
}
ASSERT_NO_FATAL_FAILURE(RunLoop(video));
delete(video);
}
VP9_INSTANTIATE_TEST_CASE(
Vp9EncoderParmsGetToDecoder,
::testing::ValuesIn(kVP9EncodeParameterSet),
::testing::ValuesIn(kVP9EncodePerfTestVectors));
} // namespace

View File

@@ -22,17 +22,8 @@ const unsigned int kHeight = 90;
const unsigned int kFramerate = 50; const unsigned int kFramerate = 50;
const unsigned int kFrames = 10; const unsigned int kFrames = 10;
const int kBitrate = 500; const int kBitrate = 500;
// List of psnr thresholds for speed settings 0-7 and 5 encoding modes const int kCpuUsed = 0;
const double kPsnrThreshold[][5] = { const double psnr_threshold = 35.0;
{ 36.0, 37.0, 37.0, 37.0, 37.0 },
{ 35.0, 36.0, 36.0, 36.0, 36.0 },
{ 34.0, 35.0, 35.0, 35.0, 35.0 },
{ 33.0, 34.0, 34.0, 34.0, 34.0 },
{ 32.0, 33.0, 33.0, 33.0, 33.0 },
{ 31.0, 32.0, 32.0, 32.0, 32.0 },
{ 30.0, 31.0, 31.0, 31.0, 31.0 },
{ 29.0, 30.0, 30.0, 30.0, 30.0 },
};
typedef struct { typedef struct {
const char *filename; const char *filename;
@@ -42,7 +33,7 @@ typedef struct {
unsigned int profile; unsigned int profile;
} TestVideoParam; } TestVideoParam;
const TestVideoParam kTestVectors[] = { const TestVideoParam TestVectors[] = {
{"park_joy_90p_8_420.y4m", 8, VPX_IMG_FMT_I420, VPX_BITS_8, 0}, {"park_joy_90p_8_420.y4m", 8, VPX_IMG_FMT_I420, VPX_BITS_8, 0},
{"park_joy_90p_8_422.y4m", 8, VPX_IMG_FMT_I422, VPX_BITS_8, 1}, {"park_joy_90p_8_422.y4m", 8, VPX_IMG_FMT_I422, VPX_BITS_8, 1},
{"park_joy_90p_8_444.y4m", 8, VPX_IMG_FMT_I444, VPX_BITS_8, 1}, {"park_joy_90p_8_444.y4m", 8, VPX_IMG_FMT_I444, VPX_BITS_8, 1},
@@ -59,16 +50,6 @@ const TestVideoParam kTestVectors[] = {
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
}; };
// Encoding modes tested
const libvpx_test::TestMode kEncodingModeVectors[] = {
::libvpx_test::kTwoPassGood,
::libvpx_test::kOnePassGood,
::libvpx_test::kRealTime,
};
// Speed settings tested
const int kCpuUsedVectors[] = {1, 2, 3, 5, 6};
int is_extension_y4m(const char *filename) { int is_extension_y4m(const char *filename) {
const char *dot = strrchr(filename, '.'); const char *dot = strrchr(filename, '.');
if (!dot || dot == filename) if (!dot || dot == filename)
@@ -79,13 +60,11 @@ int is_extension_y4m(const char *filename) {
class EndToEndTestLarge class EndToEndTestLarge
: public ::libvpx_test::EncoderTest, : public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWith3Params<libvpx_test::TestMode, \ public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, \
TestVideoParam, int> { TestVideoParam> {
protected: protected:
EndToEndTestLarge() EndToEndTestLarge()
: EncoderTest(GET_PARAM(0)), : EncoderTest(GET_PARAM(0)),
test_video_param_(GET_PARAM(2)),
cpu_used_(GET_PARAM(3)),
psnr_(0.0), psnr_(0.0),
nframes_(0), nframes_(0),
encoding_mode_(GET_PARAM(1)) { encoding_mode_(GET_PARAM(1)) {
@@ -102,11 +81,8 @@ class EndToEndTestLarge
} else { } else {
cfg_.g_lag_in_frames = 0; cfg_.g_lag_in_frames = 0;
cfg_.rc_end_usage = VPX_CBR; cfg_.rc_end_usage = VPX_CBR;
cfg_.rc_buf_sz = 1000;
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 600;
} }
dec_cfg_.threads = 4; test_video_param_ = GET_PARAM(2);
} }
virtual void BeginPassHook(unsigned int) { virtual void BeginPassHook(unsigned int) {
@@ -122,9 +98,7 @@ class EndToEndTestLarge
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) { ::libvpx_test::Encoder *encoder) {
if (video->frame() == 1) { if (video->frame() == 1) {
encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 1); encoder->Control(VP8E_SET_CPUUSED, kCpuUsed);
encoder->Control(VP9E_SET_TILE_COLUMNS, 4);
encoder->Control(VP8E_SET_CPUUSED, cpu_used_);
if (encoding_mode_ != ::libvpx_test::kRealTime) { if (encoding_mode_ != ::libvpx_test::kRealTime) {
encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1); encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
@@ -140,12 +114,7 @@ class EndToEndTestLarge
return 0.0; return 0.0;
} }
double GetPsnrThreshold() {
return kPsnrThreshold[cpu_used_][encoding_mode_];
}
TestVideoParam test_video_param_; TestVideoParam test_video_param_;
int cpu_used_;
private: private:
double psnr_; double psnr_;
@@ -160,8 +129,6 @@ TEST_P(EndToEndTestLarge, EndtoEndPSNRTest) {
cfg_.g_input_bit_depth = test_video_param_.input_bit_depth; cfg_.g_input_bit_depth = test_video_param_.input_bit_depth;
cfg_.g_bit_depth = test_video_param_.bit_depth; cfg_.g_bit_depth = test_video_param_.bit_depth;
init_flags_ = VPX_CODEC_USE_PSNR; init_flags_ = VPX_CODEC_USE_PSNR;
if (cfg_.g_bit_depth > 8)
init_flags_ |= VPX_CODEC_USE_HIGHBITDEPTH;
libvpx_test::VideoSource *video; libvpx_test::VideoSource *video;
if (is_extension_y4m(test_video_param_.filename)) { if (is_extension_y4m(test_video_param_.filename)) {
@@ -176,14 +143,13 @@ TEST_P(EndToEndTestLarge, EndtoEndPSNRTest) {
ASSERT_NO_FATAL_FAILURE(RunLoop(video)); ASSERT_NO_FATAL_FAILURE(RunLoop(video));
const double psnr = GetAveragePsnr(); const double psnr = GetAveragePsnr();
EXPECT_GT(psnr, GetPsnrThreshold()); EXPECT_GT(psnr, psnr_threshold);
delete(video); delete(video);
} }
VP9_INSTANTIATE_TEST_CASE( VP9_INSTANTIATE_TEST_CASE(
EndToEndTestLarge, EndToEndTestLarge,
::testing::ValuesIn(kEncodingModeVectors), ::testing::Values(::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood),
::testing::ValuesIn(kTestVectors), ::testing::ValuesIn(TestVectors));
::testing::ValuesIn(kCpuUsedVectors));
} // namespace } // namespace

View File

@@ -1,137 +0,0 @@
/*
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 <string>
#include <vector>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "test/codec_factory.h"
#include "test/encode_test_driver.h"
#include "test/md5_helper.h"
#include "test/util.h"
#include "test/y4m_video_source.h"
namespace {
class VP9EncoderThreadTest
: public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
protected:
VP9EncoderThreadTest()
: EncoderTest(GET_PARAM(0)),
encoder_initialized_(false),
tiles_(2),
encoding_mode_(GET_PARAM(1)),
set_cpu_used_(GET_PARAM(2)) {
init_flags_ = VPX_CODEC_USE_PSNR;
vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
cfg.w = 1280;
cfg.h = 720;
decoder_ = codec_->CreateDecoder(cfg, 0);
md5_.clear();
}
virtual ~VP9EncoderThreadTest() {
delete decoder_;
}
virtual void SetUp() {
InitializeConfig();
SetMode(encoding_mode_);
if (encoding_mode_ != ::libvpx_test::kRealTime) {
cfg_.g_lag_in_frames = 3;
cfg_.rc_end_usage = VPX_VBR;
cfg_.rc_2pass_vbr_minsection_pct = 5;
cfg_.rc_2pass_vbr_minsection_pct = 2000;
} else {
cfg_.g_lag_in_frames = 0;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_error_resilient = 1;
}
cfg_.rc_max_quantizer = 56;
cfg_.rc_min_quantizer = 0;
}
virtual void BeginPassHook(unsigned int /*pass*/) {
encoder_initialized_ = false;
}
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) {
if (!encoder_initialized_) {
// Encode 4 column tiles.
encoder->Control(VP9E_SET_TILE_COLUMNS, tiles_);
encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
if (encoding_mode_ != ::libvpx_test::kRealTime) {
encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
encoder->Control(VP8E_SET_ARNR_TYPE, 3);
} else {
encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 0);
encoder->Control(VP9E_SET_AQ_MODE, 3);
}
encoder_initialized_ = true;
}
}
virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
const vpx_codec_err_t res = decoder_->DecodeFrame(
reinterpret_cast<uint8_t*>(pkt->data.frame.buf), pkt->data.frame.sz);
if (res != VPX_CODEC_OK) {
abort_ = true;
ASSERT_EQ(VPX_CODEC_OK, res);
}
const vpx_image_t *img = decoder_->GetDxData().Next();
if (img) {
::libvpx_test::MD5 md5_res;
md5_res.Add(img);
md5_.push_back(md5_res.Get());
}
}
bool encoder_initialized_;
int tiles_;
::libvpx_test::TestMode encoding_mode_;
int set_cpu_used_;
::libvpx_test::Decoder *decoder_;
std::vector<std::string> md5_;
};
TEST_P(VP9EncoderThreadTest, EncoderResultTest) {
std::vector<std::string> single_thr_md5, multi_thr_md5;
::libvpx_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 15, 20);
cfg_.rc_target_bitrate = 1000;
// Encode using single thread.
cfg_.g_threads = 1;
init_flags_ = VPX_CODEC_USE_PSNR;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
single_thr_md5 = md5_;
md5_.clear();
// Encode using multiple threads.
cfg_.g_threads = 4;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
multi_thr_md5 = md5_;
md5_.clear();
// Compare to check if two vectors are equal.
ASSERT_EQ(single_thr_md5, multi_thr_md5);
}
VP9_INSTANTIATE_TEST_CASE(
VP9EncoderThreadTest,
::testing::Values(::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood,
::libvpx_test::kRealTime),
::testing::Range(1, 9));
} // namespace

View File

@@ -1,220 +0,0 @@
/*
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 <cstdio>
#include <cstdlib>
#include <string>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "./vpx_config.h"
#include "test/codec_factory.h"
#include "test/decode_test_driver.h"
#include "test/ivf_video_source.h"
#include "test/md5_helper.h"
#include "test/util.h"
#if CONFIG_WEBM_IO
#include "test/webm_video_source.h"
#endif
#include "vpx_mem/vpx_mem.h"
namespace {
using std::string;
#if CONFIG_WEBM_IO
struct PauseFileList {
const char *name;
// md5 sum for decoded frames which does not include skipped frames.
const char *expected_md5;
const int pause_frame_num;
};
// Decodes |filename| with |num_threads|. Pause at the specified frame_num,
// seek to next key frame and then continue decoding until the end. Return
// the md5 of the decoded frames which does not include skipped frames.
string DecodeFileWithPause(const string &filename, int num_threads,
int pause_num) {
libvpx_test::WebMVideoSource video(filename);
video.Init();
int in_frames = 0;
int out_frames = 0;
vpx_codec_dec_cfg_t cfg = {0};
cfg.threads = num_threads;
vpx_codec_flags_t flags = 0;
flags |= VPX_CODEC_USE_FRAME_THREADING;
libvpx_test::VP9Decoder decoder(cfg, flags, 0);
libvpx_test::MD5 md5;
video.Begin();
do {
++in_frames;
const vpx_codec_err_t res =
decoder.DecodeFrame(video.cxdata(), video.frame_size());
if (res != VPX_CODEC_OK) {
EXPECT_EQ(VPX_CODEC_OK, res) << decoder.DecodeError();
break;
}
// Pause at specified frame number.
if (in_frames == pause_num) {
// Flush the decoder and then seek to next key frame.
decoder.DecodeFrame(NULL, 0);
video.SeekToNextKeyFrame();
} else {
video.Next();
}
// Flush the decoder at the end of the video.
if (!video.cxdata())
decoder.DecodeFrame(NULL, 0);
libvpx_test::DxDataIterator dec_iter = decoder.GetDxData();
const vpx_image_t *img;
// Get decompressed data
while ((img = dec_iter.Next())) {
++out_frames;
md5.Add(img);
}
} while (video.cxdata() != NULL);
EXPECT_EQ(in_frames, out_frames) <<
"Input frame count does not match output frame count";
return string(md5.Get());
}
void DecodeFilesWithPause(const PauseFileList files[]) {
for (const PauseFileList *iter = files; iter->name != NULL; ++iter) {
SCOPED_TRACE(iter->name);
for (int t = 2; t <= 8; ++t) {
EXPECT_EQ(iter->expected_md5,
DecodeFileWithPause(iter->name, t, iter->pause_frame_num))
<< "threads = " << t;
}
}
}
TEST(VP9MultiThreadedFrameParallel, PauseSeekResume) {
// vp90-2-07-frame_parallel-1.webm is a 40 frame video file with
// one key frame for every ten frames.
static const PauseFileList files[] = {
{ "vp90-2-07-frame_parallel-1.webm",
"6ea7c3875d67252e7caf2bc6e75b36b1", 6 },
{ "vp90-2-07-frame_parallel-1.webm",
"4bb634160c7356a8d7d4299b6dc83a45", 12 },
{ "vp90-2-07-frame_parallel-1.webm",
"89772591e6ef461f9fa754f916c78ed8", 26 },
{ NULL, NULL, 0 },
};
DecodeFilesWithPause(files);
}
struct FileList {
const char *name;
// md5 sum for decoded frames which does not include corrupted frames.
const char *expected_md5;
// Expected number of decoded frames which does not include corrupted frames.
const int expected_frame_count;
};
// Decodes |filename| with |num_threads|. Return the md5 of the decoded
// frames which does not include corrupted frames.
string DecodeFile(const string &filename, int num_threads,
int expected_frame_count) {
libvpx_test::WebMVideoSource video(filename);
video.Init();
vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
cfg.threads = num_threads;
const vpx_codec_flags_t flags = VPX_CODEC_USE_FRAME_THREADING;
libvpx_test::VP9Decoder decoder(cfg, flags, 0);
libvpx_test::MD5 md5;
video.Begin();
int out_frames = 0;
do {
const vpx_codec_err_t res =
decoder.DecodeFrame(video.cxdata(), video.frame_size());
// TODO(hkuang): frame parallel mode should return an error on corruption.
if (res != VPX_CODEC_OK) {
EXPECT_EQ(VPX_CODEC_OK, res) << decoder.DecodeError();
break;
}
video.Next();
// Flush the decoder at the end of the video.
if (!video.cxdata())
decoder.DecodeFrame(NULL, 0);
libvpx_test::DxDataIterator dec_iter = decoder.GetDxData();
const vpx_image_t *img;
// Get decompressed data
while ((img = dec_iter.Next())) {
++out_frames;
md5.Add(img);
}
} while (video.cxdata() != NULL);
EXPECT_EQ(expected_frame_count, out_frames) <<
"Input frame count does not match expected output frame count";
return string(md5.Get());
}
void DecodeFiles(const FileList files[]) {
for (const FileList *iter = files; iter->name != NULL; ++iter) {
SCOPED_TRACE(iter->name);
for (int t = 2; t <= 8; ++t) {
EXPECT_EQ(iter->expected_md5,
DecodeFile(iter->name, t, iter->expected_frame_count))
<< "threads = " << t;
}
}
}
TEST(VP9MultiThreadedFrameParallel, InvalidFileTest) {
static const FileList files[] = {
// invalid-vp90-2-07-frame_parallel-1.webm is a 40 frame video file with
// one key frame for every ten frames. The 11th frame has corrupted data.
{ "invalid-vp90-2-07-frame_parallel-1.webm",
"0549d0f45f60deaef8eb708e6c0eb6cb", 30 },
// invalid-vp90-2-07-frame_parallel-2.webm is a 40 frame video file with
// one key frame for every ten frames. The 1st and 31st frames have
// corrupted data.
{ "invalid-vp90-2-07-frame_parallel-2.webm",
"6a1f3cf6f9e7a364212fadb9580d525e", 20 },
// invalid-vp90-2-07-frame_parallel-3.webm is a 40 frame video file with
// one key frame for every ten frames. The 5th and 13th frames have
// corrupted data.
{ "invalid-vp90-2-07-frame_parallel-3.webm",
"8256544308de926b0681e04685b98677", 27 },
{ NULL, NULL, 0 },
};
DecodeFiles(files);
}
TEST(VP9MultiThreadedFrameParallel, ValidFileTest) {
static const FileList files[] = {
#if CONFIG_VP9_HIGHBITDEPTH
{ "vp92-2-20-10bit-yuv420.webm",
"a16b99df180c584e8db2ffeda987d293", 10 },
#endif
{ NULL, NULL, 0 },
};
DecodeFiles(files);
}
#endif // CONFIG_WEBM_IO
} // namespace

View File

@@ -1,349 +0,0 @@
/*
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* 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 <math.h>
#include <stdlib.h>
#include <string.h>
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h"
#include "test/util.h"
#include "./vpx_config.h"
#include "./vp9_rtcd.h"
#include "vp9/common/vp9_entropy.h"
#include "vpx/vpx_integer.h"
using libvpx_test::ACMRandom;
namespace {
#if CONFIG_VP9_HIGHBITDEPTH
const int number_of_iterations = 100;
typedef void (*QuantizeFunc)(const tran_low_t *coeff, intptr_t count,
int skip_block, const int16_t *zbin,
const int16_t *round, const int16_t *quant,
const int16_t *quant_shift,
tran_low_t *qcoeff, tran_low_t *dqcoeff,
const int16_t *dequant,
uint16_t *eob, const int16_t *scan,
const int16_t *iscan);
typedef std::tr1::tuple<QuantizeFunc, QuantizeFunc, vpx_bit_depth_t>
QuantizeParam;
class VP9QuantizeTest : public ::testing::TestWithParam<QuantizeParam> {
public:
virtual ~VP9QuantizeTest() {}
virtual void SetUp() {
quantize_op_ = GET_PARAM(0);
ref_quantize_op_ = GET_PARAM(1);
bit_depth_ = GET_PARAM(2);
mask_ = (1 << bit_depth_) - 1;
}
virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected:
vpx_bit_depth_t bit_depth_;
int mask_;
QuantizeFunc quantize_op_;
QuantizeFunc ref_quantize_op_;
};
class VP9Quantize32Test : public ::testing::TestWithParam<QuantizeParam> {
public:
virtual ~VP9Quantize32Test() {}
virtual void SetUp() {
quantize_op_ = GET_PARAM(0);
ref_quantize_op_ = GET_PARAM(1);
bit_depth_ = GET_PARAM(2);
mask_ = (1 << bit_depth_) - 1;
}
virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected:
vpx_bit_depth_t bit_depth_;
int mask_;
QuantizeFunc quantize_op_;
QuantizeFunc ref_quantize_op_;
};
TEST_P(VP9QuantizeTest, OperationCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, int16_t, zbin_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, round_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_shift_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, qcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, dqcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_qcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_dqcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, int16_t, dequant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, uint16_t, eob_ptr, 1);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_eob_ptr, 1);
int err_count_total = 0;
int first_failure = -1;
for (int i = 0; i < number_of_iterations; ++i) {
const int skip_block = i == 0;
const TX_SIZE sz = (TX_SIZE)(i % 3); // TX_4X4, TX_8X8 TX_16X16
const TX_TYPE tx_type = (TX_TYPE)((i >> 2) % 3);
const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
const int count = (4 << sz) * (4 << sz); // 16, 64, 256
int err_count = 0;
*eob_ptr = rnd.Rand16();
*ref_eob_ptr = *eob_ptr;
for (int j = 0; j < count; j++) {
coeff_ptr[j] = rnd.Rand16()&mask_;
}
for (int j = 0; j < 2; j++) {
zbin_ptr[j] = rnd.Rand16()&mask_;
round_ptr[j] = rnd.Rand16();
quant_ptr[j] = rnd.Rand16();
quant_shift_ptr[j] = rnd.Rand16();
dequant_ptr[j] = rnd.Rand16();
}
ref_quantize_op_(coeff_ptr, count, skip_block, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, ref_qcoeff_ptr,
ref_dqcoeff_ptr, dequant_ptr,
ref_eob_ptr, scan_order->scan, scan_order->iscan);
ASM_REGISTER_STATE_CHECK(quantize_op_(coeff_ptr, count, skip_block,
zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr,
scan_order->scan, scan_order->iscan));
for (int j = 0; j < sz; ++j) {
err_count += (ref_qcoeff_ptr[j] != qcoeff_ptr[j]) |
(ref_dqcoeff_ptr[j] != dqcoeff_ptr[j]);
}
err_count += (*ref_eob_ptr != *eob_ptr);
if (err_count && !err_count_total) {
first_failure = i;
}
err_count_total += err_count;
}
EXPECT_EQ(0, err_count_total)
<< "Error: Quantization Test, C output doesn't match SSE2 output. "
<< "First failed at test case " << first_failure;
}
TEST_P(VP9Quantize32Test, OperationCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, int16_t, zbin_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, round_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_shift_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, qcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, dqcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_qcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_dqcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, int16_t, dequant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, uint16_t, eob_ptr, 1);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_eob_ptr, 1);
int err_count_total = 0;
int first_failure = -1;
for (int i = 0; i < number_of_iterations; ++i) {
const int skip_block = i == 0;
const TX_SIZE sz = TX_32X32;
const TX_TYPE tx_type = (TX_TYPE)(i % 4);
const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
const int count = (4 << sz) * (4 << sz); // 1024
int err_count = 0;
*eob_ptr = rnd.Rand16();
*ref_eob_ptr = *eob_ptr;
for (int j = 0; j < count; j++) {
coeff_ptr[j] = rnd.Rand16()&mask_;
}
for (int j = 0; j < 2; j++) {
zbin_ptr[j] = rnd.Rand16()&mask_;
round_ptr[j] = rnd.Rand16();
quant_ptr[j] = rnd.Rand16();
quant_shift_ptr[j] = rnd.Rand16();
dequant_ptr[j] = rnd.Rand16();
}
ref_quantize_op_(coeff_ptr, count, skip_block, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, ref_qcoeff_ptr,
ref_dqcoeff_ptr, dequant_ptr,
ref_eob_ptr, scan_order->scan, scan_order->iscan);
ASM_REGISTER_STATE_CHECK(quantize_op_(coeff_ptr, count, skip_block,
zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr,
scan_order->scan, scan_order->iscan));
for (int j = 0; j < sz; ++j) {
err_count += (ref_qcoeff_ptr[j] != qcoeff_ptr[j]) |
(ref_dqcoeff_ptr[j] != dqcoeff_ptr[j]);
}
err_count += (*ref_eob_ptr != *eob_ptr);
if (err_count && !err_count_total) {
first_failure = i;
}
err_count_total += err_count;
}
EXPECT_EQ(0, err_count_total)
<< "Error: Quantization Test, C output doesn't match SSE2 output. "
<< "First failed at test case " << first_failure;
}
TEST_P(VP9QuantizeTest, EOBCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, int16_t, zbin_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, round_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_shift_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, qcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, dqcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_qcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_dqcoeff_ptr, 256);
DECLARE_ALIGNED_ARRAY(16, int16_t, dequant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, uint16_t, eob_ptr, 1);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_eob_ptr, 1);
int err_count_total = 0;
int first_failure = -1;
for (int i = 0; i < number_of_iterations; ++i) {
int skip_block = i == 0;
TX_SIZE sz = (TX_SIZE)(i % 3); // TX_4X4, TX_8X8 TX_16X16
TX_TYPE tx_type = (TX_TYPE)((i >> 2) % 3);
const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
int count = (4 << sz) * (4 << sz); // 16, 64, 256
int err_count = 0;
*eob_ptr = rnd.Rand16();
*ref_eob_ptr = *eob_ptr;
// Two random entries
for (int j = 0; j < count; j++) {
coeff_ptr[j] = 0;
}
coeff_ptr[rnd(count)] = rnd.Rand16()&mask_;
coeff_ptr[rnd(count)] = rnd.Rand16()&mask_;
for (int j = 0; j < 2; j++) {
zbin_ptr[j] = rnd.Rand16()&mask_;
round_ptr[j] = rnd.Rand16();
quant_ptr[j] = rnd.Rand16();
quant_shift_ptr[j] = rnd.Rand16();
dequant_ptr[j] = rnd.Rand16();
}
ref_quantize_op_(coeff_ptr, count, skip_block, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, ref_qcoeff_ptr,
ref_dqcoeff_ptr, dequant_ptr,
ref_eob_ptr, scan_order->scan, scan_order->iscan);
ASM_REGISTER_STATE_CHECK(quantize_op_(coeff_ptr, count, skip_block,
zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr,
scan_order->scan, scan_order->iscan));
for (int j = 0; j < sz; ++j) {
err_count += (ref_qcoeff_ptr[j] != qcoeff_ptr[j]) |
(ref_dqcoeff_ptr[j] != dqcoeff_ptr[j]);
}
err_count += (*ref_eob_ptr != *eob_ptr);
if (err_count && !err_count_total) {
first_failure = i;
}
err_count_total += err_count;
}
EXPECT_EQ(0, err_count_total)
<< "Error: Quantization Test, C output doesn't match SSE2 output. "
<< "First failed at test case " << first_failure;
}
TEST_P(VP9Quantize32Test, EOBCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, int16_t, zbin_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, round_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, int16_t, quant_shift_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, qcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, dqcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_qcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_dqcoeff_ptr, 1024);
DECLARE_ALIGNED_ARRAY(16, int16_t, dequant_ptr, 2);
DECLARE_ALIGNED_ARRAY(16, uint16_t, eob_ptr, 1);
DECLARE_ALIGNED_ARRAY(16, uint16_t, ref_eob_ptr, 1);
int err_count_total = 0;
int first_failure = -1;
for (int i = 0; i < number_of_iterations; ++i) {
int skip_block = i == 0;
TX_SIZE sz = TX_32X32;
TX_TYPE tx_type = (TX_TYPE)(i % 4);
const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
int count = (4 << sz) * (4 << sz); // 1024
int err_count = 0;
*eob_ptr = rnd.Rand16();
*ref_eob_ptr = *eob_ptr;
for (int j = 0; j < count; j++) {
coeff_ptr[j] = 0;
}
// Two random entries
coeff_ptr[rnd(count)] = rnd.Rand16()&mask_;
coeff_ptr[rnd(count)] = rnd.Rand16()&mask_;
for (int j = 0; j < 2; j++) {
zbin_ptr[j] = rnd.Rand16()&mask_;
round_ptr[j] = rnd.Rand16();
quant_ptr[j] = rnd.Rand16();
quant_shift_ptr[j] = rnd.Rand16();
dequant_ptr[j] = rnd.Rand16();
}
ref_quantize_op_(coeff_ptr, count, skip_block, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, ref_qcoeff_ptr,
ref_dqcoeff_ptr, dequant_ptr,
ref_eob_ptr, scan_order->scan, scan_order->iscan);
ASM_REGISTER_STATE_CHECK(quantize_op_(coeff_ptr, count, skip_block,
zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr,
scan_order->scan, scan_order->iscan));
for (int j = 0; j < sz; ++j) {
err_count += (ref_qcoeff_ptr[j] != qcoeff_ptr[j]) |
(ref_dqcoeff_ptr[j] != dqcoeff_ptr[j]);
}
err_count += (*ref_eob_ptr != *eob_ptr);
if (err_count && !err_count_total) {
first_failure = i;
}
err_count_total += err_count;
}
EXPECT_EQ(0, err_count_total)
<< "Error: Quantization Test, C output doesn't match SSE2 output. "
<< "First failed at test case " << first_failure;
}
using std::tr1::make_tuple;
#if HAVE_SSE2
INSTANTIATE_TEST_CASE_P(
SSE2, VP9QuantizeTest,
::testing::Values(
make_tuple(&vp9_highbd_quantize_b_sse2,
&vp9_highbd_quantize_b_c, VPX_BITS_8),
make_tuple(&vp9_highbd_quantize_b_sse2,
&vp9_highbd_quantize_b_c, VPX_BITS_10),
make_tuple(&vp9_highbd_quantize_b_sse2,
&vp9_highbd_quantize_b_c, VPX_BITS_12)));
INSTANTIATE_TEST_CASE_P(
SSE2, VP9Quantize32Test,
::testing::Values(
make_tuple(&vp9_highbd_quantize_b_32x32_sse2,
&vp9_highbd_quantize_b_32x32_c, VPX_BITS_8),
make_tuple(&vp9_highbd_quantize_b_32x32_sse2,
&vp9_highbd_quantize_b_32x32_c, VPX_BITS_10),
make_tuple(&vp9_highbd_quantize_b_32x32_sse2,
&vp9_highbd_quantize_b_32x32_c, VPX_BITS_12)));
#endif // HAVE_SSE2
#endif // CONFIG_VP9_HIGHBITDEPTH
} // namespace

View File

@@ -1,72 +0,0 @@
#!/bin/sh
##
## Copyright (c) 2014 The WebM project authors. All Rights Reserved.
##
## Use of this source code is governed by a BSD-style license
## 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.
##
## This file tests the libvpx vp9_spatial_svc_encoder example. To add new
## tests to to this file, do the following:
## 1. Write a shell function (this is your test).
## 2. Add the function to vp9_spatial_svc_tests (on a new line).
##
. $(dirname $0)/tools_common.sh
# Environment check: $YUV_RAW_INPUT is required.
vp9_spatial_svc_encoder_verify_environment() {
if [ ! -e "${YUV_RAW_INPUT}" ]; then
echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
return 1
fi
}
# Runs vp9_spatial_svc_encoder. $1 is the test name.
vp9_spatial_svc_encoder() {
local readonly \
encoder="${LIBVPX_BIN_PATH}/vp9_spatial_svc_encoder${VPX_TEST_EXE_SUFFIX}"
local readonly test_name="$1"
local readonly \
output_file="${VPX_TEST_OUTPUT_DIR}/vp9_ssvc_encoder${test_name}.ivf"
local readonly frames_to_encode=10
local readonly max_kf=9999
shift
if [ ! -x "${encoder}" ]; then
elog "${encoder} does not exist or is not executable."
return 1
fi
eval "${VPX_TEST_PREFIX}" "${encoder}" -w "${YUV_RAW_INPUT_WIDTH}" \
-h "${YUV_RAW_INPUT_HEIGHT}" -k "${max_kf}" -f "${frames_to_encode}" \
"$@" "${YUV_RAW_INPUT}" "${output_file}" ${devnull}
[ -e "${output_file}" ] || return 1
}
# Each test is run with layer count 1-$vp9_ssvc_test_layers.
vp9_ssvc_test_layers=5
vp9_spatial_svc() {
if [ "$(vp9_encode_available)" = "yes" ]; then
local readonly test_name="vp9_spatial_svc"
for layers in $(seq 1 ${vp9_ssvc_test_layers}); do
vp9_spatial_svc_encoder "${test_name}" -l ${layers}
done
fi
}
readonly vp9_spatial_svc_tests="DISABLED_vp9_spatial_svc_mode_i
DISABLED_vp9_spatial_svc_mode_altip
DISABLED_vp9_spatial_svc_mode_ip
DISABLED_vp9_spatial_svc_mode_gf
vp9_spatial_svc"
if [ "$(vpx_config_option_enabled CONFIG_SPATIAL_SVC)" = "yes" ]; then
run_tests \
vp9_spatial_svc_encoder_verify_environment \
"${vp9_spatial_svc_tests}"
fi

View File

@@ -207,7 +207,7 @@ int Reset(VP9Worker *const /*worker*/) { return 1; }
int Sync(VP9Worker *const worker) { return !worker->had_error; } int Sync(VP9Worker *const worker) { return !worker->had_error; }
void Execute(VP9Worker *const worker) { void Execute(VP9Worker *const worker) {
worker->had_error |= !worker->hook(worker->data1, worker->data2); worker->had_error |= worker->hook(worker->data1, worker->data2);
} }
void Launch(VP9Worker *const worker) { Execute(worker); } void Launch(VP9Worker *const worker) { Execute(worker); }

View File

@@ -33,10 +33,10 @@ class VpxScaleBase {
void ResetImage(int width, int height) { void ResetImage(int width, int height) {
width_ = width; width_ = width;
height_ = height; height_ = height;
memset(&img_, 0, sizeof(img_)); vpx_memset(&img_, 0, sizeof(img_));
ASSERT_EQ(0, vp8_yv12_alloc_frame_buffer(&img_, width_, height_, ASSERT_EQ(0, vp8_yv12_alloc_frame_buffer(&img_, width_, height_,
VP8BORDERINPIXELS)); VP8BORDERINPIXELS));
memset(img_.buffer_alloc, kBufFiller, img_.frame_size); vpx_memset(img_.buffer_alloc, kBufFiller, img_.frame_size);
FillPlane(img_.y_buffer, img_.y_crop_width, img_.y_crop_height, FillPlane(img_.y_buffer, img_.y_crop_width, img_.y_crop_height,
img_.y_stride); img_.y_stride);
FillPlane(img_.u_buffer, img_.uv_crop_width, img_.uv_crop_height, FillPlane(img_.u_buffer, img_.uv_crop_width, img_.uv_crop_height,
@@ -44,15 +44,15 @@ class VpxScaleBase {
FillPlane(img_.v_buffer, img_.uv_crop_width, img_.uv_crop_height, FillPlane(img_.v_buffer, img_.uv_crop_width, img_.uv_crop_height,
img_.uv_stride); img_.uv_stride);
memset(&ref_img_, 0, sizeof(ref_img_)); vpx_memset(&ref_img_, 0, sizeof(ref_img_));
ASSERT_EQ(0, vp8_yv12_alloc_frame_buffer(&ref_img_, width_, height_, ASSERT_EQ(0, vp8_yv12_alloc_frame_buffer(&ref_img_, width_, height_,
VP8BORDERINPIXELS)); VP8BORDERINPIXELS));
memset(ref_img_.buffer_alloc, kBufFiller, ref_img_.frame_size); vpx_memset(ref_img_.buffer_alloc, kBufFiller, ref_img_.frame_size);
memset(&cpy_img_, 0, sizeof(cpy_img_)); vpx_memset(&cpy_img_, 0, sizeof(cpy_img_));
ASSERT_EQ(0, vp8_yv12_alloc_frame_buffer(&cpy_img_, width_, height_, ASSERT_EQ(0, vp8_yv12_alloc_frame_buffer(&cpy_img_, width_, height_,
VP8BORDERINPIXELS)); VP8BORDERINPIXELS));
memset(cpy_img_.buffer_alloc, kBufFiller, cpy_img_.frame_size); vpx_memset(cpy_img_.buffer_alloc, kBufFiller, cpy_img_.frame_size);
ReferenceCopyFrame(); ReferenceCopyFrame();
} }
@@ -87,8 +87,8 @@ class VpxScaleBase {
// Fill the border pixels from the nearest image pixel. // Fill the border pixels from the nearest image pixel.
for (int y = 0; y < crop_height; ++y) { for (int y = 0; y < crop_height; ++y) {
memset(left, left[padding], padding); vpx_memset(left, left[padding], padding);
memset(right, right[-1], right_extend); vpx_memset(right, right[-1], right_extend);
left += stride; left += stride;
right += stride; right += stride;
} }
@@ -101,13 +101,13 @@ class VpxScaleBase {
// The first row was already extended to the left and right. Copy it up. // The first row was already extended to the left and right. Copy it up.
for (int y = 0; y < padding; ++y) { for (int y = 0; y < padding; ++y) {
memcpy(top, left, extend_width); vpx_memcpy(top, left, extend_width);
top += stride; top += stride;
} }
uint8_t *bottom = left + (crop_height * stride); uint8_t *bottom = left + (crop_height * stride);
for (int y = 0; y < bottom_extend; ++y) { for (int y = 0; y < bottom_extend; ++y) {
memcpy(bottom, left + (crop_height - 1) * stride, extend_width); vpx_memcpy(bottom, left + (crop_height - 1) * stride, extend_width);
bottom += stride; bottom += stride;
} }
} }

View File

@@ -1,290 +0,0 @@
#!/bin/sh
##
## Copyright (c) 2014 The WebM project authors. All Rights Reserved.
##
## Use of this source code is governed by a BSD-style license
## 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.
##
## This file tests the libvpx vpx_temporal_svc_encoder example. To add new
## tests to this file, do the following:
## 1. Write a shell function (this is your test).
## 2. Add the function to vpx_tsvc_encoder_tests (on a new line).
##
. $(dirname $0)/tools_common.sh
# Environment check: $YUV_RAW_INPUT is required.
vpx_tsvc_encoder_verify_environment() {
if [ ! -e "${YUV_RAW_INPUT}" ]; then
echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
return 1
fi
if [ "$(vpx_config_option_enabled CONFIG_TEMPORAL_DENOISING)" != "yes" ]; then
elog "Warning: Temporal denoising is disabled! Spatial denoising will be " \
"used instead, which is probably not what you want for this test."
fi
}
# Runs vpx_temporal_svc_encoder using the codec specified by $1 and output file
# name by $2. Additional positional parameters are passed directly to
# vpx_temporal_svc_encoder.
vpx_tsvc_encoder() {
local encoder="${LIBVPX_BIN_PATH}/vpx_temporal_svc_encoder"
encoder="${encoder}${VPX_TEST_EXE_SUFFIX}"
local codec="$1"
local output_file_base="$2"
local output_file="${VPX_TEST_OUTPUT_DIR}/${output_file_base}"
local timebase_num="1"
local timebase_den="1000"
local speed="6"
local frame_drop_thresh="30"
shift 2
if [ ! -x "${encoder}" ]; then
elog "${encoder} does not exist or is not executable."
return 1
fi
eval "${VPX_TEST_PREFIX}" "${encoder}" "${YUV_RAW_INPUT}" "${output_file}" \
"${codec}" "${YUV_RAW_INPUT_WIDTH}" "${YUV_RAW_INPUT_HEIGHT}" \
"${timebase_num}" "${timebase_den}" "${speed}" "${frame_drop_thresh}" \
"$@" \
${devnull}
}
# Confirms that all expected output files exist given the output file name
# passed to vpx_temporal_svc_encoder.
# The file name passed to vpx_temporal_svc_encoder is joined with the stream
# number and the extension .ivf to produce per stream output files. Here $1 is
# file name, and $2 is expected number of files.
files_exist() {
local file_name="${VPX_TEST_OUTPUT_DIR}/$1"
local num_files="$(($2 - 1))"
for stream_num in $(seq 0 ${num_files}); do
[ -e "${file_name}_${stream_num}.ivf" ] || return 1
done
}
# Run vpx_temporal_svc_encoder in all supported modes for vp8 and vp9.
vpx_tsvc_encoder_vp8_mode_0() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 0 200 || return 1
# Mode 0 produces 1 stream
files_exist "${FUNCNAME}" 1 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_1() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 1 200 400 || return 1
# Mode 1 produces 2 streams
files_exist "${FUNCNAME}" 2 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_2() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 2 200 400 || return 1
# Mode 2 produces 2 streams
files_exist "${FUNCNAME}" 2 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_3() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 3 200 400 600 || return 1
# Mode 3 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_4() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 4 200 400 600 || return 1
# Mode 4 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_5() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 5 200 400 600 || return 1
# Mode 5 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_6() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 6 200 400 600 || return 1
# Mode 6 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_7() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 7 200 400 600 800 1000 || return 1
# Mode 7 produces 5 streams
files_exist "${FUNCNAME}" 5 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_8() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 8 200 400 || return 1
# Mode 8 produces 2 streams
files_exist "${FUNCNAME}" 2 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_9() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 9 200 400 600 || return 1
# Mode 9 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_10() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 10 200 400 600 || return 1
# Mode 10 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp8_mode_11() {
if [ "$(vp8_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp8 "${FUNCNAME}" 11 200 400 600 || return 1
# Mode 11 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_0() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 0 200 || return 1
# Mode 0 produces 1 stream
files_exist "${FUNCNAME}" 1 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_1() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 1 200 400 || return 1
# Mode 1 produces 2 streams
files_exist "${FUNCNAME}" 2 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_2() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 2 200 400 || return 1
# Mode 2 produces 2 streams
files_exist "${FUNCNAME}" 2 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_3() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 3 200 400 600 || return 1
# Mode 3 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_4() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 4 200 400 600 || return 1
# Mode 4 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_5() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 5 200 400 600 || return 1
# Mode 5 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_6() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 6 200 400 600 || return 1
# Mode 6 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_7() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 7 200 400 600 800 1000 || return 1
# Mode 7 produces 5 streams
files_exist "${FUNCNAME}" 5 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_8() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 8 200 400 || return 1
# Mode 8 produces 2 streams
files_exist "${FUNCNAME}" 2 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_9() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 9 200 400 600 || return 1
# Mode 9 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_10() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 10 200 400 600 || return 1
# Mode 10 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_vp9_mode_11() {
if [ "$(vp9_encode_available)" = "yes" ]; then
vpx_tsvc_encoder vp9 "${FUNCNAME}" 11 200 400 600 || return 1
# Mode 11 produces 3 streams
files_exist "${FUNCNAME}" 3 || return 1
fi
}
vpx_tsvc_encoder_tests="vpx_tsvc_encoder_vp8_mode_0
vpx_tsvc_encoder_vp8_mode_1
vpx_tsvc_encoder_vp8_mode_2
vpx_tsvc_encoder_vp8_mode_3
vpx_tsvc_encoder_vp8_mode_4
vpx_tsvc_encoder_vp8_mode_5
vpx_tsvc_encoder_vp8_mode_6
vpx_tsvc_encoder_vp8_mode_7
vpx_tsvc_encoder_vp8_mode_8
vpx_tsvc_encoder_vp8_mode_9
vpx_tsvc_encoder_vp8_mode_10
vpx_tsvc_encoder_vp8_mode_11
vpx_tsvc_encoder_vp9_mode_0
vpx_tsvc_encoder_vp9_mode_1
vpx_tsvc_encoder_vp9_mode_2
vpx_tsvc_encoder_vp9_mode_3
vpx_tsvc_encoder_vp9_mode_4
vpx_tsvc_encoder_vp9_mode_5
vpx_tsvc_encoder_vp9_mode_6
vpx_tsvc_encoder_vp9_mode_7
vpx_tsvc_encoder_vp9_mode_8
vpx_tsvc_encoder_vp9_mode_9
vpx_tsvc_encoder_vp9_mode_10
vpx_tsvc_encoder_vp9_mode_11"
run_tests vpx_tsvc_encoder_verify_environment "${vpx_tsvc_encoder_tests}"

View File

@@ -16,9 +16,7 @@
# Environment check: Make sure input is available. # Environment check: Make sure input is available.
vpxdec_verify_environment() { vpxdec_verify_environment() {
if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_WEBM_FILE}" ] || \ if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_WEBM_FILE}" ]; then
[ ! -e "${VP9_FPM_WEBM_FILE}" ] || \
[ ! -e "${VP9_LT_50_FRAMES_WEBM_FILE}" ] ; then
elog "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH." elog "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
return 1 return 1
fi fi
@@ -80,37 +78,8 @@ vpxdec_vp9_webm() {
fi fi
} }
vpxdec_vp9_webm_frame_parallel() {
if [ "$(vpxdec_can_decode_vp9)" = "yes" ] && \
[ "$(webm_io_available)" = "yes" ]; then
for threads in 2 3 4 5 6 7 8; do
vpxdec "${VP9_FPM_WEBM_FILE}" --summary --noblit --threads=$threads \
--frame-parallel
done
fi
}
vpxdec_vp9_webm_less_than_50_frames() {
# ensure that reaching eof in webm_guess_framerate doesn't result in invalid
# frames in actual webm_read_frame calls.
if [ "$(vpxdec_can_decode_vp9)" = "yes" ] && \
[ "$(webm_io_available)" = "yes" ]; then
local readonly decoder="$(vpx_tool_path vpxdec)"
local readonly expected=10
local readonly num_frames=$(${VPX_TEST_PREFIX} "${decoder}" \
"${VP9_LT_50_FRAMES_WEBM_FILE}" --summary --noblit 2>&1 \
| awk '/^[0-9]+ decoded frames/ { print $1 }')
if [ "$num_frames" -ne "$expected" ]; then
elog "Output frames ($num_frames) != expected ($expected)"
return 1
fi
fi
}
vpxdec_tests="vpxdec_vp8_ivf vpxdec_tests="vpxdec_vp8_ivf
vpxdec_vp8_ivf_pipe_input vpxdec_vp8_ivf_pipe_input
vpxdec_vp9_webm vpxdec_vp9_webm"
vpxdec_vp9_webm_frame_parallel
vpxdec_vp9_webm_less_than_50_frames"
run_tests vpxdec_verify_environment "${vpxdec_tests}" run_tests vpxdec_verify_environment "${vpxdec_tests}"

View File

@@ -69,18 +69,6 @@ class WebMVideoSource : public CompressedVideoSource {
} }
} }
void SeekToNextKeyFrame() {
ASSERT_TRUE(vpx_ctx_->file != NULL);
do {
const int status = webm_read_frame(webm_ctx_, &buf_, &buf_sz_, &buf_sz_);
ASSERT_GE(status, 0) << "webm_read_frame failed";
++frame_;
if (status == 1) {
end_of_file_ = true;
}
} while (!webm_ctx_->is_key_frame && !end_of_file_);
}
virtual const uint8_t *cxdata() const { virtual const uint8_t *cxdata() const {
return end_of_file_ ? NULL : buf_; return end_of_file_ ? NULL : buf_;
} }

View File

@@ -1,11 +1,17 @@
LOCAL_PATH := $(call my-dir) LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CPP_EXTENSION := .cpp include $(CLEAR_VARS)
LOCAL_SRC_FILES := mkvmuxer.cpp \ LOCAL_MODULE:= libwebm
mkvmuxerutil.cpp \ LOCAL_CPPFLAGS:=-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
mkvparser.cpp \ LOCAL_CPPFLAGS+=-D__STDC_LIMIT_MACROS -Wno-extern-c-compat
mkvreader.cpp \ LOCAL_C_INCLUDES:= $(LOCAL_PATH)
mkvwriter.cpp LOCAL_EXPORT_C_INCLUDES:= $(LOCAL_PATH)
LOCAL_MODULE := libwebm
LOCAL_SRC_FILES:= common/file_util.cc \
common/hdr_util.cc \
mkvparser/mkvparser.cc \
mkvparser/mkvreader.cc \
mkvmuxer/mkvmuxer.cc \
mkvmuxer/mkvmuxerutil.cc \
mkvmuxer/mkvwriter.cc
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)

View File

@@ -17,7 +17,7 @@ or agree to the institution of patent litigation or any other patent
enforcement activity against any entity (including a cross-claim or enforcement activity against any entity (including a cross-claim or
counterclaim in a lawsuit) alleging that any of these implementations of WebM counterclaim in a lawsuit) alleging that any of these implementations of WebM
or any code incorporated within any of these implementations of WebM or any code incorporated within any of these implementations of WebM
constitutes direct or contributory patent infringement, or inducement of constitute direct or contributory patent infringement, or inducement of
patent infringement, then any patent rights granted to you under this License patent infringement, then any patent rights granted to you under this License
for these implementations of WebM shall terminate as of the date such for these implementations of WebM shall terminate as of the date such
litigation is filed. litigation is filed.

View File

@@ -1,7 +1,10 @@
URL: https://chromium.googlesource.com/webm/libwebm URL: https://chromium.googlesource.com/webm/libwebm
Version: 249629d46c6e9391f25a90cff6d19075f47474cb Version: 32d5ac49414a8914ec1e1f285f3f927c6e8ec29d
License: BSD License: BSD
License File: LICENSE.txt License File: LICENSE.txt
Description: Description:
libwebm is used to handle WebM container I/O. libwebm is used to handle WebM container I/O.
Local Changes:
* <none>

View File

@@ -1,34 +0,0 @@
1.0.0.5
* Handled case when no duration
* Handled empty clusters
* Handled empty clusters when seeking
* Implemented check lacing bits
1.0.0.4
* Made Cues member variables mutables
* Defined against badly-formatted cue points
* Segment::GetCluster returns CuePoint too
* Separated cue-based searches
1.0.0.3
* Added Block::GetOffset() to get a frame's offset in a block
* Changed cluster count type from size_t to long
* Parsed SeekHead to find cues
* Allowed seeking beyond end of cluster cache
* Added not to attempt to reparse cues element
* Restructured Segment::LoadCluster
* Marked position of cues without parsing cues element
* Allowed cue points to be loaded incrementally
* Implemented to load lazily cue points as they're searched
* Merged Cues::LoadCuePoint into Cues::Find
* Lazy init cues
* Loaded cue point during find
1.0.0.2
* added support for Cues element
* seeking was improved
1.0.0.1
* fixed item 141
* added item 142
* added this file, RELEASE.TXT, to repository

67
third_party/libwebm/common/file_util.cc vendored Normal file
View File

@@ -0,0 +1,67 @@
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// 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 "common/file_util.h"
#include <sys/stat.h>
#ifndef _MSC_VER
#include <unistd.h> // close()
#endif
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <ios>
namespace libwebm {
std::string GetTempFileName() {
#if !defined _MSC_VER && !defined __MINGW32__
char temp_file_name_template[] = "libwebm_temp.XXXXXX";
int fd = mkstemp(temp_file_name_template);
if (fd != -1) {
close(fd);
return std::string(temp_file_name_template);
}
return std::string();
#else
char tmp_file_name[_MAX_PATH];
errno_t err = tmpnam_s(tmp_file_name);
if (err == 0) {
return std::string(tmp_file_name);
}
return std::string();
#endif
}
uint64_t GetFileSize(const std::string& file_name) {
uint64_t file_size = 0;
#ifndef _MSC_VER
struct stat st;
st.st_size = 0;
if (stat(file_name.c_str(), &st) == 0) {
#else
struct _stat st;
st.st_size = 0;
if (_stat(file_name.c_str(), &st) == 0) {
#endif
file_size = st.st_size;
}
return file_size;
}
TempFileDeleter::TempFileDeleter() { file_name_ = GetTempFileName(); }
TempFileDeleter::~TempFileDeleter() {
std::ifstream file(file_name_.c_str());
if (file.good()) {
file.close();
std::remove(file_name_.c_str());
}
}
} // namespace libwebm

41
third_party/libwebm/common/file_util.h vendored Normal file
View File

@@ -0,0 +1,41 @@
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// 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.
#ifndef LIBWEBM_COMMON_FILE_UTIL_H_
#define LIBWEBM_COMMON_FILE_UTIL_H_
#include <stdint.h>
#include <string>
#include "mkvmuxer/mkvmuxertypes.h" // LIBWEBM_DISALLOW_COPY_AND_ASSIGN()
namespace libwebm {
// Returns a temporary file name.
std::string GetTempFileName();
// Returns size of file specified by |file_name|, or 0 upon failure.
uint64_t GetFileSize(const std::string& file_name);
// Manages life of temporary file specified at time of construction. Deletes
// file upon destruction.
class TempFileDeleter {
public:
TempFileDeleter();
explicit TempFileDeleter(std::string file_name) : file_name_(file_name) {}
~TempFileDeleter();
const std::string& name() const { return file_name_; }
private:
std::string file_name_;
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TempFileDeleter);
};
} // namespace libwebm
#endif // LIBWEBM_COMMON_FILE_UTIL_H_

182
third_party/libwebm/common/hdr_util.cc vendored Normal file
View File

@@ -0,0 +1,182 @@
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// 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 "hdr_util.h"
#include <cstddef>
#include <new>
#include "mkvparser/mkvparser.h"
namespace libwebm {
bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
PrimaryChromaticityPtr* muxer_pc) {
muxer_pc->reset(new (std::nothrow)
mkvmuxer::PrimaryChromaticity(parser_pc.x, parser_pc.y));
if (!muxer_pc->get())
return false;
return true;
}
bool MasteringMetadataValuePresent(double value) {
return value != mkvparser::MasteringMetadata::kValueNotPresent;
}
bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
mkvmuxer::MasteringMetadata* muxer_mm) {
if (MasteringMetadataValuePresent(parser_mm.luminance_max))
muxer_mm->luminance_max = parser_mm.luminance_max;
if (MasteringMetadataValuePresent(parser_mm.luminance_min))
muxer_mm->luminance_min = parser_mm.luminance_min;
PrimaryChromaticityPtr r_ptr(NULL);
PrimaryChromaticityPtr g_ptr(NULL);
PrimaryChromaticityPtr b_ptr(NULL);
PrimaryChromaticityPtr wp_ptr(NULL);
if (parser_mm.r) {
if (!CopyPrimaryChromaticity(*parser_mm.r, &r_ptr))
return false;
}
if (parser_mm.g) {
if (!CopyPrimaryChromaticity(*parser_mm.g, &g_ptr))
return false;
}
if (parser_mm.b) {
if (!CopyPrimaryChromaticity(*parser_mm.b, &b_ptr))
return false;
}
if (parser_mm.white_point) {
if (!CopyPrimaryChromaticity(*parser_mm.white_point, &wp_ptr))
return false;
}
if (!muxer_mm->SetChromaticity(r_ptr.get(), g_ptr.get(), b_ptr.get(),
wp_ptr.get())) {
return false;
}
return true;
}
bool ColourValuePresent(long long value) {
return value != mkvparser::Colour::kValueNotPresent;
}
bool CopyColour(const mkvparser::Colour& parser_colour,
mkvmuxer::Colour* muxer_colour) {
if (!muxer_colour)
return false;
if (ColourValuePresent(parser_colour.matrix_coefficients))
muxer_colour->matrix_coefficients = parser_colour.matrix_coefficients;
if (ColourValuePresent(parser_colour.bits_per_channel))
muxer_colour->bits_per_channel = parser_colour.bits_per_channel;
if (ColourValuePresent(parser_colour.chroma_subsampling_horz))
muxer_colour->chroma_subsampling_horz =
parser_colour.chroma_subsampling_horz;
if (ColourValuePresent(parser_colour.chroma_subsampling_vert))
muxer_colour->chroma_subsampling_vert =
parser_colour.chroma_subsampling_vert;
if (ColourValuePresent(parser_colour.cb_subsampling_horz))
muxer_colour->cb_subsampling_horz = parser_colour.cb_subsampling_horz;
if (ColourValuePresent(parser_colour.cb_subsampling_vert))
muxer_colour->cb_subsampling_vert = parser_colour.cb_subsampling_vert;
if (ColourValuePresent(parser_colour.chroma_siting_horz))
muxer_colour->chroma_siting_horz = parser_colour.chroma_siting_horz;
if (ColourValuePresent(parser_colour.chroma_siting_vert))
muxer_colour->chroma_siting_vert = parser_colour.chroma_siting_vert;
if (ColourValuePresent(parser_colour.range))
muxer_colour->range = parser_colour.range;
if (ColourValuePresent(parser_colour.transfer_characteristics))
muxer_colour->transfer_characteristics =
parser_colour.transfer_characteristics;
if (ColourValuePresent(parser_colour.primaries))
muxer_colour->primaries = parser_colour.primaries;
if (ColourValuePresent(parser_colour.max_cll))
muxer_colour->max_cll = parser_colour.max_cll;
if (ColourValuePresent(parser_colour.max_fall))
muxer_colour->max_fall = parser_colour.max_fall;
if (parser_colour.mastering_metadata) {
mkvmuxer::MasteringMetadata muxer_mm;
if (!CopyMasteringMetadata(*parser_colour.mastering_metadata, &muxer_mm))
return false;
if (!muxer_colour->SetMasteringMetadata(muxer_mm))
return false;
}
return true;
}
// Format of VPx private data:
//
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | ID Byte | Length | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
// | |
// : Bytes 1..Length of Codec Feature :
// | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
// ID Byte Format
// ID byte is an unsigned byte.
// 0 1 2 3 4 5 6 7
// +-+-+-+-+-+-+-+-+
// |X| ID |
// +-+-+-+-+-+-+-+-+
//
// The X bit is reserved.
//
// Currently only profile level is supported. ID byte must be set to 1, and
// length must be 1. Supported values are:
//
// 10: Level 1
// 11: Level 1.1
// 20: Level 2
// 21: Level 2.1
// 30: Level 3
// 31: Level 3.1
// 40: Level 4
// 41: Level 4.1
// 50: Level 5
// 51: Level 5.1
// 52: Level 5.2
// 60: Level 6
// 61: Level 6.1
// 62: Level 6.2
//
// See the following link for more information:
// http://www.webmproject.org/vp9/profiles/
int ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length) {
const int kVpxCodecPrivateLength = 3;
if (!private_data || length != kVpxCodecPrivateLength)
return 0;
const uint8_t id_byte = *private_data;
if (id_byte != 1)
return 0;
const int kVpxProfileLength = 1;
const uint8_t length_byte = private_data[1];
if (length_byte != kVpxProfileLength)
return 0;
const int level = static_cast<int>(private_data[2]);
const int kNumLevels = 14;
const int levels[kNumLevels] = {10, 11, 20, 21, 30, 31, 40,
41, 50, 51, 52, 60, 61, 62};
for (int i = 0; i < kNumLevels; ++i) {
if (level == levels[i])
return level;
}
return 0;
}
} // namespace libwebm

51
third_party/libwebm/common/hdr_util.h vendored Normal file
View File

@@ -0,0 +1,51 @@
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// 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.
#ifndef LIBWEBM_COMMON_HDR_UTIL_H_
#define LIBWEBM_COMMON_HDR_UTIL_H_
#include <stdint.h>
#include <memory>
#include "mkvmuxer/mkvmuxer.h"
namespace mkvparser {
struct Colour;
struct MasteringMetadata;
struct PrimaryChromaticity;
} // namespace mkvparser
namespace libwebm {
// Utility types and functions for working with the Colour element and its
// children. Copiers return true upon success. Presence functions return true
// when the specified element is present.
// TODO(tomfinegan): These should be moved to libwebm_utils once c++11 is
// required by libwebm.
typedef std::auto_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
PrimaryChromaticityPtr* muxer_pc);
bool MasteringMetadataValuePresent(double value);
bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
mkvmuxer::MasteringMetadata* muxer_mm);
bool ColourValuePresent(long long value);
bool CopyColour(const mkvparser::Colour& parser_colour,
mkvmuxer::Colour* muxer_colour);
// Returns VP9 profile upon success or 0 upon failure.
int ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length);
} // namespace libwebm
#endif // LIBWEBM_COMMON_HDR_UTIL_H_

Some files were not shown because too many files have changed in this diff Show More