Commit graph

3922 commits

Author SHA1 Message Date
Suyog Pawar
266cda3c3b libavc : Enable support for MacOS
Test: ./avcenc
      ./avcdec

Change-Id: If03196cf979d7f6638b99d5b13afba6df3364178
2024-10-04 06:51:30 -07:00
Suyog Pawar
045d0c9156 libavc : Fix mutex initialization index in apv_proc_start_mutex
- Changed hardcoded index [0] to loop variable [i] in ithread_mutex_init call
- Ensures correct initialization of both mutexes in the loop

Test: ./avcdec

Change-Id: I95ccd1eec5f18b5391befbcedf3546a119681b54
2024-10-04 06:50:55 -07:00
Suyog Pawar
42068b0f6c libavc: Fix poc counts for idr slice
Test: Build
Change-Id: Ic9212b86efbc54724c09164776169bfeafb15d7b
2024-08-07 05:53:55 -07:00
Mallikarjun Kamble
bc0de21907 Limit decode calls to a maximum of 100 to prevent potential timeouts with fuzzers 2024-07-22 09:58:04 -07:00
Mallikarjun Kamble
3899610fa8 svcdec: Handled timeout by returning status of the error
Bug = ossfuzz:67415
Test: svc_dec_fuzzer
2024-07-19 01:11:00 -07:00
Mallikarjun Kamble
b0117e32b9 svcdec: Ensure decoder display dimensions match subset sequence dimensions
- Fixes for heap buffer overflow

Bug = ossfuzz:68807, ossfuzz:69682
Test: svc_dec_fuzzer
2024-07-11 00:24:15 -07:00
Ashwin Natesan
72315c11ac mvcdec: Heap overflow in 'ih264d_read_coeff4x4_cabac'
In some erroneous fuzzer bistreams, the slice data requires more
parsing than what was implied by the distance between successive
start codes. The primary culprit is the NEXTBITS macro which requires
reading 4 additional bytes of the bitstream buffer. To alleviate
this, 4 bytes per 4x4 TU have been additionally allocated to the
bitstream buffer.

Bug = ossfuzz:66989
Test: mvc_dec_fuzzer
2024-05-07 11:48:55 -07:00
Haripriya Deshmukh
828cdb77ba libavc: Add dynamic color aspects support
Bug: 325468696
Test: atest android.mediav2.cts.DecoderDynamicColorAspectTest

Change-Id: Ib33d57a1f8109a149926841fed1a3d2ff454b668
2024-04-23 23:04:49 -07:00
Harish Mahendrakar
1c9bd7e20a Remove useless neon: clause.
There hasn't been a non-neon platform build in years.

Bug: 330929681
Test: Builds
Change-Id: I712c2111722a17ecf55ab36e8069275c74379256
2024-03-23 15:08:24 -07:00
Harish Mahendrakar
5ff80617fa Enable unit tests in postsubmit
After some time of running these in postsubmit, these will be changed
to presubmit.

- Added AvcEncTest to device-tests test suite
- Also run bpfmt on test/Android.bp

Bug: 304383609
Test: atest AvcEncTest
Change-Id: Ic18b25d8ed27313b6e3a984259af1215ae240c9e
2024-01-30 15:45:17 -08:00
Harish Mahendrakar
f0214b163b Use media file zip from dl.google.com
Bug: 308464572
Test: atest AvcEncTest

Change-Id: I20387647c54e665e5b632ac0e791e259ddb519ff
2024-01-29 13:58:44 -08:00
Ashwin Natesan
a20a5df162 mvcdec: Heap overflow in 'ih264d_parse_fgc'
Although the fag end of both the NALU and the bitstream buffer
 is being parsed, not all FGC SEI symbols would have been
decoded semantically. This commit detects and returns an error
in this situation.

Bug = ossfuzz:65418
Test: mvc_dec_fuzzer
2024-01-21 21:40:27 -08:00
Mallikarjun Kamble
28727baf58 svcdec: oss-fuzz bug fixes
ID#
65031
65035
65057
65059
65060
65132
65172
65482
2024-01-09 07:12:29 -08:00
Srujan Vandrangi
0d29250b99 libavcenc: fix build issues on android
Test: Build
2023-12-19 20:45:31 -08:00
Ashwin Natesan
63b8be0524 svcenc: Integer overflow in irc_ba_get_cur_frm_est_texture_bits
'isvce_svc_rc_params_validate' was not being invoked prior to
call to 'isvce_rc_init'. This resulted in an erroneous state
within RC's context wherein the instantaneous estimate for the
texture bits for the frame being processed exceeded INT_MAX.
'isvce_svc_rc_params_validate' has code that detects such a
state and is now being correctly invoked where apprpriate.

Bug = ossfuzz:63175
Test: svc_enc_fuzzer
2023-12-13 07:40:47 -08:00
Mallikarjun Kamble
3cc9ff94db Update intra resamp flags 2023-12-11 10:41:02 -08:00
Mallikarjun Kamble
a8a8a80c5f Added compliance fixes 2023-12-11 10:41:02 -08:00
Mallikarjun Kamble
df740b5ebc Added fixes for hang 2023-12-11 10:41:02 -08:00
Mallikarjun Kamble
e49a9150a3 Fixes for heap overflow 2023-12-11 10:41:02 -08:00
Mallikarjun Kamble
82f4e69094 svcdec: Fixes for NULL dereferencing in inter-layer functions
Resolution level initialization is tracked in inter layer prediction functions

Bug = ossfuzz:62290
Test: svc_dec_fuzzer
2023-11-24 07:19:34 -08:00
Ashwin Natesan
37beb97292 mvcdec: Fixed heap overflow during SEI parsing
There can be cases where there are multiple SEI payloads within a
single SEI NAL. In the particulkar case where the payload comprises
exclusiely of FGC data, the size of the NAL can exceed the size
of the 'dynamic bitstream buffer' which is used to pass the NALU
onto its appropriate parser.

This commit adds 'imvcd_bitstream_buf_realloc' which re-allocates
the 'dynamic bitstream buffer' such that any arbitrarily sized
NALU can be stored without a heap overflow.

Bug = ossfuzz:64286
Test: svc_enc_fuzzer
2023-11-21 06:02:14 -08:00
Ram Mohan M
0e72348961 libavcenc: validate dimensions after applying config params
Before applying the config params (dimensions), the api is validating
the input buffer dimensions. This causes encode fails wrongly. This is
corrected.
2023-11-20 22:40:30 -08:00
Vivek Jadhav
972c0aa711 libavcdec: Fix timeout issue in AVC Decoder
Make use of cur_pps to compute the max number of frames
in decode gaps in frame num

Bug: oss-fuzz-61655
Test: avc_dec_fuzzer
2023-11-14 21:03:25 -08:00
Ashwin Natesan
51268b3a71 svcenc: Redundant code removed
The following lines of code have been removed to improve coverage -
  [x] Functions -
      - isvc_interleaved_copy
      - isvc_16bit_interleaved_copy
      - isvc_16bit_interleaved_memset
      - isvc_iquant_itrans_recon_chroma_4x4_neon
      - isvc_iquant_itrans_recon_chroma_4x4_sse42
      - isvc_iquant_itrans_recon_4x4_dc_with_res_output_neon
      - isvc_iquant_itrans_recon_res_dc_4x4_sse42
      - isvc_iquant_itrans_recon_4x4_dc_with_res_accumulate_neon
      - isvc_iquant_itrans_recon_res_dc_with_res_acc_4x4_sse42
      - isvce_wait_for_thread
  [x] Function pointer initialisations for the functions above

Test: svc_enc_fuzzer
2023-10-27 06:14:32 -07:00
Ram Mohan
196f0dbaec libavcenc: use number_t while computing number of bits in period
For large intra frame intervals or for a choice of bit rate that causes
large bits per frame, it possible that while computing number of bits
available in the gop overflow the datatype bounds. For these
calculations use number_t as this offers wider space

Bug: oss-fuzz-63044
Test: avc_enc_fuzzer

Change-Id: Ifee9130f0021f77905aea67832abc044537088e5
2023-10-18 06:55:59 -07:00
Harish Mahendrakar
ed96638db0 Add dependency on googletest for AvcEncTest 2023-10-17 11:02:51 -07:00
Harish Mahendrakar
cc17cb758a AvcEncTest: Use MediaPreparer to download test files
Test: atest AvcEncTest
2023-10-17 10:28:03 -07:00
Ashwin Natesan
8121651110 mvcdec: Integer overflow in imvcd_parse_subset_sps
The cases where the value for log2MaxPocLsb was exceeding
'MAX_BITS_IN_POC_LSB' was not being handled correctly,
which was resulting in an integer overflow. This has been
fixed.

Test: mvc_dec_fuzzer
2023-10-13 07:13:14 -07:00
Ashwin Natesan
ea694873e0 svcenc: Enabled and verified 420sp inputs
Test: svc_enc_fuzzer
2023-10-10 07:07:21 -07:00
Ashwin Natesan
b5a861581e svcenc: RC parameters verified before RC init
RC uses int32_t to store bitrates and other
parameters internally. For specific magnitudes of
bitrate, framerate, and GOP period, this can
result in signed integer overflow. This is now
detected before calls to RC init.

Note that calls to the 'ISVCE_CMD_CTL_SET_BITRATE' API can also
result in this behaviour but it will be appropriately handled
by 'isvce_svc_frame_params_validate'.

Bug = ossfuzz:63053
Test: svc_enc_fuzzer
2023-10-09 06:50:02 -07:00
Ram Mohan M
0ab5c42d27 libavc: Remove duplicate code and improve readability
This commit does not introduce any new functionality w.r.t previous
commit. But it fixes few things. They are listed below
1. Guard Bands in header files are fixed
2. Header files contains function definition comments. These are same
as in source file. Maintaining same comment at two locations is
unnecessary. These are removed.
3. Maintain Indentation consistency across the code.
4. Remove unused code
2023-10-06 16:53:23 -07:00
Ram Mohan M
583887f906 libavc: correct return value of buf mgr avbl check util
The function returns status as success even in failed scenarios.
This is corrected.
2023-10-04 13:51:14 -07:00
Ram Mohan M
a7b6206fab libavcenc: Sync default values of library and application
I and IDR interval default values do not comply with requirements
of the codec. This is fixed. Also corrected few other default values.
2023-10-04 13:51:14 -07:00
Harish Mahendrakar
f9f0475b63 Revert "libavcenc: Correct default values in ih264e_defs.h"
This reverts commit 7f0c8a545b.

Reason: This changes behavior w.r.t. frame rates in terms of units.
2023-10-04 23:38:08 +05:30
Ram Mohan
072e69978a avcenc: clean up sample application
This commit does not introduce any new functionality. This is a
cosmetic change. It removes redundant comments, unused variables,
indents to a common guideline.
2023-10-03 14:24:25 -07:00
Ram Mohan M
7f0c8a545b libavcenc: Correct default values in ih264e_defs.h
I and IDR interval default values do not comply with requirements
of the codec. This is fixed. Also corrected few other default values.
2023-10-03 14:24:25 -07:00
Ram Mohan M
0c9dc5e7b2 libavcenc: use signed var for integer operations 2023-10-03 14:17:51 -07:00
Ram Mohan M
e4574d306f libavcenc: increment picture count only on valid inputs
If the encoder receives inputs that are empty or frames
that have to be skipped due to frame rate pull down,
do not increment picture count.

Bug: oss-fuzz-62827
Test: ./avc-enc-fuzzer
2023-10-03 14:17:51 -07:00
Ashwin Natesan
56a598ca6f svcenc: Fixes for incorrect handling of entropy coding errors
There were cases where errors in a process thread
executing the last MB row would result in the entropy
job list without a terminnating entry, which would
result in a call to ih264_list_dequeue blocking infinitely.
The enum 'ISVCE_ENTROPY_THREAD_STATES_T' is now used to
monitor the eecution state of the entropy thread and handle
the situation described appropriately.

Bug = ossfuzz:62786
Test: svc_enc_fuzzer
2023-10-02 07:09:21 -07:00
Ram Mohan M
2e128ba913 libavcenc: Modified conversion tables between Qstep & QP
avc-qp(QP) scale is logarithmic and Qstep scale is linear.
The translation between log to linear is carried during
rate control modelling.

Look up tables for these translations are modified as per
the literature
2023-10-01 01:37:17 +05:30
Ram Mohan M
31fc8edb9c libavcenc: Correct Lagrange parameter for I, P & B slices
The Lambda tables for intra and inter(P) slices are slightly
modified. Lambda tables for B slices is completely replaced
wih new set.

This change is done in accordance with JVT-O079.doc
2023-10-01 01:37:17 +05:30
Ram Mohan M
50fd862b8d libavcenc: Remove duplicate code and improve readability
This commit does not introduce any new functionality w.r.t previous
commit. But it fixes few things. They are listed below:
1. Guard Bands in header files are fixed
2. Header files contains function definition comments. These are same
as in source file. Maintaining same comment at two locations is
unnecessary. These are removed.
3. Improved consistency and code indentation
4. Removed comments that dont align with implementation
5. Grouped headers of a workspace together
2023-10-01 01:37:17 +05:30
Ram Mohan M
f0b559e4dc libavcenc: forward current frame intra cost to rc accurately 2023-10-01 01:37:17 +05:30
Ram Mohan
2074f2bfaf avcenc: Modify vui time scale based on target frame rate 2023-10-01 01:37:17 +05:30
Ram Mohan
c68f552fce libavcenc: signal header bits consumed count accurately to rc 2023-10-01 01:37:17 +05:30
Ram Mohan
7429c17294 libavcenc: reset mb qp delta ctxt during cabac encoding
When mb qp delta is not signalled due to cbp being zero,
mb qp delta ctxt is not being reset. This is causing bitstream
decode problems when mb qp is enabled
2023-09-29 01:34:57 +05:30
Ram Mohan
d9ef5790ef libavcenc: fix computations that are resulting in overflow
Intermediate precision for few computations are exceeding int max.
This is addressed
2023-09-29 01:34:57 +05:30
Ram Mohan
fef966515c avcenc: Fix Crash for 422 ILE inputs
The input buffers allocated for 422 formats is less by a chroma
plane. This causing memory over writes and results in crash while
freeing
2023-09-28 07:24:09 -07:00
Ram Mohan
f1f3a33bc4 libavcenc: fix the order of arguments passed to get_min_level 2023-09-28 07:24:09 -07:00
Ram Mohan
eb20999248 libavcenc: Cleanup air Mode and refresh period config options
Allow any refresh period if air mode is selected as none
2023-09-28 07:24:09 -07:00