Commit graph

68 commits

Author SHA1 Message Date
Narayan Kalaburgi
0aa9a2566f libhevcdec: Fix HBD transquant bypass decoding mismatch
When transquant bypass is enabled in HBD streams, decoded frames
mismatched the reference output due to two issues:

1. Intra boundary filtering:
   In the 8-bit path, boundary filtering for horizontal (mode 10) and
   vertical (mode 26) intra predictions is disabled when transquant bypass
   is active with implicit RDPCM. However, the HBD reconstruction path was
   passing raw u1_luma_pred_mode instead of disable_boundary_filter, and the
   HBD filter functions ignored the mode parameter.

2. SAO Scratch Buffer Overflow:
   During shifted CTB SAO processing, transquant bypass blocks are temporarily
   backed up into pu1_tmp_buf_luma and restored afterwards to keep them lossless.
   In HBD, each sample requires 2 bytes (UWORD16), but the static scratch buffer
   was allocated for 8-bit samples (sizeof(UWORD8)).
   Because the shifted CTB processing window spans beyond standard CTB boundaries
   to handle delayed neighbor boundaries, the 16-bit luma backup exceeded the
   allocated buffer capacity and overflowed into pu1_tmp_buf_chroma. Consequently,
   chroma backup overwrote the luma backup data, resulting in corrupted samples
   upon restoration.

This commit resolves the above issues with the following changes:
- common/ihevc_hbd_intra_pred_filters.c: Check 'disable_boundary_filter' to bypass
  boundary filtering in ihevc_hbd_intra_pred_luma_horz and ihevc_hbd_intra_pred_luma_ver.
- decoder/ihevcd_iquant_itrans_recon_ctb.c: Pass disable_boundary_filter
  to apf_hbd_intra_pred_luma for modes 10 and 26.
- decoder/ihevcd_api.c: Scale SAO temporary scratch buffer allocation
  (pu1_tmp_buf_luma and pu1_tmp_buf_chroma) by sizeof(UWORD16) to prevent
  buffer collision in HBD mode.
2026-09-04 09:35:33 -07:00
Narayan Kalaburgi
df28e1e8ab libhevcdec: Implement 10-bit decoding support for Cross Component Prediction
Some checks failed
CMake / build (cmake, aarch64-linux-gnu-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake, aarch64-linux-gnu-g++, ubuntu-latest-cross-aarch64-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, arm-linux-gnueabihf-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake, arm-linux-gnueabihf-g++, ubuntu-latest-cross-aarch32-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-24.04-arm-clang-cmake, ubuntu-24.04-arm) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Has been cancelled
This commit implements HBD inverse transform residual functions, which is a
prerequisite to enable 10-bit decoding with Cross Component Prediction (CCP).

When CCP is enabled, the inverse transform and prediction addition cannot be
performed in a single pass (`itrans_recon`). Instead, the decoder must first
compute the unclipped transform residuals (`itrans_res`), scale them for CCP,
and then add the prediction. For 10-bit bitstreams, the decoder was missing
HBD implementations for `itrans_res` and improperly falling back to 8-bit
implementations. This resulted in the use of an incorrect second-stage inverse
transform shift (hardcoded to 12 instead of `20 - bit_depth`), significantly
corrupting the residuals.

Key Changes:
1. Created `common/ihevc_hbd_itrans_res.c` providing mathematically compliant
   HBD implementations of `itrans_res` for all Transform Unit sizes (4x4, 8x8,
   16x16, 32x32, and DC) using intermediate `CLIP_S16` logic and dynamic
   bit-depth shifting (`20 - bit_depth`).

2. Implemented `ihevc_hbd_chroma_recon_nxn_ccp` to properly scale 10-bit residuals
   with the cross-component alpha and add the prediction.

3. Modified `ihevcd_iquant_itrans_resi_recon_tu_plane` to dynamically branch to
   `ps_codec->apf_hbd_itrans_res` and `ihevc_hbd_chroma_recon_nxn_ccp` when
   `pixel_size > 1`. This cleanly handles 10-bit CCP while keeping 8-bit paths
   untouched.
2026-08-24 05:35:06 +00:00
Vivek R Jadhav
21c7ab373d libhevcdec: Update dynamic size allocation for HBD
Test: ./hevcdec
2026-08-24 05:33:38 +00:00
Narayan Kalaburgi
268af95978 libhevcdec: Add dynamic bitstream buffer reallocation for edge cases
Some checks failed
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, aarch64-linux-gnu-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake, aarch64-linux-gnu-g++, ubuntu-latest-cross-aarch64-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, arm-linux-gnueabihf-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake, arm-linux-gnueabihf-g++, ubuntu-latest-cross-aarch32-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-24.04-arm-clang-cmake, ubuntu-24.04-arm) (push) Has been cancelled
This commit introduces on-the-fly dynamic reallocation to safely decode
extreme edge-case bitstreams (e.g., random noise causing CABAC inflation)
that exceed standard MaxCPB size constraints.

It adds a dedicated `ihevcd_reallocate_dynamic_bitstream_buf` setup
function in `ihevcd_api.c`. If an incoming bitstream exceeds the currently
allocated internal buffer during parsing (`ihevcd_decode.c`), the decoder
will cleanly reallocate the buffer. This prevents truncation failures and
memory corruption for highly incompressible streams.
2026-08-17 18:50:13 +00:00
Narayan Kalaburgi
5782c001a3 libhevc: Implement HBD 444 chroma inv txfm & Recon
This commit adds the core math and CTB integration required for
inverse transform and reconstruction of 10-bit 4:4:4 chroma blocks.

Changes include:
- Added `ihevc_hbd_chroma_itrans_recon_32x32.c` to support the
  maximum 32x32 chroma block size required by the 444 profile.
- Added 10-bit chroma recon functions in `ihevc_hbd_chroma_recon.c`.
- Updated CTB decoding in `ihevcd_iquant_itrans_recon_ctb.c` to
  dynamically calculate 10-bit QP indices for 444 chroma blocks while
  preserving the original 420 fallback behavior.
- Updated headers with new HBD function declarations.
2026-08-14 21:34:32 +00:00
Vivek R Jadhav
51c80727c3 libhevcdec: Add initial support for YUV422 10 bit
Test: ./hevcdec
2026-08-13 01:17:59 +00:00
Rakesh Kumar
35eb80040b Remove dead dependency on decoder e_profile in hbd branch
Some checks are pending
CMake / build (cmake, aarch64-linux-gnu-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake, aarch64-linux-gnu-g++, ubuntu-latest-cross-aarch64-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, arm-linux-gnueabihf-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake, arm-linux-gnueabihf-g++, ubuntu-latest-cross-aarch32-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Waiting to run
CMake / build (cmake, clang, , clang++, ubuntu-24.04-arm-clang-cmake, ubuntu-24.04-arm) (push) Waiting to run
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Waiting to run
Remove vestigial HEVC_DEC_PROFILE_T enum and e_profile member from codec_t, along with its hardcoded initialization in ihevcd_init and assignment block in ihevcd_parse_sps. All dynamic bit depth, pixel size, and function selection logic in HBD relies directly on bitstream syntax elements.

TAG=agy
CONV=af8f01f3-0862-4fb5-a5ce-b37c3025b633
2026-08-11 19:49:05 +00:00
Harish Mahendrakar
18947ba8fd decoder: Clean up HBD function pointers and rename to match convention
- Rename pf_hbd_ prefixed function pointers in func_selector_t to use _fptr suffix consistently.
- Update usages of renamed function pointers.
- Clean up HBD function pointer tables (remove ihevcd_hbd_func_tables.c/h).
- Implement HBD function pointer arrays in codec_t.

TAG=agy
CONV=51cc5812-336f-4b5f-990d-34fbf4d5ef08
2026-08-09 23:47:45 +00:00
Harish Mahendrakar
01e8270cc1 Move HEVC_DEC_PROFILE_T to ihevcd_structs.h 2026-08-09 23:47:45 +00:00
Harish Mahendrakar
0476888b1f decoder: Remove unused pv_parse_residual_coding
Remove the unused function pointer pv_parse_residual_coding from
codec_t and its initialization in ihevcd_init. The function
ihevcd_parse_residual_coding is already called directly.

TAG=agy
CONV=9b39e0bf-8a07-4122-9bb2-81ec77fbdc09
2026-08-09 23:47:45 +00:00
Harish Mahendrakar
442d944cb5 decoder: Refactor pv_iquant_itrans_recon_ctb to direct call
Remove the function pointer pv_iquant_itrans_recon_ctb from codec_t
and call ihevcd_iquant_itrans_recon_ctb directly. This removes
unnecessary indirection since there is only one implementation.

TAG=agy
CONV=9b39e0bf-8a07-4122-9bb2-81ec77fbdc09
2026-08-09 23:47:45 +00:00
Harish Mahendrakar
0cc032d9ff Clean up HBD support before split
Some checks failed
CMake / build (cmake, aarch64-linux-gnu-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake, aarch64-linux-gnu-g++, ubuntu-latest-cross-aarch64-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, arm-linux-gnueabihf-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake, arm-linux-gnueabihf-g++, ubuntu-latest-cross-aarch32-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-24.04-arm-clang-cmake, ubuntu-24.04-arm) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Has been cancelled
2026-08-07 17:25:44 +00:00
Rakesh Kumar
eacaf4768e libhevcdec: Add support for extended profile parsing from SPS headers
- Update ihevcd_parse_sps to parse profile dynamically from clip SPS (profile_idc, chroma format, bit depth, intra and still constraint flags).
- Add support for Main, Main 10, Main 10 Still, Main 422 10, Main 444, Main 444 10, Main Intra, Main 10 Intra, Main 422 10 Intra, Main 444 Intra, Main 444 10 Intra, and Main 444 Still Picture profiles.
- Allow profile_idc == 4 (RExt) in SPS profile validation checks.
- Update pixel size determination in ihevcd_api.c for 8-bit vs 10-bit profiles.
- Add CLI argument parsing for new profiles in main.c.
2026-08-07 03:21:32 +00:00
Harish Mahendrakar
18fc8f6b52 Added support for 420 10-bit decoding.
This is the initial version and doesn't enable SIMD functions yet.
Has not been tested extensively yet.
This is not ready to be merged into main branch yet.
2026-08-07 03:21:32 +00:00
Harish Mahendrakar
b8c9100658 Remove incorrect prefix from ihevcd_itrans_res_dc
Some checks are pending
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Waiting to run
CMake / build (cmake, clang, , clang++, ubuntu-24.04-arm-clang-cmake, ubuntu-24.04-arm) (push) Waiting to run
CMake / build (cmake, aarch64-linux-gnu-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake, aarch64-linux-gnu-g++, ubuntu-latest-cross-aarch64-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, arm-linux-gnueabihf-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake, arm-linux-gnueabihf-g++, ubuntu-latest-cross-aarch32-cmake, ubuntu-latest) (push) Waiting to run
ihevcd_itrans_res_dc is defined in common folder but has a wrong prefix of ihevcd_.
This is now fixed to ihevc_.
2026-07-29 17:08:35 -07:00
Harish Mahendrakar
8dffbdd2d0 Move IVD_ARCH_T and IVD_SOC_T to iv.h and rename as IV_ARCH_T and IV_SOC_T
This helps in decoupling unit tests in common from depending on ivd.h
2026-07-29 15:37:52 -07:00
Harish Mahendrakar
085f030e9e Invoke ihevcd_free_dynamic_bufs() in ihevcd_allocate_dynamic_bufs()
Some checks failed
CMake / build (cmake, aarch64-linux-gnu-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake, aarch64-linux-gnu-g++, ubuntu-latest-cross-aarch64-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, arm-linux-gnueabihf-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake, arm-linux-gnueabihf-g++, ubuntu-latest-cross-aarch32-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-24.04-arm-clang-cmake, ubuntu-24.04-arm) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Has been cancelled
This will ensure that any memory that is allocated before and not yet freed, will be freed.
This is done as a precaution to ensure there are no leaks.
2026-07-13 00:08:29 -07:00
Vivek R Jadhav
091042fa3e libhevcdec: Update static allocation for SAO context
Corrected the static SAO buffer size calculation to match the
partitioned buffer bounds. Luma requires 4x and Chroma requires 8x
MAX_CTB_SIZE * MAX_CTB_SIZE, which is now correctly summed to allocate
12x MAX_CTB_SIZE * MAX_CTB_SIZE bytes per process thread.

Bug: 484436016
Test: ./hevc_dec_fuzzer

Change-Id: I40411c04ab00d7e23843eb1d033d4943e3ec76a9
2026-06-11 21:46:30 -07:00
Ram Mohan M
57d79be23a updates to odd dimensions support - 2
- reduce unused memory allocations
- revert unrequired alignments done to widths and height in format
  conversion leaf functions
- pass correct strides and base address to leaf functions

fixes oss-fuzz-520748344

Change-Id: I8b783d1dae8c53b68a6d3a32dbc3ffb16376851e
2026-06-07 16:06:11 -07:00
Harish Mahendrakar
1fac8cc5fe Updates to odd dimension support.
Reverted some of the unnecessary changes from commit: f6ef16b0f9

- Restored the format conversion structure prior to f6ef16b0f9
- No need to handle odd stride for 420 and 422 output.
- Dimensions for output format 444 and 400 format can be odd

Tested with few YUV444 and YUV400 odd dimension clips

To generate:
$ ffmpeg -f lavfi -i testsrc=s=511x511 -c:v libx265 -pix_fmt yuv444p -t 1 -tag:v hvc1 y444_511x511.hevc
$ ffmpeg -f lavfi -i testsrc=s=511x511 -c:v libx265 -pix_fmt gray -t 1 -tag:v hvc1 y400_511x511.hevc

To decode using hevcdec for YUV420 output format
$ hevcdec -i y444_511x511.hevc -o y444_511x511.yuv --save_output 1 --num_frames -1 --chroma_format YUV_420P --enable_yuv_format 31
$ hevcdec -i y400_511x511.hevc -o y400_511x511.yuv --save_output 1 --num_frames -1 --chroma_format YUV_420P --enable_yuv_format 31

To decode using hevcdec for YUV444 output format
$ hevcdec -i y444_511x511.hevc -o y444_511x511.yuv --save_output 1 --num_frames -1 --chroma_format YUV_444P --enable_yuv_format 31

To decode using hevcdec for YUV400 output format
$ hevcdec -i y400_511x511.hevc -o y400_511x511.yuv --save_output 1 --num_frames -1 --chroma_format GRAY --enable_yuv_format 31

Display resulting output using ffplay by passing `-f rawvideo -pixel_format yuv420p -video_size 511x511`
Change pixel_format to yuv420p/yuv444p/gray based on decoder chroma_format argument
2026-06-05 11:42:40 -07:00
Vivek R Jadhav
f6ef16b0f9 libhevcdec: Add support for odd dimensions
Decoding streams with odd resolutions previously caused integer truncation
during right-shift or division operations, leading to incorrect buffer size
and stride calculations.
This is fixed by applying the ALIGN2 macro to width and height across buffer
metrics, dimension queries, and outargs to safely pad boundaries.

Test: ./hevcdec

Change-Id: I5c432aa63b0975b76baa5e59a816278087b65215
2026-06-05 10:53:38 -07:00
Vivek R Jadhav
b6ad1290f0 hevcdec: update sao modules for chroma format idc 444
Test: ./hevcdec

Change-Id: I013e44e024258f2f84690fdcc01b4cd52f0fbd16
2026-05-08 08:16:51 -07:00
Ram Mohan M
38e622bf6a hevcdec: update lib for chroma format idc 422
Some checks are pending
CMake / build (cmake, aarch64-linux-gnu-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake, aarch64-linux-gnu-g++, ubuntu-latest-cross-aarch64-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, arm-linux-gnueabihf-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake, arm-linux-gnueabihf-g++, ubuntu-latest-cross-aarch32-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Waiting to run
CMake / build (cmake, clang, , clang++, ubuntu-24.04-arm-clang-cmake, ubuntu-24.04-arm) (push) Waiting to run
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Waiting to run
- updated parser for 422 specific syntax elements
- updated iqitrecon module to handle 422 subtu's. Verified functionality
  for intra only slices
- add support 422 i/o
- restrict combinations of output chroma format and internal chroma
  format allowed. That is, for a given chroma format idc not all output
  color formats are supported. The output format can now be either same
  as internal color format or 420p.

Test: ./hevcdec
Change-Id: I9dbf5c141aceb8ffcbe063aa35856eeed11e3d4f
2026-03-04 15:39:55 -08:00
Ram Mohan M
c8327aa960 hevcdec: remove unused memory allocations
while computing chroma residue, the same buffer is used for both cb and
cr. So remove allocation made for cr. Further guard the memory
allocation for rext toolsets under the macro ENABLE_MAIN_REXT_PROFILE

Test: ./hevcdec
Change-Id: I773c9413d262a4b84bcc7ec71ac11ceaadfd839d
2026-03-04 14:11:33 -08:00
Ram Mohan M
90f29517ee hevcdec: add support for transform_skip_rotation_enabled_flag
Test: ./hevcdec

Change-Id: Icc083c3bf08b23a6b91c230aace3aae148cb3ec9
2026-03-04 12:32:03 -08:00
Ram Mohan M
ad0a6d8688 hevcdec: add itrans residue functions
These functions are similar to ihevc_itrans_recon_* with the exception
that instead of computing recon directly they store residue to the
destination buffer. This helps with additional transformation of the
residue coefficients (rotation, rdpcm, ccp) before adding to the
prediction data to generate the final recon.

Test: Build
Change-Id: I9f84e66f5e9595162335cb152a6329a0f8d23337
2026-03-04 12:32:03 -08:00
Ram Mohan M
d3beb01a0d hevcdec: integrate 32x32 chroma itrans function
Some checks failed
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-24.04-arm-clang-cmake, ubuntu-24.04-arm) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, aarch64-linux-gnu-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch64_toolchain.cmake, aarch64-linux-gnu-g++, ubuntu-latest-cross-aarch64-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, arm-linux-gnueabihf-gcc, -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/aarch32_toolchain.cmake, arm-linux-gnueabihf-g++, ubuntu-latest-cross-aarch32-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Has been cancelled
Test: ./hevcdec
2026-02-23 11:55:55 -08:00
Rakesh Kumar
135285ae8a hevcdec: update inter prediction module for chroma format idc 444
Test: ./hevcdec
Change-Id: I40411c04ab00d7e23843eb1d033c4943e3ec76e9
2026-02-23 10:45:25 -08:00
Rakesh Kumar
04e7eb5698 hevcdec: add i/o support for color format yuv444
Some checks failed
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Has been cancelled
This change adds supports for handling color format yuv444 at input
output level. At the input level, it ensures the bitstream buffer
allocation is modified to cover 444 encoded streams and at the output
level it ensures the allocation is such that decoded output can be
written to 444 format.

Test: ./hevcdec

Change-Id: Icac7ca76a95c4140d7ef11189cdb6321961d88cc
2026-02-17 09:26:00 -08:00
Vivek Jadhav
8cbcc58d4a libhevcdec: Remove support for YUV422 ile, RGB565 and RGBA8888 output formats
Some checks are pending
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Waiting to run
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Waiting to run
These color formats are no longer supported. The decoder now returns
an error if configured for any of these output formats

Test: ./hevcdec

Change-Id: I944c539000f26898d5985cd6806f2968d4365f63
2026-02-14 12:54:18 -08:00
Ram Mohan M
09bc53ec53 hevcdec: fix white spacing and other cosmetic changes
Some checks failed
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Has been cancelled
Test: Build
2026-02-11 12:14:51 -08:00
Vivek Jadhav
fde75babbc hevcdec: Updated memory allocation for monochrome
Some checks are pending
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Waiting to run
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Waiting to run
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Waiting to run
Updated library to allocate memory only for luma in case of monochrome
profile.

Bug:
Test: ./hevcdec

Change-Id: I5649bbd94e10d2c19fa7548b2380db598c9ff2b6
2026-02-09 15:05:07 -08:00
Vivek Jadhav
45340a66f0 libhevcdec: Add support for monochrome
Some checks failed
CMake / build (cmake, clang, , clang++, macos-latest-clang-cmake, macos-latest) (push) Has been cancelled
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, clang, -G Ninja, clang++, ubuntu-latest-clang-cmake-ninja, ubuntu-latest) (push) Has been cancelled
CMake / build (cmake, gcc, , g++, ubuntu-latest-gcc-cmake, ubuntu-latest) (push) Has been cancelled
Bug: 382315082
Test: ./hevcdec

Change-Id: I944c539000f26898d5985cd5809f2958d4865f71
2025-11-11 07:11:03 -08:00
srujan vandrangi
a88affe6f1 libhevc: do not disable sei code in hevc decoder application
Bug: 338446610
Test: ./hevcdec
2024-06-06 21:24:32 -07:00
Srujan Vandrangi
dc225332d0 libhevc: move SEI related code under a macro
Bug: 338446610
Test: ./hevcdec
2024-05-07 10:07:49 -07:00
srujan vandrangi
90aefb438b decoder: join threads in flush mode
Test: hevcdec
2023-09-25 08:48:17 -07:00
Harish Mahendrakar
72558e3be0 decoder: join threads in reset()
Test: hevc_dec_fuzzer
2023-07-23 22:40:57 -07:00
Srujan Vandrangi
4cd4edc0f6 decoder: replace KEEP_THREADS_ACTIVE macro with hevc struct variable
Bug: 289097296
Test: Build
2023-07-21 13:18:21 -07:00
Harish Mahendrakar
e4b160c9e5 decoder: cleanup MULTICORE macro 2023-05-26 16:13:41 +05:30
Shivaansh Agrawal
f6dcd29208 Decoder: add support for QP and block_type map export in library
Bug: 176469524

Test: hevcdec -c test.cfg
Test: atest -c android.mediav2.cts.CodecDecoderTest
Test: atest VtsHalMediaC2V1_0TargetVideoDecTest

Change-Id: I75aebd3c4121d3b8cb5a2a947f643abbff41810d
2022-08-04 11:40:43 +05:30
Shivaansh Agrawal
46a37119ac Decoder: add support to use ihevcd instead of ivd structures
Bug: 176411924

Test: hevcdec -c test.cfg
Test: atest -c android.mediav2.cts.CodecDecoderTest
Test: atest VtsHalMediaC2V1_0TargetVideoDecTest

Change-Id: Iacfc73fe4bc5b755ccc1f36d9bdc12ec3c0aae21
2022-05-05 11:45:55 +05:30
Harish Mahendrakar
b10161aba2 decoder: Ignore RASL NALs after flush
After flush, if the first slice NAL sent to decoder is a CRA
picture, then it may have associated RASL NALs that need to
be skipped as they may contain references to pictures that
are not present in the bitstream that is fed to the decoder.

Currently decoder was handling this case only at the start
of decode and after receiving an EOS NAL. Now it is updated
to ignore such RASL NALs associated with CRA after flush as
well.

This is needed to handle seek in clips, where CRA NALS are
marked as sync points.

Bug: 194768162
Test: poc in bug
Test: atest VtsHalMediaC2V1_0TargetVideoDecTest
Test: atest CtsMediaV2TestCases:CodecDecoderTest

Change-Id: If5f38b0689c98c4d2a2a720b81d7e28593be5732
2021-09-29 17:20:50 -07:00
Manisha Jajoo
c57a80373a Decoder: add support for KEEP_THREADS_ACTIVE
Current design of HEVC Decoder creates new threads
to process each frame. This CL adds support to reuse
the threads across frames.

Test: manual
Bug: 167126301

Change-Id: Ic57133b25203dae9ed5d3d974e6137a733531da7
2020-08-31 22:00:10 +05:30
Harish Mahendrakar
7461e43ed8 decoder: Report unsupported bitdepth and color format as fatal errors
This will ensure clips with supported bitdepth or unsupport color
formats are not attempted to be decoded till end of the sequence.

Bug: 129796771
Bug: 130578045
Test: adb shell stagefright -s -S /sdcard/crowd422_hevc.mp4
Test: Ensure decoder doesn't attemp decoding all frames

Change-Id: I7c3cd58a0e231e7e64c278564d050086a079e12c
2019-04-30 15:50:13 -07:00
Snehal Bhamare
1b4ab78b5d Decoder: Fixing integer-overflow sanitizer issues
Bug: 111272481
Test: vendor
Change-Id: Idd5db33617ae55f70a1be67e0374adceafc174d3
2019-02-05 14:25:24 -08:00
Rakesh Kumar
303b662e0d Decoder: Memset allocated dynamic and static buffer to zero
Bug: 111764725
Bug: 112327675
Bug: 112326216
Test: manual
Change-Id: Ia775c77cb62fae89ac410805c9fca55522a2e555
2018-08-24 11:22:23 -07:00
Harish Mahendrakar
19eb590e4d Merge "Decoder: Handle ps_codec_obj memory allocation failure gracefully" into mnc-dr-dev am: 59d29f3a42 am: 1232ed762a am: c3388332a1 am: 9616d06d9f am: b248b90e5c am: 9268f7f6f8 am: ba34c2e4f6
am: e3887b800d

Change-Id: Ib7ae7465ec696d254a54e9b94b77500e2f259240
2017-11-03 19:25:21 +00:00
Harish Mahendrakar
b248b90e5c Merge "Decoder: Handle ps_codec_obj memory allocation failure gracefully" into mnc-dr-dev am: 59d29f3a42 am: 1232ed762a am: c3388332a1
am: 9616d06d9f

Change-Id: I9302f1123e6db6215640364bc8e2382d03544974
2017-11-03 19:10:47 +00:00
TreeHugger Robot
59d29f3a42 Merge "Decoder: Handle ps_codec_obj memory allocation failure gracefully" into mnc-dr-dev 2017-11-03 19:00:16 +00:00
Harish Mahendrakar
a966e2a65d Decoder: Handle ps_codec_obj memory allocation failure gracefully
If memory allocation for ps_codec_obj fails, return gracefully
with an error code. All other allocation failures are
handled correctly.

Bug: 68299873
Test: before/after with always-failing malloc
Change-Id: I5e6c07b147b13df81e65476851662d4b55d33b83
2017-10-31 16:31:31 -07:00