Return current input buffer as buffer to be freed in case
of errors that are seen before picking up the input buffer
to be from the input queue.
Once a buffer is picked up from the queue, that is returned
as the buffer to be freed.
There is no need to return a buffer from ps_proc context
Bug: 180643802
Test: poc in the bug description
Test: atest CtsMediaV2TestCases:CodecEncoderTest
Test: atest VtsHalMediaC2V1_0TargetVideoEncTest
Change-Id: I1671ca1e82f522004d1f070df89b256b856f75b8
The encoder doesn't return remaining frames if last subgop is
incomplete. This problem is solved by swapping last NULL P frame
(as subgop is incomplete last P frame will be NULL) with the
last valid (non- NULL) B frame. Complete subgop swapping is not done.
Also update MAX_NUM_BFRAMES to 8 and added a separate macro to
define maximum number of pictures in input queue
Bug: 132063959
Test: run cts -m CtsMediaTestCases \
-t android.media.cts.VideoEncoderTest
Change-Id: I9625c5f5f64ec60032c44dad54f735991921d6dd
Intrinsic _mm_set_epi8 require char input, converting everything to char.
Including log.h from android library instead of cutils.
Bug: 112316276
Test: before/after object comparison for no diff in generated code.
Change-Id: I82b8c48494619b64465eda2476c7c903652c6066
For static content, intra modes and skip mode compete with each
other neck and neck. From bitstream perspective its favourable to
pick skip. But do not over bias towards skip as intra modes
are already being penalized with mode bits * lambda.
Average bdrates improve by 1%
Test: Tested on clips of different resolutions for quality changes
Change-Id: I8ae85e7e807c9810e10b325627c84eec679327a9
Skip bias is encoder specific. It is better if it is defined in
encoder headers as opposed to me headers
Test: CL refactoring
Change-Id: I19afb9fcb4fb966c890ed41ab3fe0984e552f57f
For static content, skip and intra modes often compete with each other
neck and neck during mode evaluation. Upon fast skip detection, instead of
skipping all further mode analysis, disable motion search and allow intra
analysis.
This change applies to all presets except FASTEST.
Average bdrate improves by 1%.
Test: Tested on clips of different resolutions.
Change-Id: Ia0aabca5c1dcad03359bebaf071b7be27898e735
Encoder detects scene cut based on number of Intra MBs in the current
frame. For frames which contain plane areas which are different from
reference frames, encoder might encode these MBs as intra because of
lower SAD when compared with inter SAD.
Such cases were detected as scene cuts and RC model was being reset.
To fix this, scene cut is rejected if the current picture did not consume
all the bits that were allocated to it. In an actual scene cut where RC
needs to be reset, current frame consumes more than what is allocated to it.
Bug: 36814430
Change-Id: Ifa904fbaf28481f4762a23bb63e013fd37ec8942
Instead of using hard coded address offsets,
defined structures to access MB Header for each MB type
This improves readability of the code
Also helps in maintaining required alignment for MV
MV elements need to be aligned to 2 byte boundary
Unaligned accesses result in undefined behavior
Bug: 33073518
Test: Tested with -fsanitize=alignment enabled on avcenc
Change-Id: I51c009b7deded76315a4bf2880444d21ae7d517f
i1_ref_idx and u1_mv in cabac context are defined as char,
but were typecasted to int and were accessed, and were not
aligned to 4 byte boundary.
This results in an undefined behaviour
Bug: 33073518
Test: Tested with -fsanitize=alignment enabled on avcenc
Change-Id: Ie4a73de076a9239f2d8707af68b7d2cd796aa803
Previously, this used x5 (which is a stride parameter)
as destination pointer, and overwrote the destination in x6
with a counter, and looped to a label in another function.
In practice, this function is never used, which is why this
hasn't been noticed before.
Change-Id: Iab87a2960c36b7dc4de4216b1d4bbbe4e9f03578
For WORD32 parameters, the upper half of the parameter
registers is undefined (even though it is zero in most cases).
When easily doable, use the 'w' register names for such
parameters instead of doing the sign extension with a
separate instruction.
This fixes crashes in some configurations, when built with
clang, which can pass nonzero bits in the high half of registers
more aggressively than GCC.
Also fix the parameter/register mappings; use wN register
names where applicable, and fix incorrect parameter
placement. (Some functions still were documented to have
only 4 parameters in registers.)
Change-Id: Icedf6503b064149d1a651ff1c6a76de5c01722ea
Earlier if an MB was coded as intra in the previous frame,
corresponding MB in the current frame will not be coded as intra
even though it was supposed to be intra according to adaptive intra refresh.
Now the MB will honour adaptive intra refresh irrespective of its type
in previous frame.
Change-Id: Icc84ddf962dad6f7d1f4d11e9cb2a37bcda567b8
Earlier if an MB was coded as intra in the previous frame,
corresponding MB in the current frame will not be coded as intra
even though it was supposed to be intra according to adaptive intra refresh.
Now the MB will honour adaptive intra refresh irrespective of its type
in previous frame.
Change-Id: Icc84ddf962dad6f7d1f4d11e9cb2a37bcda567b8