Commit Graph

78 Commits

Author SHA1 Message Date
Cheng Chen
2c32425851 L2E: Make SimpleEncode take vp9 level as an input
Level conformance is standadized in vp9.
If a specific target level is set, the vp9 encoder is required to
produce conformant bitstream with limit on frame size, rate,
min alt-ref distance, etc.

This change makes the SimpleEncode environment take the target level
as an input.

To make existing tests pass, we set the level to 0.

Change-Id: Ia35224f75c2fe50338b5b86a50c84355f5daf6fd
2022-03-30 16:29:29 -07:00
Angie Chiang
0bb7bb6df8 Add use_simple_encode_api to oxcf
Use this flag to change the encoder behavior when
SimpleEncode APIs are used

BUG=webm:1733

Change-Id: I9f0852a03ff99faa01cdd8eee8ab71718cc58632
2021-06-21 14:39:40 -07:00
Angie Chiang
a1fdfbb174 Fix flaky assertions in SimpleEncode
Bug: webm:1731

Change-Id: Ieecb98a7ac19e6291acd5d51432dc6a3789e9552
2021-06-21 14:38:13 -07:00
James Zern
5d678fe78a simple_encode: fix some -Wsign-compare warnings
Bug: webm:1731
Change-Id: I1db777c0c3a8784fb3dcf7cd39f78ebf833ab915
2021-06-09 15:08:15 -07:00
Cheng Chen
463d33145d L2E: properly init two pass rc parameters
Two pass rc parameters are only initialized in the second pass
in vp9 normal two pass encoding.
However, the simple_encode API queries the keyframe group, arf group,
and number of coding frames without going throught the two pass
route.
Since recent libvpx rc changes, parameters in the TWO_PASS
struct have a great influence on the determination of the above
information.
We therefore need to properly init two pass rc parameters in
the simple_encode related environment.

Change-Id: Ie14b86d6e7ebf171b638d2da24a7fdcf5a15c3d9
2021-06-07 17:41:23 -07:00
Cheng Chen
b8273e8ae5 Fix simple encode
Properly init and delete cpi struct in simple encode functions.

Change-Id: I6e66bcac852cbb3dec9b754ba3fb01a348ac98b8
2021-05-26 15:17:18 -07:00
Cheng Chen
7a5596fa78 Fix compilation for CONFIG_RATE_CTRL
Recently, some function signatures have been changed.
This change fixes compilation error if --enable-rate-ctrl is used.

Change-Id: Ib8e9cb5e181ba1d4a6969883e377f3dd93e9289a
2021-04-06 20:28:32 -07:00
Angie Chiang
0de1df6bf7 Merge "Revert "Close out file in EndEncode()"" 2020-11-24 03:10:44 +00:00
Angie Chiang
5459c4ab98 Revert "Close out file in EndEncode()"
This reverts commit 7370cecd89.

Reason for revert: I accidentally check in this CL

Change-Id: I71ff0b98649070df3edd13b98170a7091541057b
2020-11-24 02:55:24 +00:00
Angie Chiang
71c8e0c009 Merge "Close out file in EndEncode()" 2020-11-24 02:49:12 +00:00
Angie Chiang
2ccee3928d Allow user to set rc_mode and cq_level in SimpleEncode
Change-Id: If3f56837e2c78a8b0fe7e0040f297c3f3ddb9c8b
2020-11-20 17:40:04 -08:00
Cheng Chen
b1d704f12a Accumulate frame tpl stats and pass through rate control api
Tpl stats is computed at the beginning of encoding the altref
frame. We aggregate tpl stats of all blocks for every frame of
the current group of picture.

After the altref frame is encoded, the tpl stats is passed through
the encode frame result to external environment.
Change-Id: I2284f8cf9c45d35ba02f3ea45f0187edbbf48294
2020-11-09 13:14:19 -08:00
angiebird
da7c503fe5 Add SetEncodeConfig and DumpEncodeConfigs
Change-Id: Ie6864b1133c26021d9c4883df033ecd2969585ed
2020-10-02 19:29:36 -07:00
angiebird
7370cecd89 Close out file in EndEncode()
Change-Id: Ib6549f954ce6d5d966eef09a119b46f0cc2f54f7
2020-08-10 16:13:16 -07:00
angiebird
04db83211c Correct the first pass motion vector scale
Change-Id: I005a648f7f9ead9d36a39330dfbb096919affb34
2020-08-10 16:06:49 -07:00
angiebird
246a65c696 Make target_frame_bits error margin configurable.
Change-Id: I05dd4d60741743c13951727ce6608acf4224ebec
2020-08-10 15:00:51 -07:00
angiebird
3ec043a795 Add rq_history to encode_frame_result
Change-Id: Ic2a52dcf5e5a6d57b80d390a2c48ee498e89e7b2
2020-08-07 16:48:08 -07:00
angiebird
bb7a2ccc38 Fix ObserveFirstPassMotionVectors()
1) Use kRefFrameTypeNone in the unit test
2) Reset mv_info in fp_motion_vector_info_init
3) Call fp_motion_vector_info_init() in first_pass_encode()
4) Set mv_info for intra frame.
5) Set mv_info with zero mv as default for inter frame
6) Remove duplicated fp_motion_vector_info in encode_frame_info

Change-Id: I2f7db5cd4cf1f19db039c9ce638d17b832f45b6e
2020-08-07 15:48:32 -07:00
Cheng Chen
f9ab864199 L2E: Add ObserveFirstPassMotionVector
Store motion vectors for each 16x16 block found in the first pass
motion search.
Provide an api "ObserveFirstPassMotionVector()" in SimpleEncode
class, similar to "ObserveFirstPassStats()".

Change-Id: Ia86386b7e4aa549f7000e7965c287380bf52e62c
2020-08-03 22:46:38 -07:00
angiebird
642f6a195d Add init version of EncodeFrameWithTargetFrameBits()
Will add a unit test in a followup CL.

Change-Id: I6a6354f307c427e1a352be7c6421927323eb5e1b
2020-07-20 11:07:45 -07:00
angiebird
16935397ee Add SetEncodeSpeed() to SimpleEncode
Change-Id: I2fcf37045a96bb101de3359e2e69dcc266c1dc10
2020-07-15 14:53:01 -07:00
angiebird
e753d4930f Let SetExternalGroupOfPicturesMap use c-style arr
Change-Id: Ic92ce5a3cc5bb74120eb32fc6219e43b1b861f14
2020-06-11 15:10:38 -07:00
angiebird
812eb89b26 Fix assertion error in simple_encode.cc
Change-Id: I271d11cc35d34d5450a8b56fabcedaf2bb7c6565
2020-06-08 16:46:15 -07:00
angiebird
34034789d7 Add extra check / unit test to SetExternalGroupOfPicturesMap()
Let SetExternalGroupOfPicturesMap() modify the gop_map_ to satisfy
the following constraints.
1) Each key frame position should be at the start of a gop.
2) The last gop should not use an alt ref.

Add unit test for SetExternalGroupOfPicturesMap()

Change-Id: Iee9bd238ad0fc5c2ccbf2fbd065a280c854cd718
2020-05-28 18:07:12 -07:00
angiebird
23b070f46e Add functions to compute/observe key frame map
Change-Id: I2fc0efb2ac35e64af3350bddaa802a206d1aa13c
2020-05-26 23:33:03 -07:00
angiebird
5c8431b9e4 Make SetExternalGroupOfPicture support no arf mode
Rename external_arf_indexes by gop_map

Use kGopMapFlagStart to indicate the start of a gop in the gop_map.
Use kGopMapFlagUseAltRef to indicate whether to use altref in the
gop_map.

Change-Id: I743e3199a24b9ae1abd5acd290da1a1f8660e6ac
2020-05-26 23:30:57 -07:00
angiebird
fdf04093ec Add GOP_COMMAND
Send GOP_COMMAND to vp9 for setting gop decisions on the fly.
GOP_COMMAND has three members.
use: use this command to set gop or use vp9's gop decision.
show_frame_count: number of show frames in this gop.
use_alt_ref: use alt ref frame or not.

Move the logic of processing external_arf_indexes_ from
get_gop_coding_frame_num() to GetGopCommand() and
GetCodingFrameNumFromGopMap().

Change-Id: Ic1942c7a4cf6eecdf3507864577688350c7ef0cf
2020-05-26 19:25:52 -07:00
angiebird
77c959654c Correct time_base of ivf header in SimpleEncode
Change-Id: I8a14fcad3e7b4c4689f4e7387414e59ba9c4c20a
2020-03-17 14:13:43 -07:00
angiebird
e7aa1e3630 Add unit test for ref_frame_info
Fix several bugs to make the test pass.
1) Move update_frame_indexes() out of show_frame check.
2) Init coding_indexes[i] to -1 when key frame appears
3) Fix a bug in PostUpdateRefFrameInfo()

Change-Id: Ie7c70a1d460e5b89475a1aef77416fc9a88387e1
2020-03-03 10:57:03 -08:00
angiebird
483bcb310d Add key frame group info to SimpleEncode
Change-Id: I2c5abbe23c84c6d794e06ed6429136b10fb18683
2020-03-03 10:57:03 -08:00
angiebird
fc898231f1 Add ref_frame_info to encode_frame_result
Change-Id: If41a1ea6ce0a2b8db3811f2fa8efcf16f97fa0bd
2020-03-03 10:56:53 -08:00
angiebird
a1c0c95c8c Add GetVectorData()
It's necessary to get data pointer from a vector sometimes.
This function will guarantee that the data pointer is nullptr
if the vector is empty.

Change-Id: I156308bcb193fe404452d3cd3b24b3f80c3c3727
2020-03-02 20:16:56 -08:00
angiebird
c2aa1520a4 Add RefFrameInfo
RefFrameInfo contains the coding_indexes and valid_list of
three reference frame types.

Note that I will add unit test in the follow-up CLs.

Change-Id: Ia055df1f8a5537b2bdd02c78991df9bbf48e951a
2020-02-26 14:25:00 -08:00
angiebird
d6f7334abc Keep ref frame coding indexes in SimpleEncode
Change-Id: Id76aeb54ef93b11ca9a582f76289da0e60368e56
2020-02-25 15:59:49 -08:00
Cheng Chen
8a96ad8f47 Make external arf consistent with vp9
Add a test to ensure that encoding with the external arfs gets the
same result as long as the arfs are the same as the vp9 baseline.

Change-Id: I92c79001018f4df3bc16e9fc56c733509bebb9dc
2020-02-24 19:06:57 -08:00
Cheng Chen
08b01d5e05 Allow external arf to determine gop size
When "rate_ctrl" experiment is on, we allow the external arf
passed from outside to determine group of picture size
in define_gf_group().

Change-Id: I0b8c3e1bf3087f21a4e484354168df4967d35bba
2020-02-24 14:49:14 -08:00
Cheng Chen
7e665ec968 Add interface for external arf indexes.
Pass in external arf indexes to encode command.

Change-Id: Ifea5a7d835643760fc5effc594bb448848f6d639
2020-02-24 14:29:51 -08:00
angiebird
0484849e8e Rename values in RefFrameType and FrameType
Replace golden and altref by past and future in RefFrameType.
So that we don't get confused with FrameType and RefFrameType.

Change-Id: I1be45d49f76c68869fc4bf53ff946fee9ce7eb9d
2020-02-21 10:06:26 -08:00
angiebird
bff7ecc517 Use ref_frame[0] to determine mv_count
The motion vector counts should be determined by whether this
block is using intra_mode or not.

Change-Id: If866c91fb8a3f2b3944e5b219a90154d2172690d
2020-02-20 17:14:31 -08:00
angiebird
320fb4c34a Add kGoldenFrame and kOverlayFrame to FrameType
Add coding_index to EncodeFrameInfo
Add start_coding_index to GroupOfPicture
Add frame_coding_index_ to SimpleEncode

The definition of coding index is as follows.

Each show or no show frame is assigned with a coding index based
on its coding order (starting from zero) in the coding process of
the entire video. The coding index for each frame is unique.

Change-Id: I43e18434a0dff0d1cd6f927a693d6860e4038337
2020-02-20 14:24:22 -08:00
angiebird
91f8be5045 Replace NULL by nullptr in simple_encode.c/h
Change-Id: Ib68740a02be852d03a3a2ad4d9d4a7d84d537590
2020-02-06 18:15:02 -08:00
angiebird
67377d3833 Rename inverse_vpx_rational to invert_vpx_rational
Change-Id: I9139ebc22be74e9726eee157821faf22d44bd30f
2020-02-06 18:10:25 -08:00
Cheng Chen
32b6fb96b6 Pass motion vector info to encode frame result
Pass the motion vector info stored to the encode frame result
through the interface "update_encode_frame_result()".

Change-Id: I589affa0c4c4d0fd4d639edff9068e44a715beff
2020-02-06 11:53:55 -08:00
angiebird
2c465567e6 Let SimpleEncode be able to output bitstream
Add outfile_path to SimpleEncode() with default value NULL.
The encoder will only output bitstream when outfile_path is set.

Change-Id: Ic68e5358ea454358c510bb0ae214f4201cb3db39
2020-02-05 16:12:32 -08:00
angiebird
8a5cb084e6 Add coded_frame to EncodeFrameResults
This coded_frame represents the raw coded image.

Change-Id: Iea439da2f9e84c4507b082d77ebaac49bfd74fff
2020-02-05 13:43:33 -08:00
Cheng Chen
22b23e4d98 Change partition_info to a vector
Change-Id: Ia59229da51671045448ea904ed65026155868993
2020-01-28 09:58:42 -08:00
Cheng Chen
c2b2234062 Pass partition info to encode frame result
Init the memory for partition information in "EncodeFrameResult".
And pass the partition information of vp9 encoder to it through
the interface: "update_encode_frame_result()".

Change-Id: Iea049e661da79f54d41da7924b9ef28ff7cfbfa3
2020-01-27 13:05:48 -08:00
Cheng Chen
eea06db178 Store frame partition info
Allocate partition information for the frame, and update it
when a superblock (64x64) is encoded.

The unit size of the smallest block is 4x4.

For each 4x4 block, store the current positition (row, column),
the start positition (row_start, column_start) of the partition,
and the block width and height of the partition.

Change-Id: I11c16bbca7e89a088715a1200abd23fe2f9ca1d6
2020-01-24 06:12:04 +00:00
Cheng Chen
087e4e0b07 Merge "Copy frame counts to the encode result." 2020-01-13 19:18:21 +00:00
James Zern
b809ac3c9e simple_encode*.cc: add missing copyright
Change-Id: I58ddf13698e3892aa591af4196ca03d7c09426c6
2020-01-10 16:47:48 -08:00