Commit graph

53 commits

Author SHA1 Message Date
Dan Willemsen
1c01bc10a9 Remove __DATE__/__TIME__ from Android builds
This removes unnecessary changes from build to build.

Bug: 24204119
Change-Id: I25258314fe56ea186d38d756fb5fb04aa689a812
(cherry picked from commit f197ccb756)
2015-10-30 21:54:53 +00:00
Hamsalekha S
126d84e0d3 Encoder added support for VUI params
SPS will now include vui params
Removed a trailing space in ih264e_api.c

Change-Id: I67a57741689206e571e9a83f7e3360149f87e06a
2015-10-09 11:35:29 -07:00
Ronghua Wu
374e7a8984 Merge "Encoder: Fixed an issue in handling FPS greater than 60" into mnc-dev 2015-08-03 18:07:01 +00:00
Harish Mahendrakar
bb1543bd85 Encoder: Fixed an issue in handling FPS greater than 60
FPS > 60 was resulting in an integer overflow, so using float now.

Bug: 22504214
Change-Id: I4626ba6a43167c00c42dd6440df37bd1eb1f151a
2015-08-03 09:45:14 -07:00
Martin Storsjo
bbc83b16b9 Don't use side effects in the macro PUT_BITS_SEV parameters
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
2015-07-31 18:51:33 +00:00
Harinarayanan K K
dbe9ac8936 Made gops closed
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
2015-07-31 18:51:20 +00:00
Martin Storsjo
860f75203e Always do recon of 4x4 intra blocks
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
2015-07-31 18:51:09 +00:00
Martin Storsjo
33134b2617 Validate the u4_entropy_coding_mode field
Previously, if this field wasn't set, the invalid coding mode
could lead to crashes later.

Bug: 22860270

Change-Id: If8dd2f8d5f2fbdd6bb76772344f959df23159167
2015-07-31 18:51:00 +00:00
Harinarayanan K K
8ce82804ab Fixed issue in cost computation for BIPRED ME
BIPRED ME was discarding the halfpel motion vector components
in cost computation. That is fixed now.

Bug: 22860270

Change-Id: If6c77096d701a258920b14134ff120fd1540f254
2015-07-31 18:50:48 +00:00
Doney Alex
0574be65f4 Cabac optimizations
Optimized cabac functions for writing bypass bins.
Removed unused return from cabac flush function.
Removed the macro REV_NBITS.

Bug: 22860270

Change-Id: Iece82797f2f45a35281817a2b77a7c7fe4e02bd1
2015-07-31 18:50:37 +00:00
Martin Storsjo
eddf6a33fe Use INT_MAX as i4_max_sad in ih264e_evaluate_bipred
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
2015-07-31 18:50:26 +00:00
Martin Storsjo
6fb90f8fec Make sure that apv_bufs[0] and u4_is_last always are set
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
2015-07-31 18:50:12 +00:00
Martin Storsjo
a6bcaf3690 Check the width/height and adjust level used for RC
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
2015-07-31 18:49:17 +00:00
Harinarayanan K K
01168dc07e Fixed encode of trailing B frames
In case a P frame was marked as the last frame to encode, the B frames
previous to it in the same gop were not getting encoded. This is fixed now.

Bug: 22860270

Change-Id: I871f2a1d52b8db9ee75426b00287b58203586f23
2015-07-31 18:48:48 +00:00
Martin Storsjo
b0aadd0c45 Remove the now unused stride field from the set dimensions struct
Since 90a3904fd3 and d020be5ac7, this field doesn't have any actual
effect - the strides are taken from the input pictures.

Bug: 22860270

Change-Id: I9b08cbf8ee558e038d0017a6176d7b3bd3c428bd
2015-07-31 18:48:14 +00:00
Harinarayanan K K
0cf554f73b Fixed encode of single frame
Encoding a single frame used to make encoder to go into infinite
loop. That is fixed now

Bug: 22860270

Change-Id: I51752bdc5fd6071868884c2ff6074c14d05c8564
2015-07-31 18:47:56 +00:00
Martin Storsjo
4b09a8c011 Don't declare variables after statements
This fixes building with compilers that are strict about the pre-C99
rule about having all variable declarations before statements.

(The previous version of this commit was originally made before
the commit adding support for main profile, which added a bunch
more similar issues.)

Bug: 22860270

Change-Id: I0a927deb2ef4125f79429d108439e249fa531607
2015-07-31 18:47:37 +00:00
Martin Storsjo
61791a91be Remove double semicolons (empty statements)
Some compilers can't handle this, and these occurrances are typos.

Bug: 22860270

Change-Id: I82349f103cef1f196d1a85dae307aff83c7d6090
2015-07-31 02:11:31 +00:00
Marco Nelissen
f73e92aff1 Fix MIPS build
Change-Id: I8190ce01d313f987f142a0c7ef5ae31f01562510
2015-06-25 10:43:24 -07:00
Martin Storsjo
086dd8ea90 Don't declare variables after statements
This fixes building with compilers that are strict about the pre-C99
rule about having all variable declarations before statements.

Change-Id: I06dd0cc42a6dbe90025c3c913a0c8d9ffb0acbcb
2015-06-25 08:25:58 -07:00
Martin Storsjo
4adb9f4923 Reorder code to avoid reading uninitialized data
If the current slice isn't BSLICE, u1_weighted_bipred_idc is
uninitialized, which valgrind can complain about (mostly in uninitialized
builds). By reordering the conditions, we avoid doing conditional
jumps based on uninitialized data.

Change-Id: I4d601fd1a4e34d85fe5992ecb934ac3747953960
2015-06-25 08:25:57 -07:00
Martin Storsjo
5ae9fc7e9d Force regenerating the header via i4_gen_header instead of i4_header_mode
If i4_header_mode is set (without the caller explicitly requesting it),
the next frame to be encoded will be missed altogether (when only
a header is output).

Instead force a header to be generated prepended to the next frame.
If the caller explicitly requests header mode, it will be output
in a separate call.

Change-Id: If475717edf980bccb2076f880c60c9dd7dede904
2015-06-25 08:25:57 -07:00
Martin Storsjo
c22addc6ee Don't use static structs for rc init
Most of them was benign and didn't risk any data race; they
were used for write-only memory during init.

The array as_itt_memtab in ih264e_get_rate_control_mem_tab
could however cause a real data race, if multiple threads
try to initialize an encoder at the same time, since it
used as temporary storage when mapping between different
structs.

Change-Id: I3ca29f0e3be2fad154becc3ee29867e591975a74
2015-06-25 08:25:57 -07:00
Martin Storsjo
88966cf07d Initialize i4_non_ref_frames_in_stream before encoding SPS/PPS
When header mode is enabled, the SPS is populated before this
field was initialized in ih264e_pic_init.

Change-Id: I7e38828e12bee15bd3a53562b4e4d0d65354326a
2015-06-25 08:25:56 -07:00
Martin Storsjo
b5a707eee3 Allow setting profile IV_PROFILE_MAIN
Now once that the encoder supports the main profile, allow it to
be set in the IVE_CMD_CTL_SET_PROFILE_PARAMS request.

The actual profile value set here is ignored in practice, but
at least allow setting it to main.
2015-06-25 08:25:55 -07:00
Harinarayanan K K
205e6fe110 Added check for minimum output buffer size.
Changed macro specifying the minimum size required for output buffer.

Added an error check on the size allocated for output buffer.

Change-Id: I98e4f46e62ffc974df760f2633689de079ca3e5e
2015-06-25 08:25:55 -07:00
Harinarayanan K K
7dbacdf765 Added code to handle cases with qp less than 10
When qp goes less than 10, all I16x16 mode evaluations
are disabled and I4x4 evaluations are enabled irrespective
of preset. This will ensure that the residual will not
exceed the supported range of entropy

Minimum Qp cannot be set less than 4 now. When QP goes lesser,
the residual may exceed the supported range even with I4x4 enabled.

Change-Id: I25b404fcd9c9e9dbdd77679280968635ee047eb3
2015-06-25 08:25:54 -07:00
Harinarayanan K K
d3e18f0c88 Reduced memory requirements.
Buffer allocation is based on minimum level required for the
input resolution rather than the input max level.

Number of maximum context sets can be set to 1 to reduce
memory usage.

Added a macro ENC_MIN_PU_SIZE for minimum size of
inter prediction unit supported by encoder.

Changed the maximum constraint on number of MBs for NMB
processing to width in Mbs.

Change-Id: I5a9255e93935d90c13262681aafc772aedf8ae81
2015-06-25 08:25:54 -07:00
Harinarayanan K K
a4e933db7a Fixed QP lockups
Fixed QP getting locked up at particluar values even when
it is supposed to be changing by ensuring that Qp will have
a swing of atleast +-2 from previous value and correcting
the Qp translation tables

Change-Id: Id6f0fa4f282c288b81cfe278f34957a0fa68ff8c
2015-06-25 08:25:53 -07:00
Harinarayanan K K
4e2c308d17 Fixed issues with forcing I and IDR frames.
Setting I frame interval to 1 caused encoder to go into
infinite loop. Fixed that by stopping RC update.

Forcing of I and IDR frame did not cause the frames at expected time
due to delayed encoding. This is fixed now.

Change-Id: Ibf549fb335c053ee33de768455b20e46be3e7c1c
2015-06-25 08:25:53 -07:00
Martin Storsjo
85a43d2fcf Fix string handling for generating version strings
Don't do concatenation with strncat; the length parameter in strncat
is only for how many chars to append at most, not for the full output
buffer size. To safely use strncat, one would have to do
strncat(buf, str, sizeof(buf) - strlen(buf)).

By using snprintf, we guarantee that the buffer is null terminated, and
we don't need to use strnlen at all.

(If compatibility with older MSVC versions that lack snprintf, one
can use _snprintf instead and manually add the null termination.)

Change-Id: I1c2322c7a406ddd5e6551a96c460da60deeffda1
2015-06-25 08:25:52 -07:00
Martin Storsjo
94000e8a28 Remove a duplicate header
ithread.h is already in the common directory.

Change-Id: I300fd9c07075e16793e7b645e483663d081ca0cc
2015-06-25 08:25:52 -07:00
Martin Storsjo
ce7f41973c Remove the codec level stride field
This field isn't used at the moment at all. The public field
ive_ctl_set_dimensions_ip_t.u4_strd is kept to avoid breaking
other calling code, although it doesn't have any actual function
any longer.

Change-Id: Icfc88846fa63f209c67b8e1f8e0cc21bc4ddb73a
2015-06-25 08:25:50 -07:00
Martin Storsjo
4f5ceca078 Always copy data to a local buffer if padding is needed
If horizontal padding is needed, copy the data to avoid having to try
to write into the input buffer.

If vertical padding is needed, we could get away with only copying
the last MB row (as previously was done), but then one extra row of
pixels are needed for intra pred. Thus always copy all of the picture,
for simplicity, if padding is needed.

Change-Id: I6b456a12956120d64e7c6b86d7b571e159f4566b
2015-06-25 08:25:50 -07:00
Martin Storsjo
cb6a43532c Set the luma/chroma strides depending on source buffer
If the data is read directly from the input buffer, set the stride
values to those of the input buffer. If the data is copied, set the
stride to the value of the local buffer instead.

This fixes handling of cases where the input buffer stride is
(significantly) larger than the maxwidth of the video.

This also effectively makes the parameter
ive_ctl_set_dimensions_ip_t.u4_strd useless - nothing needs to
know the stride until you actually encode a frame, and at that point,
we can either use the stride of the input buffer, or of the local
pu1_y_csc_buf_base where the copied content is stored.

Change-Id: Icde400b4a0867d25855e621e143454e608748aa3
2015-06-25 08:25:49 -07:00
Martin Storsjo
9113f5615c Use a separate field for the chroma stride
When both luma and chroma are copied to the local buffer (either
due to yuv format conversion, or due to padding), they have got
the same stride, but if chroma is copied while luma is used directly
from the input buffer, they might have different strides.

Therefore add a separate field for chroma stride.

This commit only adds the field, while it still has got the same
value as before.

Change-Id: I0dce97ad4d91cd1d9aba4b4472c6a0de45a314bc
2015-06-25 08:25:49 -07:00
Martin Storsjo
bc8456b296 armv8: Don't touch the x18 register
The x18 register is platform specific, and using it in portable assembler
code should be avoided.

In this particular case, using it is not actually needed at all.

Change-Id: I07016fdd3a264ed77eba37abcd1748b51cf7a49e
2015-06-25 08:25:49 -07:00
Martin Storsjo
f640384449 arm: Properly match /* */ comments in the arm assembly
Some versions of the clang built-in assembler interprets /* as a start
of a multi-line comment, even within lines starting with a @. Therefore,
make sure to terminate these properly.

This fixes warnings about /* within a block comment when building
using the clang built-in assembler (in some versions of clang), and
fixes issues where part of the assembly source was effectively
commented out, when building with this assembler.

Change-Id: I4b520334d92740f8c60def94ee990561b2cb8b7c
2015-06-25 08:25:48 -07:00
Martin Storsjo
3e4b6559bc armv8: Don't accidentally write 8 bytes instead of 4
This fixes running when built with clang - by pure luck the out of bounds
writes didn't cause any harm when the calling C code was built with gcc.

Change-Id: I4e33dd403b785cbcd24fb80f4db7a86310a32225
2015-06-25 08:25:47 -07:00
Martin Storsjo
9f81a0a202 armv8: Remove redundant NEON element size declarations
When specifying one specific lane of the vector, the number of
lanes don't need to be specified.

The clang built-in assembler doesn't allow the redundant
declarations, while binutils gas work fine with both forms.

Change-Id: I86077ce0774d4594a1295b6860e4944df87dde2f
2015-06-25 08:25:46 -07:00
Martin Storsjo
436fccb164 Handle non-mod-16 widths in the NEON version of 422i->420sp conversion
This uses the same mechanism as in ih264e_fmt_conv_420p_to_420sp_a9q
to do an overlapping copy of the last few pixels.

Change-Id: Ic93a00d0683337fd0f6f540119000466685f64bd
2015-06-25 08:25:45 -07:00
Harinarayanan K K
3749f6f435 Added support for Main Profile toolsets in encoder.
Added support for CABAC entropy coding.
Added support for B slices.
Fixed an issue in rate control constant QP mode.

Change-Id: Ib759d35e8e943f941aa9b8bbff0362d92c619994
2015-06-25 08:25:43 -07:00
Harish Mahendrakar
cf91c87b25 Fixed an overread in YUV420 Semi-planar input usecase
Handled non-multiple of 16 dimensions for 420 semiplanar input
Modified test code to remove alignment of width and height

Bug: 21586373
Change-Id: I83ff8165364a863d577fcac81e711b07eec9c004
2015-06-12 18:34:16 -07:00
Martin Storsjo
c75cf37283 Support levels 5.0 and 5.1 in the encoder properly
The function ih264e_get_lvl_idx lacked handling of them
before, which meant that it returned index 0 (corresponding
to level 1.0) if level 5.0 or 5.1 were selected.

Change-Id: I482213e68e11fd091c72ec57a593392aa1a0a4ae
2015-06-03 08:47:38 -07:00
Martin Storsjo
90c798b14b Remove leftover printfs in x86 encoder initialization
A library shouldn't printf things to the common stdout, at least
not in normal builds.

Change-Id: Ifd875369c2347549f141fe0f9754e51814c0de96
2015-06-03 08:42:39 -07:00
Martin Storsjo
1ff75b8cc0 Only initialize u4_deblk_prev_row if it will be used
This avoids reads out of bounds when encoding videos with a height
of one single macroblock.

Change-Id: Iec982cebb0995c8ecf160751eaa72df38604e8b0
2015-06-03 08:39:31 -07:00
Martin Storsjo
ac97f28bb6 Fix an overread in the slice map
After incrementing the macroblock position in ih264e_update_proc_ctxt,
the slice index of the next macroblock is read. The value that is read
isn't actually used, but make sure that the array is large enough to
avoid overreads.

Change-Id: I44ddb49773244c7d1e404199fc57a9e30a8959e0
2015-06-03 08:37:00 -07:00
Martin Storsjo
df06a38c5b Include space for chroma in the padding allocated in ih264e_get_total_pic_buf_size
Chroma is already accounted for in e.g. num_samples by multiplying
the number of luma samples by 3/2, so include it in the padding
calculation as well.

This fixes encoding 176x144 at level 1.0 - normally this isn't an issue
since the padding is a bit overestimated, but for this particular
resolution/level combination, it fails unless this is calculated properly.

Change-Id: Id5df6e5aee4d3d78f4c28a3b7d5fed6fe42a1f2c
2015-06-03 08:35:02 -07:00
Harish Mahendrakar
7497191460 Resolved warnings and fixed alignment of few assemblies
Resolved warnings seen in x86 modules
Fixed alignment of few modules
Updated comments in few arm modules for consistency
Fixed warnings seen in clang build

Change-Id: I0623169b5e84a6a6f09c3d2212e754101272f5e9
2015-05-05 17:51:53 +00:00
Lajos Molnar
a2b49e5f05 fix file permissions
Change-Id: Ia4f99d5b963acd8d8a1afc2fbdf06b122d898f63
2015-05-05 17:51:34 +00:00