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
pu2_intr_rfrsh_map was initialized with a wrong pointer which was
resulting in an out of bound write.
This was resulting in inconsistent output between runs when AIR was
enabled
Bug: 27076302
Change-Id: I1f36936837e3cb221ff218c3c6e7b8b20a0e26a7
This removes unnecessary changes from build to build.
Bug: 24204119
Change-Id: I25258314fe56ea186d38d756fb5fb04aa689a812
(cherry picked from commit f197ccb756)
If ENTROPY_TRACE is defined, the value parameter gets evaluated
twice. Since this parameter includes ++, the pointer gets incremented
twice.
This fixes encoding with trace enabled.
Bug: 22860270
Change-Id: I3d71ac33d007301e488d264a33c7b5c4d4ff2b56
Now no picture in a gop will depend on any picture in the previous gop
All calls to force an IDR are respected as soon as possible
Bug: 22860270
Change-Id: Id2bcd5687c3fb786336a01894c1b9228d67a87a6
Even if this 4x4 block isn't at the bottom or right border,
the other 4x4 intra blocks within the same macroblock may
use it for intra prediction.
This fixes intra coded macroblocks in b-frames.
Bug: 22860270
Change-Id: Ifdf48c1b2bbf232e785d6d5b8244aacba1ad3dd6
Previously, if this field wasn't set, the invalid coding mode
could lead to crashes later.
Bug: 22860270
Change-Id: If8dd2f8d5f2fbdd6bb76772344f959df23159167
BIPRED ME was discarding the halfpel motion vector components
in cost computation. That is fixed now.
Bug: 22860270
Change-Id: If6c77096d701a258920b14134ff120fd1540f254
The stored i4_mb_distortion that was used as i4_max_sad previously
might come from a different coding mode - even if
pf_ime_compute_sad_16x16 returns early when i4_mb_distortion is
larger than ps_mb_ctxt_bi->i4_mb_distortion, the calculated i4_mb_cost
can still end up smaller than ps_mb_ctxt_bi->i4_mb_cost.
Therefore, set i4_max_sad to INT_MAX to avoid the early exit in
pf_ime_compute_sad_16x16 here, since it can't be used reliably (and
returning early can end up choosing a suboptimal mode).
This makes sure that the encoded output is identical when the SIMD
optimized routines are disabled, when using B-frames.
Bug: 22860270
Change-Id: I9b8d524f88020e557541700133c7a0b48fe6a3b8
When encoding in header mode, the s_inp_buf struct that was written
to ps_video_encode_op->s_ive_op.s_inp_buf was completely uninitialized.
In ih264e_input_queue_update, make sure to initialize u4_is_last
when skipping frames.
Bug: 22860270
Change-Id: I87e677acd00baf4f732ca7d35ee192e7f1f73994
Since 6cb6772805, the actual level used is
MAX(u4_max_level, ih264e_get_min_level()), which means that it isn't
a fatal error to set u4_max_level to a too low level (if the caller
doesn't know or care). Despite this, the actual value set by the caller
was still used for initializing the RC.
This allows the caller to not have to set u4_max_level (currently
every caller has to duplicate a table or code snippet for determining
the right level for each resolution). The caller still can set it
to a higher value if he wants to explicitly use a higher level than
what is necessary.
This makes sure that the output is identical even if u4_max_level is
set too low.
Bug: 22860270
Change-Id: Icdc6c0652a97568d1eafc050226357a9d643d809