Commit graph

31 commits

Author SHA1 Message Date
Sushant
f308c61af0 avcenc: cleanup for thread pool memory handling
Test: avcenc -c enc.cfg
Change-Id: I5f5cf7f705d389f6938fc641daa558bedfbc573c
2025-05-23 14:59:56 +05:30
Sushant
c2714ee61c avcenc: Fixed thread handle parameter
Test: avcenc -c enc.cfg
Change-Id: I5f5cf7f705d389f6938fc641daa558bedfbc462b
2025-05-19 20:37:53 +05:30
Sushant
5e9c764903 avcenc: Replacing KEEP_THREADS_ACTIVE with runtime check
Test: avcenc -c enc.cfg
Change-Id: If6c8c29d2b5b1322796b8b25dc74231d13b61243
2025-04-22 17:09:57 +05:30
Sushant
f17635d2eb avcenc: moving mutex and cond variable init and destruction
Change-Id: I7123f43b5f3a85355b43370ae3df1930ebe5b570
2025-04-21 18:54:01 +05:30
Sushant
cdbee17b6e avcenc: add thread pool shutdown on last frame with KEEP_THREADS_ACTIVE
Test: avcenc -c enc.cfg
Change-Id: I85c9b535e2b81bf7f07a80bd7038d4f0429eecfe
2025-04-21 18:54:01 +05:30
Sushant
ee0c417a64 avcenc: add support for KEEP_THREADS_ACTIVE
Currently avc encoder creates desired number of threads at
the start of every frame and joins after frame is processed.
This change modifies the thread creation part. Now the threads
are created at the start of the sequence. Kept alive through
out the sequence and joined at the end of the sequence. This
helps in reduction of thread creation and deletion overhead.

This change does not effect the encoded bitstream. That is,
encoded output with this change is same as encoded output
without this change.

Bug: 288998933
Test: avcenc -c enc.cfg
Change-Id: I98784169052a5f05c109aaf1de97a5e46d7a773d
2025-03-20 07:11:55 -07:00
Srujan Vandrangi
0d29250b99 libavcenc: fix build issues on android
Test: Build
2023-12-19 20:45:31 -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
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
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
3fcf959359 libavcenc: relocate the update post enc routines
During bitstream overflow errors, it is possible that update post
enc gets skipped as last row might never have to be entropy coded
as we have already consumed the buffer. This can be fatal for
encoding further frames. Move this update to a location where it
is guaranteed to be updated

Bug: oss-fuzz-62378
Test: ./avc_enc_fuzzer

Change-Id: I279deb1f30c15c057c0b6e909834313a1df4fdac
2023-09-27 13:57:19 -07:00
Aayush Soni
bbf593f216 libavcenc: fix null buffer dereferencing
During encoding, if encoder encounters an error, the library returns the
same. If the application ignores it and feeds further input, library
while processing the new input is facing a null dereference.

1. Added a error check in encode API call before processing input
2. Made entropy bitstream buffer overflow errors non-fatal.

Bug: 187499509
Test: POC in bug descriptions
      atest VtsHalMediaC2V1_0TargetVideoEncTest
      atest -c CtsMediaV2TestCases:CodecEncoderTest
2023-06-01 22:39:26 -07:00
Harish Mahendrakar
ba34616a11 encoder: Initialize s_inp_buf and s_out_buf to zero in ih264e_encode
In some cases, s_inp_buf and s_out_buf on stack in ih264e_encode()
can be accessed unininitialized. This is fixed by initializing these
two structures.

Bug: oss-fuzz:57333
Bug: 274906999
Test: avc_enc_fuzzer
2023-04-04 21:48:18 +05:30
Mallikarjun Kamble
8e41a50de4 libavc: Added support for SII SEI message
- Add SII flag and SII parameters for the encoder and decoder.
- Encoder: Added support for SII SEI
- Decoder: Added support for SII SEI parsing and exporting
2023-02-14 22:00:13 -08:00
Ray Essick
a0660f6242 Merge "avcenc: Fix recon dump for last frame" 2022-08-24 16:04:57 +00:00
Harish Mahendrakar
ba6f646849 avcenc: Fix recon dump for last frame
Last recon frame wasn't being saved in some cases, it is now fixed.

Bug: 242104774
Test: avcenc -c enc.cfg

Change-Id: I50fcd6709988b7126a36cc88d8abdb75e871a37a
2022-08-17 22:41:33 +00:00
Manisha Jajoo
e559967790 Encoder: add support for PSNR export
This CL adds support to report PSNR between incoming and resulting
encoded frames. Eventually be reported upstream as part of a feedback
mechanism.

Test: avcenc -c enc.cfg
Bug: b/235899898

Change-Id: Id520913ca5964965b5a86bc520240ccd1b28176c
2022-08-17 17:22:00 +00:00
Neelkamal Semwal
954f023c74 encoder: fix invalid free of raw buffers
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
2021-04-30 14:49:41 -07:00
Harish Mahendrakar
cd1928dca1 Encoder: Fix in returning recon buffers with smaller IDR interval
For every IDR generated after the first one, one recon buffer was not
released from the buffer manager, when recon was enabled. This resulted
in encoder returning with an error after couple of IDRs when recon was
enabled.

This is fixed by calling recon buffer release based on pic_cnt instead
of frm_num. frm_num is reset to 0 for every IDR where as pic_cnt is not.

Bug: 173150684
Test: avcenc -i qcif.yuv -w 176 -h 144 -o out.h264 \
      --bframes 2 --idr_interval 4 --recon_enable 1 \
      --recon recon.yuv

Change-Id: I8b72e5aedc6a460292388e4e46f56c07486db4a6
2020-11-12 23:49:41 +00:00
Chamarthi Kishore
95a2113e4b libavc: Handling of Error propagation
This commit has changes to Error return propagation to
the caller functions.

Test: avcenc -c enc.cfg, avcdec -c dec.cfg
Bug: 142545567

Change-Id: I015ebe03e753a0edc1bf8bfc167180ead63193e1
2019-10-24 17:54:31 +05:30
Chamarthi Kishore
ad2eaf8c7d libavc: Add MDCV, CLL, CCV and AVE SEI messages
This commit add support for encoding and decoding of MDCV, CLL, CCV and
AVE SEI messages

Test: avcenc -c enc.cfg, avcdec -c dec.cfg
Bug: 141931623

Change-Id: Idc0b0db5291482ae2bc19cdff65669c32374b02a
2019-10-24 17:20:00 +05:30
Martin Storsjo
8e78e306bb 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.

Change-Id: I87e677acd00baf4f732ca7d35ee192e7f1f73994
2015-07-28 18:46:30 +00:00
Harinarayanan K K
f080d51500 Fixed encode of single frame
Encoding a single frame used to make encoder to go into infinite
loop. That is fixed now

Change-Id: I51752bdc5fd6071868884c2ff6074c14d05c8564
2015-07-28 18:37:38 +00:00
Martin Storsjo
9fbffcfb6e 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.)

Change-Id: I0a927deb2ef4125f79429d108439e249fa531607
2015-07-28 18:35:54 +00:00
Martin Storsjo
7c99adf718 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-24 21:08:11 +00:00
Harinarayanan K K
d2d469e520 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-24 21:05:34 +00:00
Harinarayanan K K
6cb6772805 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-24 21:04:04 +00:00
Harinarayanan K K
134291ea0b 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-24 20:36:11 +00:00
Martin Storsjo
afe8d03624 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-23 12:34:46 +03:00
Lajos Molnar
cd9e51fc2b fix file permissions
Change-Id: Ia4f99d5b963acd8d8a1afc2fbdf06b122d898f63
2015-05-05 17:34:51 +00:00
Hamsalekha S
8d3d303c79 Initial version
Change-Id: I7efe9a589cd24edf86e8d086b40c27cbbf8b4017
2015-04-02 15:59:02 +05:30