diff --git a/decoder/ihevcd_api.c b/decoder/ihevcd_api.c index 208cf5a..386adb7 100644 --- a/decoder/ihevcd_api.c +++ b/decoder/ihevcd_api.c @@ -91,7 +91,6 @@ #include "ihevcd_decode.h" #include "ihevcd_job_queue.h" #include "ihevcd_statistics.h" -#include "ihevcd_parse_residual.h" #define ALIGNED_FREE(ps_codec, y) \ @@ -177,12 +176,6 @@ static IV_API_CALL_STATUS_T api_check_struct_sanity(iv_obj_t *ps_handle, return IV_FAIL; } - if(ps_handle->pv_fxns != ihevcd_cxa_api_function) - { - *(pu4_api_op + 1) |= 1 << IVD_UNSUPPORTEDPARAM; - *(pu4_api_op + 1) |= IVD_INVALID_HANDLE_NULL; - return IV_FAIL; - } if(ps_handle->pv_codec_handle == NULL) { @@ -1182,7 +1175,6 @@ WORD32 ihevcd_init(codec_t *ps_codec) /* If the codec is in shared mode and required format is 420 SP VU interleaved then change * reference buffers chroma format */ - /* Nithya: 422 assignment happens after sps parsing */ if(IV_YUV_420SP_VU == ps_codec->e_chroma_fmt) { ps_codec->e_ref_chroma_fmt = IV_YUV_420SP_VU; @@ -1237,7 +1229,8 @@ WORD32 ihevcd_init(codec_t *ps_codec) ihevc_dpb_mgr_init((dpb_mgr_t *)ps_codec->pv_dpb_mgr); ps_codec->e_processor_soc = SOC_GENERIC; - ps_codec->u4_nctb = 0x7FFFFFFF; //MAX_NCTB; + /* The following can be over-ridden using soc parameter as a hack */ + ps_codec->u4_nctb = 0x7FFFFFFF; ihevcd_init_arch(ps_codec); ihevcd_init_function_ptr(ps_codec); @@ -1968,6 +1961,7 @@ WORD32 ihevcd_allocate_dynamic_bufs(codec_t *ps_codec) size += ps_codec->i4_pixel_size_uv * max_ctb_rows * 2; } + size = ALIGN64(size); pu1_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size); @@ -1989,8 +1983,8 @@ WORD32 ihevcd_allocate_dynamic_bufs(codec_t *ps_codec) } ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_left_chroma = (UWORD8 *)pu1_buf; pu1_buf += MAX(ht, wd) * (chroma_pixel_strd / v_samp_factor) * ps_codec->i4_pixel_size_uv; - } + for(i = 0; i < MAX_PROCESS_THREADS; i++) { ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_top_luma = (UWORD8 *)pu1_buf; @@ -2006,8 +2000,8 @@ WORD32 ihevcd_allocate_dynamic_bufs(codec_t *ps_codec) } ps_codec->s_parse.s_sao_ctxt.pu1_sao_src_top_chroma = (UWORD8 *)pu1_buf; pu1_buf += wd * (chroma_pixel_strd / h_samp_factor) * ps_codec->i4_pixel_size_uv; - } + for(i = 0; i < MAX_PROCESS_THREADS; i++) { ps_codec->as_process[i].s_sao_ctxt.pu1_sao_src_luma_top_left_ctb = (UWORD8 *)pu1_buf; @@ -2195,15 +2189,15 @@ WORD32 ihevcd_allocate_dynamic_bufs(codec_t *ps_codec) ps_codec->as_process[i].pu1_tile_idx = (UWORD16 *)pv_buf + wd / MIN_CTB_SIZE /* Offset 1 row */; } - if (sizeof(UWORD8) == pixel_size) - { - /* 4 bytes per color component per CTB */ - size = 3 * 4; - } - else /* HBD: currently upto 12 bit depth case */ - { - size = sizeof(sao_10bd_t); - } + if (sizeof(UWORD8) == pixel_size) + { + /* 4 bytes per color component per CTB */ + size = 3 * 4; + } + else /* HBD: currently upto 12 bit depth case */ + { + size = sizeof(sao_10bd_t); + } /* MAX number of CTBs in a row */ size *= wd / MIN_CTB_SIZE; diff --git a/decoder/ihevcd_deblk.c b/decoder/ihevcd_deblk.c index 8aad307..8099be6 100644 --- a/decoder/ihevcd_deblk.c +++ b/decoder/ihevcd_deblk.c @@ -360,28 +360,28 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk, filter_p, filter_q); if (BIT_DEPTH_LUMA == u1_bit_depth_luma) { - ps_codec->s_func_selector.ihevc_deblk_luma_vert_fptr(pu1_src, src_strd, - u4_bs & 3, qp_p, qp_q, - i1_beta_offset_div2, - i1_tc_offset_div2, - filter_p, filter_q); - } + ps_codec->s_func_selector.ihevc_deblk_luma_vert_fptr(pu1_src, src_strd, + u4_bs & 3, qp_p, qp_q, + i1_beta_offset_div2, + i1_tc_offset_div2, + filter_p, filter_q); + } else { ps_codec->s_func_selector.ihevc_hbd_deblk_luma_vert_fptr((UWORD16 *)pu1_src, - src_strd, - u4_bs & 3, qp_p, qp_q, - i1_beta_offset_div2, - i1_tc_offset_div2, - filter_p, filter_q, - u1_bit_depth_luma); + src_strd, + u4_bs & 3, qp_p, qp_q, + i1_beta_offset_div2, + i1_tc_offset_div2, + filter_p, filter_q, + u1_bit_depth_luma); } } pu1_src += 4 * src_strd * pixel_size_y; u4_bs = u4_bs >> 2; row++; - } /* End of loop over rows */ + } if((64 == ctb_size) || ((32 == ctb_size) && (col & 1))) @@ -516,20 +516,20 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk, filter_p, filter_q); if (BIT_DEPTH_LUMA == u1_bit_depth_luma) { - ps_codec->s_func_selector.ihevc_deblk_luma_horz_fptr(pu1_src, src_strd, - u4_bs & 3, qp_p, qp_q, - i1_beta_offset_div2, - i1_tc_offset_div2, filter_p, filter_q); - } + ps_codec->s_func_selector.ihevc_deblk_luma_horz_fptr(pu1_src, src_strd, + u4_bs & 3, qp_p, qp_q, + i1_beta_offset_div2, + i1_tc_offset_div2, filter_p, filter_q); + } else { ps_codec->s_func_selector.ihevc_hbd_deblk_luma_horz_fptr((UWORD16 *)pu1_src, - src_strd, - u4_bs & 3, qp_p, qp_q, - i1_beta_offset_div2, - i1_tc_offset_div2, - filter_p, filter_q, - u1_bit_depth_luma); + src_strd, + u4_bs & 3, qp_p, qp_q, + i1_beta_offset_div2, + i1_tc_offset_div2, + filter_p, filter_q, + u1_bit_depth_luma); } } @@ -579,8 +579,8 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk, WORD32 shift = 0; if(is_yuv444 && 6 != log2_ctb_size) - shift = (col & 1) << (log2_ctb_size - 1); + /* BS for the column - Last row is excluded and the top row is included*/ u4_bs = (pu4_vert_bs[0] >> shift) << 2; @@ -739,7 +739,7 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk, pu1_src += 4 * chroma_strd * pixel_size_uv; u4_bs = u4_bs >> (2 * v_samp_factor); row++; - } /* End of loop over rows */ + } pu1_src -= ((((src_strd * chroma_pixel_strd) / (h_samp_factor * v_samp_factor)) << log2_ctb_size) * pixel_size_uv); if(is_yuv444) @@ -754,8 +754,8 @@ void ihevcd_deblk_ctb(deblk_ctxt_t *ps_deblk, } } - /* Chroma Horizontal Edge */ + if(CHROMA_FMT_IDC_MONOCHROME != ps_sps->i1_chroma_format_idc && 0 == i4_is_last_ctb_y) { diff --git a/decoder/ihevcd_decode.c b/decoder/ihevcd_decode.c index 7fb54e4..b6fa1a5 100644 --- a/decoder/ihevcd_decode.c +++ b/decoder/ihevcd_decode.c @@ -187,6 +187,7 @@ static void ihevcd_fill_outargs(codec_t *ps_codec, void *pv_api_ip, void *pv_api_op) { + ihevcd_cxa_video_decode_ip_t *ps_hevcd_dec_ip; ihevcd_cxa_video_decode_op_t *ps_hevcd_dec_op; ivd_video_decode_ip_t *ps_dec_ip; diff --git a/decoder/ihevcd_fmt_conv.c b/decoder/ihevcd_fmt_conv.c index f7d6706..09c6dac 100644 --- a/decoder/ihevcd_fmt_conv.c +++ b/decoder/ihevcd_fmt_conv.c @@ -1799,6 +1799,7 @@ IHEVCD_ERROR_T ihevcd_fmt_conv(codec_t *ps_codec, pu1_uv_dst_tmp = pu1_u_dst + ((cur_row + 1) / 2) * ALIGN2(ps_codec->i4_disp_strd) * ps_codec->i4_pixel_size_uv; } + /* In case of multi threaded implementation, format conversion might be called * before reconstruction is completed. If the frame being converted/copied * is same as the frame being reconstructed, @@ -1830,7 +1831,7 @@ IHEVCD_ERROR_T ihevcd_fmt_conv(codec_t *ps_codec, /*Check if the row below is completely processed before proceeding with format conversion*/ status = 1; - for( ctb_in_row = 0; ctb_in_row < ps_sps->i2_pic_wd_in_ctb ; ctb_in_row++) + for(ctb_in_row = 0; (WORD32)ctb_in_row < ps_sps->i2_pic_wd_in_ctb; ctb_in_row++) { pu1_buf = (ps_codec->pu1_proc_map + idx + ctb_in_row); status &= *pu1_buf; @@ -1853,21 +1854,21 @@ IHEVCD_ERROR_T ihevcd_fmt_conv(codec_t *ps_codec, { if(1 == ps_codec->i4_pixel_size_y) { - ihevcd_fmt_conv_420sp_to_420sp_ft *fmt_conv_fptr; - if(ps_codec->i4_disp_wd >= MIN_FMT_CONV_SIMD_WIDTH) - { - fmt_conv_fptr = ps_codec->s_func_selector.ihevcd_fmt_conv_420sp_to_420sp_fptr; + ihevcd_fmt_conv_420sp_to_420sp_ft *fmt_conv_fptr; + if(ps_codec->i4_disp_wd >= MIN_FMT_CONV_SIMD_WIDTH) + { + fmt_conv_fptr = ps_codec->s_func_selector.ihevcd_fmt_conv_420sp_to_420sp_fptr; + } + else + { + fmt_conv_fptr = ihevcd_fmt_conv_420sp_to_420sp; + } + fmt_conv_fptr(pu1_y_src, pu1_uv_src, + pu1_y_dst_tmp, pu1_uv_dst_tmp, + ps_codec->i4_disp_wd, num_rows, + ps_codec->i4_strd, ps_codec->i4_strd, + ps_codec->i4_disp_strd, ps_codec->i4_disp_strd); } - else - { - fmt_conv_fptr = ihevcd_fmt_conv_420sp_to_420sp; - } - fmt_conv_fptr(pu1_y_src, pu1_uv_src, - pu1_y_dst_tmp, pu1_uv_dst_tmp, - ps_codec->i4_disp_wd, num_rows, - ps_codec->i4_strd, ps_codec->i4_strd, - ps_codec->i4_disp_strd, ps_codec->i4_disp_strd); - } else { ihevcd_hbd_fmt_conv_420sp_to_420sp((UWORD16 *)pu1_y_src, (UWORD16 *)pu1_uv_src, @@ -1993,7 +1994,6 @@ IHEVCD_ERROR_T ihevcd_fmt_conv(codec_t *ps_codec, else { fmt_conv_fptr = ihevcd_fmt_conv_420sp_to_420p; - } if(0 == disable_luma_copy) { diff --git a/decoder/ihevcd_structs.h b/decoder/ihevcd_structs.h index 9d8e710..df50f80 100644 --- a/decoder/ihevcd_structs.h +++ b/decoder/ihevcd_structs.h @@ -37,7 +37,6 @@ #ifndef _IHEVCD_STRUCTS_H_ #define _IHEVCD_STRUCTS_H_ - typedef enum { INIT_DONE, HEADER_DONE, FIRST_FRAME_DONE, @@ -1884,6 +1883,21 @@ struct _codec_t */ IV_COLOR_FORMAT_T e_ref_chroma_fmt; + /** + * Frame skip mode + */ + IVD_FRAME_SKIP_MODE_T e_pic_skip_mode; + + /** + * Display or decode order dump of output + */ + IVD_DISPLAY_FRAME_OUT_MODE_T e_pic_out_order; + + /** + * Coding type of the picture that is decoded + */ + IV_PICTURE_CODING_TYPE_T e_dec_pic_type; + /** * ChromaFormatIDC */ @@ -1919,21 +1933,6 @@ struct _codec_t */ WORD32 i4_qp_bd_offset_uv; - /** - * Frame skip mode - */ - IVD_FRAME_SKIP_MODE_T e_pic_skip_mode; - - /** - * Display or decode order dump of output - */ - IVD_DISPLAY_FRAME_OUT_MODE_T e_pic_out_order; - - /** - * Coding type of the picture that is decoded - */ - IV_PICTURE_CODING_TYPE_T e_dec_pic_type; - /** * Flag to signal if a frame was decoded in this call */ @@ -2411,14 +2410,14 @@ struct _codec_t pf_sao_chroma apf_sao_chroma[4]; /* HBD function pointers */ - pf_hbd_intra_pred_luma apf_hbd_intra_pred_luma[11]; - pf_hbd_intra_pred_chroma apf_hbd_intra_pred_chroma[11]; - pf_hbd_itrans_recon apf_hbd_itrans_recon[9]; - pf_hbd_itrans_recon_dc apf_hbd_itrans_recon_dc[2]; - pf_hbd_recon apf_hbd_recon[9]; - pf_hbd_sao_luma apf_hbd_sao_luma[4]; - pf_hbd_sao_chroma apf_hbd_sao_chroma[4]; - pf_hbd_inter_pred apf_hbd_inter_pred[22]; + pf_hbd_intra_pred_luma apf_hbd_intra_pred_luma[11]; + pf_hbd_intra_pred_chroma apf_hbd_intra_pred_chroma[11]; + pf_hbd_itrans_recon apf_hbd_itrans_recon[9]; + pf_hbd_itrans_recon_dc apf_hbd_itrans_recon_dc[2]; + pf_hbd_recon apf_hbd_recon[9]; + pf_hbd_sao_luma apf_hbd_sao_luma[4]; + pf_hbd_sao_chroma apf_hbd_sao_chroma[4]; + pf_hbd_inter_pred apf_hbd_inter_pred[22]; /** Funtion pointers for all the leaf level functions */ func_selector_t s_func_selector; diff --git a/examples/decoder/main.c b/examples/decoder/main.c index bcd73fe..f496af7 100644 --- a/examples/decoder/main.c +++ b/examples/decoder/main.c @@ -1013,8 +1013,8 @@ void dump_output(vid_dec_ctx_t *ps_app_ctx, fwrite(buf, 1, s_dump_disp_frm_buf.u4_v_wd * pixel_size, ps_op_file); buf += s_dump_disp_frm_buf.u4_v_strd * pixel_size; } - } } + } if(0 != chksum_save) {