diff --git a/mpp/hal/rkdec/h264d/hal_h264d_vdpu383.c b/mpp/hal/rkdec/h264d/hal_h264d_vdpu383.c index 1323ecef..e368d051 100644 --- a/mpp/hal/rkdec/h264d/hal_h264d_vdpu383.c +++ b/mpp/hal/rkdec/h264d/hal_h264d_vdpu383.c @@ -109,110 +109,6 @@ typedef struct Vdpu383H264dRegCtx_t { Vdpu383H264dRegSet *regs; } Vdpu383H264dRegCtx; -//#define DUMP_DATA - -#ifdef DUMP_DATA -static RK_U32 dump_cur_frame = 0; -static char dump_cur_dir[128]; -static char dump_cur_fname_path[512]; - -static MPP_RET flip_string(char *str) -{ - RK_U32 len = strlen(str); - RK_U32 i, j; - - for (i = 0, j = len - 1; i <= j; i++, j--) { - // swapping characters - char c = str[i]; - str[i] = str[j]; - str[j] = c; - } - - return MPP_OK; -} - -static MPP_RET dump_data(char *fname_path, void *data, RK_U32 data_bit_size, RK_U32 line_bits, RK_U32 big_end) -{ - RK_U8 *buf_p = (RK_U8 *)data; - RK_U8 cur_data; - RK_U32 i; - RK_U32 loop_cnt; - FILE *dump_fp = NULL; - char line_tmp[256]; - RK_U32 str_idx = 0; - - dump_fp = fopen(fname_path, "w+"); - if (!dump_fp) { - mpp_err_f("open file: %s error!\n", fname_path); - return MPP_NOK; - } - - if ((data_bit_size % 4 != 0) || (line_bits % 8 != 0)) { - mpp_err_f("line bits not align to 4!\n"); - return MPP_NOK; - } - - loop_cnt = data_bit_size / 8; - for (i = 0; i < loop_cnt; i++) { - cur_data = buf_p[i]; - - sprintf(&line_tmp[str_idx++], "%0x", cur_data & 0xf); - if ((i * 8 + 4) % line_bits == 0) { - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - sprintf(&line_tmp[str_idx++], "%0x", (cur_data >> 4) & 0xf); - if ((i * 8 + 8) % line_bits == 0) { - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - } - - // last line - if (data_bit_size % 4) { - cur_data = buf_p[i]; - sprintf(&line_tmp[str_idx++], "%0x", cur_data & 0xf); - if ((i * 8 + 8) % line_bits == 0) { - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - } - if (data_bit_size % line_bits) { - loop_cnt = (line_bits - (data_bit_size % line_bits)) / 4; - for (i = 0; i < loop_cnt; i++) - sprintf(&line_tmp[str_idx++], "%0x", 0); - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - - fclose(dump_fp); - - return MPP_OK; -} - -static MPP_RET dump_reg(RK_U32 *reg_s, RK_U32 count, RK_U32 log_start_idx) -{ - RK_U32 loop; - for (loop = 0; loop < count; loop++) { - mpp_log("reg[%03d]: 0%08x", log_start_idx + loop, reg_s[loop]); - } - - return MPP_OK; -} -#endif - static RK_U32 rkv_ver_align(RK_U32 val) { return MPP_ALIGN(val, 16); @@ -577,13 +473,13 @@ static MPP_RET set_registers(H264dHalCtx_t *p_hal, Vdpu383H264dRegSet *regs, Hal mpp_buf_slot_get_prop(p_hal->packet_slots, task->dec.input, SLOT_BUFFER, &mbuffer); regs->common_addr.reg128_strm_base = mpp_buffer_get_fd(mbuffer); // regs->h264d_paras.reg65_strm_start_bit = 2 * 8; -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { char *cur_fname = "stream_in.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mbuffer), - 8 * p_hal->strm_len, 128, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mbuffer), + 8 * p_hal->strm_len, 128, 0); } #endif @@ -883,15 +779,15 @@ MPP_RET vdpu383_h264d_gen_regs(void *hal, HalTaskInfo *task) } } -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { - dump_cur_frame++; memset(dump_cur_dir, 0, sizeof(dump_cur_dir)); sprintf(dump_cur_dir, "avc/Frame%04d", dump_cur_frame); if (access(dump_cur_dir, 0)) { if (mkdir(dump_cur_dir)) mpp_err_f("error: mkdir %s\n", dump_cur_dir); } + dump_cur_frame++; } #endif diff --git a/mpp/hal/rkdec/h265d/hal_h265d_vdpu383.c b/mpp/hal/rkdec/h265d/hal_h265d_vdpu383.c index 82444e71..33d6fbd4 100644 --- a/mpp/hal/rkdec/h265d/hal_h265d_vdpu383.c +++ b/mpp/hal/rkdec/h265d/hal_h265d_vdpu383.c @@ -27,94 +27,6 @@ #include "vdpu383_h265d.h" #include "vdpu383_com.h" -// #define DUMP_DATA - -#ifdef DUMP_DATA -static RK_U32 dump_cur_frame = 0; -static char dump_cur_dir[128]; -static char dump_cur_fname_path[512]; - -static flip_string(char *str) -{ - RK_U32 len = strlen(str); - RK_U32 i, j; - - for (i = 0, j = len - 1; i <= j; i++, j--) { - // swapping characters - char c = str[i]; - str[i] = str[j]; - str[j] = c; - } -} - -static MPP_RET dump_data(char *fname_path, void *data, RK_U32 data_bit_size, RK_U32 line_bits, RK_U32 big_end) -{ - RK_U8 *buf_p = (RK_U8 *)data; - RK_U8 cur_data; - RK_U32 i; - RK_U32 loop_cnt; - FILE *dump_fp = NULL; - char line_tmp[256]; - RK_U32 str_idx = 0; - - dump_fp = fopen(fname_path, "w+"); - - if ((data_bit_size % 4 != 0) || (line_bits % 8 != 0)) { - mpp_err_f("line bits not align to 4!\n"); - return MPP_NOK; - } - - loop_cnt = data_bit_size / 8; - for (i = 0; i < loop_cnt; i++) { - cur_data = buf_p[i]; - - sprintf(&line_tmp[str_idx++], "%0x", cur_data & 0xf); - if ((i * 8 + 4) % line_bits == 0) { - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - sprintf(&line_tmp[str_idx++], "%0x", (cur_data >> 4) & 0xf); - if ((i * 8 + 8) % line_bits == 0) { - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - } - - // last line - if (data_bit_size % 4) { - cur_data = buf_p[i]; - sprintf(&line_tmp[str_idx++], "%0x", cur_data & 0xf); - if ((i * 8 + 8) % line_bits == 0) { - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - } - if (data_bit_size % line_bits) { - loop_cnt = (line_bits - (data_bit_size % line_bits)) / 4; - for (i = 0; i < loop_cnt; i++) - sprintf(&line_tmp[str_idx++], "%0x", 0); - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - - fclose(dump_fp); - - return MPP_OK; -} -#endif - #define HW_RPS #define PPS_SIZE (112 * 64)//(96x64) @@ -702,12 +614,12 @@ static RK_S32 hal_h265d_v345_output_pps_packet(void *hal, void *dxva) mpp_log("pps[%3d] = 0x%08x\n", i, tmp[i]); } #endif -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { char *cur_fname = "global_cfg.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)bp.pbuf, 64 * bp.index + bp.bitpos, 128, 0); + dump_data_to_file(dump_cur_fname_path, (void *)bp.pbuf, 64 * bp.index + bp.bitpos, 128, 0); } #endif @@ -907,12 +819,12 @@ static RK_S32 hal_h265d_vdpu383_rps(void *dxva, void *rps_buf, void* sw_rps_buf, mpp_put_bits(&bp, 0, 128); } -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { char *cur_fname = "rps_128bit.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)bp.pbuf, 64 * bp.index + bp.bitpos, 128, 0); + dump_data_to_file(dump_cur_fname_path, (void *)bp.pbuf, 64 * bp.index + bp.bitpos, 128, 0); } #endif @@ -1001,7 +913,7 @@ static MPP_RET hal_h265d_vdpu383_gen_regs(void *hal, HalTaskInfo *syn) return MPP_ERR_NULL_PTR; } -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { memset(dump_cur_dir, 0, sizeof(dump_cur_dir)); sprintf(dump_cur_dir, "hevc/Frame%04d", dump_cur_frame); @@ -1119,12 +1031,13 @@ static MPP_RET hal_h265d_vdpu383_gen_regs(void *hal, HalTaskInfo *syn) mv_buf = hal_bufs_get_buf(reg_ctx->cmv_bufs, dxva_ctx->pp.CurrPic.Index7Bits); hw_regs->h265d_addrs.reg216_colmv_cur_base = mpp_buffer_get_fd(mv_buf->buf[0]); -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { char *cur_fname = "colmv_cur_frame.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mv_buf->buf[0]), mpp_buffer_get_size(mv_buf->buf[0]), 64, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mv_buf->buf[0]), + mpp_buffer_get_size(mv_buf->buf[0]), 64, 0); } #endif @@ -1134,12 +1047,13 @@ static MPP_RET hal_h265d_vdpu383_gen_regs(void *hal, HalTaskInfo *syn) dxva_ctx->bitstream = mpp_buffer_get_ptr(streambuf); } -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { char *cur_fname = "stream_in_128bit.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(streambuf), mpp_buffer_get_size(streambuf), 128, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(streambuf), + mpp_buffer_get_size(streambuf), 128, 0); } #endif diff --git a/mpp/hal/rkdec/inc/vdpu383_com.h b/mpp/hal/rkdec/inc/vdpu383_com.h index c0ac620a..2bc1b47a 100644 --- a/mpp/hal/rkdec/inc/vdpu383_com.h +++ b/mpp/hal/rkdec/inc/vdpu383_com.h @@ -20,6 +20,8 @@ #define MPP_RCB_BYTES(bits) MPP_ALIGN((bits + 7) / 8, RCB_ALLINE_SIZE) +// #define DUMP_VDPU383_DATAS + typedef enum Vdpu383RcbType_e { RCB_STRMD_ROW, RCB_STRMD_TILE_ROW, @@ -523,6 +525,16 @@ void vdpu383_setup_statistic(Vdpu383CtrlReg *com); void vdpu383_afbc_align_calc(MppBufSlots slots, MppFrame frame, RK_U32 expand); RK_S32 vdpu383_set_rcbinfo(MppDev dev, Vdpu383RcbInfo *rcb_info); +#ifdef DUMP_VDPU383_DATAS +extern RK_U32 dump_cur_frame; +extern char dump_cur_dir[128]; +extern char dump_cur_fname_path[512]; + +MPP_RET flip_string(char *str); +MPP_RET dump_data_to_file(char *fname_path, void *data, RK_U32 data_bit_size, + RK_U32 line_bits, RK_U32 big_end); +#endif + #ifdef __cplusplus } #endif diff --git a/mpp/hal/rkdec/vdpu383_com.c b/mpp/hal/rkdec/vdpu383_com.c index bcb29cd1..3311b13d 100644 --- a/mpp/hal/rkdec/vdpu383_com.c +++ b/mpp/hal/rkdec/vdpu383_com.c @@ -168,3 +168,96 @@ RK_S32 vdpu383_set_rcbinfo(MppDev dev, Vdpu383RcbInfo *rcb_info) return 0; } + +#ifdef DUMP_VDPU383_DATAS +RK_U32 dump_cur_frame = 0; +char dump_cur_dir[128]; +char dump_cur_fname_path[512]; + +MPP_RET flip_string(char *str) +{ + RK_U32 len = strlen(str); + RK_U32 i, j; + + for (i = 0, j = len - 1; i <= j; i++, j--) { + // swapping characters + char c = str[i]; + str[i] = str[j]; + str[j] = c; + } + + return MPP_OK; +} + +MPP_RET dump_data_to_file(char *fname_path, void *data, RK_U32 data_bit_size, + RK_U32 line_bits, RK_U32 big_end) +{ + RK_U8 *buf_p = (RK_U8 *)data; + RK_U8 cur_data; + RK_U32 i; + RK_U32 loop_cnt; + FILE *dump_fp = NULL; + char line_tmp[256]; + RK_U32 str_idx = 0; + + dump_fp = fopen(fname_path, "w+"); + if (!dump_fp) { + mpp_err_f("open file: %s error!\n", fname_path); + return MPP_NOK; + } + + if ((data_bit_size % 4 != 0) || (line_bits % 8 != 0)) { + mpp_err_f("line bits not align to 4!\n"); + return MPP_NOK; + } + + loop_cnt = data_bit_size / 8; + for (i = 0; i < loop_cnt; i++) { + cur_data = buf_p[i]; + + sprintf(&line_tmp[str_idx++], "%0x", cur_data & 0xf); + if ((i * 8 + 4) % line_bits == 0) { + line_tmp[str_idx++] = '\0'; + str_idx = 0; + if (!big_end) + flip_string(line_tmp); + fprintf(dump_fp, "%s\n", line_tmp); + } + sprintf(&line_tmp[str_idx++], "%0x", (cur_data >> 4) & 0xf); + if ((i * 8 + 8) % line_bits == 0) { + line_tmp[str_idx++] = '\0'; + str_idx = 0; + if (!big_end) + flip_string(line_tmp); + fprintf(dump_fp, "%s\n", line_tmp); + } + } + + // last line + if (data_bit_size % 4) { + cur_data = buf_p[i]; + sprintf(&line_tmp[str_idx++], "%0x", cur_data & 0xf); + if ((i * 8 + 8) % line_bits == 0) { + line_tmp[str_idx++] = '\0'; + str_idx = 0; + if (!big_end) + flip_string(line_tmp); + fprintf(dump_fp, "%s\n", line_tmp); + } + } + if (data_bit_size % line_bits) { + loop_cnt = (line_bits - (data_bit_size % line_bits)) / 4; + for (i = 0; i < loop_cnt; i++) + sprintf(&line_tmp[str_idx++], "%0x", 0); + line_tmp[str_idx++] = '\0'; + str_idx = 0; + if (!big_end) + flip_string(line_tmp); + fprintf(dump_fp, "%s\n", line_tmp); + } + + fclose(dump_fp); + + return MPP_OK; +} +#endif \ No newline at end of file diff --git a/mpp/hal/rkdec/vp9d/hal_vp9d_vdpu383.c b/mpp/hal/rkdec/vp9d/hal_vp9d_vdpu383.c index 2efffa64..57a9c93b 100644 --- a/mpp/hal/rkdec/vp9d/hal_vp9d_vdpu383.c +++ b/mpp/hal/rkdec/vp9d/hal_vp9d_vdpu383.c @@ -71,99 +71,9 @@ typedef struct Vdpu383Vp9dCtx_t { RK_U8 header_data[168]; } Vdpu383Vp9dCtx; -// #define DUMP_DATA - -#ifdef DUMP_DATA -static RK_U32 dump_cur_frame = 0; -static char dump_cur_dir[128]; -static char dump_cur_fname_path[512]; +#ifdef DUMP_VDPU383_DATAS static RK_U32 cur_last_segid_flag; static MppBuffer cur_last_prob_base; - -static MPP_RET flip_string(char *str) -{ - RK_U32 len = strlen(str); - RK_U32 i, j; - - for (i = 0, j = len - 1; i <= j; i++, j--) { - // swapping characters - char c = str[i]; - str[i] = str[j]; - str[j] = c; - } - return MPP_OK; -} - -static MPP_RET dump_data(char *fname_path, void *data, RK_U32 data_bit_size, RK_U32 line_bits, RK_U32 big_end) -{ - RK_U8 *buf_p = (RK_U8 *)data; - RK_U8 cur_data; - RK_U32 i; - RK_U32 loop_cnt; - FILE *dump_fp = NULL; - char line_tmp[256]; - RK_U32 str_idx = 0; - - dump_fp = fopen(fname_path, "w+"); - if (!dump_fp) { - mpp_err_f("open file: %s error!\n", fname_path); - return MPP_NOK; - } - - if ((data_bit_size % 4 != 0) || (line_bits % 8 != 0)) { - mpp_err_f("line bits not align to 4!\n"); - return MPP_NOK; - } - - loop_cnt = data_bit_size / 8; - for (i = 0; i < loop_cnt; i++) { - cur_data = buf_p[i]; - - sprintf(&line_tmp[str_idx++], "%0x", cur_data & 0xf); - if ((i * 8 + 4) % line_bits == 0) { - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - sprintf(&line_tmp[str_idx++], "%0x", (cur_data >> 4) & 0xf); - if ((i * 8 + 8) % line_bits == 0) { - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - } - - // last line - if (data_bit_size % 4) { - cur_data = buf_p[i]; - sprintf(&line_tmp[str_idx++], "%0x", cur_data & 0xf); - if ((i * 8 + 8) % line_bits == 0) { - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - } - if (data_bit_size % line_bits) { - loop_cnt = (line_bits - (data_bit_size % line_bits)) / 4; - for (i = 0; i < loop_cnt; i++) - sprintf(&line_tmp[str_idx++], "%0x", 0); - line_tmp[str_idx++] = '\0'; - str_idx = 0; - if (!big_end) - flip_string(line_tmp); - fprintf(dump_fp, "%s\n", line_tmp); - } - - fclose(dump_fp); - - return MPP_OK; -} #endif static MPP_RET hal_vp9d_alloc_res(HalVp9dCtx *hal) @@ -742,12 +652,12 @@ static MPP_RET prepare_uncompress_header(HalVp9dCtx *p_hal, DXVA_PicParams_VP9 * mpp_put_align(&bp, 64, 0);//128 -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { char *cur_fname = "global_cfg.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)bp.pbuf, 64 * (bp.index - 1) + bp.bitpos, 64, 0); + dump_data_to_file(dump_cur_fname_path, (void *)bp.pbuf, 64 * (bp.index - 1) + bp.bitpos, 64, 0); } #endif @@ -810,15 +720,15 @@ static MPP_RET hal_vp9d_vdpu383_gen_regs(void *hal, HalTaskInfo *task) vp9_hw_regs = (Vdpu383Vp9dRegSet*)hw_ctx->hw_regs; memset(vp9_hw_regs, 0, sizeof(Vdpu383Vp9dRegSet)); -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { - dump_cur_frame++; memset(dump_cur_dir, 0, sizeof(dump_cur_dir)); - sprintf(dump_cur_dir, "vp9/Frame%04d", p_hal->frame_no); + sprintf(dump_cur_dir, "vp9/Frame%04d", dump_cur_frame); if (access(dump_cur_dir, 0)) { if (mkdir(dump_cur_dir)) mpp_err_f("error: mkdir %s\n", dump_cur_dir); } + dump_cur_frame++; } #endif @@ -871,13 +781,13 @@ static MPP_RET hal_vp9d_vdpu383_gen_regs(void *hal, HalTaskInfo *task) if (hw_ctx->prob_ctx_valid[frame_ctx_id]) { vp9_hw_regs->vp9d_addrs.reg184_lastprob_base = mpp_buffer_get_fd(hw_ctx->prob_loop_base[frame_ctx_id]); -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { cur_last_prob_base = hw_ctx->prob_loop_base[frame_ctx_id]; } #endif } else { vp9_hw_regs->vp9d_addrs.reg184_lastprob_base = mpp_buffer_get_fd(hw_ctx->prob_default_base); hw_ctx->prob_ctx_valid[frame_ctx_id] |= pic_param->refresh_frame_context; -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { cur_last_prob_base = hw_ctx->prob_default_base; } #endif } @@ -885,20 +795,20 @@ static MPP_RET hal_vp9d_vdpu383_gen_regs(void *hal, HalTaskInfo *task) mpp_buffer_get_fd(hw_ctx->prob_loop_base[frame_ctx_id]); } vp9_hw_regs->vp9d_addrs.reg183_kfprob_base = mpp_buffer_get_fd(hw_ctx->probe_base); -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { char *cur_fname = "cabac_last_probe.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(cur_last_prob_base), - 8 * 152 * 16, 128, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(cur_last_prob_base), + 8 * 152 * 16, 128, 0); } { char *cur_fname = "cabac_kf_probe.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(hw_ctx->probe_base), - 8 * PROB_KF_SIZE, 128, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(hw_ctx->probe_base), + 8 * PROB_KF_SIZE, 128, 0); } #endif #else @@ -985,15 +895,15 @@ static MPP_RET hal_vp9d_vdpu383_gen_regs(void *hal, HalTaskInfo *task) vp9_hw_regs->vp9d_addrs.reg181_segidlast_base = mpp_buffer_get_fd(hw_ctx->segid_cur_base); vp9_hw_regs->vp9d_addrs.reg182_segidcur_base = mpp_buffer_get_fd(hw_ctx->segid_last_base); } -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS cur_last_segid_flag = hw_ctx->last_segid_flag; { char *cur_fname = "stream_in.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(streambuf) - + pic_param->uncompressed_header_size_byte_aligned, - 8 * (((stream_len + 15) & (~15)) + 0x80), 128, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(streambuf) + + pic_param->uncompressed_header_size_byte_aligned, + 8 * (((stream_len + 15) & (~15)) + 0x80), 128, 0); } #endif /* set last segid flag */ @@ -1237,37 +1147,42 @@ static MPP_RET hal_vp9d_vdpu383_wait(void *hal, HalTaskInfo *task) ret = mpp_dev_ioctl(p_hal->dev, MPP_DEV_CMD_POLL, NULL); if (ret) mpp_err_f("poll cmd failed %d\n", ret); -#ifdef DUMP_DATA +#ifdef DUMP_VDPU383_DATAS { char *cur_fname = "cabac_update_probe.dat"; DXVA_PicParams_VP9 *pic_param = (DXVA_PicParams_VP9*)task->dec.syntax.data; RK_U32 frame_ctx_id = pic_param->frame_context_idx; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(hw_ctx->prob_loop_base[frame_ctx_id]), - 8 * 152 * 16, 128, 0); + dump_data_to_file(dump_cur_fname_path, + (void *)mpp_buffer_get_ptr(hw_ctx->prob_loop_base[frame_ctx_id]), + 8 * 152 * 16, 128, 0); } { char *cur_fname = "segid_last.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); if (!cur_last_segid_flag) - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(hw_ctx->segid_cur_base), - 8 * 1559 * 8, 64, 0); + dump_data_to_file(dump_cur_fname_path, + (void *)mpp_buffer_get_ptr(hw_ctx->segid_cur_base), + 8 * 1559 * 8, 64, 0); else - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(hw_ctx->segid_last_base), - 8 * 1559 * 8, 64, 0); + dump_data_to_file(dump_cur_fname_path, + (void *)mpp_buffer_get_ptr(hw_ctx->segid_last_base), + 8 * 1559 * 8, 64, 0); } { char *cur_fname = "segid_cur.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); if (cur_last_segid_flag) - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(hw_ctx->segid_cur_base), - 8 * 1559 * 8, 64, 0); + dump_data_to_file(dump_cur_fname_path, + (void *)mpp_buffer_get_ptr(hw_ctx->segid_cur_base), + 8 * 1559 * 8, 64, 0); else - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(hw_ctx->segid_last_base), - 8 * 1559 * 8, 64, 0); + dump_data_to_file(dump_cur_fname_path, + (void *)mpp_buffer_get_ptr(hw_ctx->segid_last_base), + 8 * 1559 * 8, 64, 0); } #endif diff --git a/mpp/hal/vpu/av1d/hal_av1d_vdpu383.c b/mpp/hal/vpu/av1d/hal_av1d_vdpu383.c index 2a2c85df..8698b2a3 100644 --- a/mpp/hal/vpu/av1d/hal_av1d_vdpu383.c +++ b/mpp/hal/vpu/av1d/hal_av1d_vdpu383.c @@ -130,8 +130,6 @@ #define OFFSET_AV1D_ADDR_REGS (168 * sizeof(RK_U32)) #define OFFSET_INTERRUPT_REGS (15 * sizeof(RK_U32)) -#define DUMP_AV1_DATAS 0 - typedef struct av1d_rkv_buf_t { RK_U32 valid; Vdpu383Av1dRegSet *regs; @@ -220,9 +218,9 @@ typedef struct VdpuAv1dRegCtx_t { RK_U8 header_data[VDPU383_UNCMPS_HEADER_SIZE]; } Vdpu383Av1dRegCtx; -// #define DUMP_DATA +// #define DUMP_AV1D_VDPU383_DATAS -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS static RK_U32 dump_cur_frame = 0; static char dump_cur_dir[128]; static char dump_cur_fname_path[512]; @@ -241,8 +239,8 @@ static MPP_RET flip_string(char *str) return MPP_OK; } -static MPP_RET dump_data(char *fname_path, void *data, RK_U32 data_bit_size, - RK_U32 line_bits, RK_U32 big_end, RK_U32 append) +static MPP_RET dump_data_to_file(char *fname_path, void *data, RK_U32 data_bit_size, + RK_U32 line_bits, RK_U32 big_end, RK_U32 append) { RK_U8 *buf_p = (RK_U8 *)data; RK_U8 cur_data; @@ -1987,7 +1985,7 @@ static void vdpu383_av1d_set_cdf(Av1dHalCtx *p_hal, DXVA_PicParams_AV1 *dxva) } /* use para in decoder */ -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS { char *cur_fname = "cabac_cdf_in.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); @@ -2006,13 +2004,13 @@ static void vdpu383_av1d_set_cdf(Av1dHalCtx *p_hal, DXVA_PicParams_AV1 *dxva) regs->av1d_addrs.reg184_av1_noncoef_rd_base = mpp_buffer_get_fd(reg_ctx->cdf_rd_def_base); regs->av1d_addrs.reg178_av1_coef_rd_base = mpp_buffer_get_fd(reg_ctx->cdf_rd_def_base); -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS { - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(reg_ctx->cdf_rd_def_base), - 8 * NON_COEF_CDF_SIZE, 128, 0, 0); - dump_data(dump_cur_fname_path, (RK_U8 *)mpp_buffer_get_ptr(reg_ctx->cdf_rd_def_base) - + NON_COEF_CDF_SIZE + COEF_CDF_SIZE * coeff_cdf_idx, - 8 * COEF_CDF_SIZE, 128, 0, 1); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(reg_ctx->cdf_rd_def_base), + 8 * NON_COEF_CDF_SIZE, 128, 0, 0); + dump_data_to_file(dump_cur_fname_path, (RK_U8 *)mpp_buffer_get_ptr(reg_ctx->cdf_rd_def_base) + + NON_COEF_CDF_SIZE + COEF_CDF_SIZE * coeff_cdf_idx, + 8 * COEF_CDF_SIZE, 128, 0, 1); } #endif } else { @@ -2022,13 +2020,13 @@ static void vdpu383_av1d_set_cdf(Av1dHalCtx *p_hal, DXVA_PicParams_AV1 *dxva) cdf_buf = hal_bufs_get_buf(reg_ctx->cdf_bufs, dxva->frame_refs[mapped_idx].Index); regs->av1d_addrs.reg184_av1_noncoef_rd_base = mpp_buffer_get_fd(cdf_buf->buf[0]); regs->av1d_addrs.reg178_av1_coef_rd_base = mpp_buffer_get_fd(cdf_buf->buf[0]); -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS { - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(cdf_buf->buf[0]), - 8 * NON_COEF_CDF_SIZE, 128, 0, 0); - dump_data(dump_cur_fname_path, (RK_U8 *)mpp_buffer_get_ptr(cdf_buf->buf[0]) - + NON_COEF_CDF_SIZE + COEF_CDF_SIZE * coeff_cdf_idx, - 8 * COEF_CDF_SIZE, 128, 0, 1); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(cdf_buf->buf[0]), + 8 * NON_COEF_CDF_SIZE, 128, 0, 0); + dump_data_to_file(dump_cur_fname_path, (RK_U8 *)mpp_buffer_get_ptr(cdf_buf->buf[0]) + + NON_COEF_CDF_SIZE + COEF_CDF_SIZE * coeff_cdf_idx, + 8 * COEF_CDF_SIZE, 128, 0, 1); } #endif } @@ -2070,13 +2068,13 @@ static void vdpu383_av1d_set_cdf(Av1dHalCtx *p_hal, DXVA_PicParams_AV1 *dxva) } } -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS { char *cur_fname = "cdf_rd_def.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(reg_ctx->cdf_rd_def_base), - (NON_COEF_CDF_SIZE + COEF_CDF_SIZE * 4) * 8, 128, 0, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(reg_ctx->cdf_rd_def_base), + (NON_COEF_CDF_SIZE + COEF_CDF_SIZE * 4) * 8, 128, 0, 0); } #endif @@ -2117,15 +2115,15 @@ MPP_RET vdpu383_av1d_gen_regs(void *hal, HalTaskInfo *task) memset(regs, 0, sizeof(*regs)); p_hal->strm_len = (RK_S32)mpp_packet_get_length(task->dec.input_packet); -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS { - dump_cur_frame++; memset(dump_cur_dir, 0, sizeof(dump_cur_dir)); - sprintf(dump_cur_dir, "av1/Frame%04d", p_hal->frame_no); + sprintf(dump_cur_dir, "av1/Frame%04d", dump_cur_frame); if (access(dump_cur_dir, 0)) { if (mkdir(dump_cur_dir)) mpp_err_f("error: mkdir %s\n", dump_cur_dir); } + dump_cur_frame++; } #endif @@ -2182,13 +2180,13 @@ MPP_RET vdpu383_av1d_gen_regs(void *hal, HalTaskInfo *task) regs->av1d_paras.reg67_global_len = VDPU383_UNCMPS_HEADER_SIZE / 16; // 128 bit as unit regs->com_pkt_addr.reg131_gbl_base = ctx->bufs_fd; // mpp_dev_set_reg_offset(p_hal->dev, 131, ctx->offset_uncomps); -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS { char *cur_fname = "global_cfg.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, ctx->bufs_ptr, - 8 * regs->av1d_paras.reg67_global_len * 16, 64, 0, 0); + dump_data_to_file(dump_cur_fname_path, ctx->bufs_ptr, + 8 * regs->av1d_paras.reg67_global_len * 16, 64, 0, 0); } #endif // input strm @@ -2200,21 +2198,21 @@ MPP_RET vdpu383_av1d_gen_regs(void *hal, HalTaskInfo *task) mpp_dev_set_reg_offset(p_hal->dev, 128, ctx->offset_uncomps & 0xfffffff0); /* error */ regs->av1d_addrs.reg169_error_ref_base = mpp_buffer_get_fd(mbuffer); -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS { char *cur_fname = "stream_in.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mbuffer) - + ctx->offset_uncomps, - 8 * p_hal->strm_len, 128, 0, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mbuffer) + + ctx->offset_uncomps, + 8 * p_hal->strm_len, 128, 0, 0); } { char *cur_fname = "stream_in_no_offset.dat"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mbuffer), - 8 * p_hal->strm_len, 128, 0, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mbuffer), + 8 * p_hal->strm_len, 128, 0, 0); } #endif } @@ -2333,20 +2331,20 @@ MPP_RET vdpu383_av1d_gen_regs(void *hal, HalTaskInfo *task) vdpu383_av1d_colmv_setup(p_hal, dxva); mv_buf = hal_bufs_get_buf(ctx->colmv_bufs, dxva->CurrPic.Index7Bits); regs->av1d_addrs.reg216_colmv_cur_base = mpp_buffer_get_fd(mv_buf->buf[0]); -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS memset(mpp_buffer_get_ptr(mv_buf->buf[0]), 0, mpp_buffer_get_size(mv_buf->buf[0])); #endif for (i = 0; i < NUM_REF_FRAMES; i++) { if (dxva->frame_refs[i].Index != (CHAR)0xff && dxva->frame_refs[i].Index != 0x7f) { mv_buf = hal_bufs_get_buf(ctx->colmv_bufs, dxva->frame_refs[i].Index); regs->av1d_addrs.reg217_232_colmv_ref_base[i] = mpp_buffer_get_fd(mv_buf->buf[0]); -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS { char *cur_fname = "colmv_ref_frame"; memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s%d.dat", dump_cur_dir, cur_fname, i); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mv_buf->buf[0]), - 8 * 5120 * 8, 64, 0, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mv_buf->buf[0]), + 8 * 5120 * 8, 64, 0, 0); } #endif } @@ -2377,23 +2375,6 @@ MPP_RET vdpu383_av1d_start(void *hal, HalTaskInfo *task) reg_ctx->reg_buf[task->dec.reg_index].regs : reg_ctx->regs; MppDev dev = p_hal->dev; -#if DUMP_AV1_DATAS - { - RK_U32 i = 0; - RK_U32 *p = (RK_U32*)regs; - char fname[128]; - FILE *fp_in = NULL; - static RK_U32 g_frame_no = 0; - - sprintf(fname, "/data/video/reg_%d_in.txt", g_frame_no++); - fp_in = fopen(fname, "wb"); - for (i = 0; i < sizeof(*regs) / 4; i++, p++) - fprintf(fp_in, "reg[%3d] = %08x\n", i, *p); - - fflush(fp_in); - fclose(fp_in); - } -#endif do { MppDevRegWrCfg wr_cfg; MppDevRegRdCfg rd_cfg; @@ -2475,7 +2456,7 @@ MPP_RET vdpu383_av1d_wait(void *hal, HalTaskInfo *task) reg_ctx->reg_buf[task->dec.reg_index].regs : reg_ctx->regs; (void) p_regs; -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS { char *cur_fname = "colmv_cur_frame.dat"; DXVA_PicParams_AV1 *dxva = (DXVA_PicParams_AV1*)task->dec.syntax.data; @@ -2483,8 +2464,8 @@ MPP_RET vdpu383_av1d_wait(void *hal, HalTaskInfo *task) mv_buf = hal_bufs_get_buf(reg_ctx->colmv_bufs, dxva->CurrPic.Index7Bits); memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mv_buf->buf[0]), - 8 * 5120 * 8, 64, 0, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mv_buf->buf[0]), + 8 * 5120 * 8, 64, 0, 0); } { char *cur_fname = "decout.dat"; @@ -2492,8 +2473,8 @@ MPP_RET vdpu383_av1d_wait(void *hal, HalTaskInfo *task) mpp_buf_slot_get_prop(p_hal->slots, task->dec.output, SLOT_BUFFER, &mbuffer); memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mbuffer), - 8 * mpp_buffer_get_size(mbuffer), 64, 0, 0); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(mbuffer), + 8 * mpp_buffer_get_size(mbuffer), 64, 0, 0); } #endif @@ -2512,7 +2493,7 @@ MPP_RET vdpu383_av1d_wait(void *hal, HalTaskInfo *task) ret = mpp_dev_ioctl(p_hal->dev, MPP_DEV_CMD_POLL, NULL); if (ret) mpp_err_f("poll cmd failed %d\n", ret); -#ifdef DUMP_DATA +#ifdef DUMP_AV1D_VDPU383_DATAS { char *cur_fname = "cabac_cdf_out.dat"; HalBuf *cdf_buf = NULL; @@ -2520,24 +2501,8 @@ MPP_RET vdpu383_av1d_wait(void *hal, HalTaskInfo *task) memset(dump_cur_fname_path, 0, sizeof(dump_cur_fname_path)); sprintf(dump_cur_fname_path, "%s/%s", dump_cur_dir, cur_fname); cdf_buf = hal_bufs_get_buf(reg_ctx->cdf_bufs, dxva->CurrPic.Index7Bits); - dump_data(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(cdf_buf->buf[0]), - (NON_COEF_CDF_SIZE + COEF_CDF_SIZE) * 8, 128, 0, 0); - } -#endif -#if DUMP_AV1_DATAS - { - char fname[128]; - FILE *fp_in = NULL; - static RK_U32 g_frame_no = 0; - RK_U32 *p = (RK_U32*)p_regs; - - sprintf(fname, "/data/video/reg_%d_out.txt", g_frame_no++); - fp_in = fopen(fname, "wb"); - for (i = 0; i < sizeof(*p_regs) / 4; i++, p++) - fprintf(fp_in, "reg[%3d] = %08x\n", i, *p); - - fflush(fp_in); - fclose(fp_in); + dump_data_to_file(dump_cur_fname_path, (void *)mpp_buffer_get_ptr(cdf_buf->buf[0]), + (NON_COEF_CDF_SIZE + COEF_CDF_SIZE) * 8, 128, 0, 0); } #endif