Commit graph

21 commits

Author SHA1 Message Date
Narayan Kalaburgi
9886db71d3 libhevcdec: Unify itrans_res family and remove redundant HBD implementation
Currently, libhevc maintains two separate implementations for inverse
transform residual functions: ihevc_itrans_res_* and ihevc_hbd_itrans_res_*.

Since both 8-bit and HBD inverse transform residual routines output signed
16-bit residuals (WORD16 *pi2_dst), the only algorithmic difference between
8-bit and HBD variants is the 2nd stage shift:

    Stage 1 shift: IT_SHIFT_STAGE_1 = 7 (fixed across all bit depths)
    Stage 2 shift: shift = 20 - bit_depth
        - 8-bit:  20 - 8  = 12 (IT_SHIFT_STAGE_2)
        - 10-bit: 20 - 10 = 10

This commit cleans up the entire itrans_res family (4x4_ttype1, 4x4, dc, 8x8,
16x16, 32x32) as follows:

1. common/ihevc_itrans_res.h & common/ihevc_itrans_res.c:
   - Add 'UWORD8 bit_depth' parameter to ihevc_itrans_res_* function
     signatures and typedefs.
   - Replace hardcoded 'shift = IT_SHIFT_STAGE_2;' with 'shift = 20 - bit_depth;'.
   - Remove obsolete ihevc_hbd_itrans_res_* prototypes and typedefs.

2. common/ihevc_hbd_itrans_res.c:
   - Delete file (~2,335 redundant lines removed).

3. Update tests/common/ihevc_itrans_res_test.cc to test bit depths 8 and 10
2026-09-10 11:21:07 -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
Rakesh Kumar
c38cfe068d hevcdec: Remove rext generic function pointer override for 422/444
Some checks are pending
CMake / build (cmake, clang, , clang++, ubuntu-latest-clang-cmake, 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, -DSANITIZE=fuzzer-no-link,address, clang++, ubuntu-latest-clang-cmake-asan-fuzzer, ubuntu-latest) (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
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
With SIMD optimizations updated and enabled for 422 and 444 chroma formats,
the fallback override in ihevcd_init_function_ptr_rext_generic is no longer
necessary.

Test: ./build
(cherry picked from commit e3ce7e69cb)
2026-08-19 22:18:26 +00:00
Narayan Kalaburgi
00cd256a04 libhevcdec: Fix missing chroma ref filtering function call for HBD 444 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
Harish Mahendrakar
2a74434513 Few minor cleanups in headers to minimize the differences with main branch
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-12 05:24:06 +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
3d2cafda86 Remove few more unnecessary changes from HBD path 2026-08-09 23:47:45 +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
Vivek R Jadhav
6f423a375a libhevcdec: Enable architecture-specific SIMD optimizations for 422 and 444
Previously, when 422 or 444 chroma formats were encountered, all
function pointers were overridden to generic C implementations due to
lack of support in optimized assemblies/intrinsics for certain
components.

This change introduces `ihevcd_init_function_ptr_rext` which:
- First initializes all function pointers with architecture-optimized
versions.
- Explicitly overrides only the components not yet optimized for 422/444 formats (intra prediction, SAO, deblocking and chroma padding) to point
back to their C implementations.

This allows other fully-compatible modules (e.g: inter prediction modes, transform/reconstruction, format conversion) to benefit from SIMD
optimizations on 422/444 formats without degrading YUV 420 decoding.

Test: ./hevcdec

Change-Id: I013e44e024258f2f84690fdc0109200129042145
2026-08-03 13:29:07 +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
Sushant
646ee99888 libhevc: Direct memcpy and memset calls to enable _FORTIFY_SOURCE
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
Bypass wrappers functions for memcpy and memset, calling standard
C library functions directly. This allows _FORTIFY_SOURCE to
perform compile-time safety checks.

Bug: 514722372
Test: ./hevcdec

Change-Id: Id9faf0919ecedfd1833d40a7fbf6ddac454628b4
2026-06-18 06:44:56 -07:00
Vivek R Jadhav
2f827d5db0 libhevcdec: Update deblock modules for yuv422 format
Test: ./hevcdec

Change-Id: I40411c04ab00d7e23843eb1d033c4543e3ec66e9
2026-05-21 08:22:42 -07:00
Vivek R Jadhav
98462a6e46 libhevcdec: Unify ihevcd_function_selector_generic.c and ihevcd_function_selector_noneon.c
Test: ./hevcdec

Change-Id: I40411c04ab00d7e23843eb1d033c4943e3ec56e5
2026-05-07 07:00:35 -07: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
Harish Mahendrakar
2cf1cc917d decoder: Change function pointer argument to avoid passing codec_t 2026-02-28 22:39:33 +05:30
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
Rakesh Kumar
c4245ca34c hevcdec: add intra pred chroma reference samples filtering functions
Test: ./hevcdec

Change-Id: I3972d5ccb09a087a173dfe264ff885a5e55d3118
2026-02-13 07:43:12 -08:00
Rakesh Kumar
464af74ef0 hevcdec: add 32x32 chroma inverse trans recon functions
Test: ./hevcdec
Change-Id: I6d02a519738727257392d7d13b187c998e8e82d5
2026-02-13 07:43:12 -08:00
Rakesh Kumar
c684b4fd98 hevcdec: add 444 specific yuv color space conversion functions
Added 444 specific yuv color conversion functions. This change
only include function definition, call to these functions are
not enabled.

Test: ./hevcdec

Change-Id: I26a727d5e24c22c31f8188b38b980bd545251187
2026-02-10 07:14:13 -08:00
Harish Mahendrakar
0d8951cef4 Initial Version of HEVC decoder
Compliant to reference software HM11.0 onwards

Bug: 14571712
Change-Id: I8af25c1221cc6ab70440141c4d9b48c1ac69696a
2014-05-21 18:14:55 -07:00