- For CTB size 16 in 4:2:2, sub-block width is 0, causing the Top
and Current SAO blocks to be skipped.
- Fix Top-Right neighbor in Left block to read from picture buffer
when ctb_size == 16 and ctb_y != 0, while keeping line buffer for
larger CTBs (32, 64).
- Fix Bottom-Left neighbor in Left block to read from picture buffer
when ctb_size == 16 to avoid uninitialized backup buffer access.
- Generalize Top-Left block condition to (8 * v_samp_factor).
Test: ./hevcdec
Change-Id: I013e44e024258f2f84690fdc0109210129042245
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.
Earlier condition in ihevcd_hbd_sao_shift_ctb was hardcoded
for 420 with luma ctb size as 16. Updated the condition to scale
for other chroma factors with vert and horz subsample factors.
Earlier condition was correctly hardcoded for 420 with
luma ctb size as 16. Updated the condition to scale for
other chroma factors with vert, and horz subsample factor.
Change-Id: I013e67e024258f2f84690fdcc01b4cd52f0fac52
(cherry picked from commit 7da5afcd72)
- Explicitly cast IHEVCD_SUCCESS to IHEVCD_ERROR_T in ihevcd_10bd_parse_sao to fix -Wimplicit-enum-enum-cast.
- Fix pointer comparison in ihevcd_parse_slice_data by replacing UWORD32 pointer cast with UWORD8* arithmetic to fix -Wpointer-to-int-cast.
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)
Remove generic C overrides for chroma and luma intra prediction in ihevcd_init_function_ptr_rext_generic to allow architecture-specific assembly and SIMD intrinsics to be used during 422 and 444 decoding.
(cherry picked from commit efa8b27448)
This commit enables 10-bit decoding support for Implicit Residual DPCM
Key changes include:
- Removed the ASSERT(0) bypass limitation in ihevcd_iquant_itrans_resi_recon_tu_plane when i4_pixel_size_y > 1.
- Dynamically determining the bit_depth for luma/chroma plane.
- Branching the apf_recon calls to correctly use apf_hbd_recon for HBD reconstruction.
According to ITU-T H.265 Section 7.4.7.1, the initial SliceQpY value
shall be in the range of -QpBdOffsetY to +51, inclusive, where
QpBdOffsetY = 6 * (bit_depth_luma - 8).
Previously, the slice_qp_delta validity check in ihevcd_parse_slice_header
assumed an 8-bit lower bound of MIN_HEVC_QP (0), causing valid negative
slice QP values in high bit depth (10-bit/12-bit) streams to fail header
parsing with IHEVCD_INVALID_PARAMETER.
Updated the lower bound check to account for (6 * bit_depth_luma_minus8),
allowing valid HBD low QP bitstreams (such as QP = 0) to parse and decode
correctly.
Test: ./hevcdec
Apply Min(chroma_qp, 51) cap before adding QpBdOffsetC in HBD path for YUV422
and YUV444, matching the HEVC specification (Section 8.6.2).
Test: ./hevcdec
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.
This commit implements the output formatting stage required to output
uncompressed 10-bit 444 frames to the application.
Changes include:
- Added `ihevcd_fmt_conv_hbd_444sp_to_444p` to handle de-interleaving of
16-bit U and V chroma channels into a planar format.
- Leveraged existing `ihevcd_fmt_conv_luma_copy` for 16-bit Luma copying
by doubling the width and stride parameters.
- Hooked the new conversion function into `ihevcd_fmt_conv` when processing
`IV_YUV_444P` formats with `pixel_size > 1`.
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.
This commit adds spatial intra-prediction support for 10-bit 444
chroma blocks during the decoder's prediction stage.
Changes include:
- Updated ihevc_hbd_chroma_intra_pred_filters.c to add 444 scaling
(sub_sample = 2 vs sub_sample = 1).
- Added support for 32x32 chroma block predictions (nt == 32), which
is the maximum chroma transform unit size in the 444 profile.
- Integrated the new filtering logic by updating the CTB intra-prediction
loop in ihevcd_iquant_itrans_recon_ctb.c
Cast pu1_pic_qp (UWORD8 *) to (WORD8 *) when assigning to pi1_qp
to resolve -Wpointer-sign compiler error.
Test: mm -j64 SANITIZE_TARGET=address SANITIZE_HOST=address
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
- 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
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
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
Remove the function pointer pf_sao_shift_ctb from sao_ctxt_t.
Instead of using a function pointer in codec_t, call a new wrapper
function ihevcd_sao_shift_ctb_wrapper directly. The wrapper dynamically
dispatches to 8-bit or 10-bit implementation based on stream bit depth.
TAG=agy
CONV=9b39e0bf-8a07-4122-9bb2-81ec77fbdc09
Trigger IVD_RES_CHANGED when bit depth or chroma format changes in SPS,
forcing reallocation of picture buffers.
To prevent corrupting the codec state on invalid SPS parses, the updates to
global codec parameters (like i4_pixel_size_y and i4_bit_depth_luma) are
deferred to the end of ihevcd_parse_sps, after all validation checks have
passed. The resolution change check now compares the old active values in
ps_codec against the newly parsed values in the temporary ps_sps structure.
TAG=agy
CONV=2aef6402-f7fc-4ff8-ba56-d78e01754035
- 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.
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.
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
- disable_boundary_filter flag was not reset within the TU loop. This
caused the flag to remain sticky at 1 for all subsequent TUs in the
CTB once set by any TU.
- Transform-skip blocks larger than 4x4, the scaling/dequantization
matrix is bypassed and the scaling factor is set to a constant of 16
as per HEVC specification section 8.6.3.
- Bypassing the inverse transform for transform-skip blocks requires
applying a scaling of tsShift (Rec. ITU-T H.265 Section 8.6.2
Eq 8-296: tsShift = 5 + log2_trans_size) and descaling of bdShift
(Eq 8-295: bdShift = 20 - bit_depth).
Net shift: shift_ts = bdShift - tsShift
(20 - bit_depth) - (5 + log2_trans_size)
15 - bit_depth - log2_trans_size.
Test: ./hevcdec
Change-Id: I40411c04ab00d7e23842eb1d033c4543e4ec75e9
For clips with chroma format idc 444/422 and output format selected to
420, after decoding during chroma sampling conversion from 444/422 to
420, neighbor filtering is done currently. This is updated to area.
Test: ./hevcdec
Change-Id: I024886655084051093858c5c40a94c0373c64813