From 0cc032d9ffd08ac41384371c0bd9c7d2ae3141aa Mon Sep 17 00:00:00 2001 From: Harish Mahendrakar Date: Fri, 7 Aug 2026 08:30:34 -0700 Subject: [PATCH] Clean up HBD support before split --- common/iv.h | 13 +++---------- decoder/ihevcd_api.c | 4 +--- decoder/ihevcd_decode.c | 26 +++++++++++++++----------- decoder/ihevcd_defs.h | 3 +-- decoder/ihevcd_ittiam_logo.h | 9 ++++----- decoder/ihevcd_parse_headers.c | 3 +++ decoder/ihevcd_version.c | 5 +++-- examples/decoder/main.c | 22 ++++++++-------------- fuzzer/hevc_dec_fuzzer.cpp | 6 +++--- 9 files changed, 41 insertions(+), 50 deletions(-) diff --git a/common/iv.h b/common/iv.h index 1045c9a..b21f7df 100644 --- a/common/iv.h +++ b/common/iv.h @@ -81,9 +81,7 @@ typedef enum { IV_RGB_24 = 0xa, IV_YUV_420SP_UV = 0xb, IV_YUV_420SP_VU = 0xc, - IV_RGBA_8888 = 0xd, - IV_YUV_422SP_UV = 0xe, - IV_YUV_422SP_VU = 0xf + IV_RGBA_8888 = 0xd }IV_COLOR_FORMAT_T; /* IV_PICTURE_CODING_TYPE_T: VOP/Frame coding type Enumeration */ @@ -262,14 +260,9 @@ typedef struct { UWORD32 u4_v_strd; /** - * Bit depth of the Luma (Y) Buffer + * Bit depth of the YUV Buffers */ - UWORD32 u4_y_bit_depth; - - /** - * Bit depth of the Chroma (U and V) Buffers - */ - UWORD32 u4_uv_bit_depth; + UWORD32 u4_bit_depth; }iv_yuv_buf_t; diff --git a/decoder/ihevcd_api.c b/decoder/ihevcd_api.c index cb23863..7589954 100644 --- a/decoder/ihevcd_api.c +++ b/decoder/ihevcd_api.c @@ -2880,9 +2880,7 @@ WORD32 ihevcd_get_buf_info(iv_obj_t *ps_codec_obj, ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_GRAY; else if(ps_codec->e_chroma_fmt == IV_YUV_422P) ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_422; - else if((ps_codec->e_chroma_fmt == IV_YUV_422SP_UV) - || (ps_codec->e_chroma_fmt == IV_YUV_422SP_VU)) - ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_422SP; + ps_ctl_op->u4_num_disp_bufs = 1; diff --git a/decoder/ihevcd_decode.c b/decoder/ihevcd_decode.c index c1b4984..605f5b9 100644 --- a/decoder/ihevcd_decode.c +++ b/decoder/ihevcd_decode.c @@ -254,8 +254,7 @@ static void ihevcd_fill_outargs(codec_t *ps_codec, ps_dec_op->u4_frame_decoded_flag = 0; } - ps_dec_op->s_disp_frm_buf.u4_y_bit_depth = i4_bit_depth_luma; - ps_dec_op->s_disp_frm_buf.u4_uv_bit_depth = i4_bit_depth_chroma; + ps_dec_op->s_disp_frm_buf.u4_bit_depth = i4_bit_depth_luma; /* If there is a display buffer */ if(ps_codec->ps_disp_buf) @@ -294,8 +293,7 @@ static void ihevcd_fill_outargs(codec_t *ps_codec, ps_dec_op->u4_output_present = 0; ps_dec_op->s_disp_frm_buf.u4_y_wd = ps_codec->i4_disp_wd; ps_dec_op->s_disp_frm_buf.u4_y_ht = ps_codec->i4_disp_ht; - // ps_dec_op->s_disp_frm_buf.u4_y_bit_depth = i4_bit_depth_luma; - // ps_dec_op->s_disp_frm_buf.u4_uv_bit_depth = i4_bit_depth_chroma; + // ps_dec_op->s_disp_frm_buf.u4_bit_depth = i4_bit_depth_luma; if(ps_codec->i4_share_disp_buf) { @@ -642,18 +640,21 @@ WORD32 ihevcd_decode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op) if(1 == ps_dec_op->u4_output_present) { - WORD32 ypos = ps_codec->i4_disp_ht - 64 - LOGO_HT; + WORD32 xpos = ps_codec->i4_disp_wd - 32 - LOGO_WD; + WORD32 ypos = ps_codec->i4_disp_ht - 32 - LOGO_HT; if(ypos < 0) ypos = 0; + if(xpos < 0) + xpos = 0; + INSERT_LOGO(ps_dec_ip->s_out_buffer.pu1_bufs[0], ps_dec_ip->s_out_buffer.pu1_bufs[1], ps_dec_ip->s_out_buffer.pu1_bufs[2], ps_codec->i4_disp_strd, - 32 , - ps_codec->i4_disp_ht - 32 - LOGO_HT, + xpos, + ypos, ps_codec->e_chroma_fmt, - ps_codec->i4_bit_depth_luma, ps_codec->i4_disp_wd, ps_codec->i4_disp_ht); } @@ -1048,18 +1049,21 @@ WORD32 ihevcd_decode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op) if(1 == ps_dec_op->u4_output_present) { - WORD32 ypos = ps_codec->i4_disp_ht - 64 - LOGO_HT; + WORD32 xpos = ps_codec->i4_disp_wd - 32 - LOGO_WD; + WORD32 ypos = ps_codec->i4_disp_ht - 32 - LOGO_HT; if(ypos < 0) ypos = 0; + if(xpos < 0) + xpos = 0; + INSERT_LOGO(ps_dec_ip->s_out_buffer.pu1_bufs[0], ps_dec_ip->s_out_buffer.pu1_bufs[1], ps_dec_ip->s_out_buffer.pu1_bufs[2], ps_codec->i4_disp_strd, - 32 , + xpos, ypos, ps_codec->e_chroma_fmt, - ps_codec->i4_bit_depth_luma, ps_codec->i4_disp_wd, ps_codec->i4_disp_ht); } diff --git a/decoder/ihevcd_defs.h b/decoder/ihevcd_defs.h index 18fec3f..63df670 100644 --- a/decoder/ihevcd_defs.h +++ b/decoder/ihevcd_defs.h @@ -446,8 +446,7 @@ enum #define MIN_OUT_BUFS_444 3 #define MIN_OUT_BUFS_420SP 2 #define MIN_OUT_BUFS_GRAY 1 -#define MIN_OUT_BUFS_422 3 -#define MIN_OUT_BUFS_422SP 2 + /** **************************************************************************** diff --git a/decoder/ihevcd_ittiam_logo.h b/decoder/ihevcd_ittiam_logo.h index d8879be..8c8d7a6 100644 --- a/decoder/ihevcd_ittiam_logo.h +++ b/decoder/ihevcd_ittiam_logo.h @@ -38,8 +38,8 @@ //#define LOGO_EN -#define LOGO_WD 164 -#define LOGO_HT 48 +#define LOGO_WD 90 +#define LOGO_HT 36 #define LOGO_WD_Y LOGO_WD #define LOGO_HT_Y LOGO_HT @@ -88,14 +88,13 @@ void ihevcd_insert_logo(UWORD8 *buf_y, UWORD8 *buf_u, UWORD8 *buf_v, UWORD32 x_pos, UWORD32 y_pos, UWORD32 yuv_fmt, - WORD32 bit_depth_luma, UWORD32 u4_disp_wd, UWORD32 u4_disp_ht); #ifdef LOGO_EN -#define INSERT_LOGO(buf_y, buf_u, buf_v, stride, x_pos, y_pos, yuv_fmt,bit_depth_luma,disp_wd,disp_ht) ihevcd_insert_logo(buf_y, buf_u, buf_v, stride, x_pos, y_pos, yuv_fmt,bit_depth_luma,disp_wd,disp_ht); +#define INSERT_LOGO(buf_y, buf_u, buf_v, stride, x_pos, y_pos, yuv_fmt,disp_wd,disp_ht) ihevcd_insert_logo(buf_y, buf_u, buf_v, stride, x_pos, y_pos, yuv_fmt,disp_wd,disp_ht); #else -#define INSERT_LOGO(buf_y, buf_u, buf_v, stride, x_pos, y_pos, yuv_fmt,bit_depth_luma,disp_wd,disp_ht) +#define INSERT_LOGO(buf_y, buf_u, buf_v, stride, x_pos, y_pos, yuv_fmt,disp_wd,disp_ht) #endif #endif /* LOGO_INSERT_H */ diff --git a/decoder/ihevcd_parse_headers.c b/decoder/ihevcd_parse_headers.c index dcc6838..7bc3981 100644 --- a/decoder/ihevcd_parse_headers.c +++ b/decoder/ihevcd_parse_headers.c @@ -1751,6 +1751,9 @@ IHEVCD_ERROR_T ihevcd_parse_sps(codec_t *ps_codec) return IHEVCD_UNSUPPORTED_BIT_DEPTH; ps_sps->i1_bit_depth_chroma_minus8 = value; + if (ps_sps->i1_bit_depth_luma_minus8 != ps_sps->i1_bit_depth_chroma_minus8) + return IHEVCD_UNSUPPORTED_BIT_DEPTH; + { WORD8 intra_flag = s_ptl.s_ptl_gen.i1_general_intra_constraint_flag; WORD8 still_flag = s_ptl.s_ptl_gen.i1_general_one_picture_only_constraint_flag; diff --git a/decoder/ihevcd_version.c b/decoder/ihevcd_version.c index 349c17e..6ea1dcf 100644 --- a/decoder/ihevcd_version.c +++ b/decoder/ihevcd_version.c @@ -51,15 +51,16 @@ #include "ihevc_debug.h" #include "ihevc_structs.h" /** - * Name of the codec and target platform (All Cortex A processors in this case) + * Name of the codec */ -#define CODEC_NAME "HEVCDEC_CXA_HM-14.0+RExt-7.2" +#define CODEC_NAME "HEVCDEC" /** * Codec release type, production or evaluation */ #define CODEC_RELEASE_TYPE "production" /** * Version string. First two digits signify major version and last two minor + * Increment major version for API change or major feature update */ #define CODEC_RELEASE_VER "05.00" /** diff --git a/examples/decoder/main.c b/examples/decoder/main.c index 645645f..2b3169a 100644 --- a/examples/decoder/main.c +++ b/examples/decoder/main.c @@ -996,7 +996,7 @@ void dump_output(vid_dec_ctx_t *ps_app_ctx, WORD32 i4_pixel_size; buf = (UWORD8 *)s_dump_disp_frm_buf.pv_y_buf; - i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_y_bit_depth > 8); + i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_bit_depth > 8); for(i = 0; i < s_dump_disp_frm_buf.u4_y_ht; i++) { fwrite(buf, 1, (s_dump_disp_frm_buf.u4_y_wd * i4_pixel_size), ps_op_file); @@ -1005,7 +1005,7 @@ void dump_output(vid_dec_ctx_t *ps_app_ctx, if(ps_app_ctx->e_output_chroma_format != IV_GRAY) { - i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_uv_bit_depth > 8); + i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_bit_depth > 8); buf = (UWORD8*)s_dump_disp_frm_buf.pv_u_buf; for(i = 0; i < s_dump_disp_frm_buf.u4_u_ht; i++) { @@ -1026,7 +1026,7 @@ void dump_output(vid_dec_ctx_t *ps_app_ctx, UWORD8 au1_y_chksum[16]; WORD32 i4_pixel_size; - i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_y_bit_depth > 8); + i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_bit_depth > 8); calc_md5_cksum((UWORD8 *)s_dump_disp_frm_buf.pv_y_buf, s_dump_disp_frm_buf.u4_y_strd * i4_pixel_size, s_dump_disp_frm_buf.u4_y_wd * i4_pixel_size, @@ -1038,7 +1038,7 @@ void dump_output(vid_dec_ctx_t *ps_app_ctx, { UWORD8 au1_u_chksum[16]; UWORD8 au1_v_chksum[16]; - WORD32 i4_pixel_size_uv = 1 + (s_dump_disp_frm_buf.u4_uv_bit_depth > 8); + WORD32 i4_pixel_size_uv = 1 + (s_dump_disp_frm_buf.u4_bit_depth > 8); calc_md5_cksum((UWORD8 *)s_dump_disp_frm_buf.pv_u_buf, s_dump_disp_frm_buf.u4_u_strd * i4_pixel_size_uv, s_dump_disp_frm_buf.u4_u_wd * i4_pixel_size_uv, @@ -1056,9 +1056,7 @@ void dump_output(vid_dec_ctx_t *ps_app_ctx, #endif } else if((ps_app_ctx->e_output_chroma_format == IV_YUV_420SP_UV) - || (ps_app_ctx->e_output_chroma_format == IV_YUV_420SP_VU) - || (ps_app_ctx->e_output_chroma_format == IV_YUV_422SP_UV) - || (ps_app_ctx->e_output_chroma_format == IV_YUV_422SP_VU)) + || (ps_app_ctx->e_output_chroma_format == IV_YUV_420SP_VU)) { #if DUMP_SINGLE_BUF { @@ -1074,7 +1072,7 @@ void dump_output(vid_dec_ctx_t *ps_app_ctx, WORD32 i4_pixel_size; buf = (UWORD8 *)s_dump_disp_frm_buf.pv_y_buf; - i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_y_bit_depth > 8); + i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_bit_depth > 8); for(i = 0; i < s_dump_disp_frm_buf.u4_y_ht; i++) { fwrite(buf, 1, (s_dump_disp_frm_buf.u4_y_wd * i4_pixel_size), ps_op_file); @@ -1082,7 +1080,7 @@ void dump_output(vid_dec_ctx_t *ps_app_ctx, } buf = (UWORD8 *)s_dump_disp_frm_buf.pv_u_buf; - i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_uv_bit_depth > 8); + i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_bit_depth > 8); for(i = 0; i < s_dump_disp_frm_buf.u4_u_ht; i++) { fwrite(buf, 1, (s_dump_disp_frm_buf.u4_u_wd * i4_pixel_size), ps_op_file); @@ -1108,7 +1106,7 @@ void dump_output(vid_dec_ctx_t *ps_app_ctx, WORD32 i4_pixel_size; buf = (UWORD8 *)s_dump_disp_frm_buf.pv_y_buf; - i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_y_bit_depth > 8); + i4_pixel_size = 1 + (s_dump_disp_frm_buf.u4_bit_depth > 8); for(i = 0; i < s_dump_disp_frm_buf.u4_y_ht; i++) { fwrite(buf, 1, (s_dump_disp_frm_buf.u4_y_strd * 2 * i4_pixel_size), ps_op_file); @@ -1277,10 +1275,6 @@ void parse_argument(vid_dec_ctx_t *ps_app_ctx, CHAR *argument, CHAR *value) ps_app_ctx->e_output_chroma_format = IV_YUV_420SP_VU; else if((strcmp(value, "GRAY")) == 0) ps_app_ctx->e_output_chroma_format = IV_GRAY; - else if((strcmp(value, "YUV_422SP_UV")) == 0) - ps_app_ctx->e_output_chroma_format = IV_YUV_422SP_UV; - else if((strcmp(value, "YUV_422SP_VU")) == 0) - ps_app_ctx->e_output_chroma_format = IV_YUV_422SP_VU; else if((strcmp(value, "YUV_422P")) == 0) ps_app_ctx->e_output_chroma_format = IV_YUV_422P; else diff --git a/fuzzer/hevc_dec_fuzzer.cpp b/fuzzer/hevc_dec_fuzzer.cpp index 2581896..597a5c8 100644 --- a/fuzzer/hevc_dec_fuzzer.cpp +++ b/fuzzer/hevc_dec_fuzzer.cpp @@ -291,7 +291,7 @@ void Codec::decodeHeader(const uint8_t *data, size_t size) { mWidth = std::min(dec_op.u4_pic_wd, (UWORD32)10240); mHeight = std::min(dec_op.u4_pic_ht, (UWORD32)10240); - mBitDepth = dec_op.s_disp_frm_buf.u4_y_bit_depth; + mBitDepth = dec_op.s_disp_frm_buf.u4_bit_depth; if (mBitDepth == 0) mBitDepth = 8; /* Break after successful header decode */ @@ -327,7 +327,7 @@ IV_API_CALL_STATUS_T Codec::decodeFrame(const uint8_t *data, size_t size, /* In case of change in resolution, reset codec and feed the same data again */ if (IVD_RES_CHANGED == (dec_op.u4_error_code & 0xFF)) { - UWORD32 bitDepth = dec_op.s_disp_frm_buf.u4_y_bit_depth; + UWORD32 bitDepth = dec_op.s_disp_frm_buf.u4_bit_depth; if (bitDepth == 0) bitDepth = 8; if (dec_op.u4_pic_wd && dec_op.u4_pic_ht && @@ -347,7 +347,7 @@ IV_API_CALL_STATUS_T Codec::decodeFrame(const uint8_t *data, size_t size, * to feed next data */ if (!*bytesConsumed) *bytesConsumed = 4; - UWORD32 bitDepth = dec_op.s_disp_frm_buf.u4_y_bit_depth; + UWORD32 bitDepth = dec_op.s_disp_frm_buf.u4_bit_depth; if (bitDepth == 0) bitDepth = 8; if (dec_op.u4_pic_wd && dec_op.u4_pic_ht &&