A59项目初版工程 1.电压+光感adc采样优化 2.串口逻辑优化

This commit is contained in:
2024-08-27 10:54:23 +08:00
commit 16b6433a98
14081 changed files with 6865556 additions and 0 deletions

View File

@ -0,0 +1,699 @@
HWIF_DEC_PIC_INF,
HWIF_DEC_TIMEOUT,
HWIF_DEC_SLICE_INT,
HWIF_DEC_ERROR_INT,
HWIF_DEC_ASO_INT,
HWIF_DEC_BUFFER_INT,
HWIF_DEC_BUS_INT,
HWIF_DEC_RDY_INT,
HWIF_DEC_IRQ,
HWIF_DEC_IRQ_DIS,
HWIF_DEC_E,
HWIF_DEC_AXI_RD_ID,
HWIF_DEC_TIMEOUT_E,
HWIF_DEC_STRSWAP32_E,
HWIF_DEC_STRENDIAN_E,
HWIF_DEC_INSWAP32_E,
HWIF_DEC_OUTSWAP32_E,
HWIF_DEC_DATA_DISC_E,
HWIF_TILED_MODE_MSB,
HWIF_DEC_OUT_TILED_E,
HWIF_DEC_LATENCY,
HWIF_DEC_CLK_GATE_E,
HWIF_DEC_IN_ENDIAN,
HWIF_DEC_OUT_ENDIAN,
HWIF_PRIORITY_MODE,
HWIF_TILED_MODE_LSB,
HWIF_DEC_ADV_PRE_DIS,
HWIF_DEC_SCMD_DIS,
HWIF_DEC_MAX_BURST,
HWIF_DEC_MODE,
HWIF_RLC_MODE_E,
HWIF_SKIP_MODE,
HWIF_DIVX3_E,
HWIF_PJPEG_E,
HWIF_PIC_INTERLACE_E,
HWIF_PIC_FIELDMODE_E,
HWIF_PIC_B_E,
HWIF_PIC_INTER_E,
HWIF_PIC_TOPFIELD_E,
HWIF_FWD_INTERLACE_E,
HWIF_SORENSON_E,
HWIF_REF_TOPFIELD_E,
HWIF_DEC_OUT_DIS,
HWIF_FILTERING_DIS,
HWIF_MVC_E,
HWIF_PIC_FIXED_QUANT,
HWIF_WRITE_MVS_E,
HWIF_REFTOPFIRST_E,
HWIF_SEQ_MBAFF_E,
HWIF_PICORD_COUNT_E,
HWIF_DEC_AHB_HLOCK_E,
HWIF_DEC_AXI_WR_ID,
HWIF_PIC_MB_WIDTH,
HWIF_MB_WIDTH_OFF,
HWIF_PIC_MB_HEIGHT_P,
HWIF_MB_HEIGHT_OFF,
HWIF_ALT_SCAN_E,
HWIF_TOPFIELDFIRST_E,
HWIF_REF_FRAMES,
HWIF_PIC_MB_W_EXT,
HWIF_PIC_MB_H_EXT,
HWIF_PIC_REFER_FLAG,
HWIF_STRM_START_BIT,
HWIF_SYNC_MARKER_E,
HWIF_TYPE1_QUANT_E,
HWIF_CH_QP_OFFSET,
HWIF_CH_QP_OFFSET2,
HWIF_FIELDPIC_FLAG_E,
HWIF_INTRADC_VLC_THR,
HWIF_VOP_TIME_INCR,
HWIF_DQ_PROFILE,
HWIF_DQBI_LEVEL,
HWIF_RANGE_RED_FRM_E,
HWIF_FAST_UVMC_E,
HWIF_TRANSDCTAB,
HWIF_TRANSACFRM,
HWIF_TRANSACFRM2,
HWIF_MB_MODE_TAB,
HWIF_MVTAB,
HWIF_CBPTAB,
HWIF_2MV_BLK_PAT_TAB,
HWIF_4MV_BLK_PAT_TAB,
HWIF_QSCALE_TYPE,
HWIF_CON_MV_E,
HWIF_INTRA_DC_PREC,
HWIF_INTRA_VLC_TAB,
HWIF_FRAME_PRED_DCT,
HWIF_JPEG_QTABLES,
HWIF_JPEG_MODE,
HWIF_JPEG_FILRIGHT_E,
HWIF_JPEG_STREAM_ALL,
HWIF_CR_AC_VLCTABLE,
HWIF_CB_AC_VLCTABLE,
HWIF_CR_DC_VLCTABLE,
HWIF_CB_DC_VLCTABLE,
HWIF_CR_DC_VLCTABLE3,
HWIF_CB_DC_VLCTABLE3,
HWIF_STRM1_START_BIT,
HWIF_HUFFMAN_E,
HWIF_MULTISTREAM_E,
HWIF_BOOLEAN_VALUE,
HWIF_BOOLEAN_RANGE,
HWIF_ALPHA_OFFSET,
HWIF_BETA_OFFSET,
HWIF_START_CODE_E,
HWIF_INIT_QP,
HWIF_CH_8PIX_ILEAV_E,
HWIF_STREAM_LEN,
HWIF_CABAC_E,
HWIF_BLACKWHITE_E,
HWIF_DIR_8X8_INFER_E,
HWIF_WEIGHT_PRED_E,
HWIF_WEIGHT_BIPR_IDC,
HWIF_FRAMENUM_LEN,
HWIF_FRAMENUM,
HWIF_BITPLANE0_E,
HWIF_BITPLANE1_E,
HWIF_BITPLANE2_E,
HWIF_ALT_PQUANT,
HWIF_DQ_EDGES,
HWIF_TTMBF,
HWIF_PQINDEX,
HWIF_BILIN_MC_E,
HWIF_UNIQP_E,
HWIF_HALFQP_E,
HWIF_TTFRM,
HWIF_2ND_BYTE_EMUL_E,
HWIF_DQUANT_E,
HWIF_VC1_ADV_E,
HWIF_PJPEG_FILDOWN_E,
HWIF_PJPEG_WDIV8,
HWIF_PJPEG_HDIV8,
HWIF_PJPEG_AH,
HWIF_PJPEG_AL,
HWIF_PJPEG_SS,
HWIF_PJPEG_SE,
HWIF_DCT1_START_BIT,
HWIF_DCT2_START_BIT,
HWIF_CH_MV_RES,
HWIF_INIT_DC_MATCH0,
HWIF_INIT_DC_MATCH1,
HWIF_VP7_VERSION,
HWIF_CONST_INTRA_E,
HWIF_FILT_CTRL_PRES,
HWIF_RDPIC_CNT_PRES,
HWIF_8X8TRANS_FLAG_E,
HWIF_REFPIC_MK_LEN,
HWIF_IDR_PIC_E,
HWIF_IDR_PIC_ID,
HWIF_MV_SCALEFACTOR,
HWIF_REF_DIST_FWD,
HWIF_REF_DIST_BWD,
HWIF_LOOP_FILT_LIMIT,
HWIF_VARIANCE_TEST_E,
HWIF_MV_THRESHOLD,
HWIF_VAR_THRESHOLD,
HWIF_DIVX_IDCT_E,
HWIF_DIVX3_SLICE_SIZE,
HWIF_PJPEG_REST_FREQ,
HWIF_RV_PROFILE,
HWIF_RV_OSV_QUANT,
HWIF_RV_FWD_SCALE,
HWIF_RV_BWD_SCALE,
HWIF_INIT_DC_COMP0,
HWIF_INIT_DC_COMP1,
HWIF_PPS_ID,
HWIF_REFIDX1_ACTIVE,
HWIF_REFIDX0_ACTIVE,
HWIF_POC_LENGTH,
HWIF_ICOMP0_E,
HWIF_ISCALE0,
HWIF_ISHIFT0,
HWIF_STREAM1_LEN,
HWIF_MB_CTRL_BASE,
HWIF_PIC_SLICE_AM,
HWIF_COEFFS_PART_AM,
HWIF_DIFF_MV_BASE,
HWIF_PINIT_RLIST_F9,
HWIF_PINIT_RLIST_F8,
HWIF_PINIT_RLIST_F7,
HWIF_PINIT_RLIST_F6,
HWIF_PINIT_RLIST_F5,
HWIF_PINIT_RLIST_F4,
HWIF_ICOMP1_E,
HWIF_ISCALE1,
HWIF_ISHIFT1,
HWIF_SEGMENT_BASE,
HWIF_SEGMENT_UPD_E,
HWIF_SEGMENT_E,
HWIF_I4X4_OR_DC_BASE,
HWIF_PINIT_RLIST_F15,
HWIF_PINIT_RLIST_F14,
HWIF_PINIT_RLIST_F13,
HWIF_PINIT_RLIST_F12,
HWIF_PINIT_RLIST_F11,
HWIF_PINIT_RLIST_F10,
HWIF_ICOMP2_E,
HWIF_ISCALE2,
HWIF_ISHIFT2,
HWIF_DCT3_START_BIT,
HWIF_DCT4_START_BIT,
HWIF_DCT5_START_BIT,
HWIF_DCT6_START_BIT,
HWIF_DCT7_START_BIT,
HWIF_RLC_VLC_BASE,
HWIF_DEC_OUT_BASE,
HWIF_REFER0_BASE,
HWIF_REFER0_FIELD_E,
HWIF_REFER0_TOPC_E,
HWIF_JPG_CH_OUT_BASE,
HWIF_REFER1_BASE,
HWIF_REFER1_FIELD_E,
HWIF_REFER1_TOPC_E,
HWIF_JPEG_SLICE_H,
HWIF_REFER2_BASE,
HWIF_REFER2_FIELD_E,
HWIF_REFER2_TOPC_E,
HWIF_AC1_CODE6_CNT,
HWIF_AC1_CODE5_CNT,
HWIF_AC1_CODE4_CNT,
HWIF_AC1_CODE3_CNT,
HWIF_AC1_CODE2_CNT,
HWIF_AC1_CODE1_CNT,
HWIF_REFER3_BASE,
HWIF_REFER3_FIELD_E,
HWIF_REFER3_TOPC_E,
HWIF_AC1_CODE10_CNT,
HWIF_AC1_CODE9_CNT,
HWIF_AC1_CODE8_CNT,
HWIF_AC1_CODE7_CNT,
HWIF_REFER4_BASE,
HWIF_REFER4_FIELD_E,
HWIF_REFER4_TOPC_E,
HWIF_PIC_HEADER_LEN,
HWIF_PIC_4MV_E,
HWIF_RANGE_RED_REF_E,
HWIF_VC1_DIFMV_RANGE,
HWIF_MV_RANGE,
HWIF_OVERLAP_E,
HWIF_OVERLAP_METHOD,
HWIF_ALT_SCAN_FLAG_E,
HWIF_FCODE_FWD_HOR,
HWIF_FCODE_FWD_VER,
HWIF_FCODE_BWD_HOR,
HWIF_FCODE_BWD_VER,
HWIF_MV_ACCURACY_FWD,
HWIF_MV_ACCURACY_BWD,
HWIF_MPEG4_VC1_RC,
HWIF_PREV_ANC_TYPE,
HWIF_AC1_CODE14_CNT,
HWIF_AC1_CODE13_CNT,
HWIF_AC1_CODE12_CNT,
HWIF_AC1_CODE11_CNT,
HWIF_GREF_SIGN_BIAS,
HWIF_REFER5_BASE,
HWIF_REFER5_FIELD_E,
HWIF_REFER5_TOPC_E,
HWIF_TRB_PER_TRD_D0,
HWIF_ICOMP3_E,
HWIF_ISCALE3,
HWIF_ISHIFT3,
HWIF_AC2_CODE4_CNT,
HWIF_AC2_CODE3_CNT,
HWIF_AC2_CODE2_CNT,
HWIF_AC2_CODE1_CNT,
HWIF_AC1_CODE16_CNT,
HWIF_AC1_CODE15_CNT,
HWIF_SCAN_MAP_1,
HWIF_SCAN_MAP_2,
HWIF_SCAN_MAP_3,
HWIF_SCAN_MAP_4,
HWIF_SCAN_MAP_5,
HWIF_AREF_SIGN_BIAS,
HWIF_REFER6_BASE,
HWIF_REFER6_FIELD_E,
HWIF_REFER6_TOPC_E,
HWIF_TRB_PER_TRD_DM1,
HWIF_ICOMP4_E,
HWIF_ISCALE4,
HWIF_ISHIFT4,
HWIF_AC2_CODE8_CNT,
HWIF_AC2_CODE7_CNT,
HWIF_AC2_CODE6_CNT,
HWIF_AC2_CODE5_CNT,
HWIF_SCAN_MAP_6,
HWIF_SCAN_MAP_7,
HWIF_SCAN_MAP_8,
HWIF_SCAN_MAP_9,
HWIF_SCAN_MAP_10,
HWIF_REFER7_BASE,
HWIF_REFER7_FIELD_E,
HWIF_REFER7_TOPC_E,
HWIF_TRB_PER_TRD_D1,
HWIF_AC2_CODE12_CNT,
HWIF_AC2_CODE11_CNT,
HWIF_AC2_CODE10_CNT,
HWIF_AC2_CODE9_CNT,
HWIF_SCAN_MAP_11,
HWIF_SCAN_MAP_12,
HWIF_SCAN_MAP_13,
HWIF_SCAN_MAP_14,
HWIF_SCAN_MAP_15,
HWIF_REFER8_BASE,
HWIF_DCT_STRM1_BASE,
HWIF_REFER8_FIELD_E,
HWIF_REFER8_TOPC_E,
HWIF_AC2_CODE16_CNT,
HWIF_AC2_CODE15_CNT,
HWIF_AC2_CODE14_CNT,
HWIF_AC2_CODE13_CNT,
HWIF_SCAN_MAP_16,
HWIF_SCAN_MAP_17,
HWIF_SCAN_MAP_18,
HWIF_SCAN_MAP_19,
HWIF_SCAN_MAP_20,
HWIF_REFER9_BASE,
HWIF_DCT_STRM2_BASE,
HWIF_REFER9_FIELD_E,
HWIF_REFER9_TOPC_E,
HWIF_DC1_CODE8_CNT,
HWIF_DC1_CODE7_CNT,
HWIF_DC1_CODE6_CNT,
HWIF_DC1_CODE5_CNT,
HWIF_DC1_CODE4_CNT,
HWIF_DC1_CODE3_CNT,
HWIF_DC1_CODE2_CNT,
HWIF_DC1_CODE1_CNT,
HWIF_SCAN_MAP_21,
HWIF_SCAN_MAP_22,
HWIF_SCAN_MAP_23,
HWIF_SCAN_MAP_24,
HWIF_SCAN_MAP_25,
HWIF_REFER10_BASE,
HWIF_DCT_STRM3_BASE,
HWIF_REFER10_FIELD_E,
HWIF_REFER10_TOPC_E,
HWIF_DC1_CODE16_CNT,
HWIF_DC1_CODE15_CNT,
HWIF_DC1_CODE14_CNT,
HWIF_DC1_CODE13_CNT,
HWIF_DC1_CODE12_CNT,
HWIF_DC1_CODE11_CNT,
HWIF_DC1_CODE10_CNT,
HWIF_DC1_CODE9_CNT,
HWIF_SCAN_MAP_26,
HWIF_SCAN_MAP_27,
HWIF_SCAN_MAP_28,
HWIF_SCAN_MAP_29,
HWIF_SCAN_MAP_30,
HWIF_REFER11_BASE,
HWIF_DCT_STRM4_BASE,
HWIF_REFER11_FIELD_E,
HWIF_REFER11_TOPC_E,
HWIF_DC2_CODE8_CNT,
HWIF_DC2_CODE7_CNT,
HWIF_DC2_CODE6_CNT,
HWIF_DC2_CODE5_CNT,
HWIF_DC2_CODE4_CNT,
HWIF_DC2_CODE3_CNT,
HWIF_DC2_CODE2_CNT,
HWIF_DC2_CODE1_CNT,
HWIF_SCAN_MAP_31,
HWIF_SCAN_MAP_32,
HWIF_SCAN_MAP_33,
HWIF_SCAN_MAP_34,
HWIF_SCAN_MAP_35,
HWIF_REFER12_BASE,
HWIF_DCT_STRM5_BASE,
HWIF_REFER12_FIELD_E,
HWIF_REFER12_TOPC_E,
HWIF_DC2_CODE16_CNT,
HWIF_DC2_CODE15_CNT,
HWIF_DC2_CODE14_CNT,
HWIF_DC2_CODE13_CNT,
HWIF_DC2_CODE12_CNT,
HWIF_DC2_CODE11_CNT,
HWIF_DC2_CODE10_CNT,
HWIF_DC2_CODE9_CNT,
HWIF_SCAN_MAP_36,
HWIF_SCAN_MAP_37,
HWIF_SCAN_MAP_38,
HWIF_SCAN_MAP_39,
HWIF_SCAN_MAP_40,
HWIF_REFER13_BASE,
HWIF_REFER13_FIELD_E,
HWIF_REFER13_TOPC_E,
HWIF_DC3_CODE8_CNT,
HWIF_DC3_CODE7_CNT,
HWIF_DC3_CODE6_CNT,
HWIF_DC3_CODE5_CNT,
HWIF_DC3_CODE4_CNT,
HWIF_DC3_CODE3_CNT,
HWIF_DC3_CODE2_CNT,
HWIF_DC3_CODE1_CNT,
HWIF_BITPL_CTRL_BASE,
HWIF_REFER14_BASE,
HWIF_DCT_STRM6_BASE,
HWIF_REFER14_FIELD_E,
HWIF_REFER14_TOPC_E,
HWIF_REF_INVD_CUR_1,
HWIF_REF_INVD_CUR_0,
HWIF_DC3_CODE16_CNT,
HWIF_DC3_CODE15_CNT,
HWIF_DC3_CODE14_CNT,
HWIF_DC3_CODE13_CNT,
HWIF_DC3_CODE12_CNT,
HWIF_DC3_CODE11_CNT,
HWIF_DC3_CODE10_CNT,
HWIF_DC3_CODE9_CNT,
HWIF_SCAN_MAP_41,
HWIF_SCAN_MAP_42,
HWIF_SCAN_MAP_43,
HWIF_SCAN_MAP_44,
HWIF_SCAN_MAP_45,
HWIF_REFER15_BASE,
HWIF_DCT_STRM7_BASE,
HWIF_REFER15_FIELD_E,
HWIF_REFER15_TOPC_E,
HWIF_REF_INVD_CUR_3,
HWIF_REF_INVD_CUR_2,
HWIF_SCAN_MAP_46,
HWIF_SCAN_MAP_47,
HWIF_SCAN_MAP_48,
HWIF_SCAN_MAP_49,
HWIF_SCAN_MAP_50,
HWIF_REFER1_NBR,
HWIF_REFER0_NBR,
HWIF_REF_DIST_CUR_1,
HWIF_REF_DIST_CUR_0,
HWIF_FILT_TYPE,
HWIF_FILT_SHARPNESS,
HWIF_FILT_MB_ADJ_0,
HWIF_FILT_MB_ADJ_1,
HWIF_FILT_MB_ADJ_2,
HWIF_FILT_MB_ADJ_3,
HWIF_REFER3_NBR,
HWIF_REFER2_NBR,
HWIF_SCAN_MAP_51,
HWIF_SCAN_MAP_52,
HWIF_SCAN_MAP_53,
HWIF_SCAN_MAP_54,
HWIF_SCAN_MAP_55,
HWIF_REF_DIST_CUR_3,
HWIF_REF_DIST_CUR_2,
HWIF_FILT_REF_ADJ_0,
HWIF_FILT_REF_ADJ_1,
HWIF_FILT_REF_ADJ_2,
HWIF_FILT_REF_ADJ_3,
HWIF_REFER5_NBR,
HWIF_REFER4_NBR,
HWIF_SCAN_MAP_56,
HWIF_SCAN_MAP_57,
HWIF_SCAN_MAP_58,
HWIF_SCAN_MAP_59,
HWIF_SCAN_MAP_60,
HWIF_REF_INVD_COL_1,
HWIF_REF_INVD_COL_0,
HWIF_FILT_LEVEL_0,
HWIF_FILT_LEVEL_1,
HWIF_FILT_LEVEL_2,
HWIF_FILT_LEVEL_3,
HWIF_REFER7_NBR,
HWIF_REFER6_NBR,
HWIF_SCAN_MAP_61,
HWIF_SCAN_MAP_62,
HWIF_SCAN_MAP_63,
HWIF_REF_INVD_COL_3,
HWIF_REF_INVD_COL_2,
HWIF_QUANT_DELTA_0,
HWIF_QUANT_DELTA_1,
HWIF_QUANT_0,
HWIF_QUANT_1,
HWIF_REFER9_NBR,
HWIF_REFER8_NBR,
HWIF_PRED_BC_TAP_0_3,
HWIF_PRED_BC_TAP_1_0,
HWIF_PRED_BC_TAP_1_1,
HWIF_REFER11_NBR,
HWIF_REFER10_NBR,
HWIF_PRED_BC_TAP_1_2,
HWIF_PRED_BC_TAP_1_3,
HWIF_PRED_BC_TAP_2_0,
HWIF_REFER13_NBR,
HWIF_REFER12_NBR,
HWIF_PRED_BC_TAP_2_1,
HWIF_PRED_BC_TAP_2_2,
HWIF_PRED_BC_TAP_2_3,
HWIF_REFER15_NBR,
HWIF_REFER14_NBR,
HWIF_PRED_BC_TAP_3_0,
HWIF_PRED_BC_TAP_3_1,
HWIF_PRED_BC_TAP_3_2,
HWIF_REFER_LTERM_E,
HWIF_PRED_BC_TAP_3_3,
HWIF_PRED_BC_TAP_4_0,
HWIF_PRED_BC_TAP_4_1,
HWIF_REFER_VALID_E,
HWIF_PRED_BC_TAP_4_2,
HWIF_PRED_BC_TAP_4_3,
HWIF_PRED_BC_TAP_5_0,
HWIF_QTABLE_BASE,
HWIF_DIR_MV_BASE,
HWIF_BINIT_RLIST_B2,
HWIF_BINIT_RLIST_F2,
HWIF_BINIT_RLIST_B1,
HWIF_BINIT_RLIST_F1,
HWIF_BINIT_RLIST_B0,
HWIF_BINIT_RLIST_F0,
HWIF_PRED_BC_TAP_5_1,
HWIF_PRED_BC_TAP_5_2,
HWIF_PRED_BC_TAP_5_3,
HWIF_PJPEG_DCCB_BASE,
HWIF_BINIT_RLIST_B5,
HWIF_BINIT_RLIST_F5,
HWIF_BINIT_RLIST_B4,
HWIF_BINIT_RLIST_F4,
HWIF_BINIT_RLIST_B3,
HWIF_BINIT_RLIST_F3,
HWIF_PRED_BC_TAP_6_0,
HWIF_PRED_BC_TAP_6_1,
HWIF_PRED_BC_TAP_6_2,
HWIF_PJPEG_DCCR_BASE,
HWIF_BINIT_RLIST_B8,
HWIF_BINIT_RLIST_F8,
HWIF_BINIT_RLIST_B7,
HWIF_BINIT_RLIST_F7,
HWIF_BINIT_RLIST_B6,
HWIF_BINIT_RLIST_F6,
HWIF_PRED_BC_TAP_6_3,
HWIF_PRED_BC_TAP_7_0,
HWIF_PRED_BC_TAP_7_1,
HWIF_BINIT_RLIST_B11,
HWIF_BINIT_RLIST_F11,
HWIF_BINIT_RLIST_B10,
HWIF_BINIT_RLIST_F10,
HWIF_BINIT_RLIST_B9,
HWIF_BINIT_RLIST_F9,
HWIF_PRED_BC_TAP_7_2,
HWIF_PRED_BC_TAP_7_3,
HWIF_PRED_TAP_2_M1,
HWIF_PRED_TAP_2_4,
HWIF_PRED_TAP_4_M1,
HWIF_PRED_TAP_4_4,
HWIF_PRED_TAP_6_M1,
HWIF_PRED_TAP_6_4,
HWIF_BINIT_RLIST_B14,
HWIF_BINIT_RLIST_F14,
HWIF_BINIT_RLIST_B13,
HWIF_BINIT_RLIST_F13,
HWIF_BINIT_RLIST_B12,
HWIF_BINIT_RLIST_F12,
HWIF_QUANT_DELTA_2,
HWIF_QUANT_DELTA_3,
HWIF_QUANT_2,
HWIF_QUANT_3,
HWIF_PINIT_RLIST_F3,
HWIF_PINIT_RLIST_F2,
HWIF_PINIT_RLIST_F1,
HWIF_PINIT_RLIST_F0,
HWIF_BINIT_RLIST_B15,
HWIF_BINIT_RLIST_F15,
HWIF_QUANT_DELTA_4,
HWIF_QUANT_4,
HWIF_QUANT_5,
HWIF_STARTMB_X,
HWIF_STARTMB_Y,
HWIF_PRED_BC_TAP_0_0,
HWIF_PRED_BC_TAP_0_1,
HWIF_PRED_BC_TAP_0_2,
HWIF_REFBU_E,
HWIF_REFBU_THR,
HWIF_REFBU_PICID,
HWIF_REFBU_EVAL_E,
HWIF_REFBU_FPARMOD_E,
HWIF_REFBU_Y_OFFSET,
HWIF_REFBU_HIT_SUM,
HWIF_REFBU_INTRA_SUM,
HWIF_REFBU_Y_MV_SUM,
HWIF_REFBU2_BUF_E,
HWIF_REFBU2_THR,
HWIF_REFBU2_PICID,
HWIF_APF_THRESHOLD,
HWIF_REFBU_TOP_SUM,
HWIF_REFBU_BOT_SUM,
HWIF_DEC_CH8PIX_BASE,
HWIF_PP_BUS_INT,
HWIF_PP_RDY_INT,
HWIF_PP_IRQ,
HWIF_PP_IRQ_DIS,
HWIF_PP_PIPELINE_E,
HWIF_PP_E,
HWIF_PP_AXI_RD_ID,
HWIF_PP_AXI_WR_ID,
HWIF_PP_AHB_HLOCK_E,
HWIF_PP_SCMD_DIS,
HWIF_PP_IN_A2_ENDSEL,
HWIF_PP_IN_A1_SWAP32,
HWIF_PP_IN_A1_ENDIAN,
HWIF_PP_IN_SWAP32_E,
HWIF_PP_DATA_DISC_E,
HWIF_PP_CLK_GATE_E,
HWIF_PP_IN_ENDIAN,
HWIF_PP_OUT_ENDIAN,
HWIF_PP_OUT_SWAP32_E,
HWIF_PP_MAX_BURST,
HWIF_DEINT_E,
HWIF_DEINT_THRESHOLD,
HWIF_DEINT_BLEND_E,
HWIF_DEINT_EDGE_DET,
HWIF_PP_IN_LU_BASE,
HWIF_PP_IN_CB_BASE,
HWIF_PP_IN_CR_BASE,
HWIF_PP_OUT_LU_BASE,
HWIF_PP_OUT_CH_BASE,
HWIF_CONTRAST_THR1,
HWIF_CONTRAST_OFF2,
HWIF_CONTRAST_OFF1,
HWIF_PP_IN_START_CH,
HWIF_PP_IN_CR_FIRST,
HWIF_PP_OUT_START_CH,
HWIF_PP_OUT_CR_FIRST,
HWIF_COLOR_COEFFA2,
HWIF_COLOR_COEFFA1,
HWIF_CONTRAST_THR2,
HWIF_COLOR_COEFFD,
HWIF_COLOR_COEFFC,
HWIF_COLOR_COEFFB,
HWIF_CROP_STARTX,
HWIF_ROTATION_MODE,
HWIF_COLOR_COEFFF,
HWIF_COLOR_COEFFE,
HWIF_CROP_STARTY,
HWIF_RANGEMAP_COEF_Y,
HWIF_PP_IN_HEIGHT,
HWIF_PP_IN_WIDTH,
HWIF_PP_BOT_YIN_BASE,
HWIF_PP_BOT_CIN_BASE,
HWIF_RANGEMAP_Y_E,
HWIF_RANGEMAP_C_E,
HWIF_YCBCR_RANGE,
HWIF_RGB_PIX_IN32,
HWIF_RGB_R_PADD,
HWIF_RGB_G_PADD,
HWIF_SCALE_WRATIO,
HWIF_PP_FAST_SCALE_E,
HWIF_PP_IN_STRUCT,
HWIF_HOR_SCALE_MODE,
HWIF_VER_SCALE_MODE,
HWIF_RGB_B_PADD,
HWIF_SCALE_HRATIO,
HWIF_WSCALE_INVRA,
HWIF_HSCALE_INVRA,
HWIF_R_MASK,
HWIF_G_MASK,
HWIF_B_MASK,
HWIF_PP_IN_FORMAT,
HWIF_PP_OUT_FORMAT,
HWIF_PP_OUT_HEIGHT,
HWIF_PP_OUT_WIDTH,
HWIF_PP_OUT_TILED_E,
HWIF_PP_OUT_SWAP16_E,
HWIF_PP_CROP8_R_E,
HWIF_PP_CROP8_D_E,
HWIF_PP_IN_FORMAT_ES,
HWIF_RANGEMAP_COEF_C,
HWIF_MASK1_ABLEND_E,
HWIF_MASK1_STARTY,
HWIF_MASK1_STARTX,
HWIF_MASK2_ABLEND_E,
HWIF_MASK2_STARTY,
HWIF_MASK2_STARTX,
HWIF_EXT_ORIG_WIDTH,
HWIF_MASK1_E,
HWIF_MASK1_ENDY,
HWIF_MASK1_ENDX,
HWIF_MASK2_E,
HWIF_MASK2_ENDY,
HWIF_MASK2_ENDX,
HWIF_RIGHT_CROSS_E,
HWIF_LEFT_CROSS_E,
HWIF_UP_CROSS_E,
HWIF_DOWN_CROSS_E,
HWIF_UP_CROSS,
HWIF_DOWN_CROSS,
HWIF_DITHER_SELECT_R,
HWIF_DITHER_SELECT_G,
HWIF_DITHER_SELECT_B,
HWIF_PP_TILED_MODE,
HWIF_RIGHT_CROSS,
HWIF_LEFT_CROSS,
HWIF_PP_IN_H_EXT,
HWIF_PP_IN_W_EXT,
HWIF_CROP_STARTY_EXT,
HWIF_CROP_STARTX_EXT,
HWIF_DISPLAY_WIDTH,
HWIF_ABLEND1_BASE,
HWIF_ABLEND2_BASE,
HWIF_ABLEND2_SCANL,
HWIF_ABLEND1_SCANL,

View File

@ -0,0 +1,699 @@
/* HWIF_DEC_PIC_INF */ {/*swreg*/1 , 1, 24},
/* HWIF_DEC_TIMEOUT */ {/*swreg*/1 , 1, 18},
/* HWIF_DEC_SLICE_INT */ {/*swreg*/1 , 1, 17},
/* HWIF_DEC_ERROR_INT */ {/*swreg*/1 , 1, 16},
/* HWIF_DEC_ASO_INT */ {/*swreg*/1 , 1, 15},
/* HWIF_DEC_BUFFER_INT */ {/*swreg*/1 , 1, 14},
/* HWIF_DEC_BUS_INT */ {/*swreg*/1 , 1, 13},
/* HWIF_DEC_RDY_INT */ {/*swreg*/1 , 1, 12},
/* HWIF_DEC_IRQ */ {/*swreg*/1 , 1, 8},
/* HWIF_DEC_IRQ_DIS */ {/*swreg*/1 , 1, 4},
/* HWIF_DEC_E */ {/*swreg*/1 , 1, 0},
/* HWIF_DEC_AXI_RD_ID */ {/*swreg*/2 , 8, 24},
/* HWIF_DEC_TIMEOUT_E */ {/*swreg*/2 , 1, 23},
/* HWIF_DEC_STRSWAP32_E */ {/*swreg*/2 , 1, 22},
/* HWIF_DEC_STRENDIAN_E */ {/*swreg*/2 , 1, 21},
/* HWIF_DEC_INSWAP32_E */ {/*swreg*/2 , 1, 20},
/* HWIF_DEC_OUTSWAP32_E */ {/*swreg*/2 , 1, 19},
/* HWIF_DEC_DATA_DISC_E */ {/*swreg*/2 , 1, 18},
/* HWIF_TILED_MODE_MSB */ {/*swreg*/2 , 1, 17},
/* HWIF_DEC_OUT_TILED_E */ {/*swreg*/2 , 1, 17},
/* HWIF_DEC_LATENCY */ {/*swreg*/2 , 6, 11},
/* HWIF_DEC_CLK_GATE_E */ {/*swreg*/2 , 1, 10},
/* HWIF_DEC_IN_ENDIAN */ {/*swreg*/2 , 1, 9},
/* HWIF_DEC_OUT_ENDIAN */ {/*swreg*/2 , 1, 8},
/* HWIF_PRIORITY_MODE */ {/*swreg*/2 , 3, 5},
/* HWIF_TILED_MODE_LSB */ {/*swreg*/2 , 1, 7},
/* HWIF_DEC_ADV_PRE_DIS */ {/*swreg*/2 , 1, 6},
/* HWIF_DEC_SCMD_DIS */ {/*swreg*/2 , 1, 5},
/* HWIF_DEC_MAX_BURST */ {/*swreg*/2 , 5, 0},
/* HWIF_DEC_MODE */ {/*swreg*/3 , 4, 28},
/* HWIF_RLC_MODE_E */ {/*swreg*/3 , 1, 27},
/* HWIF_SKIP_MODE */ {/*swreg*/3 , 1, 26},
/* HWIF_DIVX3_E */ {/*swreg*/3 , 1, 25},
/* HWIF_PJPEG_E */ {/*swreg*/3 , 1, 24},
/* HWIF_PIC_INTERLACE_E */ {/*swreg*/3 , 1, 23},
/* HWIF_PIC_FIELDMODE_E */ {/*swreg*/3 , 1, 22},
/* HWIF_PIC_B_E */ {/*swreg*/3 , 1, 21},
/* HWIF_PIC_INTER_E */ {/*swreg*/3 , 1, 20},
/* HWIF_PIC_TOPFIELD_E */ {/*swreg*/3 , 1, 19},
/* HWIF_FWD_INTERLACE_E */ {/*swreg*/3 , 1, 18},
/* HWIF_SORENSON_E */ {/*swreg*/3 , 1, 17},
/* HWIF_REF_TOPFIELD_E */ {/*swreg*/3 , 1, 16},
/* HWIF_DEC_OUT_DIS */ {/*swreg*/3 , 1, 15},
/* HWIF_FILTERING_DIS */ {/*swreg*/3 , 1, 14},
/* HWIF_MVC_E */ {/*swreg*/3 , 1, 13},
/* HWIF_PIC_FIXED_QUANT */ {/*swreg*/3 , 1, 13},
/* HWIF_WRITE_MVS_E */ {/*swreg*/3 , 1, 12},
/* HWIF_REFTOPFIRST_E */ {/*swreg*/3 , 1, 11},
/* HWIF_SEQ_MBAFF_E */ {/*swreg*/3 , 1, 10},
/* HWIF_PICORD_COUNT_E */ {/*swreg*/3 , 1, 9},
/* HWIF_DEC_AHB_HLOCK_E */ {/*swreg*/3 , 1, 8},
/* HWIF_DEC_AXI_WR_ID */ {/*swreg*/3 , 8, 0},
/* HWIF_PIC_MB_WIDTH */ {/*swreg*/4 , 9, 23},
/* HWIF_MB_WIDTH_OFF */ {/*swreg*/4 , 4, 19},
/* HWIF_PIC_MB_HEIGHT_P */ {/*swreg*/4 , 8, 11},
/* HWIF_MB_HEIGHT_OFF */ {/*swreg*/4 , 4, 7},
/* HWIF_ALT_SCAN_E */ {/*swreg*/4 , 1, 6},
/* HWIF_TOPFIELDFIRST_E */ {/*swreg*/4 , 1, 5},
/* HWIF_REF_FRAMES */ {/*swreg*/4 , 5, 0},
/* HWIF_PIC_MB_W_EXT */ {/*swreg*/4 , 3, 3},
/* HWIF_PIC_MB_H_EXT */ {/*swreg*/4 , 3, 0},
/* HWIF_PIC_REFER_FLAG */ {/*swreg*/4 , 1, 0},
/* HWIF_STRM_START_BIT */ {/*swreg*/5 , 6, 26},
/* HWIF_SYNC_MARKER_E */ {/*swreg*/5 , 1, 25},
/* HWIF_TYPE1_QUANT_E */ {/*swreg*/5 , 1, 24},
/* HWIF_CH_QP_OFFSET */ {/*swreg*/5 , 5, 19},
/* HWIF_CH_QP_OFFSET2 */ {/*swreg*/5 , 5, 14},
/* HWIF_FIELDPIC_FLAG_E */ {/*swreg*/5 , 1, 0},
/* HWIF_INTRADC_VLC_THR */ {/*swreg*/5 , 3, 16},
/* HWIF_VOP_TIME_INCR */ {/*swreg*/5 , 16, 0},
/* HWIF_DQ_PROFILE */ {/*swreg*/5 , 1, 24},
/* HWIF_DQBI_LEVEL */ {/*swreg*/5 , 1, 23},
/* HWIF_RANGE_RED_FRM_E */ {/*swreg*/5 , 1, 22},
/* HWIF_FAST_UVMC_E */ {/*swreg*/5 , 1, 20},
/* HWIF_TRANSDCTAB */ {/*swreg*/5 , 1, 17},
/* HWIF_TRANSACFRM */ {/*swreg*/5 , 2, 15},
/* HWIF_TRANSACFRM2 */ {/*swreg*/5 , 2, 13},
/* HWIF_MB_MODE_TAB */ {/*swreg*/5 , 3, 10},
/* HWIF_MVTAB */ {/*swreg*/5 , 3, 7},
/* HWIF_CBPTAB */ {/*swreg*/5 , 3, 4},
/* HWIF_2MV_BLK_PAT_TAB */ {/*swreg*/5 , 2, 2},
/* HWIF_4MV_BLK_PAT_TAB */ {/*swreg*/5 , 2, 0},
/* HWIF_QSCALE_TYPE */ {/*swreg*/5 , 1, 24},
/* HWIF_CON_MV_E */ {/*swreg*/5 , 1, 4},
/* HWIF_INTRA_DC_PREC */ {/*swreg*/5 , 2, 2},
/* HWIF_INTRA_VLC_TAB */ {/*swreg*/5 , 1, 1},
/* HWIF_FRAME_PRED_DCT */ {/*swreg*/5 , 1, 0},
/* HWIF_JPEG_QTABLES */ {/*swreg*/5 , 2, 11},
/* HWIF_JPEG_MODE */ {/*swreg*/5 , 3, 8},
/* HWIF_JPEG_FILRIGHT_E */ {/*swreg*/5 , 1, 7},
/* HWIF_JPEG_STREAM_ALL */ {/*swreg*/5 , 1, 6},
/* HWIF_CR_AC_VLCTABLE */ {/*swreg*/5 , 1, 5},
/* HWIF_CB_AC_VLCTABLE */ {/*swreg*/5 , 1, 4},
/* HWIF_CR_DC_VLCTABLE */ {/*swreg*/5 , 1, 3},
/* HWIF_CB_DC_VLCTABLE */ {/*swreg*/5 , 1, 2},
/* HWIF_CR_DC_VLCTABLE3 */ {/*swreg*/5 , 1, 1},
/* HWIF_CB_DC_VLCTABLE3 */ {/*swreg*/5 , 1, 0},
/* HWIF_STRM1_START_BIT */ {/*swreg*/5 , 6, 18},
/* HWIF_HUFFMAN_E */ {/*swreg*/5 , 1, 17},
/* HWIF_MULTISTREAM_E */ {/*swreg*/5 , 1, 16},
/* HWIF_BOOLEAN_VALUE */ {/*swreg*/5 , 8, 8},
/* HWIF_BOOLEAN_RANGE */ {/*swreg*/5 , 8, 0},
/* HWIF_ALPHA_OFFSET */ {/*swreg*/5 , 5, 5},
/* HWIF_BETA_OFFSET */ {/*swreg*/5 , 5, 0},
/* HWIF_START_CODE_E */ {/*swreg*/6 , 1, 31},
/* HWIF_INIT_QP */ {/*swreg*/6 , 6, 25},
/* HWIF_CH_8PIX_ILEAV_E */ {/*swreg*/6 , 1, 24},
/* HWIF_STREAM_LEN */ {/*swreg*/6 , 24, 0},
/* HWIF_CABAC_E */ {/*swreg*/7 , 1, 31},
/* HWIF_BLACKWHITE_E */ {/*swreg*/7 , 1, 30},
/* HWIF_DIR_8X8_INFER_E */ {/*swreg*/7 , 1, 29},
/* HWIF_WEIGHT_PRED_E */ {/*swreg*/7 , 1, 28},
/* HWIF_WEIGHT_BIPR_IDC */ {/*swreg*/7 , 2, 26},
/* HWIF_FRAMENUM_LEN */ {/*swreg*/7 , 5, 16},
/* HWIF_FRAMENUM */ {/*swreg*/7 , 16, 0},
/* HWIF_BITPLANE0_E */ {/*swreg*/7 , 1, 31},
/* HWIF_BITPLANE1_E */ {/*swreg*/7 , 1, 30},
/* HWIF_BITPLANE2_E */ {/*swreg*/7 , 1, 29},
/* HWIF_ALT_PQUANT */ {/*swreg*/7 , 5, 24},
/* HWIF_DQ_EDGES */ {/*swreg*/7 , 4, 20},
/* HWIF_TTMBF */ {/*swreg*/7 , 1, 19},
/* HWIF_PQINDEX */ {/*swreg*/7 , 5, 14},
/* HWIF_BILIN_MC_E */ {/*swreg*/7 , 1, 12},
/* HWIF_UNIQP_E */ {/*swreg*/7 , 1, 11},
/* HWIF_HALFQP_E */ {/*swreg*/7 , 1, 10},
/* HWIF_TTFRM */ {/*swreg*/7 , 2, 8},
/* HWIF_2ND_BYTE_EMUL_E */ {/*swreg*/7 , 1, 7},
/* HWIF_DQUANT_E */ {/*swreg*/7 , 1, 6},
/* HWIF_VC1_ADV_E */ {/*swreg*/7 , 1, 5},
/* HWIF_PJPEG_FILDOWN_E */ {/*swreg*/7 , 1, 26},
/* HWIF_PJPEG_WDIV8 */ {/*swreg*/7 , 1, 25},
/* HWIF_PJPEG_HDIV8 */ {/*swreg*/7 , 1, 24},
/* HWIF_PJPEG_AH */ {/*swreg*/7 , 4, 20},
/* HWIF_PJPEG_AL */ {/*swreg*/7 , 4, 16},
/* HWIF_PJPEG_SS */ {/*swreg*/7 , 8, 8},
/* HWIF_PJPEG_SE */ {/*swreg*/7 , 8, 0},
/* HWIF_DCT1_START_BIT */ {/*swreg*/7 , 6, 26},
/* HWIF_DCT2_START_BIT */ {/*swreg*/7 , 6, 20},
/* HWIF_CH_MV_RES */ {/*swreg*/7 , 1, 13},
/* HWIF_INIT_DC_MATCH0 */ {/*swreg*/7 , 3, 9},
/* HWIF_INIT_DC_MATCH1 */ {/*swreg*/7 , 3, 6},
/* HWIF_VP7_VERSION */ {/*swreg*/7 , 1, 5},
/* HWIF_CONST_INTRA_E */ {/*swreg*/8 , 1, 31},
/* HWIF_FILT_CTRL_PRES */ {/*swreg*/8 , 1, 30},
/* HWIF_RDPIC_CNT_PRES */ {/*swreg*/8 , 1, 29},
/* HWIF_8X8TRANS_FLAG_E */ {/*swreg*/8 , 1, 28},
/* HWIF_REFPIC_MK_LEN */ {/*swreg*/8 , 11, 17},
/* HWIF_IDR_PIC_E */ {/*swreg*/8 , 1, 16},
/* HWIF_IDR_PIC_ID */ {/*swreg*/8 , 16, 0},
/* HWIF_MV_SCALEFACTOR */ {/*swreg*/8 , 8, 24},
/* HWIF_REF_DIST_FWD */ {/*swreg*/8 , 5, 19},
/* HWIF_REF_DIST_BWD */ {/*swreg*/8 , 5, 14},
/* HWIF_LOOP_FILT_LIMIT */ {/*swreg*/8 , 4, 14},
/* HWIF_VARIANCE_TEST_E */ {/*swreg*/8 , 1, 13},
/* HWIF_MV_THRESHOLD */ {/*swreg*/8 , 3, 10},
/* HWIF_VAR_THRESHOLD */ {/*swreg*/8 , 10, 0},
/* HWIF_DIVX_IDCT_E */ {/*swreg*/8 , 1, 8},
/* HWIF_DIVX3_SLICE_SIZE */ {/*swreg*/8 , 8, 0},
/* HWIF_PJPEG_REST_FREQ */ {/*swreg*/8 , 16, 0},
/* HWIF_RV_PROFILE */ {/*swreg*/8 , 2, 30},
/* HWIF_RV_OSV_QUANT */ {/*swreg*/8 , 2, 28},
/* HWIF_RV_FWD_SCALE */ {/*swreg*/8 , 14, 14},
/* HWIF_RV_BWD_SCALE */ {/*swreg*/8 , 14, 0},
/* HWIF_INIT_DC_COMP0 */ {/*swreg*/8 , 16, 16},
/* HWIF_INIT_DC_COMP1 */ {/*swreg*/8 , 16, 0},
/* HWIF_PPS_ID */ {/*swreg*/9 , 8, 24},
/* HWIF_REFIDX1_ACTIVE */ {/*swreg*/9 , 5, 19},
/* HWIF_REFIDX0_ACTIVE */ {/*swreg*/9 , 5, 14},
/* HWIF_POC_LENGTH */ {/*swreg*/9 , 8, 0},
/* HWIF_ICOMP0_E */ {/*swreg*/9 , 1, 24},
/* HWIF_ISCALE0 */ {/*swreg*/9 , 8, 16},
/* HWIF_ISHIFT0 */ {/*swreg*/9 , 16, 0},
/* HWIF_STREAM1_LEN */ {/*swreg*/9 , 24, 0},
/* HWIF_MB_CTRL_BASE */ {/*swreg*/9 , 32, 0},
/* HWIF_PIC_SLICE_AM */ {/*swreg*/9 , 13, 0},
/* HWIF_COEFFS_PART_AM */ {/*swreg*/9 , 4, 24},
/* HWIF_DIFF_MV_BASE */ {/*swreg*/10, 32, 0},
/* HWIF_PINIT_RLIST_F9 */ {/*swreg*/10, 5, 25},
/* HWIF_PINIT_RLIST_F8 */ {/*swreg*/10, 5, 20},
/* HWIF_PINIT_RLIST_F7 */ {/*swreg*/10, 5, 15},
/* HWIF_PINIT_RLIST_F6 */ {/*swreg*/10, 5, 10},
/* HWIF_PINIT_RLIST_F5 */ {/*swreg*/10, 5, 5},
/* HWIF_PINIT_RLIST_F4 */ {/*swreg*/10, 5, 0},
/* HWIF_ICOMP1_E */ {/*swreg*/10, 1, 24},
/* HWIF_ISCALE1 */ {/*swreg*/10, 8, 16},
/* HWIF_ISHIFT1 */ {/*swreg*/10, 16, 0},
/* HWIF_SEGMENT_BASE */ {/*swreg*/10, 32, 0},
/* HWIF_SEGMENT_UPD_E */ {/*swreg*/10, 1, 1},
/* HWIF_SEGMENT_E */ {/*swreg*/10, 1, 0},
/* HWIF_I4X4_OR_DC_BASE */ {/*swreg*/11, 32, 0},
/* HWIF_PINIT_RLIST_F15 */ {/*swreg*/11, 5, 25},
/* HWIF_PINIT_RLIST_F14 */ {/*swreg*/11, 5, 20},
/* HWIF_PINIT_RLIST_F13 */ {/*swreg*/11, 5, 15},
/* HWIF_PINIT_RLIST_F12 */ {/*swreg*/11, 5, 10},
/* HWIF_PINIT_RLIST_F11 */ {/*swreg*/11, 5, 5},
/* HWIF_PINIT_RLIST_F10 */ {/*swreg*/11, 5, 0},
/* HWIF_ICOMP2_E */ {/*swreg*/11, 1, 24},
/* HWIF_ISCALE2 */ {/*swreg*/11, 8, 16},
/* HWIF_ISHIFT2 */ {/*swreg*/11, 16, 0},
/* HWIF_DCT3_START_BIT */ {/*swreg*/11, 6, 24},
/* HWIF_DCT4_START_BIT */ {/*swreg*/11, 6, 18},
/* HWIF_DCT5_START_BIT */ {/*swreg*/11, 6, 12},
/* HWIF_DCT6_START_BIT */ {/*swreg*/11, 6, 6},
/* HWIF_DCT7_START_BIT */ {/*swreg*/11, 6, 0},
/* HWIF_RLC_VLC_BASE */ {/*swreg*/12, 32, 0},
/* HWIF_DEC_OUT_BASE */ {/*swreg*/13, 32, 0},
/* HWIF_REFER0_BASE */ {/*swreg*/14, 32, 0},
/* HWIF_REFER0_FIELD_E */ {/*swreg*/14, 1, 1},
/* HWIF_REFER0_TOPC_E */ {/*swreg*/14, 1, 0},
/* HWIF_JPG_CH_OUT_BASE */ {/*swreg*/14, 32, 0},
/* HWIF_REFER1_BASE */ {/*swreg*/15, 32, 0},
/* HWIF_REFER1_FIELD_E */ {/*swreg*/15, 1, 1},
/* HWIF_REFER1_TOPC_E */ {/*swreg*/15, 1, 0},
/* HWIF_JPEG_SLICE_H */ {/*swreg*/15, 8, 0},
/* HWIF_REFER2_BASE */ {/*swreg*/16, 32, 0},
/* HWIF_REFER2_FIELD_E */ {/*swreg*/16, 1, 1},
/* HWIF_REFER2_TOPC_E */ {/*swreg*/16, 1, 0},
/* HWIF_AC1_CODE6_CNT */ {/*swreg*/16, 7, 24},
/* HWIF_AC1_CODE5_CNT */ {/*swreg*/16, 6, 16},
/* HWIF_AC1_CODE4_CNT */ {/*swreg*/16, 5, 11},
/* HWIF_AC1_CODE3_CNT */ {/*swreg*/16, 4, 7},
/* HWIF_AC1_CODE2_CNT */ {/*swreg*/16, 3, 3},
/* HWIF_AC1_CODE1_CNT */ {/*swreg*/16, 2, 0},
/* HWIF_REFER3_BASE */ {/*swreg*/17, 32, 0},
/* HWIF_REFER3_FIELD_E */ {/*swreg*/17, 1, 1},
/* HWIF_REFER3_TOPC_E */ {/*swreg*/17, 1, 0},
/* HWIF_AC1_CODE10_CNT */ {/*swreg*/17, 8, 24},
/* HWIF_AC1_CODE9_CNT */ {/*swreg*/17, 8, 16},
/* HWIF_AC1_CODE8_CNT */ {/*swreg*/17, 8, 8},
/* HWIF_AC1_CODE7_CNT */ {/*swreg*/17, 8, 0},
/* HWIF_REFER4_BASE */ {/*swreg*/18, 32, 0},
/* HWIF_REFER4_FIELD_E */ {/*swreg*/18, 1, 1},
/* HWIF_REFER4_TOPC_E */ {/*swreg*/18, 1, 0},
/* HWIF_PIC_HEADER_LEN */ {/*swreg*/18, 16, 16},
/* HWIF_PIC_4MV_E */ {/*swreg*/18, 1, 13},
/* HWIF_RANGE_RED_REF_E */ {/*swreg*/18, 1, 11},
/* HWIF_VC1_DIFMV_RANGE */ {/*swreg*/18, 2, 9},
/* HWIF_MV_RANGE */ {/*swreg*/18, 2, 6},
/* HWIF_OVERLAP_E */ {/*swreg*/18, 1, 5},
/* HWIF_OVERLAP_METHOD */ {/*swreg*/18, 2, 3},
/* HWIF_ALT_SCAN_FLAG_E */ {/*swreg*/18, 1, 19},
/* HWIF_FCODE_FWD_HOR */ {/*swreg*/18, 4, 15},
/* HWIF_FCODE_FWD_VER */ {/*swreg*/18, 4, 11},
/* HWIF_FCODE_BWD_HOR */ {/*swreg*/18, 4, 7},
/* HWIF_FCODE_BWD_VER */ {/*swreg*/18, 4, 3},
/* HWIF_MV_ACCURACY_FWD */ {/*swreg*/18, 1, 2},
/* HWIF_MV_ACCURACY_BWD */ {/*swreg*/18, 1, 1},
/* HWIF_MPEG4_VC1_RC */ {/*swreg*/18, 1, 1},
/* HWIF_PREV_ANC_TYPE */ {/*swreg*/18, 1, 0},
/* HWIF_AC1_CODE14_CNT */ {/*swreg*/18, 8, 24},
/* HWIF_AC1_CODE13_CNT */ {/*swreg*/18, 8, 16},
/* HWIF_AC1_CODE12_CNT */ {/*swreg*/18, 8, 8},
/* HWIF_AC1_CODE11_CNT */ {/*swreg*/18, 8, 0},
/* HWIF_GREF_SIGN_BIAS */ {/*swreg*/18, 1, 0},
/* HWIF_REFER5_BASE */ {/*swreg*/19, 32, 0},
/* HWIF_REFER5_FIELD_E */ {/*swreg*/19, 1, 1},
/* HWIF_REFER5_TOPC_E */ {/*swreg*/19, 1, 0},
/* HWIF_TRB_PER_TRD_D0 */ {/*swreg*/19, 27, 0},
/* HWIF_ICOMP3_E */ {/*swreg*/19, 1, 24},
/* HWIF_ISCALE3 */ {/*swreg*/19, 8, 16},
/* HWIF_ISHIFT3 */ {/*swreg*/19, 16, 0},
/* HWIF_AC2_CODE4_CNT */ {/*swreg*/19, 5, 27},
/* HWIF_AC2_CODE3_CNT */ {/*swreg*/19, 4, 23},
/* HWIF_AC2_CODE2_CNT */ {/*swreg*/19, 3, 19},
/* HWIF_AC2_CODE1_CNT */ {/*swreg*/19, 2, 16},
/* HWIF_AC1_CODE16_CNT */ {/*swreg*/19, 8, 8},
/* HWIF_AC1_CODE15_CNT */ {/*swreg*/19, 8, 0},
/* HWIF_SCAN_MAP_1 */ {/*swreg*/19, 6, 24},
/* HWIF_SCAN_MAP_2 */ {/*swreg*/19, 6, 18},
/* HWIF_SCAN_MAP_3 */ {/*swreg*/19, 6, 12},
/* HWIF_SCAN_MAP_4 */ {/*swreg*/19, 6, 6},
/* HWIF_SCAN_MAP_5 */ {/*swreg*/19, 6, 0},
/* HWIF_AREF_SIGN_BIAS */ {/*swreg*/19, 1, 0},
/* HWIF_REFER6_BASE */ {/*swreg*/20, 32, 0},
/* HWIF_REFER6_FIELD_E */ {/*swreg*/20, 1, 1},
/* HWIF_REFER6_TOPC_E */ {/*swreg*/20, 1, 0},
/* HWIF_TRB_PER_TRD_DM1 */ {/*swreg*/20, 27, 0},
/* HWIF_ICOMP4_E */ {/*swreg*/20, 1, 24},
/* HWIF_ISCALE4 */ {/*swreg*/20, 8, 16},
/* HWIF_ISHIFT4 */ {/*swreg*/20, 16, 0},
/* HWIF_AC2_CODE8_CNT */ {/*swreg*/20, 8, 24},
/* HWIF_AC2_CODE7_CNT */ {/*swreg*/20, 8, 16},
/* HWIF_AC2_CODE6_CNT */ {/*swreg*/20, 7, 8},
/* HWIF_AC2_CODE5_CNT */ {/*swreg*/20, 6, 0},
/* HWIF_SCAN_MAP_6 */ {/*swreg*/20, 6, 24},
/* HWIF_SCAN_MAP_7 */ {/*swreg*/20, 6, 18},
/* HWIF_SCAN_MAP_8 */ {/*swreg*/20, 6, 12},
/* HWIF_SCAN_MAP_9 */ {/*swreg*/20, 6, 6},
/* HWIF_SCAN_MAP_10 */ {/*swreg*/20, 6, 0},
/* HWIF_REFER7_BASE */ {/*swreg*/21, 32, 0},
/* HWIF_REFER7_FIELD_E */ {/*swreg*/21, 1, 1},
/* HWIF_REFER7_TOPC_E */ {/*swreg*/21, 1, 0},
/* HWIF_TRB_PER_TRD_D1 */ {/*swreg*/21, 27, 0},
/* HWIF_AC2_CODE12_CNT */ {/*swreg*/21, 8, 24},
/* HWIF_AC2_CODE11_CNT */ {/*swreg*/21, 8, 16},
/* HWIF_AC2_CODE10_CNT */ {/*swreg*/21, 8, 8},
/* HWIF_AC2_CODE9_CNT */ {/*swreg*/21, 8, 0},
/* HWIF_SCAN_MAP_11 */ {/*swreg*/21, 6, 24},
/* HWIF_SCAN_MAP_12 */ {/*swreg*/21, 6, 18},
/* HWIF_SCAN_MAP_13 */ {/*swreg*/21, 6, 12},
/* HWIF_SCAN_MAP_14 */ {/*swreg*/21, 6, 6},
/* HWIF_SCAN_MAP_15 */ {/*swreg*/21, 6, 0},
/* HWIF_REFER8_BASE */ {/*swreg*/22, 32, 0},
/* HWIF_DCT_STRM1_BASE */ {/*swreg*/22, 32, 0},
/* HWIF_REFER8_FIELD_E */ {/*swreg*/22, 1, 1},
/* HWIF_REFER8_TOPC_E */ {/*swreg*/22, 1, 0},
/* HWIF_AC2_CODE16_CNT */ {/*swreg*/22, 8, 24},
/* HWIF_AC2_CODE15_CNT */ {/*swreg*/22, 8, 16},
/* HWIF_AC2_CODE14_CNT */ {/*swreg*/22, 8, 8},
/* HWIF_AC2_CODE13_CNT */ {/*swreg*/22, 8, 0},
/* HWIF_SCAN_MAP_16 */ {/*swreg*/22, 6, 24},
/* HWIF_SCAN_MAP_17 */ {/*swreg*/22, 6, 18},
/* HWIF_SCAN_MAP_18 */ {/*swreg*/22, 6, 12},
/* HWIF_SCAN_MAP_19 */ {/*swreg*/22, 6, 6},
/* HWIF_SCAN_MAP_20 */ {/*swreg*/22, 6, 0},
/* HWIF_REFER9_BASE */ {/*swreg*/23, 32, 0},
/* HWIF_DCT_STRM2_BASE */ {/*swreg*/23, 32, 0},
/* HWIF_REFER9_FIELD_E */ {/*swreg*/23, 1, 1},
/* HWIF_REFER9_TOPC_E */ {/*swreg*/23, 1, 0},
/* HWIF_DC1_CODE8_CNT */ {/*swreg*/23, 4, 28},
/* HWIF_DC1_CODE7_CNT */ {/*swreg*/23, 4, 24},
/* HWIF_DC1_CODE6_CNT */ {/*swreg*/23, 4, 20},
/* HWIF_DC1_CODE5_CNT */ {/*swreg*/23, 4, 16},
/* HWIF_DC1_CODE4_CNT */ {/*swreg*/23, 4, 12},
/* HWIF_DC1_CODE3_CNT */ {/*swreg*/23, 4, 8},
/* HWIF_DC1_CODE2_CNT */ {/*swreg*/23, 3, 4},
/* HWIF_DC1_CODE1_CNT */ {/*swreg*/23, 2, 0},
/* HWIF_SCAN_MAP_21 */ {/*swreg*/23, 6, 24},
/* HWIF_SCAN_MAP_22 */ {/*swreg*/23, 6, 18},
/* HWIF_SCAN_MAP_23 */ {/*swreg*/23, 6, 12},
/* HWIF_SCAN_MAP_24 */ {/*swreg*/23, 6, 6},
/* HWIF_SCAN_MAP_25 */ {/*swreg*/23, 6, 0},
/* HWIF_REFER10_BASE */ {/*swreg*/24, 32, 0},
/* HWIF_DCT_STRM3_BASE */ {/*swreg*/24, 32, 0},
/* HWIF_REFER10_FIELD_E */ {/*swreg*/24, 1, 1},
/* HWIF_REFER10_TOPC_E */ {/*swreg*/24, 1, 0},
/* HWIF_DC1_CODE16_CNT */ {/*swreg*/24, 4, 28},
/* HWIF_DC1_CODE15_CNT */ {/*swreg*/24, 4, 24},
/* HWIF_DC1_CODE14_CNT */ {/*swreg*/24, 4, 20},
/* HWIF_DC1_CODE13_CNT */ {/*swreg*/24, 4, 16},
/* HWIF_DC1_CODE12_CNT */ {/*swreg*/24, 4, 12},
/* HWIF_DC1_CODE11_CNT */ {/*swreg*/24, 4, 8},
/* HWIF_DC1_CODE10_CNT */ {/*swreg*/24, 4, 4},
/* HWIF_DC1_CODE9_CNT */ {/*swreg*/24, 4, 0},
/* HWIF_SCAN_MAP_26 */ {/*swreg*/24, 6, 24},
/* HWIF_SCAN_MAP_27 */ {/*swreg*/24, 6, 18},
/* HWIF_SCAN_MAP_28 */ {/*swreg*/24, 6, 12},
/* HWIF_SCAN_MAP_29 */ {/*swreg*/24, 6, 6},
/* HWIF_SCAN_MAP_30 */ {/*swreg*/24, 6, 0},
/* HWIF_REFER11_BASE */ {/*swreg*/25, 32, 0},
/* HWIF_DCT_STRM4_BASE */ {/*swreg*/25, 32, 0},
/* HWIF_REFER11_FIELD_E */ {/*swreg*/25, 1, 1},
/* HWIF_REFER11_TOPC_E */ {/*swreg*/25, 1, 0},
/* HWIF_DC2_CODE8_CNT */ {/*swreg*/25, 4, 28},
/* HWIF_DC2_CODE7_CNT */ {/*swreg*/25, 4, 24},
/* HWIF_DC2_CODE6_CNT */ {/*swreg*/25, 4, 20},
/* HWIF_DC2_CODE5_CNT */ {/*swreg*/25, 4, 16},
/* HWIF_DC2_CODE4_CNT */ {/*swreg*/25, 4, 12},
/* HWIF_DC2_CODE3_CNT */ {/*swreg*/25, 4, 8},
/* HWIF_DC2_CODE2_CNT */ {/*swreg*/25, 3, 4},
/* HWIF_DC2_CODE1_CNT */ {/*swreg*/25, 2, 0},
/* HWIF_SCAN_MAP_31 */ {/*swreg*/25, 6, 24},
/* HWIF_SCAN_MAP_32 */ {/*swreg*/25, 6, 18},
/* HWIF_SCAN_MAP_33 */ {/*swreg*/25, 6, 12},
/* HWIF_SCAN_MAP_34 */ {/*swreg*/25, 6, 6},
/* HWIF_SCAN_MAP_35 */ {/*swreg*/25, 6, 0},
/* HWIF_REFER12_BASE */ {/*swreg*/26, 32, 0},
/* HWIF_DCT_STRM5_BASE */ {/*swreg*/26, 32, 0},
/* HWIF_REFER12_FIELD_E */ {/*swreg*/26, 1, 1},
/* HWIF_REFER12_TOPC_E */ {/*swreg*/26, 1, 0},
/* HWIF_DC2_CODE16_CNT */ {/*swreg*/26, 4, 28},
/* HWIF_DC2_CODE15_CNT */ {/*swreg*/26, 4, 24},
/* HWIF_DC2_CODE14_CNT */ {/*swreg*/26, 4, 20},
/* HWIF_DC2_CODE13_CNT */ {/*swreg*/26, 4, 16},
/* HWIF_DC2_CODE12_CNT */ {/*swreg*/26, 4, 12},
/* HWIF_DC2_CODE11_CNT */ {/*swreg*/26, 4, 8},
/* HWIF_DC2_CODE10_CNT */ {/*swreg*/26, 4, 4},
/* HWIF_DC2_CODE9_CNT */ {/*swreg*/26, 4, 0},
/* HWIF_SCAN_MAP_36 */ {/*swreg*/26, 6, 24},
/* HWIF_SCAN_MAP_37 */ {/*swreg*/26, 6, 18},
/* HWIF_SCAN_MAP_38 */ {/*swreg*/26, 6, 12},
/* HWIF_SCAN_MAP_39 */ {/*swreg*/26, 6, 6},
/* HWIF_SCAN_MAP_40 */ {/*swreg*/26, 6, 0},
/* HWIF_REFER13_BASE */ {/*swreg*/27, 32, 0},
/* HWIF_REFER13_FIELD_E */ {/*swreg*/27, 1, 1},
/* HWIF_REFER13_TOPC_E */ {/*swreg*/27, 1, 0},
/* HWIF_DC3_CODE8_CNT */ {/*swreg*/27, 4, 28},
/* HWIF_DC3_CODE7_CNT */ {/*swreg*/27, 4, 24},
/* HWIF_DC3_CODE6_CNT */ {/*swreg*/27, 4, 20},
/* HWIF_DC3_CODE5_CNT */ {/*swreg*/27, 4, 16},
/* HWIF_DC3_CODE4_CNT */ {/*swreg*/27, 4, 12},
/* HWIF_DC3_CODE3_CNT */ {/*swreg*/27, 4, 8},
/* HWIF_DC3_CODE2_CNT */ {/*swreg*/27, 3, 4},
/* HWIF_DC3_CODE1_CNT */ {/*swreg*/27, 2, 0},
/* HWIF_BITPL_CTRL_BASE */ {/*swreg*/27, 32, 0},
/* HWIF_REFER14_BASE */ {/*swreg*/28, 32, 0},
/* HWIF_DCT_STRM6_BASE */ {/*swreg*/28, 32, 0},
/* HWIF_REFER14_FIELD_E */ {/*swreg*/28, 1, 1},
/* HWIF_REFER14_TOPC_E */ {/*swreg*/28, 1, 0},
/* HWIF_REF_INVD_CUR_1 */ {/*swreg*/28, 16, 16},
/* HWIF_REF_INVD_CUR_0 */ {/*swreg*/28, 16, 0},
/* HWIF_DC3_CODE16_CNT */ {/*swreg*/28, 4, 28},
/* HWIF_DC3_CODE15_CNT */ {/*swreg*/28, 4, 24},
/* HWIF_DC3_CODE14_CNT */ {/*swreg*/28, 4, 20},
/* HWIF_DC3_CODE13_CNT */ {/*swreg*/28, 4, 16},
/* HWIF_DC3_CODE12_CNT */ {/*swreg*/28, 4, 12},
/* HWIF_DC3_CODE11_CNT */ {/*swreg*/28, 4, 8},
/* HWIF_DC3_CODE10_CNT */ {/*swreg*/28, 4, 4},
/* HWIF_DC3_CODE9_CNT */ {/*swreg*/28, 4, 0},
/* HWIF_SCAN_MAP_41 */ {/*swreg*/28, 6, 24},
/* HWIF_SCAN_MAP_42 */ {/*swreg*/28, 6, 18},
/* HWIF_SCAN_MAP_43 */ {/*swreg*/28, 6, 12},
/* HWIF_SCAN_MAP_44 */ {/*swreg*/28, 6, 6},
/* HWIF_SCAN_MAP_45 */ {/*swreg*/28, 6, 0},
/* HWIF_REFER15_BASE */ {/*swreg*/29, 32, 0},
/* HWIF_DCT_STRM7_BASE */ {/*swreg*/29, 32, 0},
/* HWIF_REFER15_FIELD_E */ {/*swreg*/29, 1, 1},
/* HWIF_REFER15_TOPC_E */ {/*swreg*/29, 1, 0},
/* HWIF_REF_INVD_CUR_3 */ {/*swreg*/29, 16, 16},
/* HWIF_REF_INVD_CUR_2 */ {/*swreg*/29, 16, 0},
/* HWIF_SCAN_MAP_46 */ {/*swreg*/29, 6, 24},
/* HWIF_SCAN_MAP_47 */ {/*swreg*/29, 6, 18},
/* HWIF_SCAN_MAP_48 */ {/*swreg*/29, 6, 12},
/* HWIF_SCAN_MAP_49 */ {/*swreg*/29, 6, 6},
/* HWIF_SCAN_MAP_50 */ {/*swreg*/29, 6, 0},
/* HWIF_REFER1_NBR */ {/*swreg*/30, 16, 16},
/* HWIF_REFER0_NBR */ {/*swreg*/30, 16, 0},
/* HWIF_REF_DIST_CUR_1 */ {/*swreg*/30, 16, 16},
/* HWIF_REF_DIST_CUR_0 */ {/*swreg*/30, 16, 0},
/* HWIF_FILT_TYPE */ {/*swreg*/30, 1, 31},
/* HWIF_FILT_SHARPNESS */ {/*swreg*/30, 3, 28},
/* HWIF_FILT_MB_ADJ_0 */ {/*swreg*/30, 7, 21},
/* HWIF_FILT_MB_ADJ_1 */ {/*swreg*/30, 7, 14},
/* HWIF_FILT_MB_ADJ_2 */ {/*swreg*/30, 7, 7},
/* HWIF_FILT_MB_ADJ_3 */ {/*swreg*/30, 7, 0},
/* HWIF_REFER3_NBR */ {/*swreg*/31, 16, 16},
/* HWIF_REFER2_NBR */ {/*swreg*/31, 16, 0},
/* HWIF_SCAN_MAP_51 */ {/*swreg*/31, 6, 24},
/* HWIF_SCAN_MAP_52 */ {/*swreg*/31, 6, 18},
/* HWIF_SCAN_MAP_53 */ {/*swreg*/31, 6, 12},
/* HWIF_SCAN_MAP_54 */ {/*swreg*/31, 6, 6},
/* HWIF_SCAN_MAP_55 */ {/*swreg*/31, 6, 0},
/* HWIF_REF_DIST_CUR_3 */ {/*swreg*/31, 16, 16},
/* HWIF_REF_DIST_CUR_2 */ {/*swreg*/31, 16, 0},
/* HWIF_FILT_REF_ADJ_0 */ {/*swreg*/31, 7, 21},
/* HWIF_FILT_REF_ADJ_1 */ {/*swreg*/31, 7, 14},
/* HWIF_FILT_REF_ADJ_2 */ {/*swreg*/31, 7, 7},
/* HWIF_FILT_REF_ADJ_3 */ {/*swreg*/31, 7, 0},
/* HWIF_REFER5_NBR */ {/*swreg*/32, 16, 16},
/* HWIF_REFER4_NBR */ {/*swreg*/32, 16, 0},
/* HWIF_SCAN_MAP_56 */ {/*swreg*/32, 6, 24},
/* HWIF_SCAN_MAP_57 */ {/*swreg*/32, 6, 18},
/* HWIF_SCAN_MAP_58 */ {/*swreg*/32, 6, 12},
/* HWIF_SCAN_MAP_59 */ {/*swreg*/32, 6, 6},
/* HWIF_SCAN_MAP_60 */ {/*swreg*/32, 6, 0},
/* HWIF_REF_INVD_COL_1 */ {/*swreg*/32, 16, 16},
/* HWIF_REF_INVD_COL_0 */ {/*swreg*/32, 16, 0},
/* HWIF_FILT_LEVEL_0 */ {/*swreg*/32, 6, 18},
/* HWIF_FILT_LEVEL_1 */ {/*swreg*/32, 6, 12},
/* HWIF_FILT_LEVEL_2 */ {/*swreg*/32, 6, 6},
/* HWIF_FILT_LEVEL_3 */ {/*swreg*/32, 6, 0},
/* HWIF_REFER7_NBR */ {/*swreg*/33, 16, 16},
/* HWIF_REFER6_NBR */ {/*swreg*/33, 16, 0},
/* HWIF_SCAN_MAP_61 */ {/*swreg*/33, 6, 24},
/* HWIF_SCAN_MAP_62 */ {/*swreg*/33, 6, 18},
/* HWIF_SCAN_MAP_63 */ {/*swreg*/33, 6, 12},
/* HWIF_REF_INVD_COL_3 */ {/*swreg*/33, 16, 16},
/* HWIF_REF_INVD_COL_2 */ {/*swreg*/33, 16, 0},
/* HWIF_QUANT_DELTA_0 */ {/*swreg*/33, 5, 27},
/* HWIF_QUANT_DELTA_1 */ {/*swreg*/33, 5, 22},
/* HWIF_QUANT_0 */ {/*swreg*/33, 11, 11},
/* HWIF_QUANT_1 */ {/*swreg*/33, 11, 0},
/* HWIF_REFER9_NBR */ {/*swreg*/34, 16, 16},
/* HWIF_REFER8_NBR */ {/*swreg*/34, 16, 0},
/* HWIF_PRED_BC_TAP_0_3 */ {/*swreg*/34, 10, 22},
/* HWIF_PRED_BC_TAP_1_0 */ {/*swreg*/34, 10, 12},
/* HWIF_PRED_BC_TAP_1_1 */ {/*swreg*/34, 10, 2},
/* HWIF_REFER11_NBR */ {/*swreg*/35, 16, 16},
/* HWIF_REFER10_NBR */ {/*swreg*/35, 16, 0},
/* HWIF_PRED_BC_TAP_1_2 */ {/*swreg*/35, 10, 22},
/* HWIF_PRED_BC_TAP_1_3 */ {/*swreg*/35, 10, 12},
/* HWIF_PRED_BC_TAP_2_0 */ {/*swreg*/35, 10, 2},
/* HWIF_REFER13_NBR */ {/*swreg*/36, 16, 16},
/* HWIF_REFER12_NBR */ {/*swreg*/36, 16, 0},
/* HWIF_PRED_BC_TAP_2_1 */ {/*swreg*/36, 10, 22},
/* HWIF_PRED_BC_TAP_2_2 */ {/*swreg*/36, 10, 12},
/* HWIF_PRED_BC_TAP_2_3 */ {/*swreg*/36, 10, 2},
/* HWIF_REFER15_NBR */ {/*swreg*/37, 16, 16},
/* HWIF_REFER14_NBR */ {/*swreg*/37, 16, 0},
/* HWIF_PRED_BC_TAP_3_0 */ {/*swreg*/37, 10, 22},
/* HWIF_PRED_BC_TAP_3_1 */ {/*swreg*/37, 10, 12},
/* HWIF_PRED_BC_TAP_3_2 */ {/*swreg*/37, 10, 2},
/* HWIF_REFER_LTERM_E */ {/*swreg*/38, 32, 0},
/* HWIF_PRED_BC_TAP_3_3 */ {/*swreg*/38, 10, 22},
/* HWIF_PRED_BC_TAP_4_0 */ {/*swreg*/38, 10, 12},
/* HWIF_PRED_BC_TAP_4_1 */ {/*swreg*/38, 10, 2},
/* HWIF_REFER_VALID_E */ {/*swreg*/39, 32, 0},
/* HWIF_PRED_BC_TAP_4_2 */ {/*swreg*/39, 10, 22},
/* HWIF_PRED_BC_TAP_4_3 */ {/*swreg*/39, 10, 12},
/* HWIF_PRED_BC_TAP_5_0 */ {/*swreg*/39, 10, 2},
/* HWIF_QTABLE_BASE */ {/*swreg*/40, 32, 0},
/* HWIF_DIR_MV_BASE */ {/*swreg*/41, 32, 0},
/* HWIF_BINIT_RLIST_B2 */ {/*swreg*/42, 5, 25},
/* HWIF_BINIT_RLIST_F2 */ {/*swreg*/42, 5, 20},
/* HWIF_BINIT_RLIST_B1 */ {/*swreg*/42, 5, 15},
/* HWIF_BINIT_RLIST_F1 */ {/*swreg*/42, 5, 10},
/* HWIF_BINIT_RLIST_B0 */ {/*swreg*/42, 5, 5},
/* HWIF_BINIT_RLIST_F0 */ {/*swreg*/42, 5, 0},
/* HWIF_PRED_BC_TAP_5_1 */ {/*swreg*/42, 10, 22},
/* HWIF_PRED_BC_TAP_5_2 */ {/*swreg*/42, 10, 12},
/* HWIF_PRED_BC_TAP_5_3 */ {/*swreg*/42, 10, 2},
/* HWIF_PJPEG_DCCB_BASE */ {/*swreg*/42, 32, 0},
/* HWIF_BINIT_RLIST_B5 */ {/*swreg*/43, 5, 25},
/* HWIF_BINIT_RLIST_F5 */ {/*swreg*/43, 5, 20},
/* HWIF_BINIT_RLIST_B4 */ {/*swreg*/43, 5, 15},
/* HWIF_BINIT_RLIST_F4 */ {/*swreg*/43, 5, 10},
/* HWIF_BINIT_RLIST_B3 */ {/*swreg*/43, 5, 5},
/* HWIF_BINIT_RLIST_F3 */ {/*swreg*/43, 5, 0},
/* HWIF_PRED_BC_TAP_6_0 */ {/*swreg*/43, 10, 22},
/* HWIF_PRED_BC_TAP_6_1 */ {/*swreg*/43, 10, 12},
/* HWIF_PRED_BC_TAP_6_2 */ {/*swreg*/43, 10, 2},
/* HWIF_PJPEG_DCCR_BASE */ {/*swreg*/43, 32, 0},
/* HWIF_BINIT_RLIST_B8 */ {/*swreg*/44, 5, 25},
/* HWIF_BINIT_RLIST_F8 */ {/*swreg*/44, 5, 20},
/* HWIF_BINIT_RLIST_B7 */ {/*swreg*/44, 5, 15},
/* HWIF_BINIT_RLIST_F7 */ {/*swreg*/44, 5, 10},
/* HWIF_BINIT_RLIST_B6 */ {/*swreg*/44, 5, 5},
/* HWIF_BINIT_RLIST_F6 */ {/*swreg*/44, 5, 0},
/* HWIF_PRED_BC_TAP_6_3 */ {/*swreg*/44, 10, 22},
/* HWIF_PRED_BC_TAP_7_0 */ {/*swreg*/44, 10, 12},
/* HWIF_PRED_BC_TAP_7_1 */ {/*swreg*/44, 10, 2},
/* HWIF_BINIT_RLIST_B11 */ {/*swreg*/45, 5, 25},
/* HWIF_BINIT_RLIST_F11 */ {/*swreg*/45, 5, 20},
/* HWIF_BINIT_RLIST_B10 */ {/*swreg*/45, 5, 15},
/* HWIF_BINIT_RLIST_F10 */ {/*swreg*/45, 5, 10},
/* HWIF_BINIT_RLIST_B9 */ {/*swreg*/45, 5, 5},
/* HWIF_BINIT_RLIST_F9 */ {/*swreg*/45, 5, 0},
/* HWIF_PRED_BC_TAP_7_2 */ {/*swreg*/45, 10, 22},
/* HWIF_PRED_BC_TAP_7_3 */ {/*swreg*/45, 10, 12},
/* HWIF_PRED_TAP_2_M1 */ {/*swreg*/45, 2, 10},
/* HWIF_PRED_TAP_2_4 */ {/*swreg*/45, 2, 8},
/* HWIF_PRED_TAP_4_M1 */ {/*swreg*/45, 2, 6},
/* HWIF_PRED_TAP_4_4 */ {/*swreg*/45, 2, 4},
/* HWIF_PRED_TAP_6_M1 */ {/*swreg*/45, 2, 2},
/* HWIF_PRED_TAP_6_4 */ {/*swreg*/45, 2, 0},
/* HWIF_BINIT_RLIST_B14 */ {/*swreg*/46, 5, 25},
/* HWIF_BINIT_RLIST_F14 */ {/*swreg*/46, 5, 20},
/* HWIF_BINIT_RLIST_B13 */ {/*swreg*/46, 5, 15},
/* HWIF_BINIT_RLIST_F13 */ {/*swreg*/46, 5, 10},
/* HWIF_BINIT_RLIST_B12 */ {/*swreg*/46, 5, 5},
/* HWIF_BINIT_RLIST_F12 */ {/*swreg*/46, 5, 0},
/* HWIF_QUANT_DELTA_2 */ {/*swreg*/46, 5, 27},
/* HWIF_QUANT_DELTA_3 */ {/*swreg*/46, 5, 22},
/* HWIF_QUANT_2 */ {/*swreg*/46, 11, 11},
/* HWIF_QUANT_3 */ {/*swreg*/46, 11, 0},
/* HWIF_PINIT_RLIST_F3 */ {/*swreg*/47, 5, 25},
/* HWIF_PINIT_RLIST_F2 */ {/*swreg*/47, 5, 20},
/* HWIF_PINIT_RLIST_F1 */ {/*swreg*/47, 5, 15},
/* HWIF_PINIT_RLIST_F0 */ {/*swreg*/47, 5, 10},
/* HWIF_BINIT_RLIST_B15 */ {/*swreg*/47, 5, 5},
/* HWIF_BINIT_RLIST_F15 */ {/*swreg*/47, 5, 0},
/* HWIF_QUANT_DELTA_4 */ {/*swreg*/47, 5, 27},
/* HWIF_QUANT_4 */ {/*swreg*/47, 11, 11},
/* HWIF_QUANT_5 */ {/*swreg*/47, 11, 0},
/* HWIF_STARTMB_X */ {/*swreg*/48, 9, 23},
/* HWIF_STARTMB_Y */ {/*swreg*/48, 8, 15},
/* HWIF_PRED_BC_TAP_0_0 */ {/*swreg*/49, 10, 22},
/* HWIF_PRED_BC_TAP_0_1 */ {/*swreg*/49, 10, 12},
/* HWIF_PRED_BC_TAP_0_2 */ {/*swreg*/49, 10, 2},
/* HWIF_REFBU_E */ {/*swreg*/51, 1, 31},
/* HWIF_REFBU_THR */ {/*swreg*/51, 12, 19},
/* HWIF_REFBU_PICID */ {/*swreg*/51, 5, 14},
/* HWIF_REFBU_EVAL_E */ {/*swreg*/51, 1, 13},
/* HWIF_REFBU_FPARMOD_E */ {/*swreg*/51, 1, 12},
/* HWIF_REFBU_Y_OFFSET */ {/*swreg*/51, 9, 0},
/* HWIF_REFBU_HIT_SUM */ {/*swreg*/52, 16, 16},
/* HWIF_REFBU_INTRA_SUM */ {/*swreg*/52, 16, 0},
/* HWIF_REFBU_Y_MV_SUM */ {/*swreg*/53, 22, 0},
/* HWIF_REFBU2_BUF_E */ {/*swreg*/55, 1, 31},
/* HWIF_REFBU2_THR */ {/*swreg*/55, 12, 19},
/* HWIF_REFBU2_PICID */ {/*swreg*/55, 5, 14},
/* HWIF_APF_THRESHOLD */ {/*swreg*/55, 14, 0},
/* HWIF_REFBU_TOP_SUM */ {/*swreg*/56, 16, 16},
/* HWIF_REFBU_BOT_SUM */ {/*swreg*/56, 16, 0},
/* HWIF_DEC_CH8PIX_BASE */ {/*swreg*/59, 32, 0},
/* HWIF_PP_BUS_INT */ {/*swreg*/60, 1, 13},
/* HWIF_PP_RDY_INT */ {/*swreg*/60, 1, 12},
/* HWIF_PP_IRQ */ {/*swreg*/60, 1, 8},
/* HWIF_PP_IRQ_DIS */ {/*swreg*/60, 1, 4},
/* HWIF_PP_PIPELINE_E */ {/*swreg*/60, 1, 1},
/* HWIF_PP_E */ {/*swreg*/60, 1, 0},
/* HWIF_PP_AXI_RD_ID */ {/*swreg*/61, 8, 24},
/* HWIF_PP_AXI_WR_ID */ {/*swreg*/61, 8, 16},
/* HWIF_PP_AHB_HLOCK_E */ {/*swreg*/61, 1, 15},
/* HWIF_PP_SCMD_DIS */ {/*swreg*/61, 1, 14},
/* HWIF_PP_IN_A2_ENDSEL */ {/*swreg*/61, 1, 13},
/* HWIF_PP_IN_A1_SWAP32 */ {/*swreg*/61, 1, 12},
/* HWIF_PP_IN_A1_ENDIAN */ {/*swreg*/61, 1, 11},
/* HWIF_PP_IN_SWAP32_E */ {/*swreg*/61, 1, 10},
/* HWIF_PP_DATA_DISC_E */ {/*swreg*/61, 1, 9},
/* HWIF_PP_CLK_GATE_E */ {/*swreg*/61, 1, 8},
/* HWIF_PP_IN_ENDIAN */ {/*swreg*/61, 1, 7},
/* HWIF_PP_OUT_ENDIAN */ {/*swreg*/61, 1, 6},
/* HWIF_PP_OUT_SWAP32_E */ {/*swreg*/61, 1, 5},
/* HWIF_PP_MAX_BURST */ {/*swreg*/61, 5, 0},
/* HWIF_DEINT_E */ {/*swreg*/62, 1, 31},
/* HWIF_DEINT_THRESHOLD */ {/*swreg*/62, 14, 16},
/* HWIF_DEINT_BLEND_E */ {/*swreg*/62, 1, 15},
/* HWIF_DEINT_EDGE_DET */ {/*swreg*/62, 15, 0},
/* HWIF_PP_IN_LU_BASE */ {/*swreg*/63, 32, 0},
/* HWIF_PP_IN_CB_BASE */ {/*swreg*/64, 32, 0},
/* HWIF_PP_IN_CR_BASE */ {/*swreg*/65, 32, 0},
/* HWIF_PP_OUT_LU_BASE */ {/*swreg*/66, 32, 0},
/* HWIF_PP_OUT_CH_BASE */ {/*swreg*/67, 32, 0},
/* HWIF_CONTRAST_THR1 */ {/*swreg*/68, 8, 24},
/* HWIF_CONTRAST_OFF2 */ {/*swreg*/68, 10, 10},
/* HWIF_CONTRAST_OFF1 */ {/*swreg*/68, 10, 0},
/* HWIF_PP_IN_START_CH */ {/*swreg*/69, 1, 31},
/* HWIF_PP_IN_CR_FIRST */ {/*swreg*/69, 1, 30},
/* HWIF_PP_OUT_START_CH */ {/*swreg*/69, 1, 29},
/* HWIF_PP_OUT_CR_FIRST */ {/*swreg*/69, 1, 28},
/* HWIF_COLOR_COEFFA2 */ {/*swreg*/69, 10, 18},
/* HWIF_COLOR_COEFFA1 */ {/*swreg*/69, 10, 8},
/* HWIF_CONTRAST_THR2 */ {/*swreg*/69, 8, 0},
/* HWIF_COLOR_COEFFD */ {/*swreg*/70, 10, 20},
/* HWIF_COLOR_COEFFC */ {/*swreg*/70, 10, 10},
/* HWIF_COLOR_COEFFB */ {/*swreg*/70, 10, 0},
/* HWIF_CROP_STARTX */ {/*swreg*/71, 9, 21},
/* HWIF_ROTATION_MODE */ {/*swreg*/71, 3, 18},
/* HWIF_COLOR_COEFFF */ {/*swreg*/71, 8, 10},
/* HWIF_COLOR_COEFFE */ {/*swreg*/71, 10, 0},
/* HWIF_CROP_STARTY */ {/*swreg*/72, 8, 24},
/* HWIF_RANGEMAP_COEF_Y */ {/*swreg*/72, 5, 18},
/* HWIF_PP_IN_HEIGHT */ {/*swreg*/72, 8, 9},
/* HWIF_PP_IN_WIDTH */ {/*swreg*/72, 9, 0},
/* HWIF_PP_BOT_YIN_BASE */ {/*swreg*/73, 32, 0},
/* HWIF_PP_BOT_CIN_BASE */ {/*swreg*/74, 32, 0},
/* HWIF_RANGEMAP_Y_E */ {/*swreg*/79, 1, 31},
/* HWIF_RANGEMAP_C_E */ {/*swreg*/79, 1, 30},
/* HWIF_YCBCR_RANGE */ {/*swreg*/79, 1, 29},
/* HWIF_RGB_PIX_IN32 */ {/*swreg*/79, 1, 28},
/* HWIF_RGB_R_PADD */ {/*swreg*/79, 5, 23},
/* HWIF_RGB_G_PADD */ {/*swreg*/79, 5, 18},
/* HWIF_SCALE_WRATIO */ {/*swreg*/79, 18, 0},
/* HWIF_PP_FAST_SCALE_E */ {/*swreg*/80, 1, 30},
/* HWIF_PP_IN_STRUCT */ {/*swreg*/80, 3, 27},
/* HWIF_HOR_SCALE_MODE */ {/*swreg*/80, 2, 25},
/* HWIF_VER_SCALE_MODE */ {/*swreg*/80, 2, 23},
/* HWIF_RGB_B_PADD */ {/*swreg*/80, 5, 18},
/* HWIF_SCALE_HRATIO */ {/*swreg*/80, 18, 0},
/* HWIF_WSCALE_INVRA */ {/*swreg*/81, 16, 16},
/* HWIF_HSCALE_INVRA */ {/*swreg*/81, 16, 0},
/* HWIF_R_MASK */ {/*swreg*/82, 32, 0},
/* HWIF_G_MASK */ {/*swreg*/83, 32, 0},
/* HWIF_B_MASK */ {/*swreg*/84, 32, 0},
/* HWIF_PP_IN_FORMAT */ {/*swreg*/85, 3, 29},
/* HWIF_PP_OUT_FORMAT */ {/*swreg*/85, 3, 26},
/* HWIF_PP_OUT_HEIGHT */ {/*swreg*/85, 11, 15},
/* HWIF_PP_OUT_WIDTH */ {/*swreg*/85, 11, 4},
/* HWIF_PP_OUT_TILED_E */ {/*swreg*/85, 1, 3},
/* HWIF_PP_OUT_SWAP16_E */ {/*swreg*/85, 1, 2},
/* HWIF_PP_CROP8_R_E */ {/*swreg*/85, 1, 1},
/* HWIF_PP_CROP8_D_E */ {/*swreg*/85, 1, 0},
/* HWIF_PP_IN_FORMAT_ES */ {/*swreg*/86, 3, 29},
/* HWIF_RANGEMAP_COEF_C */ {/*swreg*/86, 5, 23},
/* HWIF_MASK1_ABLEND_E */ {/*swreg*/86, 1, 22},
/* HWIF_MASK1_STARTY */ {/*swreg*/86, 11, 11},
/* HWIF_MASK1_STARTX */ {/*swreg*/86, 11, 0},
/* HWIF_MASK2_ABLEND_E */ {/*swreg*/87, 1, 22},
/* HWIF_MASK2_STARTY */ {/*swreg*/87, 11, 11},
/* HWIF_MASK2_STARTX */ {/*swreg*/87, 11, 0},
/* HWIF_EXT_ORIG_WIDTH */ {/*swreg*/88, 9, 23},
/* HWIF_MASK1_E */ {/*swreg*/88, 1, 22},
/* HWIF_MASK1_ENDY */ {/*swreg*/88, 11, 11},
/* HWIF_MASK1_ENDX */ {/*swreg*/88, 11, 0},
/* HWIF_MASK2_E */ {/*swreg*/89, 1, 22},
/* HWIF_MASK2_ENDY */ {/*swreg*/89, 11, 11},
/* HWIF_MASK2_ENDX */ {/*swreg*/89, 11, 0},
/* HWIF_RIGHT_CROSS_E */ {/*swreg*/90, 1, 29},
/* HWIF_LEFT_CROSS_E */ {/*swreg*/90, 1, 28},
/* HWIF_UP_CROSS_E */ {/*swreg*/90, 1, 27},
/* HWIF_DOWN_CROSS_E */ {/*swreg*/90, 1, 26},
/* HWIF_UP_CROSS */ {/*swreg*/90, 11, 15},
/* HWIF_DOWN_CROSS */ {/*swreg*/90, 11, 0},
/* HWIF_DITHER_SELECT_R */ {/*swreg*/91, 2, 30},
/* HWIF_DITHER_SELECT_G */ {/*swreg*/91, 2, 28},
/* HWIF_DITHER_SELECT_B */ {/*swreg*/91, 2, 26},
/* HWIF_PP_TILED_MODE */ {/*swreg*/91, 2, 22},
/* HWIF_RIGHT_CROSS */ {/*swreg*/91, 11, 11},
/* HWIF_LEFT_CROSS */ {/*swreg*/91, 11, 0},
/* HWIF_PP_IN_H_EXT */ {/*swreg*/92, 3, 29},
/* HWIF_PP_IN_W_EXT */ {/*swreg*/92, 3, 26},
/* HWIF_CROP_STARTY_EXT */ {/*swreg*/92, 3, 23},
/* HWIF_CROP_STARTX_EXT */ {/*swreg*/92, 3, 20},
/* HWIF_DISPLAY_WIDTH */ {/*swreg*/92, 12, 0},
/* HWIF_ABLEND1_BASE */ {/*swreg*/93, 32, 0},
/* HWIF_ABLEND2_BASE */ {/*swreg*/94, 32, 0},
/* HWIF_ABLEND2_SCANL */ {/*swreg*/95, 13, 13},
/* HWIF_ABLEND1_SCANL */ {/*swreg*/95, 13, 0},

View File

@ -0,0 +1,62 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Basic type definitions.
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: basetype.h,v $
-- $Revision: 1.3 $
-- $Date: 2007/11/19 08:26:14 $
--
------------------------------------------------------------------------------*/
#ifndef __BASETYPE_H__
#define __BASETYPE_H__
#if defined( __linux__ ) || defined( WIN32 )
#include <stddef.h>
#endif
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
/* Macro to signal unused parameter. */
#define UNUSED(x) (void)(x)
typedef unsigned char u8;
typedef signed char i8;
typedef unsigned short u16;
typedef signed short i16;
typedef unsigned int u32;
typedef signed int i32;
/* SW decoder 16 bits types */
#if defined(VC1SWDEC_16BIT) || defined(MP4ENC_ARM11)
typedef unsigned short u16x;
typedef signed short i16x;
#else
typedef unsigned int u16x;
typedef signed int i16x;
#endif
#endif /* __BASETYPE_H__ */

View File

@ -0,0 +1,48 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Header file for stream decoding utilities
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: bqueue.h,v $
-- $Date: 2010/02/25 12:18:56 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef BQUEUE_H_DEFINED
#define BQUEUE_H_DEFINED
#include "basetype.h"
typedef struct
{
u32 *picI;
u32 ctr;
u32 queueSize;
u32 prevAnchorSlot;
} bufferQueue_t;
#define BQUEUE_UNUSED (u32)(0xffffffff)
u32 BqueueInit( bufferQueue_t *bq, u32 numBuffers );
void BqueueRelease( bufferQueue_t *bq );
u32 BqueueNext( bufferQueue_t *bq, u32 ref0, u32 ref1, u32 ref2, u32 bPic );
void BqueueDiscard( bufferQueue_t *bq, u32 buffer );
#endif /* BQUEUE_H_DEFINED */

View File

@ -0,0 +1,197 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2007 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Common Decoder API definitions
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: decapicommon.h,v $
-- $Date: 2011/05/26 13:14:23 $
-- $Revision: 1.25 $
--
------------------------------------------------------------------------------*/
#ifndef __DECAPICOMMON_H__
#define __DECAPICOMMON_H__
#include "basetype.h"
#define MAX_ASIC_CORES 4
#define MPEG4_NOT_SUPPORTED (u32)(0x00)
#define MPEG4_SIMPLE_PROFILE (u32)(0x01)
#define MPEG4_ADVANCED_SIMPLE_PROFILE (u32)(0x02)
#define MPEG4_CUSTOM_NOT_SUPPORTED (u32)(0x00)
#define MPEG4_CUSTOM_FEATURE_1 (u32)(0x01)
#define H264_NOT_SUPPORTED (u32)(0x00)
#define H264_BASELINE_PROFILE (u32)(0x01)
#define H264_MAIN_PROFILE (u32)(0x02)
#define H264_HIGH_PROFILE (u32)(0x03)
#define VC1_NOT_SUPPORTED (u32)(0x00)
#define VC1_SIMPLE_PROFILE (u32)(0x01)
#define VC1_MAIN_PROFILE (u32)(0x02)
#define VC1_ADVANCED_PROFILE (u32)(0x03)
#define MPEG2_NOT_SUPPORTED (u32)(0x00)
#define MPEG2_MAIN_PROFILE (u32)(0x01)
#define JPEG_NOT_SUPPORTED (u32)(0x00)
#define JPEG_BASELINE (u32)(0x01)
#define JPEG_PROGRESSIVE (u32)(0x02)
#define PP_NOT_SUPPORTED (u32)(0x00)
#define PP_SUPPORTED (u32)(0x01)
#define PP_TILED_4X4 (u32)(0x20000000)
#define PP_DITHERING (u32)(0x10000000)
#define PP_SCALING (u32)(0x0C000000)
#define PP_DEINTERLACING (u32)(0x02000000)
#define PP_ALPHA_BLENDING (u32)(0x01000000)
#define PP_OUTP_ENDIAN (u32)(0x00040000)
#define PP_TILED_INPUT (u32)(0x0000C000)
#define PP_PIX_ACC_OUTPUT (u32)(0x40000000)
#define PP_ABLEND_CROP (u32)(0x80000000)
#define SORENSON_SPARK_NOT_SUPPORTED (u32)(0x00)
#define SORENSON_SPARK_SUPPORTED (u32)(0x01)
#define VP6_NOT_SUPPORTED (u32)(0x00)
#define VP6_SUPPORTED (u32)(0x01)
#define VP7_NOT_SUPPORTED (u32)(0x00)
#define VP7_SUPPORTED (u32)(0x01)
#define VP8_NOT_SUPPORTED (u32)(0x00)
#define VP8_SUPPORTED (u32)(0x01)
#define REF_BUF_NOT_SUPPORTED (u32)(0x00)
#define REF_BUF_SUPPORTED (u32)(0x01)
#define REF_BUF_INTERLACED (u32)(0x02)
#define REF_BUF_DOUBLE (u32)(0x04)
#define TILED_NOT_SUPPORTED (u32)(0x00)
#define TILED_8x4_SUPPORTED (u32)(0x01)
#define AVS_NOT_SUPPORTED (u32)(0x00)
#define AVS_SUPPORTED (u32)(0x01)
#define JPEG_EXT_NOT_SUPPORTED (u32)(0x00)
#define JPEG_EXT_SUPPORTED (u32)(0x01)
#define RV_NOT_SUPPORTED (u32)(0x00)
#define RV_SUPPORTED (u32)(0x01)
#define MVC_NOT_SUPPORTED (u32)(0x00)
#define MVC_SUPPORTED (u32)(0x01)
#define WEBP_NOT_SUPPORTED (u32)(0x00)
#define WEBP_SUPPORTED (u32)(0x01)
#define EC_NOT_SUPPORTED (u32)(0x00)
#define EC_SUPPORTED (u32)(0x01)
#define H264_NOT_SUPPORTED_FUSE (u32)(0x00)
#define H264_FUSE_ENABLED (u32)(0x01)
#define MPEG4_NOT_SUPPORTED_FUSE (u32)(0x00)
#define MPEG4_FUSE_ENABLED (u32)(0x01)
#define MPEG2_NOT_SUPPORTED_FUSE (u32)(0x00)
#define MPEG2_FUSE_ENABLED (u32)(0x01)
#define SORENSON_SPARK_NOT_SUPPORTED_FUSE (u32)(0x00)
#define SORENSON_SPARK_ENABLED (u32)(0x01)
#define JPEG_NOT_SUPPORTED_FUSE (u32)(0x00)
#define JPEG_FUSE_ENABLED (u32)(0x01)
#define VP6_NOT_SUPPORTED_FUSE (u32)(0x00)
#define VP6_FUSE_ENABLED (u32)(0x01)
#define VP7_NOT_SUPPORTED_FUSE (u32)(0x00)
#define VP7_FUSE_ENABLED (u32)(0x01)
#define VP8_NOT_SUPPORTED_FUSE (u32)(0x00)
#define VP8_FUSE_ENABLED (u32)(0x01)
#define VC1_NOT_SUPPORTED_FUSE (u32)(0x00)
#define VC1_FUSE_ENABLED (u32)(0x01)
#define JPEG_PROGRESSIVE_NOT_SUPPORTED_FUSE (u32)(0x00)
#define JPEG_PROGRESSIVE_FUSE_ENABLED (u32)(0x01)
#define REF_BUF_NOT_SUPPORTED_FUSE (u32)(0x00)
#define REF_BUF_FUSE_ENABLED (u32)(0x01)
#define AVS_NOT_SUPPORTED_FUSE (u32)(0x00)
#define AVS_FUSE_ENABLED (u32)(0x01)
#define RV_NOT_SUPPORTED_FUSE (u32)(0x00)
#define RV_FUSE_ENABLED (u32)(0x01)
#define MVC_NOT_SUPPORTED_FUSE (u32)(0x00)
#define MVC_FUSE_ENABLED (u32)(0x01)
#define PP_NOT_SUPPORTED_FUSE (u32)(0x00)
#define PP_FUSE_ENABLED (u32)(0x01)
#define PP_FUSE_DEINTERLACING_ENABLED (u32)(0x40000000)
#define PP_FUSE_ALPHA_BLENDING_ENABLED (u32)(0x20000000)
#define MAX_PP_OUT_WIDHT_1920_FUSE_ENABLED (u32)(0x00008000)
#define MAX_PP_OUT_WIDHT_1280_FUSE_ENABLED (u32)(0x00004000)
#define MAX_PP_OUT_WIDHT_720_FUSE_ENABLED (u32)(0x00002000)
#define MAX_PP_OUT_WIDHT_352_FUSE_ENABLED (u32)(0x00001000)
/* Macro to copy support flags and picture max width from DWL HW config
* to Decoder HW config */
#define SET_DEC_BUILD_SUPPORT(decHwCfg, dwlHwCfg) \
decHwCfg.maxDecPicWidth = dwlHwCfg.maxDecPicWidth; \
decHwCfg.maxPpOutPicWidth = dwlHwCfg.maxPpOutPicWidth; \
decHwCfg.h264Support = dwlHwCfg.h264Support; \
decHwCfg.jpegSupport = dwlHwCfg.jpegSupport; \
decHwCfg.jpegESupport = dwlHwCfg.jpegESupport; \
decHwCfg.mpeg2Support = dwlHwCfg.mpeg2Support; \
decHwCfg.mpeg4Support = dwlHwCfg.mpeg4Support; \
decHwCfg.vc1Support = dwlHwCfg.vc1Support; \
decHwCfg.ppSupport = dwlHwCfg.ppSupport; \
decHwCfg.ppConfig = dwlHwCfg.ppConfig; \
decHwCfg.sorensonSparkSupport = dwlHwCfg.sorensonSparkSupport; \
decHwCfg.vp6Support = dwlHwCfg.vp6Support; \
decHwCfg.vp7Support = dwlHwCfg.vp7Support; \
decHwCfg.vp8Support = dwlHwCfg.vp8Support; \
decHwCfg.refBufSupport = dwlHwCfg.refBufSupport; \
decHwCfg.tiledModeSupport = dwlHwCfg.tiledModeSupport; \
decHwCfg.avsSupport = dwlHwCfg.avsSupport; \
decHwCfg.rvSupport = dwlHwCfg.rvSupport; \
decHwCfg.customMpeg4Support = dwlHwCfg.customMpeg4Support; \
decHwCfg.mvcSupport = dwlHwCfg.mvcSupport; \
decHwCfg.webpSupport = dwlHwCfg.webpSupport; \
decHwCfg.ecSupport = dwlHwCfg.ecSupport;
typedef struct DecHwConfig_
{
u32 mpeg4Support; /* one of the MPEG4 values defined above */
u32 customMpeg4Support; /* one of the MPEG4 custom values defined above */
u32 h264Support; /* one of the H264 values defined above */
u32 vc1Support; /* one of the VC1 values defined above */
u32 mpeg2Support; /* one of the MPEG2 values defined above */
u32 jpegSupport; /* one of the JPEG values defined above */
u32 jpegProgSupport; /* one of the Progressive JPEG values defined above */
u32 maxDecPicWidth; /* maximum picture width in decoder */
u32 ppSupport; /* PP_SUPPORTED or PP_NOT_SUPPORTED */
u32 ppConfig; /* Bitwise list of PP function */
u32 maxPpOutPicWidth; /* maximum post-processor output picture width */
u32 sorensonSparkSupport; /* one of the SORENSON_SPARK values defined above */
u32 refBufSupport; /* one of the REF_BUF values defined above */
u32 tiledModeSupport; /* one of the TILED values defined above */
u32 vp6Support; /* one of the VP6 values defined above */
u32 vp7Support; /* one of the VP7 values defined above */
u32 vp8Support; /* one of the VP8 values defined above */
u32 avsSupport; /* one of the AVS values defined above */
u32 jpegESupport; /* one of the JPEG EXT values defined above */
u32 rvSupport; /* one of the HUKKA values defined above */
u32 mvcSupport; /* one of the MVC values defined above */
u32 webpSupport; /* one of the WEBP values defined above */
u32 ecSupport; /* one of the EC values defined above */
u32 strideSupport; /* HW supports separate Y and C strides */
u32 fieldDpbSupport;
} DecHwConfig;
/* Reference picture format types */
typedef enum
{
DEC_REF_FRM_RASTER_SCAN = 0,
DEC_REF_FRM_TILED_DEFAULT = 1
} DecRefFrmFormat;
/* Output picture format types */
typedef enum
{
DEC_OUT_FRM_RASTER_SCAN = 0,
DEC_OUT_FRM_TILED_8X4 = 1
} DecOutFrmFormat;
#endif /* __DECAPICOMMON_H__ */

View File

@ -0,0 +1,229 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Hardware decoder system configuration
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: deccfg.h,v $
-- $Revision: 1.16 $
-- $Date: 2010/05/14 10:45:43 $
--
------------------------------------------------------------------------------*/
#ifndef __DEC_X170_CFG_H__
#define __DEC_X170_CFG_H__
/* predefined values of HW system parameters. DO NOT ALTER! */
#define DEC_X170_LITTLE_ENDIAN 1
#define DEC_X170_BIG_ENDIAN 0
#define DEC_X170_BUS_BURST_LENGTH_UNDEFINED 0
#define DEC_X170_BUS_BURST_LENGTH_4 4
#define DEC_X170_BUS_BURST_LENGTH_8 8
#define DEC_X170_BUS_BURST_LENGTH_16 16
#define DEC_X170_ASIC_SERVICE_PRIORITY_DEFAULT 0
#define DEC_X170_ASIC_SERVICE_PRIORITY_WR_1 1
#define DEC_X170_ASIC_SERVICE_PRIORITY_WR_2 2
#define DEC_X170_ASIC_SERVICE_PRIORITY_RD_1 3
#define DEC_X170_ASIC_SERVICE_PRIORITY_RD_2 4
#define DEC_X170_OUTPUT_FORMAT_RASTER_SCAN 0
#define DEC_X170_OUTPUT_FORMAT_TILED 1
/* end of predefined values */
/* now what we use */
#ifndef DEC_X170_USING_IRQ
/* Control IRQ generation by decoder hardware */
#define DEC_X170_USING_IRQ 1
#endif
#ifndef DEC_X170_ASIC_SERVICE_PRIORITY
/* hardware intgernal prioriy scheme. better left unchanged */
#define DEC_X170_ASIC_SERVICE_PRIORITY DEC_X170_ASIC_SERVICE_PRIORITY_DEFAULT
#endif
/* AXI single command multiple data disable not set */
#define DEC_X170_SCMD_DISABLE 0
/* Advanced prefetch disable flag. If disable flag is set, product shall
* operate akin to 9190 and earlier products. */
#define DEC_X170_APF_DISABLE 0
#ifndef DEC_X170_BUS_BURST_LENGTH
/* how long are the hardware data bursts; better left unchanged */
#define DEC_X170_BUS_BURST_LENGTH DEC_X170_BUS_BURST_LENGTH_16
#endif
#ifndef DEC_X170_INPUT_STREAM_ENDIAN
/* this should match the system endianess, so that Decoder reads */
/* the input stream in the right order */
#define DEC_X170_INPUT_STREAM_ENDIAN DEC_X170_LITTLE_ENDIAN
#endif
#ifndef DEC_X170_OUTPUT_PICTURE_ENDIAN
/* this should match the system endianess, so that Decoder writes */
/* the output pixel data in the right order */
#define DEC_X170_OUTPUT_PICTURE_ENDIAN DEC_X170_LITTLE_ENDIAN
#endif
#ifndef DEC_X170_LATENCY_COMPENSATION
/* compensation for bus latency; values up to 63 */
#define DEC_X170_LATENCY_COMPENSATION 0
#endif
#ifndef DEC_X170_INTERNAL_CLOCK_GATING
/* clock is gated from decoder structures that are not used */
#define DEC_X170_INTERNAL_CLOCK_GATING 0
#endif
#ifndef DEC_X170_OUTPUT_FORMAT
/* Decoder output picture format in external memory: Raster-scan or */
/*macroblock tiled i.e. macroblock data written in consecutive addresses */
#define DEC_X170_OUTPUT_FORMAT DEC_X170_OUTPUT_FORMAT_RASTER_SCAN
#endif
#ifndef DEC_X170_DATA_DISCARD_ENABLE
#define DEC_X170_DATA_DISCARD_ENABLE 0
#endif
/* Decoder output data swap for 32bit words*/
#ifndef DEC_X170_OUTPUT_SWAP_32_ENABLE
#define DEC_X170_OUTPUT_SWAP_32_ENABLE 1
#endif
/* Decoder input data swap(excluding stream data) for 32bit words*/
#ifndef DEC_X170_INPUT_DATA_SWAP_32_ENABLE
#define DEC_X170_INPUT_DATA_SWAP_32_ENABLE 1
#endif
/* Decoder input stream swap for 32bit words */
#ifndef DEC_X170_INPUT_STREAM_SWAP_32_ENABLE
#define DEC_X170_INPUT_STREAM_SWAP_32_ENABLE 1
#endif
/* Decoder input data endian. Do not modify this! */
#ifndef DEC_X170_INPUT_DATA_ENDIAN
#define DEC_X170_INPUT_DATA_ENDIAN DEC_X170_BIG_ENDIAN
#endif
/* AXI bus read and write ID values used by HW. 0 - 255 */
#ifndef DEC_X170_AXI_ID_R
#define DEC_X170_AXI_ID_R 0
#endif
#ifndef DEC_X170_AXI_ID_W
#define DEC_X170_AXI_ID_W 0
#endif
/* Check validity of values */
/* data discard and tiled mode can not be on simultaneously */
#if (DEC_X170_DATA_DISCARD_ENABLE && (DEC_X170_OUTPUT_FORMAT == DEC_X170_OUTPUT_FORMAT_TILED))
#error "Bad value specified: DEC_X170_DATA_DISCARD_ENABLE && (DEC_X170_OUTPUT_FORMAT == DEC_X170_OUTPUT_FORMAT_TILED)"
#endif
#if (DEC_X170_OUTPUT_PICTURE_ENDIAN > 1)
#error "Bad value specified for DEC_X170_OUTPUT_PICTURE_ENDIAN"
#endif
#if (DEC_X170_OUTPUT_FORMAT > 1)
#error "Bad value specified for DEC_X170_OUTPUT_FORMAT"
#endif
#if (DEC_X170_BUS_BURST_LENGTH > 31)
#error "Bad value specified for DEC_X170_AMBA_BURST_LENGTH"
#endif
#if (DEC_X170_ASIC_SERVICE_PRIORITY > 4)
#error "Bad value specified for DEC_X170_ASIC_SERVICE_PRIORITY"
#endif
#if (DEC_X170_LATENCY_COMPENSATION > 63)
#error "Bad value specified for DEC_X170_LATENCY_COMPENSATION"
#endif
#if (DEC_X170_OUTPUT_SWAP_32_ENABLE > 1)
#error "Bad value specified for DEC_X170_OUTPUT_SWAP_32_ENABLE"
#endif
#if (DEC_X170_INPUT_DATA_SWAP_32_ENABLE > 1)
#error "Bad value specified for DEC_X170_INPUT_DATA_SWAP_32_ENABLE"
#endif
#if (DEC_X170_INPUT_STREAM_SWAP_32_ENABLE > 1)
#error "Bad value specified for DEC_X170_INPUT_STREAM_SWAP_32_ENABLE"
#endif
#if (DEC_X170_OUTPUT_SWAP_32_ENABLE > 1)
#error "Bad value specified for DEC_X170_INPUT_DATA_ENDIAN"
#endif
#if (DEC_X170_DATA_DISCARD_ENABLE > 1)
#error "Bad value specified for DEC_X170_DATA_DISCARD_ENABLE"
#endif
/* Common defines for the decoder */
/* Number registers for the decoder */
#define DEC_X170_REGISTERS 60
/* Max amount of stream */
#define DEC_X170_MAX_STREAM ((1<<24)-1)
/* Timeout value for the DWLWaitHwReady() call. */
/* Set to -1 for an unspecified value */
#ifndef DEC_X170_TIMEOUT_LENGTH
#define DEC_X170_TIMEOUT_LENGTH -1
#endif
/* Enable HW internal watchdog timeout IRQ */
#define DEC_X170_HW_TIMEOUT_INT_ENA 1
/* Memory wait states for reference buffer */
#define DEC_X170_REFBU_WIDTH 64
#define DEC_X170_REFBU_LATENCY 20
#define DEC_X170_REFBU_NONSEQ 8
#define DEC_X170_REFBU_SEQ 1
#define DEC_SET_APF_THRESHOLD(regBase) \
{ \
u32 apfTmpThreshold = 0; \
SetDecRegister(regBase, HWIF_DEC_ADV_PRE_DIS, DEC_X170_APF_DISABLE ); \
if((DEC_X170_APF_DISABLE) == 0) \
{ \
if(DEC_X170_REFBU_SEQ) \
apfTmpThreshold = DEC_X170_REFBU_NONSEQ/DEC_X170_REFBU_SEQ; \
else \
apfTmpThreshold = DEC_X170_REFBU_NONSEQ; \
if( apfTmpThreshold > 63 ) \
apfTmpThreshold = 63; \
} \
SetDecRegister(regBase, HWIF_APF_THRESHOLD, apfTmpThreshold ); \
}
/* Check validity of the stream addresses */
#define X170_CHECK_BUS_ADDRESS(d) ((d) < 64 ? 1 : 0)
#define X170_CHECK_VIRTUAL_ADDRESS(d) (((void*)(d) < (void*)64) ? 1 : 0)
#endif /* __DEC_X170_CFG_H__ */

View File

@ -0,0 +1,110 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : interface between pp and decoder
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: decppif.h,v $
-- $Date: 2010/12/02 10:53:50 $
-- $Revision: 1.16 $
--
------------------------------------------------------------------------------*/
#ifndef _PPDEC_H_
#define _PPDEC_H_
#include "basetype.h"
/* PP input types (picStruct) */
/* Frame or top field */
#define DECPP_PIC_FRAME_OR_TOP_FIELD 0U
/* Bottom field only */
#define DECPP_PIC_BOT_FIELD 1U
/* top and bottom is separate locations */
#define DECPP_PIC_TOP_AND_BOT_FIELD 2U
/* top and bottom interleaved */
#define DECPP_PIC_TOP_AND_BOT_FIELD_FRAME 3U
/* interleaved top only */
#define DECPP_PIC_TOP_FIELD_FRAME 4U
/* interleaved bottom only */
#define DECPP_PIC_BOT_FIELD_FRAME 5U
/* Control interface between decoder and pp */
/* decoder writes, pp read-only */
typedef struct DecPpInterface_
{
enum
{
DECPP_IDLE = 0,
DECPP_RUNNING, /* PP was started */
DECPP_PIC_READY, /* PP has finished a picture */
DECPP_PIC_NOT_FINISHED /* PP still processing a picture */
} ppStatus; /* Decoder keeps track of what it asked the pp to do */
enum
{
MULTIBUFFER_UNINIT = 0, /* buffering mode not yet decided */
MULTIBUFFER_DISABLED, /* Single buffer legacy mode */
MULTIBUFFER_SEMIMODE, /* enabled but full pipel cannot be used */
MULTIBUFFER_FULLMODE /* enabled and full pipeline successful */
} multiBufStat;
u32 inputBusLuma;
u32 inputBusChroma;
u32 bottomBusLuma;
u32 bottomBusChroma;
u32 picStruct; /* structure of input picture */
u32 topField;
u32 inwidth;
u32 inheight;
u32 usePipeline;
u32 littleEndian;
u32 wordSwap;
u32 croppedW;
u32 croppedH;
u32 bufferIndex; /* multibuffer, where to put PP output */
u32 displayIndex; /* multibuffer, next picture in display order */
u32 prevAnchorDisplayIndex;
/* VC-1 */
u32 rangeRed;
u32 rangeMapYEnable;
u32 rangeMapYCoeff;
u32 rangeMapCEnable;
u32 rangeMapCCoeff;
u32 tiledMode;
} DecPpInterface;
/* Decoder asks with this struct information about pp setup */
/* pp writes, decoder read-only */
typedef struct DecPpQuery_
{
/* Dec-to-PP direction */
u32 tiledMode;
/* PP-to-Dec direction */
u32 pipelineAccepted; /* PP accepts pipeline */
u32 deinterlace; /* Deinterlace feature used */
u32 multiBuffer; /* multibuffer PP output enabled */
u32 ppConfigChanged; /* PP config changed after previous output */
} DecPpQuery;
#endif

180
lib/hx170dec/include/dwl.h Normal file
View File

@ -0,0 +1,180 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Sytem Wrapper Layer
--
------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: dwl.h,v $
-- $Revision: 1.21 $
-- $Date: 2010/12/01 12:31:03 $
--
------------------------------------------------------------------------------*/
#ifndef __DWL_H__
#define __DWL_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "basetype.h"
#include "decapicommon.h"
#define DWL_OK 0
#define DWL_ERROR -1
#define DWL_HW_WAIT_OK DWL_OK
#define DWL_HW_WAIT_ERROR DWL_ERROR
#define DWL_HW_WAIT_TIMEOUT 1
#define DWL_CLIENT_TYPE_H264_DEC 1U
#define DWL_CLIENT_TYPE_MPEG4_DEC 2U
#define DWL_CLIENT_TYPE_JPEG_DEC 3U
#define DWL_CLIENT_TYPE_PP 4U
#define DWL_CLIENT_TYPE_VC1_DEC 5U
#define DWL_CLIENT_TYPE_MPEG2_DEC 6U
#define DWL_CLIENT_TYPE_VP6_DEC 7U
#define DWL_CLIENT_TYPE_AVS_DEC 9U /* TODO: fix */
#define DWL_CLIENT_TYPE_RV_DEC 8U
#define DWL_CLIENT_TYPE_VP8_DEC 10U
/* Linear memory area descriptor */
typedef struct DWLLinearMem
{
u32 *virtualAddress;
u32 busAddress;
u32 size;
} DWLLinearMem_t;
/* DWLInitParam is used to pass parameters when initializing the DWL */
typedef struct DWLInitParam
{
u32 clientType;
} DWLInitParam_t;
/* Hardware configuration description */
typedef struct DWLHwConfig
{
u32 maxDecPicWidth; /* Maximum video decoding width supported */
u32 maxPpOutPicWidth; /* Maximum output width of Post-Processor */
u32 h264Support; /* HW supports h.264 */
u32 jpegSupport; /* HW supports JPEG */
u32 mpeg4Support; /* HW supports MPEG-4 */
u32 customMpeg4Support; /* HW supports custom MPEG-4 features */
u32 vc1Support; /* HW supports VC-1 Simple */
u32 mpeg2Support; /* HW supports MPEG-2 */
u32 ppSupport; /* HW supports post-processor */
u32 ppConfig; /* HW post-processor functions bitmask */
u32 sorensonSparkSupport; /* HW supports Sorenson Spark */
u32 refBufSupport; /* HW supports reference picture buffering */
u32 tiledModeSupport; /* HW supports tiled reference pictuers */
u32 vp6Support; /* HW supports VP6 */
u32 vp7Support; /* HW supports VP7 */
u32 vp8Support; /* HW supports VP8 */
u32 avsSupport; /* HW supports AVS */
u32 jpegESupport; /* HW supports JPEG extensions */
u32 rvSupport; /* HW supports REAL */
u32 mvcSupport; /* HW supports H264 MVC extension */
u32 webpSupport; /* HW supports WebP (VP8 snapshot) */
u32 ecSupport; /* one of the EC values defined above */
u32 strideSupport; /* HW supports separate Y and C strides */
u32 fieldDpbSupport;
} DWLHwConfig_t;
typedef struct DWLHwFuseStatus
{
u32 h264SupportFuse; /* HW supports h.264 */
u32 mpeg4SupportFuse; /* HW supports MPEG-4 */
u32 mpeg2SupportFuse; /* HW supports MPEG-2 */
u32 sorensonSparkSupportFuse; /* HW supports Sorenson Spark */
u32 jpegSupportFuse; /* HW supports JPEG */
u32 vp6SupportFuse; /* HW supports VP6 */
u32 vp7SupportFuse; /* HW supports VP6 */
u32 vp8SupportFuse; /* HW supports VP6 */
u32 vc1SupportFuse; /* HW supports VC-1 Simple */
u32 jpegProgSupportFuse; /* HW supports Progressive JPEG */
u32 ppSupportFuse; /* HW supports post-processor */
u32 ppConfigFuse; /* HW post-processor functions bitmask */
u32 maxDecPicWidthFuse; /* Maximum video decoding width supported */
u32 maxPpOutPicWidthFuse; /* Maximum output width of Post-Processor */
u32 refBufSupportFuse; /* HW supports reference picture buffering */
u32 avsSupportFuse; /* one of the AVS values defined above */
u32 rvSupportFuse; /* one of the REAL values defined above */
u32 mvcSupportFuse;
u32 customMpeg4SupportFuse; /* Fuse for custom MPEG-4 */
} DWLHwFuseStatus_t;
/* HW ID retriving, static implementation */
u32 DWLReadAsicID(void);
/* HW configuration retrieving, static implementation */
void DWLReadAsicConfig(DWLHwConfig_t * pHwCfg);
/* HW fuse retrieving, static implementation */
void DWLReadAsicFuseStatus(DWLHwFuseStatus_t * pHwFuseSts);
/* DWL initilaization and release */
const void *DWLInit(DWLInitParam_t * param);
i32 DWLRelease(const void *instance);
/* HW sharing */
i32 DWLReserveHw(const void *instance);
void DWLReleaseHw(const void *instance);
/* Frame buffers memory */
i32 DWLMallocRefFrm(const void *instance, u32 size, DWLLinearMem_t * info);
void DWLFreeRefFrm(const void *instance, DWLLinearMem_t * info);
/* SW/HW shared memory */
i32 DWLMallocLinear(const void *instance, u32 size, DWLLinearMem_t * info);
void DWLFreeLinear(const void *instance, DWLLinearMem_t * info);
/* D-Cache coherence */
void DWLDCacheRangeFlush(const void *instance, DWLLinearMem_t * info); /* NOT in use */
void DWLDCacheRangeRefresh(const void *instance, DWLLinearMem_t * info); /* NOT in use */
/* Register access */
void DWLWriteReg(const void *instance, u32 offset, u32 value);
u32 DWLReadReg(const void *instance, u32 offset);
void DWLWriteRegAll(const void *instance, const u32 * table, u32 size); /* NOT in use */
void DWLReadRegAll(const void *instance, u32 * table, u32 size); /* NOT in use */
/* HW starting/stopping */
void DWLEnableHW(const void *instance, u32 offset, u32 value);
void DWLDisableHW(const void *instance, u32 offset, u32 value);
/* HW synchronization */
i32 DWLWaitHwReady(const void *instance, u32 timeout);
/* SW/SW shared memory */
void *DWLmalloc(u32 n);
void DWLfree(void *p);
void *DWLcalloc(u32 n, u32 s);
void *DWLmemcpy(void *d, const void *s, u32 n);
void *DWLmemset(void *d, i32 c, u32 n);
void DWLSoftResetAsic(void);
#ifdef __cplusplus
}
#endif
#endif /* __DWL_H__ */

View File

@ -0,0 +1,75 @@
/*------------------------------------------------------------------------------
-- Copyright (c) 2015-2017, VeriSilicon Inc. All rights reserved --
-- Copyright (c) 2011-2014, Google Inc. All rights reserved. --
-- Copyright (c) 2007-2010, Hantro OY. All rights reserved. --
-- --
-- This software is confidential and proprietary and may be used only as --
-- expressly authorized by VeriSilicon in a written licensing agreement. --
-- --
-- This entire notice must be reproduced on all copies --
-- and may not be removed. --
-- --
--------------------------------------------------------------------------------
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are met:--
-- * Redistributions of source code must retain the above copyright notice, --
-- this list of conditions and the following disclaimer. --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- * Neither the names of Google nor the names of its contributors may be --
-- used to endorse or promote products derived from this software --
-- without specific prior written permission. --
--------------------------------------------------------------------------------
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"--
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE --
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE --
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE --
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR --
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF --
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS --
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN --
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) --
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE --
-- POSSIBILITY OF SUCH DAMAGE. --
--------------------------------------------------------------------------------
------------------------------------------------------------------------------*/
#ifndef SOFTWARE_LINUX_DWL_DWL_DEFS_H_
#define SOFTWARE_LINUX_DWL_DWL_DEFS_H_
#define DWL_MPEG2_E 31 /* 1 bit */
#define DWL_VC1_E 29 /* 2 bits */
#define DWL_JPEG_E 28 /* 1 bit */
#define DWL_MPEG4_E 26 /* 2 bits */
#define DWL_H264_E 24 /* 2 bits */
#define DWL_VP6_E 23 /* 1 bit */
#define DWL_RV_E 26 /* 2 bits */
#define DWL_VP8_E 23 /* 1 bit */
#define DWL_VP7_E 24 /* 1 bit */
#define DWL_WEBP_E 19 /* 1 bit */
#define DWL_AVS_E 22 /* 1 bit */
#define DWL_PP_E 16 /* 1 bit */
#define HX170_IRQ_STAT_DEC 1
#define HX170_IRQ_STAT_DEC_OFF (HX170_IRQ_STAT_DEC * 4)
#define HX170_IRQ_STAT_PP 60
#define HX170_IRQ_STAT_PP_OFF (HX170_IRQ_STAT_PP * 4)
#define HX170PP_SYNTH_CFG 100
#define HX170PP_SYNTH_CFG_OFF (HX170PP_SYNTH_CFG * 4)
#define HX170DEC_SYNTH_CFG 50
#define HX170DEC_SYNTH_CFG_OFF (HX170DEC_SYNTH_CFG * 4)
#define HX170DEC_SYNTH_CFG_2 54
#define HX170DEC_SYNTH_CFG_2_OFF (HX170DEC_SYNTH_CFG_2 * 4)
#define HX170_DEC_E 0x01
#define HX170_PP_E 0x01
#define HX170_DEC_ABORT 0x20
#define HX170_DEC_IRQ_DISABLE 0x10
#define HX170_PP_IRQ_DISABLE 0x10
#define HX170_DEC_IRQ 0x100
#define HX170_PP_IRQ 0x100
#endif /* SOFTWARE_LINUX_DWL_DWL_DEFS_H_ */

View File

@ -0,0 +1,69 @@
#include "basetype.h"
#include "dwl.h"
//#define _DWL_DEBUG
#ifdef _DWL_DEBUG
#define DWL_DEBUG(fmt, args...) printf(__FILE__ ":%d: " fmt, __LINE__ , ## args)
#else
#define DWL_DEBUG(fmt, args...) /* not debugging: nothing */
#endif
#ifndef HX170DEC_IO_BASE
#define HX170DEC_IO_BASE 0xC0000000U
#endif
#define HX170PP_REG_START 0xF0
#define HX170DEC_REG_START 0x4
#define HX170PP_SYNTH_CFG 100
#define HX170DEC_SYNTH_CFG 50
#define HX170DEC_SYNTH_CFG_2 54
#define HX170PP_FUSE_CFG 99
#define HX170DEC_FUSE_CFG 57
#define DWL_DECODER_INT ((DWLReadReg(dec_dwl, HX170DEC_REG_START) >> 12) & 0xFFU)
#define DWL_PP_INT ((DWLReadReg(dec_dwl, HX170PP_REG_START) >> 12) & 0xFFU)
#define DEC_IRQ_ABORT (1 << 11)
#define DEC_IRQ_RDY (1 << 12)
#define DEC_IRQ_BUS (1 << 13)
#define DEC_IRQ_BUFFER (1 << 14)
#define DEC_IRQ_ASO (1 << 15)
#define DEC_IRQ_ERROR (1 << 16)
#define DEC_IRQ_SLICE (1 << 17)
#define DEC_IRQ_TIMEOUT (1 << 18)
#define PP_IRQ_RDY (1 << 12)
#define PP_IRQ_BUS (1 << 13)
#define DWL_STREAM_ERROR_BIT 0x010000 /* 16th bit */
#define DWL_HW_TIMEOUT_BIT 0x040000 /* 18th bit */
#define DWL_HW_ENABLE_BIT 0x000001 /* 0th bit */
#define DWL_HW_PIC_RDY_BIT 0x001000 /* 12th bit */
#ifdef _DWL_HW_PERFORMANCE
/* signal that decoder/pp is enabled */
void DwlDecoderEnable(void);
void DwlPpEnable(void);
#endif
/* Function prototypes */
/* wrapper information */
typedef struct hX170dwl
{
u32 clientType;
u32 numCores;
volatile u32 *pRegBase; /* IO mem base */
u32 regSize; /* IO mem size */
u32 freeLinMem; /* Start address of free linear memory */
u32 freeRefFrmMem; /* Start address of free reference frame memory */
int semid;
int sigio_needed;
u32 bPPReserved;
} hX170dwl_t;
i32 DWLWaitPpHwReady(const void *instance, u32 timeout);
i32 DWLWaitDecHwReady(const void *instance, u32 timeout);
void DWLSoftResetAsic(void);

View File

@ -0,0 +1,41 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
-
- Description : Dec/PP multibuiffer handling
-
--------------------------------------------------------------------------------
-
- Version control information, please leave untouched.
-
- $RCSfile: h264_pp_multibuffer.h,v $
- $Revision: 1.1 $
- $Date: 2008/08/27 11:59:54 $
-
------------------------------------------------------------------------------*/
#ifndef H264_PP_MULTIBUFFER_H
#define H264_PP_MULTIBUFFER_H
#include "basetype.h"
#include "dwl.h"
#include "h264hwd_container.h"
void h264PpMultiInit(decContainer_t * pDecCont, u32 maxBuff);
u32 h264PpMultiAddPic(decContainer_t * pDecCont, const DWLLinearMem_t * data);
u32 h264PpMultiRemovePic(decContainer_t * pDecCont,
const DWLLinearMem_t * data);
u32 h264PpMultiFindPic(decContainer_t * pDecCont, const DWLLinearMem_t * data);
#endif /* H264_PP_MULTIBUFFER_H */

View File

@ -0,0 +1,43 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : H264 decoder and PP pipeline support
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264_pp_pipeline.h,v $
-- $Date: 2010/07/23 09:51:27 $
-- $Revision: 1.6 $
--
------------------------------------------------------------------------------*/
#ifndef H264_PP_PIPELINE_H
#define H264_PP_PIPELINE_H
#include "decppif.h"
i32 h264RegisterPP(const void *decInst, const void *ppInst,
void (*PPDecStart) (const void *, const DecPpInterface *),
void (*PPDecWaitEnd) (const void *),
void (*PPConfigQuery) (const void *, DecPpQuery *),
void (*PPDisplayIndex) (const void *, u32));
i32 h264UnregisterPP(const void *decInst, const void *ppInst);
u32 h264UseDisplaySmoothing(const void *decInst);
#endif /* #ifdef H264_PP_PIPELINE_H */

View File

@ -0,0 +1,193 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : API of H.264 Decoder
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264decapi.h,v $
-- $Date: 2010/02/17 13:28:46 $
-- $Revision: 1.9 $
--
------------------------------------------------------------------------------*/
#ifndef __H264DECAPI_H__
#define __H264DECAPI_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "basetype.h"
#include "decapicommon.h"
/*------------------------------------------------------------------------------
API type definitions
------------------------------------------------------------------------------*/
/* Return values */
typedef enum H264DecRet_
{
H264DEC_OK = 0,
H264DEC_STRM_PROCESSED = 1,
H264DEC_PIC_RDY = 2,
H264DEC_PIC_DECODED = 3,
H264DEC_HDRS_RDY = 4,
H264DEC_ADVANCED_TOOLS = 5,
H264DEC_PENDING_FLUSH = 6,
H264DEC_PARAM_ERROR = -1,
H264DEC_STRM_ERROR = -2,
H264DEC_NOT_INITIALIZED = -3,
H264DEC_MEMFAIL = -4,
H264DEC_INITFAIL = -5,
H264DEC_HDRS_NOT_RDY = -6,
H264DEC_STREAM_NOT_SUPPORTED = -8,
H264DEC_HW_RESERVED = -254,
H264DEC_HW_TIMEOUT = -255,
H264DEC_HW_BUS_ERROR = -256,
H264DEC_SYSTEM_ERROR = -257,
H264DEC_DWL_ERROR = -258,
H264DEC_EVALUATION_LIMIT_EXCEEDED = -999,
H264DEC_FORMAT_NOT_SUPPORTED = -1000
} H264DecRet;
/* decoder output picture format */
typedef enum H264DecOutFormat_
{
H264DEC_SEMIPLANAR_YUV420 = 0x020001,
H264DEC_TILED_YUV420 = 0x020002,
H264DEC_YUV400 = 0x080000
} H264DecOutFormat;
/* Decoder instance */
typedef const void *H264DecInst;
/* Input structure */
typedef struct H264DecInput_
{
u8 *pStream; /* Pointer to the input */
u32 streamBusAddress; /* DMA bus address of the input stream */
u32 dataLen; /* Number of bytes to be decoded */
u32 picId; /* Identifier for the picture to be decoded */
} H264DecInput;
/* Output structure */
typedef struct H264DecOutput_
{
u8 *pStrmCurrPos; /* Pointer to stream position where decoding ended */
u32 strmCurrBusAddress; /* DMA bus address location where the decoding ended */
u32 dataLeft; /* how many bytes left undecoded */
} H264DecOutput;
/* cropping info */
typedef struct H264CropParams_
{
u32 cropLeftOffset;
u32 cropOutWidth;
u32 cropTopOffset;
u32 cropOutHeight;
} H264CropParams;
/* Output structure for H264DecNextPicture */
typedef struct H264DecPicture_
{
u32 picWidth; /* pixels width of the picture as stored in memory */
u32 picHeight; /* pixel height of the picture as stored in memory */
H264CropParams cropParams; /* cropping parameters */
const u32 *pOutputPicture; /* Pointer to the picture */
u32 outputPictureBusAddress; /* DMA bus address of the output picture buffer */
u32 picId; /* Identifier of the picture to be displayed */
u32 isIdrPicture; /* Indicates if picture is an IDR picture */
u32 nbrOfErrMBs; /* Number of concealed MB's in the picture */
u32 interlaced; /* non-zero for interlaced picture */
u32 fieldPicture; /* non-zero if interlaced and only one field present */
u32 topField; /* if only one field, non-zero signals TOP field otherwise BOTTOM */
} H264DecPicture;
/* stream info filled by H264DecGetInfo */
typedef struct H264DecInfo_
{
u32 picWidth; /* decoded picture width in pixels */
u32 picHeight; /* decoded picture height in pixels */
u32 videoRange; /* samples' video range */
u32 matrixCoefficients;
H264CropParams cropParams; /* display cropping information */
H264DecOutFormat outputFormat; /* format of the output picture */
u32 sarWidth; /* sample aspect ratio */
u32 sarHeight; /* sample aspect ratio */
u32 monoChrome; /* is sequence monochrome */
u32 interlacedSequence; /* is sequence interlaced */
u32 picBuffSize; /* number of picture buffers allocated&used by decoder */
u32 multiBuffPpSize; /* number of picture buffers needed in decoder+postprocessor multibuffer mode */
} H264DecInfo;
/* Version information */
typedef struct H264DecApiVersion_
{
u32 major; /* API major version */
u32 minor; /* API minor version */
} H264DecApiVersion;
typedef struct H264DecBuild_
{
u32 swBuild; /* Software build ID */
u32 hwBuild; /* Hardware build ID */
DecHwConfig hwConfig; /* hardware supported configuration */
} H264DecBuild;
/*------------------------------------------------------------------------------
Prototypes of Decoder API functions
------------------------------------------------------------------------------*/
H264DecApiVersion H264DecGetAPIVersion(void);
H264DecBuild H264DecGetBuild(void);
H264DecRet H264DecInit(H264DecInst * pDecInst, u32 noOutputReordering,
u32 useVideoFreezeConcealment,
u32 useDisplaySmoothing);
void H264DecRelease(H264DecInst decInst);
H264DecRet H264DecDecode(H264DecInst decInst,
const H264DecInput * pInput,
H264DecOutput * pOutput);
H264DecRet H264DecNextPicture(H264DecInst decInst,
H264DecPicture * pOutput, u32 endOfStream);
H264DecRet H264DecGetInfo(H264DecInst decInst, H264DecInfo * pDecInfo);
H264DecRet H264DecPeek(H264DecInst decInst, H264DecPicture * pOutput);
/*------------------------------------------------------------------------------
Prototype of the API trace funtion. Traces all API entries and returns.
This must be implemented by the application using the decoder API!
Argument:
string - trace message, a null terminated string
------------------------------------------------------------------------------*/
void H264DecTrace(const char *string);
#ifdef __cplusplus
}
#endif
#endif /* __H264DECAPI_H__ */

View File

@ -0,0 +1,51 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : API extension of H.264 Decoder
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264decapi_e.h,v $
-- $Date: 2009/06/08 12:21:05 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef __H264DECAPI_E_H__
#define __H264DECAPI_E_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "h264decapi.h"
/*------------------------------------------------------------------------------
Prototypes of Decoder API extension functions
------------------------------------------------------------------------------*/
H264DecRet H264DecNextChPicture(H264DecInst decInst,
u32 **pOutputPicture,
u32 *outputPictureBusAddress);
#ifdef __cplusplus
}
#endif
#endif /* __H264DECAPI_E_H__ */

View File

@ -0,0 +1,76 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Hardware interface read/write
--
------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_asic.h,v $
-- $Revision: 1.2 $
-- $Date: 2008/09/15 09:55:40 $
--
------------------------------------------------------------------------------*/
#ifndef __H264ASIC_H__
#define __H264ASIC_H__
#include "basetype.h"
#include "dwl.h"
#include "h264hwd_container.h"
#include "h264hwd_storage.h"
#define ASIC_MB_RLC_BUFFER_SIZE 880 /* bytes */
#define ASIC_MB_CTRL_BUFFER_SIZE 8 /* bytes */
#define ASIC_MB_MV_BUFFER_SIZE 64 /* bytes */
#define ASIC_MB_I4X4_BUFFER_SIZE 8 /* bytes */
#define ASIC_CABAC_INIT_BUFFER_SIZE 3680/* bytes */
#define ASIC_SCALING_LIST_SIZE 6*16+2*64
#define ASIC_POC_BUFFER_SIZE 34*4
#define X170_DEC_TIMEOUT 0x00FFU
#define X170_DEC_SYSTEM_ERROR 0x0FFFU
#define X170_DEC_HW_RESERVED 0xFFFFU
/* asic macroblock types */
typedef enum H264AsicMbTypes
{
HW_P_16x16 = 0,
HW_P_16x8 = 1,
HW_P_8x16 = 2,
HW_P_8x8 = 3,
HW_I_4x4 = 4,
HW_I_16x16 = 5,
HW_I_PCM = 6,
HW_P_SKIP = 7
} H264AsicMbTypes_t;
u32 AllocateAsicBuffers(decContainer_t * pDecCont,
DecAsicBuffers_t * asicBuff, u32 mbs);
void ReleaseAsicBuffers(const void *dwl, DecAsicBuffers_t * asicBuff);
void PrepareIntra4x4ModeData(storage_t * pStorage,
DecAsicBuffers_t * pAsicBuff);
void PrepareMvData(storage_t * pStorage, DecAsicBuffers_t * pAsicBuff);
void PrepareRlcCount(storage_t * pStorage, DecAsicBuffers_t * pAsicBuff);
void H264SetupVlcRegs(decContainer_t * pDecCont);
void H264InitRefPicList(decContainer_t *pDecCont);
u32 H264RunAsic(decContainer_t * pDecCont, DecAsicBuffers_t * pAsicBuff);
#endif /* __H264ASIC_H__ */

View File

@ -0,0 +1,67 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Extract a NAL unit from byte stream
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_byte_stream.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_BYTE_STREAM_H
#define H264HWD_BYTE_STREAM_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_stream.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdExtractNalUnit(const u8 * pByteStream, u32 len,
strmData_t * pStrmData, u32 * readBytes, u32 rlcMode);
const u8 *h264bsdFindNextStartCode(const u8 * pByteStream, u32 len);
#endif /* #ifdef H264HWD_BYTE_STREAM_H */

View File

@ -0,0 +1,35 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : CABAC initialization tables.
--
------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_cabac.h,v $
-- $Revision: 1.1 $
-- $Date: 2008/03/13 12:48:06 $
--
------------------------------------------------------------------------------*/
#ifndef __H264CABAC_H__
#define __H264CABAC_H__
#include "basetype.h"
extern const u32 cabacInitValues[4*460*2/4];
#endif /* __H264CABAC_H__ */

View File

@ -0,0 +1,53 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Context Adaptive Variable Lengtch Code (CAVLC) decoding
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_cavlc.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef H264HWD_CAVLC_H
#define H264HWD_CAVLC_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_stream.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdDecodeResidualBlockCavlc(strmData_t * pStrmData,
u16 * coeffLevel, i32 nc, u32 maxNumCoeff);
#endif /* #ifdef H264HWD_CAVLC_H */

View File

@ -0,0 +1,66 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decoder configuration information
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_cfg.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_CFG_H
#define H264HWD_CFG_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
#define MAX_NUM_REF_PICS 16
#define MAX_NUM_SLICE_GROUPS 8
#define MAX_NUM_SEQ_PARAM_SETS 32
#define MAX_NUM_PIC_PARAM_SETS 256
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
#endif /* #ifdef H264HWD_CFG_H */

View File

@ -0,0 +1,39 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Error concealment
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_conceal.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef __H264HWD_CONCEAL_H__
#define __H264HWD_CONCEAL_H__
#include "basetype.h"
#include "h264hwd_slice_header.h"
#include "h264hwd_storage.h"
#include "h264hwd_asic.h"
void h264bsdConceal(storage_t *pStorage, DecAsicBuffers_t * pAsicBuff,
u32 sliceType);
#endif /* __H264HWD_CONCEAL_H__ */

View File

@ -0,0 +1,130 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Definition of decContainer_t data structure
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_container.h,v $
-- $Date: 2009/04/27 08:56:17 $
-- $Revision: 1.10 $
--
------------------------------------------------------------------------------*/
#ifndef H264HWD_CONTAINER_H
#define H264HWD_CONTAINER_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_storage.h"
#include "h264hwd_util.h"
#include "refbuffer.h"
#include "deccfg.h"
#include "decppif.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
#define H264DEC_UNINITIALIZED 0U
#define H264DEC_INITIALIZED 1U
#define H264DEC_BUFFER_EMPTY 2U
#define H264DEC_NEW_HEADERS 3U
/* asic interface */
typedef struct DecAsicBuffers
{
u32 buff_status;
DWLLinearMem_t mbCtrl;
DWLLinearMem_t mv;
DWLLinearMem_t intraPred;
DWLLinearMem_t residual;
DWLLinearMem_t *outBuffer;
DWLLinearMem_t cabacInit;
u32 refPicList[16];
u32 maxRefFrm;
u32 filterDisable;
i32 chromaQpIndexOffset;
i32 chromaQpIndexOffset2;
u32 currentMB;
u32 notCodedMask;
u32 rlcWords;
u32 picSizeInMbs;
u32 wholePicConcealed;
u32 disableOutWriting;
u32 enableDmvAndPoc;
} DecAsicBuffers_t;
typedef struct decContainer
{
const void *checksum;
u32 decStat;
u32 picNumber;
u32 asicRunning;
u32 rlcMode;
u32 tryVlc;
u32 reallocate;
const u8 *pHwStreamStart;
u32 hwStreamStartBus;
u32 hwBitPos;
u32 hwLength;
u32 streamPosUpdated;
u32 nalStartCode;
u32 modeChange;
u32 gapsCheckedForThis;
u32 packetDecoded;
u32 forceRlcMode; /* by default stays 0, testing can set it to 1 for RLC mode */
u32 h264Regs[DEC_X170_REGISTERS];
storage_t storage; /* h264bsd storage */
DecAsicBuffers_t asicBuff[1];
const void *dwl; /* DWL instance */
u32 refBufSupport;
u32 h264ProfileSupport;
u32 is8190;
u32 maxDecPicWidth;
refBuffer_t refBufferCtrl;
u32 keepHwReserved;
struct pp_
{
const void *ppInstance;
void (*PPDecStart) (const void *, const DecPpInterface *);
void (*PPDecWaitEnd) (const void *);
void (*PPConfigQuery) (const void *, DecPpQuery *);
void (*PPNextDisplayId)(const void *, u32); /* set the next PP outpic ID (multibuffer) */
DecPpInterface decPpIf;
DecPpQuery ppInfo;
const DWLLinearMem_t * sentPicToPp[17]; /* list of pictures sent to pp */
const DWLLinearMem_t * queuedPicToPp; /* queued picture that should be processed next */
u32 multiMaxId; /* maximum position used in sentPicToPp[] */
} pp;
} decContainer_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
#endif /* #ifdef H264HWD_CONTAINER_H */

View File

@ -0,0 +1,85 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Utility macros for debugging and tracing
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_debug.h,v $
-- $Date: 2008/03/13 12:47:14 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef __H264DEBUG_H__
#define __H264DEBUG_H__
/* macro for assertion, used only when _ASSERT_USED is defined */
#ifdef _ASSERT_USED
#ifndef ASSERT
#include <assert.h>
#define ASSERT(expr) assert(expr)
#endif
#else
#define ASSERT(expr)
#endif
/* macros for range checking used only when _RANGE_CHECK is defined */
#ifdef _RANGE_CHECK
#include <stdio.h>
/* macro for range checking an single value */
#define RANGE_CHECK(value, minBound, maxBound) \
{ \
if ((value) < (minBound) || (value) > (maxBound)) \
fprintf(stderr, "Warning: Value exceeds given limit(s)!\n"); \
}
/* macro for range checking an array of values */
#define RANGE_CHECK_ARRAY(array, minBound, maxBound, length) \
{ \
i32 i; \
for (i = 0; i < (length); i++) \
if ((array)[i] < (minBound) || (array)[i] > (maxBound)) \
fprintf(stderr,"Warning: Value [%d] exceeds given limit(s)!\n",i); \
}
#else /* _RANGE_CHECK */
#define RANGE_CHECK_ARRAY(array, minBound, maxBound, length)
#define RANGE_CHECK(value, minBound, maxBound)
#endif /* _RANGE_CHECK */
/* macro for debug printing, used only when _DEBUG_PRINT is defined */
#ifdef _DEBUG_PRINT
#include <stdio.h>
#define DEBUG_PRINT(args) printf args
#else
#define DEBUG_PRINT(args)
#endif
/* macro for error printing, used only when _ERROR_PRINT is defined */
#ifdef _ERROR_PRINT
#include <stdio.h>
#define ERROR_PRINT(msg) fprintf(stderr,"ERROR: %s\n",msg)
#else
#define ERROR_PRINT(msg)
#endif
#endif /* __H264DEBUG_H__ */

View File

@ -0,0 +1,88 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Top level control of the decoder
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_decoder.h,v $
-- $Date: 2009/11/26 13:32:15 $
-- $Revision: 1.4 $
--
------------------------------------------------------------------------------*/
#ifndef H264HWD_DECODER_H
#define H264HWD_DECODER_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_storage.h"
#include "h264hwd_container.h"
#include "h264hwd_dpb.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/* enumerated return values of the functions */
enum
{
H264BSD_RDY,
H264BSD_PIC_RDY,
H264BSD_HDRS_RDY,
H264BSD_ERROR,
H264BSD_PARAM_SET_ERROR,
H264BSD_NEW_ACCESS_UNIT,
H264BSD_FMO,
H264BSD_UNPAIRED_FIELD
};
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
void h264bsdInit(storage_t * pStorage, u32 noOutputReordering,
u32 useSmoothingBuffer);
u32 h264bsdDecode(decContainer_t * pDecCont, const u8 * byteStrm, u32 len,
u32 picId, u32 * readBytes);
void h264bsdShutdown(storage_t * pStorage);
const dpbOutPicture_t *h264bsdNextOutputPicture(storage_t * pStorage);
u32 h264bsdPicWidth(storage_t * pStorage);
u32 h264bsdPicHeight(storage_t * pStorage);
u32 h264bsdVideoRange(storage_t * pStorage);
u32 h264bsdMatrixCoefficients(storage_t * pStorage);
u32 h264bsdIsMonoChrome(storage_t * pStorage);
void h264bsdCroppingParams(storage_t * pStorage, u32 * croppingFlag,
u32 * left, u32 * width, u32 * top, u32 * height);
u32 h264bsdCheckValidParamSets(storage_t * pStorage);
void h264bsdFlushBuffer(storage_t * pStorage);
u32 h264bsdAspectRatioIdc(const storage_t * pStorage);
void h264bsdSarSize(const storage_t * pStorage, u32 * sar_width,
u32 * sar_height);
#endif /* #ifdef H264HWD_DECODER_H */

View File

@ -0,0 +1,185 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decoded Picture Buffer (DPB) handling
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_dpb.h,v $
-- $Date: 2010/01/12 07:06:02 $
-- $Revision: 1.11 $
--
------------------------------------------------------------------------------*/
#ifndef H264HWD_DPB_H
#define H264HWD_DPB_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_slice_header.h"
#include "h264hwd_image.h"
#include "dwl.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/* enumeration to represent status of buffered image */
typedef enum
{
UNUSED = 0,
NON_EXISTING,
SHORT_TERM,
LONG_TERM,
EMPTY
} dpbPictureStatus_e;
/* structure to represent a buffered picture */
typedef struct dpbPicture
{
u32 memIdx;
DWLLinearMem_t *data;
i32 picNum;
u32 frameNum;
i32 picOrderCnt[2];
dpbPictureStatus_e status[2];
u32 toBeDisplayed;
u32 picId;
u32 numErrMbs;
u32 isIdr;
u32 isFieldPic;
} dpbPicture_t;
/* structure to represent display image output from the buffer */
typedef struct
{
u32 memIdx;
DWLLinearMem_t *data;
u32 picId;
u32 numErrMbs;
u32 isIdr;
u32 interlaced;
u32 fieldPicture;
u32 topField;
} dpbOutPicture_t;
/* structure to represent DPB */
typedef struct dpbStorage
{
dpbPicture_t buffer[16 + 1];
u32 list[16 + 1];
dpbPicture_t *currentOut;
u32 currentOutPos;
dpbOutPicture_t *outBuf;
u32 numOut;
u32 outIndexW;
u32 outIndexR;
u32 maxRefFrames;
u32 dpbSize;
u32 maxFrameNum;
u32 maxLongTermFrameIdx;
u32 numRefFrames;
u32 fullness;
u32 prevRefFrameNum;
u32 lastContainsMmco5;
u32 noReordering;
u32 flushed;
u32 picSizeInMbs;
u32 dirMvOffset;
DWLLinearMem_t poc;
u32 delayedOut;
u32 delayedId;
u32 interlaced;
u32 ch2Offset;
u32 numFreeBuffers;
u32 freeBuffers[16+1];
u32 memStat[16+1+16+1];
u32 totBuffers;
DWLLinearMem_t picBuffers[16+1+16+1];
/* flag to prevent output when display smoothing is used and second field
* of a picture was just decoded */
u32 noOutput;
u32 prevOutIdx;
} dpbStorage_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdInitDpb(const void *dwl,
dpbStorage_t * dpb,
u32 picSizeInMbs,
u32 dpbSize,
u32 numRefFrames, u32 maxFrameNum, u32 noReordering,
u32 displaySmoothing,
u32 monoChrome, u32 isHighSupported, u32 enable2ndChroma);
u32 h264bsdResetDpb(const void *dwl,
dpbStorage_t * dpb,
u32 picSizeInMbs,
u32 dpbSize,
u32 numRefFrames, u32 maxFrameNum, u32 noReordering,
u32 displaySmoothing,
u32 monoChrome, u32 isHighSupported, u32 enable2ndChroma);
void h264bsdInitRefPicList(dpbStorage_t * dpb);
void *h264bsdAllocateDpbImage(dpbStorage_t * dpb);
i32 h264bsdGetRefPicData(const dpbStorage_t * dpb, u32 index);
u8 *h264bsdGetRefPicDataVlcMode(const dpbStorage_t * dpb, u32 index,
u32 fieldMode);
u32 h264bsdReorderRefPicList(dpbStorage_t * dpb,
refPicListReordering_t * order,
u32 currFrameNum, u32 numRefIdxActive);
u32 h264bsdMarkDecRefPic(dpbStorage_t * dpb,
/*@null@ */ const decRefPicMarking_t * mark,
const image_t * image, u32 frameNum, i32 *picOrderCnt,
u32 isIdr, u32 picId, u32 numErrMbs);
u32 h264bsdCheckGapsInFrameNum(dpbStorage_t * dpb, u32 frameNum, u32 isRefPic,
u32 gapsAllowed);
/*@null@*/ dpbOutPicture_t *h264bsdDpbOutputPicture(dpbStorage_t * dpb);
void h264bsdFlushDpb(dpbStorage_t * dpb);
void h264bsdFreeDpb(const void *dwl, dpbStorage_t * dpb);
void ShellSort(dpbStorage_t * dpb, u32 *list, u32 type, i32 par);
void ShellSortF(dpbStorage_t * dpb, u32 *list, u32 type, /*u32 parity,*/ i32 par);
void SetPicNums(dpbStorage_t * dpb, u32 currFrameNum);
void h264DpbUpdateOutputList(dpbStorage_t * dpb, const image_t * image);
#endif /* #ifdef H264HWD_DPB_H */

View File

@ -0,0 +1,45 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Macroblock level stream decoding and macroblock reconstruction
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_exports.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef __H264HWD_EXPORTS_H__
#define __H264HWD_EXPORTS_H__
#include "h264hwd_asic.h"
#include "h264hwd_storage.h"
u32 h264bsdDecodeMacroblock(storage_t * pStorage, u32 mbNum, i32 * qpY,
DecAsicBuffers_t * pAsicBuff);
u32 PrepareIntraPrediction(mbStorage_t * pMb, macroblockLayer_t * mbLayer,
u32 constrainedIntraPred,
DecAsicBuffers_t * pAsicBuff);
u32 PrepareInterPrediction(mbStorage_t * pMb, macroblockLayer_t * pMbLayer,
dpbStorage_t * dpb, DecAsicBuffers_t * pAsicBuff);
#endif /* __H264HWD_EXPORTS_H__ */

View File

@ -0,0 +1,66 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Write macroblock data into the picture
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_image.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_IMAGE_H
#define H264HWD_IMAGE_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "dwl.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
typedef struct
{
DWLLinearMem_t *data;
u32 width;
u32 height;
u32 picStruct;
} image_t;
#endif /* #ifdef H264HWD_IMAGE_H */

View File

@ -0,0 +1,208 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Macroblock level stream decoding and macroblock reconstruction
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_macroblock_layer.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef H264HWD_MACROBLOCK_LAYER_H
#define H264HWD_MACROBLOCK_LAYER_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_stream.h"
#include "h264hwd_slice_header.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/* Macro to determine if a mb is an intra mb */
#define IS_INTRA_MB(a) ((a).mbType > 5)
/* Macro to determine if a mb is an I_PCM mb */
#define IS_I_PCM_MB(a) ((a).mbType == 31)
typedef enum mbType
{
P_Skip = 0,
P_L0_16x16 = 1,
P_L0_L0_16x8 = 2,
P_L0_L0_8x16 = 3,
P_8x8 = 4,
P_8x8ref0 = 5,
I_4x4 = 6,
I_16x16_0_0_0 = 7,
I_16x16_1_0_0 = 8,
I_16x16_2_0_0 = 9,
I_16x16_3_0_0 = 10,
I_16x16_0_1_0 = 11,
I_16x16_1_1_0 = 12,
I_16x16_2_1_0 = 13,
I_16x16_3_1_0 = 14,
I_16x16_0_2_0 = 15,
I_16x16_1_2_0 = 16,
I_16x16_2_2_0 = 17,
I_16x16_3_2_0 = 18,
I_16x16_0_0_1 = 19,
I_16x16_1_0_1 = 20,
I_16x16_2_0_1 = 21,
I_16x16_3_0_1 = 22,
I_16x16_0_1_1 = 23,
I_16x16_1_1_1 = 24,
I_16x16_2_1_1 = 25,
I_16x16_3_1_1 = 26,
I_16x16_0_2_1 = 27,
I_16x16_1_2_1 = 28,
I_16x16_2_2_1 = 29,
I_16x16_3_2_1 = 30,
I_PCM = 31
} mbType_e;
typedef enum subMbType
{
P_L0_8x8 = 0,
P_L0_8x4 = 1,
P_L0_4x8 = 2,
P_L0_4x4 = 3
} subMbType_e;
typedef enum mbPartMode
{
MB_P_16x16 = 0,
MB_P_16x8,
MB_P_8x16,
MB_P_8x8
} mbPartMode_e;
typedef enum subMbPartMode
{
MB_SP_8x8 = 0,
MB_SP_8x4,
MB_SP_4x8,
MB_SP_4x4
} subMbPartMode_e;
typedef enum mbPartPredMode
{
PRED_MODE_INTRA4x4 = 0,
PRED_MODE_INTRA16x16,
PRED_MODE_INTER
} mbPartPredMode_e;
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
typedef struct mv
{
i16 hor;
i16 ver;
} mv_t;
typedef struct mbPred
{
u32 prevIntra4x4PredModeFlag[16];
u32 remIntra4x4PredMode[16];
u32 intraChromaPredMode;
} mbPred_t;
typedef struct subMbPred
{
subMbType_e subMbType[4];
} subMbPred_t;
typedef struct
{
u16 rlc[468];
u8 totalCoeff[28];
} residual_t;
typedef struct macroblockLayer
{
/*u32 disableDeblockingFilterIdc; */
i32 filterOffsetA;
i32 filterOffsetB;
u32 disableDeblockingFilterIdc;
mbType_e mbType;
u32 codedBlockPattern;
i32 mbQpDelta;
mbPred_t mbPred;
subMbPred_t subMbPred;
residual_t residual;
} macroblockLayer_t;
typedef struct mbStorage
{
mbType_e mbType;
mbType_e mbType_asic;
u32 sliceId;
/*u32 disableDeblockingFilterIdc; */
/*i32 filterOffsetA; */
/*i32 filterOffsetB; */
u32 qpY;
/*i32 chromaQpIndexOffset; */
u8 totalCoeff[24];
u8 intra4x4PredMode[16];
u8 intra4x4PredMode_asic[16];
/* u32 refPic[4]; */
u8 refIdxL0[4];
u8 refID[4];
mv_t mv[16];
u32 decoded;
struct mbStorage *mbA;
struct mbStorage *mbB;
struct mbStorage *mbC;
struct mbStorage *mbD;
} mbStorage_t;
struct cabac_s;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdDecodeMacroblockLayerCavlc(strmData_t * pStrmData,
macroblockLayer_t * pMbLayer,
mbStorage_t * pMb,
const sliceHeader_t * pSliceHdr );
u32 h264bsdDecodeMacroblockLayerCabac(strmData_t * pStrmData,
macroblockLayer_t * pMbLayer,
mbStorage_t * pMb,
const sliceHeader_t * pSliceHdr,
struct cabac_s * pCabac );
u32 h264bsdNumSubMbPart(subMbType_e subMbType);
subMbPartMode_e h264bsdSubMbPartMode(subMbType_e subMbType);
u32 h264bsdPredModeIntra16x16(mbType_e mbType);
mbPartPredMode_e h264bsdMbPartPredMode(mbType_e mbType);
#endif /* #ifdef H264HWD_MACROBLOCK_LAYER_H */

View File

@ -0,0 +1,93 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode NAL unit header
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_nal_unit.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_NAL_UNIT_H
#define H264HWD_NAL_UNIT_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_stream.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/* macro to determine if NAL unit pointed by pNalUnit contains an IDR slice */
#define IS_IDR_NAL_UNIT(pNalUnit) \
((pNalUnit)->nalUnitType == NAL_CODED_SLICE_IDR)
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
typedef enum
{
NAL_UNSPECIFIED = 0,
NAL_CODED_SLICE = 1,
NAL_CODED_SLICE_DP_A = 2,
NAL_CODED_SLICE_DP_B = 3,
NAL_CODED_SLICE_DP_C = 4,
NAL_CODED_SLICE_IDR = 5,
NAL_SEI = 6,
NAL_SEQ_PARAM_SET = 7,
NAL_PIC_PARAM_SET = 8,
NAL_ACCESS_UNIT_DELIMITER = 9,
NAL_END_OF_SEQUENCE = 10,
NAL_END_OF_STREAM = 11,
NAL_FILLER_DATA = 12,
NAL_SPS_EXT = 13,
NAL_CODED_SLICE_AUX = 19,
NAL_MAX_TYPE_VALUE = 31
} nalUnitType_e;
typedef struct
{
nalUnitType_e nalUnitType;
u32 nalRefIdc;
} nalUnit_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdDecodeNalUnit(strmData_t * pStrmData, nalUnit_t * pNalUnit);
#endif /* #ifdef H264HWD_NAL_UNIT_H */

View File

@ -0,0 +1,91 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Get neighbour blocks
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_neighbour.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_NEIGHBOUR_H
#define H264HWD_NEIGHBOUR_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_macroblock_layer.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
typedef enum {
MB_A = 0,
MB_B,
MB_C,
MB_D,
MB_CURR,
MB_NA = 0xFF
} neighbourMb_e;
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
typedef struct
{
neighbourMb_e mb;
u8 index;
} neighbour_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
void h264bsdInitMbNeighbours(mbStorage_t *pMbStorage, u32 picWidth,
u32 picSizeInMbs);
/*@null@*/ mbStorage_t* h264bsdGetNeighbourMb(mbStorage_t *pMb,
neighbourMb_e neighbour);
u32 h264bsdIsNeighbourAvailable(mbStorage_t *pMb,
/*@null@*/ mbStorage_t *pNeighbour);
const neighbour_t* h264bsdNeighbour4x4BlockA(u32 blockIndex);
const neighbour_t* h264bsdNeighbour4x4BlockB(u32 blockIndex);
const neighbour_t* h264bsdNeighbour4x4BlockC(u32 blockIndex);
const neighbour_t* h264bsdNeighbour4x4BlockD(u32 blockIndex);
#endif /* #ifdef H264HWD_NEIGHBOUR_H */

View File

@ -0,0 +1,80 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Compute Picture Order Count (POC) for a picture
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_pic_order_cnt.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_PIC_ORDER_CNT_H
#define H264HWD_PIC_ORDER_CNT_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_seq_param_set.h"
#include "h264hwd_slice_header.h"
#include "h264hwd_nal_unit.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/* structure to store information computed for previous picture, needed for
* POC computation of a picture. Two first fields for POC type 0, last two
* for types 1 and 2 */
typedef struct
{
u32 prevPicOrderCntLsb;
i32 prevPicOrderCntMsb;
u32 prevFrameNum;
u32 prevFrameNumOffset;
u32 containsMmco5;
i32 picOrderCnt[2];
} pocStorage_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
void h264bsdDecodePicOrderCnt(pocStorage_t *poc, const seqParamSet_t *sps,
const sliceHeader_t *sliceHeader, const nalUnit_t *pNalUnit);
#endif /* #ifdef H264HWD_PIC_ORDER_CNT_H */

View File

@ -0,0 +1,98 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode picture parameter set information from the stream
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_pic_param_set.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_PIC_PARAM_SET_H
#define H264HWD_PIC_PARAM_SET_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_stream.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/* data structure to store PPS information decoded from the stream */
typedef struct
{
u32 picParameterSetId;
u32 seqParameterSetId;
u32 picOrderPresentFlag;
u32 numSliceGroups;
u32 sliceGroupMapType;
u32 *runLength;
u32 *topLeft;
u32 *bottomRight;
u32 sliceGroupChangeDirectionFlag;
u32 sliceGroupChangeRate;
u32 picSizeInMapUnits;
u32 *sliceGroupId;
u32 numRefIdxL0Active;
u32 numRefIdxL1Active;
u32 picInitQp;
i32 chromaQpIndexOffset;
i32 chromaQpIndexOffset2;
u32 deblockingFilterControlPresentFlag;
u32 constrainedIntraPredFlag;
u32 redundantPicCntPresentFlag;
u32 entropyCodingModeFlag;
u32 weightedPredFlag;
u32 weightedBiPredIdc;
u32 transform8x8Flag;
u32 scalingMatrixPresentFlag;
u32 scalingListPresent[8];
u32 useDefaultScaling[8];
u8 scalingList[8][64];
} picParamSet_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdDecodePicParamSet(strmData_t *pStrmData,
picParamSet_t *pPicParamSet);
#endif /* #ifdef H264HWD_PIC_PARAM_SET_H */

View File

@ -0,0 +1,44 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Hardware interface read/write
--
------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_regdrv.h,v $
-- $Revision: 1.1 $
-- $Date: 2008/03/13 12:48:06 $
--
------------------------------------------------------------------------------*/
#ifndef __H264HWD_REGDRV_H__
#define __H264HWD_REGDRV_H__
#include "basetype.h"
#include "regdrv.h"
#define DEC_X170_ALIGN_MASK 0x07
#define DEC_X170_MODE_H264 0x00
#define DEC_X170_IRQ_DEC_RDY 0x01
#define DEC_X170_IRQ_BUS_ERROR 0x02
#define DEC_X170_IRQ_BUFFER_EMPTY 0x04
#define DEC_X170_IRQ_ASO 0x08
#define DEC_X170_IRQ_STREAM_ERROR 0x10
#define DEC_X170_IRQ_TIMEOUT 0x40
#endif /* __H264HWD_REGDRV_H__ */

View File

@ -0,0 +1,110 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode seq parameter set information from the stream
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_seq_param_set.h,v $
-- $Date: 2008/07/31 08:51:30 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_SEQ_PARAM_SET_H
#define H264HWD_SEQ_PARAM_SET_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_stream.h"
#include "h264hwd_vui.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/* structure to store sequence parameter set information decoded from the
* stream */
typedef struct
{
u32 profileIdc;
u32 levelIdc;
u8 constrained_set0_flag;
u8 constrained_set1_flag;
u8 constrained_set2_flag;
u8 constrained_set3_flag;
u32 seqParameterSetId;
u32 maxFrameNum;
u32 picOrderCntType;
u32 maxPicOrderCntLsb;
u32 deltaPicOrderAlwaysZeroFlag;
i32 offsetForNonRefPic;
i32 offsetForTopToBottomField;
u32 numRefFramesInPicOrderCntCycle;
i32 *offsetForRefFrame;
u32 numRefFrames;
u32 gapsInFrameNumValueAllowedFlag;
u32 picWidthInMbs;
u32 picHeightInMbs;
u32 frameCroppingFlag;
u32 frameCropLeftOffset;
u32 frameCropRightOffset;
u32 frameCropTopOffset;
u32 frameCropBottomOffset;
u32 vuiParametersPresentFlag;
vuiParameters_t *vuiParameters;
u32 maxDpbSize;
u32 frameMbsOnlyFlag;
u32 mbAdaptiveFrameFieldFlag;
u32 direct8x8InferenceFlag;
u32 chromaFormatIdc;
u32 monoChrome;
u32 scalingMatrixPresentFlag;
u32 scalingListPresent[8];
u32 useDefaultScaling[8];
u8 scalingList[8][64];
} seqParamSet_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdDecodeSeqParamSet(strmData_t *pStrmData,
seqParamSet_t *pSeqParamSet);
u32 h264bsdCompareSeqParamSets(seqParamSet_t *pSps1, seqParamSet_t *pSps2);
#endif /* #ifdef H264HWD_SEQ_PARAM_SET_H */

View File

@ -0,0 +1,70 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode slice data, i.e. macroblocks of a slice, from the stream
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_slice_data.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_SLICE_DATA_H
#define H264HWD_SLICE_DATA_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "h264hwd_container.h"
#include "basetype.h"
#include "h264hwd_stream.h"
#include "h264hwd_cfg.h"
#include "h264hwd_slice_header.h"
#include "h264hwd_storage.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdDecodeSliceData( decContainer_t * pDecCont, strmData_t *pStrmData,
sliceHeader_t *pSliceHeader);
void h264bsdMarkSliceCorrupted(storage_t *pStorage, u32 firstMbInSlice);
#endif /* #ifdef H264HWD_SLICE_DATA_H */

View File

@ -0,0 +1,70 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Compute macroblock to slice group map
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_slice_group_map.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_SLICE_GROUP_MAP_H
#define H264HWD_SLICE_GROUP_MAP_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_pic_param_set.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
void h264bsdDecodeSliceGroupMap(
u32 *map,
picParamSet_t *pps,
u32 sliceGroupChangeCycle,
u32 picWidth,
u32 picHeight);
#endif /* #ifdef H264HWD_SLICE_GROUP_MAP_H */

View File

@ -0,0 +1,243 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode slice header information from the stream
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_slice_header.h,v $
-- $Date: 2009/09/16 11:33:06 $
-- $Revision: 1.3 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_SLICE_HEADER_H
#define H264HWD_SLICE_HEADER_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_stream.h"
#include "h264hwd_cfg.h"
#include "h264hwd_seq_param_set.h"
#include "h264hwd_pic_param_set.h"
#include "h264hwd_nal_unit.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
enum {
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2
};
enum {NO_LONG_TERM_FRAME_INDICES = 0xFFFF};
/* macro to determine if slice is an inter slice, sliceTypes 0 and 5 */
#define IS_P_SLICE(sliceType) (((sliceType) == P_SLICE) || \
((sliceType) == P_SLICE + 5))
/* macro to determine if slice is an intra slice, sliceTypes 2 and 7 */
#define IS_I_SLICE(sliceType) (((sliceType) == I_SLICE) || \
((sliceType) == I_SLICE + 5))
#define IS_B_SLICE(sliceType) (((sliceType) == B_SLICE) || \
((sliceType) == B_SLICE + 5))
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/* structure to store data of one reference picture list reordering operation */
typedef struct
{
u32 reorderingOfPicNumsIdc;
u32 absDiffPicNum;
u32 longTermPicNum;
} refPicListReorderingOperation_t;
/* structure to store reference picture list reordering operations */
typedef struct
{
u32 refPicListReorderingFlagL0;
refPicListReorderingOperation_t command[MAX_NUM_REF_PICS+1];
} refPicListReordering_t;
/* structure to store data of one DPB memory management control operation */
typedef struct
{
u32 memoryManagementControlOperation;
u32 differenceOfPicNums;
u32 longTermPicNum;
u32 longTermFrameIdx;
u32 maxLongTermFrameIdx;
} memoryManagementOperation_t;
/* worst case scenario: all MAX_NUM_REF_PICS pictures in the buffer are
* short term pictures, each one of them is first marked as long term
* reference picture which is then marked as unused for reference.
* Additionally, max long-term frame index is set and current picture is
* marked as long term reference picture. Last position reserved for
* end memory_management_control_operation command */
#define MAX_NUM_MMC_OPERATIONS (2*MAX_NUM_REF_PICS+2+1)
/* structure to store decoded reference picture marking data */
typedef struct
{
u32 strmLen;
u32 noOutputOfPriorPicsFlag;
u32 longTermReferenceFlag;
u32 adaptiveRefPicMarkingModeFlag;
memoryManagementOperation_t operation[MAX_NUM_MMC_OPERATIONS];
} decRefPicMarking_t;
/* structure to store slice header data decoded from the stream */
typedef struct
{
u32 firstMbInSlice;
u32 sliceType;
u32 picParameterSetId;
u32 frameNum;
u32 idrPicId;
u32 pocLength;
u32 pocLengthHw;
u32 picOrderCntLsb;
i32 deltaPicOrderCntBottom;
i32 deltaPicOrderCnt[2];
u32 redundantPicCnt;
u32 numRefIdxActiveOverrideFlag;
u32 numRefIdxL0Active;
u32 numRefIdxL1Active;
i32 sliceQpDelta;
u32 disableDeblockingFilterIdc;
i32 sliceAlphaC0Offset;
i32 sliceBetaOffset;
u32 sliceGroupChangeCycle;
refPicListReordering_t refPicListReordering;
refPicListReordering_t refPicListReorderingL1;
decRefPicMarking_t decRefPicMarking;
u32 cabacInitIdc;
u32 fieldPicFlag;
u32 bottomFieldFlag;
u32 directSpatialMvPredFlag;
} sliceHeader_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdDecodeSliceHeader(strmData_t *pStrmData,
sliceHeader_t *pSliceHeader,
seqParamSet_t *pSeqParamSet,
picParamSet_t *pPicParamSet,
nalUnit_t *pNalUnit);
u32 h264bsdCheckPpsId(strmData_t *pStrmData, u32 *ppsId);
u32 h264bsdCheckFrameNum(
strmData_t *pStrmData,
u32 maxFrameNum,
u32 *frameNum);
u32 h264bsdCheckIdrPicId(
strmData_t *pStrmData,
u32 maxFrameNum,
nalUnitType_e nalUnitType,
u32 fieldPicFlag,
u32 *idrPicId);
u32 h264bsdCheckPicOrderCntLsb(
strmData_t *pStrmData,
seqParamSet_t *pSeqParamSet,
nalUnitType_e nalUnitType,
u32 *picOrderCntLsb);
u32 h264bsdCheckDeltaPicOrderCntBottom(
strmData_t *pStrmData,
seqParamSet_t *pSeqParamSet,
nalUnitType_e nalUnitType,
i32 *deltaPicOrderCntBottom);
u32 h264bsdCheckDeltaPicOrderCnt(
strmData_t *pStrmData,
seqParamSet_t *pSeqParamSet,
nalUnitType_e nalUnitType,
u32 picOrderPresentFlag,
i32 *deltaPicOrderCnt);
u32 h264bsdCheckRedundantPicCnt(
const strmData_t *pStrmData,
const seqParamSet_t *pSeqParamSet,
const picParamSet_t *pPicParamSet,
nalUnitType_e nalUnitType,
u32 *redundantPicCnt);
u32 h264bsdCheckPriorPicsFlag(u32 * noOutputOfPriorPicsFlag,
const strmData_t * pStrmData,
const seqParamSet_t * pSeqParamSet,
const picParamSet_t * pPicParamSet,
nalUnitType_e nalUnitType);
u32 h264bsdFieldPicFlag(strmData_t * pStrmData,
u32 maxFrameNum,
nalUnitType_e nalUnitType,
u32 fieldPicFlagPresent,
u32 *fieldPicFlag);
u32 h264bsdBottomFieldFlag(strmData_t * pStrmData,
u32 maxFrameNum,
nalUnitType_e nalUnitType,
u32 fieldPicFlag,
u32 *bottomFieldFlag);
u32 h264bsdIsOppositeFieldPic(sliceHeader_t * pSliceCurr,
sliceHeader_t * pSlicePrev,
u32 *secondField, u32 prevRefFrameNum,
u32 newPicture);
u32 h264bsdCheckFieldPicFlag(strmData_t * pStrmData,
u32 maxFrameNum,
nalUnitType_e nalUnitType,
u32 fieldPicFlagPresent,
u32 *fieldPicFlag);
u32 h264bsdCheckBottomFieldFlag(strmData_t * pStrmData,
u32 maxFrameNum,
nalUnitType_e nalUnitType, u32 fieldPicFlag,
u32 * bottomFieldFlag);
u32 h264bsdCheckFirstMbInSlice(strmData_t * pStrmData,
nalUnitType_e nalUnitType,
u32 * firstMbInSlice);
#endif /* #ifdef H264HWD_SLICE_HEADER_H */

View File

@ -0,0 +1,204 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Storage handling functionality
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_storage.h,v $
-- $Date: 2010/02/15 06:59:52 $
-- $Revision: 1.10 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_STORAGE_H
#define H264HWD_STORAGE_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_cfg.h"
#include "h264hwd_seq_param_set.h"
#include "h264hwd_pic_param_set.h"
#include "h264hwd_macroblock_layer.h"
#include "h264hwd_nal_unit.h"
#include "h264hwd_slice_header.h"
#include "h264hwd_seq_param_set.h"
#include "h264hwd_dpb.h"
#include "h264hwd_pic_order_cnt.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
typedef struct
{
u32 sliceId;
u32 numDecodedMbs;
u32 lastMbAddr;
} sliceStorage_t;
/* structure to store parameters needed for access unit boundary checking */
typedef struct
{
nalUnit_t nuPrev[1];
u32 prevFrameNum;
u32 prevIdrPicId;
u32 prevPicOrderCntLsb;
i32 prevDeltaPicOrderCntBottom;
i32 prevDeltaPicOrderCnt[2];
u32 prevFieldPicFlag;
u32 prevBottomFieldFlag;
u32 firstCallFlag;
u32 newPicture;
} aubCheck_t;
/* storage data structure, holds all data of a decoder instance */
typedef struct
{
/* active paramet set ids and pointers */
u32 oldSpsId;
u32 activePpsId;
u32 activeSpsId;
picParamSet_t *activePps;
seqParamSet_t *activeSps;
seqParamSet_t *sps[MAX_NUM_SEQ_PARAM_SETS];
picParamSet_t *pps[MAX_NUM_PIC_PARAM_SETS];
/* current slice group map, recomputed for each slice */
u32 *sliceGroupMap;
u32 picSizeInMbs;
/* this flag is set after all macroblocks of a picture successfully
* decoded -> redundant slices not decoded */
u32 skipRedundantSlices;
u32 picStarted;
/* flag to indicate if current access unit contains any valid slices */
u32 validSliceInAccessUnit;
/* store information needed for handling of slice decoding */
sliceStorage_t slice[1];
/* number of concealed macroblocks in the current image */
u32 numConcealedMbs;
/* picId given by application */
u32 currentPicId;
/* macroblock specific storages, size determined by image dimensions */
mbStorage_t *mb;
/* flag to store noOutputReordering flag set by the application */
u32 noReordering;
/* DPB */
dpbStorage_t dpb[2];
/* structure to store picture order count related information */
pocStorage_t poc[2];
/* access unit boundary checking related data */
aubCheck_t aub[1];
/* current processed image */
image_t currImage[1];
/* last valid NAL unit header is stored here */
nalUnit_t prevNalUnit[1];
/* slice header, second structure used as a temporary storage while
* decoding slice header, first one stores last successfully decoded
* slice header */
sliceHeader_t sliceHeader[2];
/* fields to store old stream buffer pointers, needed when only part of
* a stream buffer is processed by h264bsdDecode function */
u32 prevBufNotFinished;
const u8 *prevBufPointer;
u32 prevBytesConsumed;
strmData_t strm[1];
/* macroblock layer structure, there is no need to store this but it
* would have increased the stack size excessively and needed to be
* allocated from heap -> easiest to put it here */
macroblockLayer_t mbLayer[1];
u32 asoDetected;
u32 secondField;
u32 checkedAub; /* signal that AUB was checked already */
u32 prevIdrPicReady; /* for FFWD workaround */
u32 intraFreeze;
u32 pictureBroken;
u32 enable2ndChroma; /* by default set according to ENABLE_2ND_CHROMA
compiler flag, may be overridden by testbench */
/* pointers to 2nd chroma output, only available if extension enabled */
u32 *pCh2;
u32 bCh2;
u32 ppUsed;
u32 useSmoothing;
u32 currentMarked;
} storage_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
void h264bsdInitStorage(storage_t * pStorage);
void h264bsdResetStorage(storage_t * pStorage);
u32 h264bsdIsStartOfPicture(storage_t * pStorage);
u32 h264bsdIsEndOfPicture(storage_t * pStorage);
u32 h264bsdStoreSeqParamSet(storage_t * pStorage, seqParamSet_t * pSeqParamSet);
u32 h264bsdStorePicParamSet(storage_t * pStorage, picParamSet_t * pPicParamSet);
u32 h264bsdActivateParamSets(storage_t * pStorage, u32 ppsId, u32 isIdr);
void h264bsdComputeSliceGroupMap(storage_t * pStorage,
u32 sliceGroupChangeCycle);
u32 h264bsdCheckAccessUnitBoundary(strmData_t * strm,
nalUnit_t * nuNext,
storage_t * storage,
u32 * accessUnitBoundaryFlag);
u32 h264bsdValidParamSets(storage_t * pStorage);
u32 h264bsdAllocateSwResources(const void *dwl, storage_t * pStorage,
u32 isHighSupported);
#endif /* #ifdef H264HWD_STORAGE_H */

View File

@ -0,0 +1,79 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Stream buffer handling
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_stream.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_STREAM_H
#define H264HWD_STREAM_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
typedef struct
{
const u8 *pStrmBuffStart; /* pointer to start of stream buffer */
const u8 *pStrmCurrPos; /* current read address in stream buffer */
u32 bitPosInWord; /* bit position in stream buffer byte */
u32 strmBuffSize; /* size of stream buffer (bytes) */
u32 strmBuffReadBits; /* number of bits read from stream buffer */
u32 removeEmul3Byte; /* signal the pre-removal of emulation prevention 3 bytes */
u32 emulByteCount; /* counter incremented for each removed byte */
} strmData_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdGetBits(strmData_t * pStrmData, u32 numBits);
u32 h264bsdShowBits(strmData_t * pStrmData, u32 numBits);
u32 h264bsdFlushBits(strmData_t * pStrmData, u32 numBits);
u32 h264bsdIsByteAligned(strmData_t *);
#endif /* #ifdef H264HWD_STREAM_H */

View File

@ -0,0 +1,119 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Utility macros and functions
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_util.h,v $
-- $Date: 2008/09/03 05:56:16 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
#ifndef H264BSDDEC_UTIL_H
#define H264BSDDEC_UTIL_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "dwl.h"
#include "h264hwd_stream.h"
#include "h264hwd_debug.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
#define HANTRO_OK 0
#define HANTRO_NOK 1
#define HANTRO_FALSE (0U)
#define HANTRO_TRUE (1U)
#define MEMORY_ALLOCATION_ERROR 0xFFFF
#define PARAM_SET_ERROR 0xFFF0
/* value to be returned by GetBits if stream buffer is empty */
#define END_OF_STREAM 0xFFFFFFFFU
#define EMPTY_RESIDUAL_INDICATOR 0xFFFFFF
/* macro to mark a residual block empty, i.e. contain zero coefficients */
#define MARK_RESIDUAL_EMPTY(residual) ((residual)[0] = EMPTY_RESIDUAL_INDICATOR)
/* macro to check if residual block is empty */
#define IS_RESIDUAL_EMPTY(residual) ((residual)[0] == EMPTY_RESIDUAL_INDICATOR)
/* macro to get smaller of two values */
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
/* macro to get greater of two values */
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
/* macro to get absolute value */
#define ABS(a) (((a) < 0) ? -(a) : (a))
/* macro to clip a value z, so that x <= z =< y */
#define CLIP3(x,y,z) (((z) < (x)) ? (x) : (((z) > (y)) ? (y) : (z)))
/* macro to clip a value z, so that 0 <= z =< 255 */
#define CLIP1(z) (((z) < 0) ? 0 : (((z) > 255) ? 255 : (z)))
/* macro to allocate memory */
#define ALLOCATE(ptr, count, type) \
{ \
ptr = DWLmalloc((count) * sizeof(type)); \
}
/* macro to free allocated memory */
#define FREE(ptr) \
{ \
if(ptr != NULL) {DWLfree(ptr); ptr = NULL;}\
}
extern const u32 h264bsdQpC[52];
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
typedef enum
{
TOPFIELD = 0,
BOTFIELD = 1,
FRAME = 2
} picStruct_e;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdCountLeadingZeros(u32 value, u32 length);
u32 h264bsdRbspTrailingBits(strmData_t * strmData);
u32 h264bsdMoreRbspData(strmData_t * strmData);
u32 h264bsdNextMbAddress(u32 * pSliceGroupMap, u32 picSizeInMbs,
u32 currMbAddr);
u32 h264CheckCabacZeroWords( strmData_t *strmData );
#endif /* #ifdef H264BSDDEC_UTIL_H */

View File

@ -0,0 +1,73 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode Exp-Golomb code words
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_vlc.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_VLC_H
#define H264HWD_VLC_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_stream.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdDecodeExpGolombUnsigned(strmData_t *pStrmData, u32 *value);
u32 h264bsdDecodeExpGolombSigned(strmData_t *pStrmData, i32 *value);
u32 h264bsdDecodeExpGolombMapped(strmData_t *pStrmData, u32 *value,
u32 isIntra);
u32 h264bsdDecodeExpGolombTruncated(strmData_t *pStrmData, u32 *value,
u32 greaterThanOne);
#endif /* #ifdef H264HWD_VLC_H */

View File

@ -0,0 +1,141 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode Video Usability Information (VUI) from the stream
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_vui.h,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef H264HWD_VUI_H
#define H264HWD_VUI_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_stream.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
#define MAX_CPB_CNT 32
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/* enumerated sample aspect ratios, ASPECT_RATIO_M_N means M:N */
enum
{
ASPECT_RATIO_UNSPECIFIED = 0,
ASPECT_RATIO_1_1,
ASPECT_RATIO_12_11,
ASPECT_RATIO_10_11,
ASPECT_RATIO_16_11,
ASPECT_RATIO_40_33,
ASPECT_RATIO_24_11,
ASPECT_RATIO_20_11,
ASPECT_RATIO_32_11,
ASPECT_RATIO_80_33,
ASPECT_RATIO_18_11,
ASPECT_RATIO_15_11,
ASPECT_RATIO_64_33,
ASPECT_RATIO_160_99,
ASPECT_RATIO_EXTENDED_SAR = 255
};
/* structure to store Hypothetical Reference Decoder (HRD) parameters */
typedef struct
{
u32 cpbCnt;
u32 bitRateScale;
u32 cpbSizeScale;
u32 bitRateValue[MAX_CPB_CNT];
u32 cpbSizeValue[MAX_CPB_CNT];
u32 cbrFlag[MAX_CPB_CNT];
u32 initialCpbRemovalDelayLength;
u32 cpbRemovalDelayLength;
u32 dpbOutputDelayLength;
u32 timeOffsetLength;
} hrdParameters_t;
/* storage for VUI parameters */
typedef struct
{
u32 aspectRatioPresentFlag;
u32 aspectRatioIdc;
u32 sarWidth;
u32 sarHeight;
u32 overscanInfoPresentFlag;
u32 overscanAppropriateFlag;
u32 videoSignalTypePresentFlag;
u32 videoFormat;
u32 videoFullRangeFlag;
u32 colourDescriptionPresentFlag;
u32 colourPrimaries;
u32 transferCharacteristics;
u32 matrixCoefficients;
u32 chromaLocInfoPresentFlag;
u32 chromaSampleLocTypeTopField;
u32 chromaSampleLocTypeBottomField;
u32 timingInfoPresentFlag;
u32 numUnitsInTick;
u32 timeScale;
u32 fixedFrameRateFlag;
u32 nalHrdParametersPresentFlag;
hrdParameters_t nalHrdParameters;
u32 vclHrdParametersPresentFlag;
hrdParameters_t vclHrdParameters;
u32 lowDelayHrdFlag;
u32 picStructPresentFlag;
u32 bitstreamRestrictionFlag;
u32 motionVectorsOverPicBoundariesFlag;
u32 maxBytesPerPicDenom;
u32 maxBitsPerMbDenom;
u32 log2MaxMvLengthHorizontal;
u32 log2MaxMvLengthVertical;
u32 numReorderFrames;
u32 maxDecFrameBuffering;
} vuiParameters_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 h264bsdDecodeVuiParameters(strmData_t *pStrmData,
vuiParameters_t *pVuiParameters);
#endif /* #ifdef H264HWD_VUI_H */

View File

@ -0,0 +1,40 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : JPEG decoder and PP pipeline support
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpeg_pp_pipeline.h,v $
-- $Date: 2007/10/22 08:21:36 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
#ifndef JPEG_PP_PIPELINE_H
#define JPEG_PP_PIPELINE_H
#include "decppif.h"
i32 jpegRegisterPP(const void *decInst, const void *ppInst,
void (*PPRun) (const void *, DecPpInterface *),
void (*PPEndCallback) (const void *),
void (*PPConfigQuery) (const void *, DecPpQuery *));
i32 jpegUnregisterPP(const void *decInst, const void *ppInst);
#endif /* #ifdef JPEG_PP_PIPELINE_H */

View File

@ -0,0 +1,45 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Debug Trace funtions
--
------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpegasicdbgtrace.h,v $
-- $Revision: 1.1 $
-- $Date: 2007/03/30 05:45:21 $
--
------------------------------------------------------------------------------*/
#ifndef __JPEGDEC_TRACE__
#define __JPEGDEC_TRACE__
#include <stdio.h>
#include "basetype.h"
#include "jpegdeccontainer.h"
void PrintJPEGReg(u32 * regBase);
void ppRegDump(const u32 * regBase);
void DumpJPEGCtrlReg(u32 * regBase, FILE *fd);
void HexDumpJPEGCtrlReg(u32 * regBase, FILE *fd);
void HexDumpJPEGTables(u32 * regBase, JpegDecContainer *pJpegDecCont, FILE *fd);
void HexDumpJPEGOutput(JpegDecContainer *pJpegDecCont, FILE *fd);
void HexDumpRegs(u32 * regBase, FILE *fd);
void ResetAsicBuffers(JpegDecContainer *pJpegDecCont, FILE *fd);
#endif /* __JPEGDEC_TRACE__ */

View File

@ -0,0 +1,69 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Utility macros for debugging and tracing
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpegdebug.h,v $
-- $Date: 2007/03/30 05:45:21 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef __JPEGDEBUG_H__
#define __JPEGDEBUG_H__
#ifdef _ASSERT_USED
#ifndef ASSERT
#include <assert.h>
#define ASSERT(expr) assert(expr)
#endif
#else
#define ASSERT(expr)
#endif
#ifdef _JPEGDECAPITRACE
#include <stdio.h>
#elif _JPEGDEC_TRACE
#include <stdio.h>
#elif _JPEGDEC_API_TRC
#include <stdio.h>
#elif _JPEGDEC_PP_TRACE
#include <stdio.h>
#elif _DEBUG
#include <stdio.h>
#elif _DEBUG
#include <stdio.h>
#endif
/* macro for debug printing. Note that double parenthesis has to be used, i.e.
* DEBUG(("Debug printing %d\n",%d)) */
#ifdef _JPEGAPITRACE
#define JPEG_API_TRC(args) printf args
#else
#define JPEG_API_TRC(args)
#endif
#ifdef _DEBUG
#define DEBUG(args) printf args
#else
#define DEBUG(args)
#endif
#endif

View File

@ -0,0 +1,237 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : JPEG decoder header file
--
------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpegdecapi.h,v $
-- $Revision: 1.8 $
-- $Date: 2008/11/12 12:47:03 $
--
------------------------------------------------------------------------------*/
#ifndef __JPEGDECAPI_H__
#define __JPEGDECAPI_H__
#ifdef __cplusplus
extern "C"
{
#endif
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. External compiler flags
3. Module defines
4. Local function prototypes
5. Functions
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "decapicommon.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
#define JPEGDEC_YCbCr400 0x080000U
#define JPEGDEC_YCbCr420_SEMIPLANAR 0x020001U
#define JPEGDEC_YCbCr422_SEMIPLANAR 0x010001U
#define JPEGDEC_YCbCr440 0x010004U
#define JPEGDEC_YCbCr411_SEMIPLANAR 0x100000U
#define JPEGDEC_YCbCr444_SEMIPLANAR 0x200000U
#define JPEGDEC_BASELINE 0x0
#define JPEGDEC_PROGRESSIVE 0x1
#define JPEGDEC_NONINTERLEAVED 0x2
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
typedef void *JpegDecInst;
typedef enum
{
JPEGDEC_SLICE_READY = 2,
JPEGDEC_FRAME_READY = 1,
JPEGDEC_STRM_PROCESSED = 3,
JPEGDEC_SCAN_PROCESSED = 4,
JPEGDEC_OK = 0,
JPEGDEC_ERROR = -1,
JPEGDEC_UNSUPPORTED = -2,
JPEGDEC_PARAM_ERROR = -3,
JPEGDEC_MEMFAIL = -4,
JPEGDEC_INITFAIL = -5,
JPEGDEC_INVALID_STREAM_LENGTH = -6,
JPEGDEC_STRM_ERROR = -7,
JPEGDEC_INVALID_INPUT_BUFFER_SIZE = -8,
JPEGDEC_HW_RESERVED = -9,
JPEGDEC_INCREASE_INPUT_BUFFER = -10,
JPEGDEC_SLICE_MODE_UNSUPPORTED = -11,
JPEGDEC_DWL_HW_TIMEOUT = -253,
JPEGDEC_DWL_ERROR = -254,
JPEGDEC_HW_BUS_ERROR = -255,
JPEGDEC_SYSTEM_ERROR = -256,
JPEGDEC_FORMAT_NOT_SUPPORTED = -1000
} JpegDecRet;
enum
{
JPEGDEC_NO_UNITS = 0, /* No units, X and Y specify
* the pixel aspect ratio */
JPEGDEC_DOTS_PER_INCH = 1, /* X and Y are dots per inch */
JPEGDEC_DOTS_PER_CM = 2 /* X and Y are dots per cm */
};
enum
{
JPEGDEC_THUMBNAIL_JPEG = 0x10,
JPEGDEC_THUMBNAIL_NOT_SUPPORTED_FORMAT = 0x11,
JPEGDEC_NO_THUMBNAIL = 0x12
};
enum
{
JPEGDEC_IMAGE = 0,
JPEGDEC_THUMBNAIL = 1
};
typedef struct
{
u32 *pVirtualAddress;
u32 busAddress;
} JpegDecLinearMem;
/* Image information */
typedef struct
{
u32 displayWidth;
u32 displayHeight;
u32 outputWidth; /* Number of pixels/line in the image */
u32 outputHeight; /* Number of lines in in the image */
u32 version;
u32 units;
u32 xDensity;
u32 yDensity;
u32 outputFormat; /* JPEGDEC_YCbCr400
* JPEGDEC_YCbCr420
* JPEGDEC_YCbCr422
*/
u32 codingMode; /* JPEGDEC_BASELINE
* JPEGDEC_PROGRESSIVE
* JPEGDEC_NONINTERLEAVED
*/
u32 thumbnailType; /* Thumbnail exist or not or not supported */
u32 displayWidthThumb;
u32 displayHeightThumb;
u32 outputWidthThumb; /* Number of pixels/line in the image */
u32 outputHeightThumb; /* Number of lines in in the image */
u32 outputFormatThumb; /* JPEGDEC_YCbCr400
* JPEGDEC_YCbCr420
* JPEGDEC_YCbCr422
*/
u32 codingModeThumb; /* JPEGDEC_BASELINE
* JPEGDEC_PROGRESSIVE
* JPEGDEC_NONINTERLEAVED
*/
} JpegDecImageInfo;
/* Decoder input JFIF information */
typedef struct
{
JpegDecLinearMem streamBuffer; /* input stream buffer */
u32 streamLength; /* input stream length or buffer size */
u32 bufferSize; /* input stream buffer size */
u32 decImageType; /* Full image or Thumbnail to be decoded */
u32 sliceMbSet; /* slice mode: mcu rows to decode */
JpegDecLinearMem pictureBufferY; /* luma output address ==> if user allocated */
JpegDecLinearMem pictureBufferCbCr; /* chroma output address ==> if user allocated */
JpegDecLinearMem pictureBufferCr; /* chroma output address ==> if user allocated */
} JpegDecInput;
/* Decoder output */
typedef struct
{
JpegDecLinearMem outputPictureY; /* Pointer to the Luma output image */
JpegDecLinearMem outputPictureCbCr; /* Pointer to the Chroma output image */
JpegDecLinearMem outputPictureCr; /* Pointer to the Chroma output image */
} JpegDecOutput;
typedef struct
{
u32 major; /* API major version */
u32 minor; /* API minor version */
} JpegDecApiVersion;
typedef struct
{
u32 swBuild; /* Software build ID */
u32 hwBuild; /* Hardware build ID */
DecHwConfig hwConfig; /* hardware supported configuration */
} JpegDecBuild;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
/* Version information */
JpegDecApiVersion JpegGetAPIVersion(void);
/* Build information */
JpegDecBuild JpegDecGetBuild(void);
/* Initialization */
JpegDecRet JpegDecInit(JpegDecInst * pDecInst);
/* Release */
void JpegDecRelease(JpegDecInst decInst);
/* Get image information of the JFIF */
JpegDecRet JpegDecGetImageInfo(JpegDecInst decInst,
JpegDecInput * pDecIn,
JpegDecImageInfo * pImageInfo);
/* Decode JFIF */
JpegDecRet JpegDecDecode(JpegDecInst decInst,
JpegDecInput * pDecIn, JpegDecOutput * pDecOut);
/*------------------------------------------------------------------------------
Prototype of the API trace funtion. Traces all API entries and returns.
This must be implemented by the application using the decoder API!
Argument:
string - trace message, a null terminated string
------------------------------------------------------------------------------*/
void JpegDecTrace(const char *string);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,335 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Jpeg Decoder Container
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpegdeccontainer.h,v $
-- $Revision: 1.22 $
-- $Date: 2009/02/16 08:51:06 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef JPEGDECCONT_H
#define JPEGDECCONT_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "jpegdecapi.h"
#include "dwl.h"
#include "deccfg.h"
#include "decppif.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
#ifdef _ASSERT_USED
#include <assert.h>
#endif
/* macro for assertion, used only if compiler flag _ASSERT_USED is defined */
#ifdef _ASSERT_USED
#define ASSERT(expr) assert(expr)
#else
#define ASSERT(expr)
#endif
#define MIN_NUMBER_OF_COMPONENTS 1
#define MAX_NUMBER_OF_COMPONENTS 3
#define JPEGDEC_X170_MIN_BUFFER 5120
#define JPEGDEC_X170_MAX_BUFFER 16776960
#define JPEGDEC_MAX_SLICE_SIZE 4096
#define JPEGDEC_TABLE_SIZE 544
#define JPEGDEC_MIN_WIDTH 48
#define JPEGDEC_MIN_HEIGHT 48
#define JPEGDEC_MAX_WIDTH 4672
#define JPEGDEC_MAX_HEIGHT 4672
#define JPEGDEC_MAX_PIXEL_AMOUNT 16370688
#define JPEGDEC_MAX_WIDTH_8190 8176
#define JPEGDEC_MAX_HEIGHT_8190 8176
#define JPEGDEC_MAX_PIXEL_AMOUNT_8190 66846976
#define JPEGDEC_MAX_SLICE_SIZE_8190 8100
#define JPEGDEC_MAX_WIDTH_TN 256
#define JPEGDEC_MAX_HEIGHT_TN 256
#define JPEGDEC_YUV400 0
#define JPEGDEC_YUV420 2
#define JPEGDEC_YUV422 3
#define JPEGDEC_YUV444 4
#define JPEGDEC_YUV440 5
#define JPEGDEC_YUV411 6
#define JPEGDEC_BASELINE_TABLE_SIZE 544
#define JPEGDEC_PROGRESSIVE_TABLE_SIZE 576
#define JPEGDEC_QP_BASE 32
#define JPEGDEC_AC1_BASE 48
#define JPEGDEC_AC2_BASE 88
#define JPEGDEC_DC1_BASE 129
#define JPEGDEC_DC2_BASE 132
#define JPEGDEC_DC3_BASE 135
/* progressive */
#define JPEGDEC_COEFF_SIZE 96
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
typedef struct
{
u32 C; /* Component id */
u32 H; /* Horizontal sampling factor */
u32 V; /* Vertical sampling factor */
u32 Tq; /* Quantization table destination selector */
} Components;
typedef struct
{
u8 *pStartOfStream;
u8 *pCurrPos;
u32 streamBus;
u32 bitPosInByte;
u32 streamLength;
u32 readBits;
u32 appnFlag;
u32 thumbnail;
u32 returnSosMarker;
} StreamStorage;
typedef struct
{
u8 *pStartOfImage;
u8 *pLum;
u8 *pCr;
u8 *pCb;
u32 imageReady;
u32 headerReady;
u32 size;
u32 sizeLuma;
u32 sizeChroma;
u32 ready;
u32 columns[MAX_NUMBER_OF_COMPONENTS];
u32 pixelsPerRow[MAX_NUMBER_OF_COMPONENTS];
} ImageData;
typedef struct
{
u32 Lf;
u32 P;
u32 Y;
u32 hwY;
u32 X;
u32 hwX;
u32 Nf; /* Number of components in frame */
u32 codingType;
u32 numMcuInFrame;
u32 numMcuInRow;
u32 mcuNumber;
u32 nextRstNumber;
u32 Ri;
u32 driPeriod;
u32 block;
u32 row;
u32 col;
u32 cIndex;
u32 *pBuffer;
u32 bufferBus;
i32 *pBufferCb;
i32 *pBufferCr;
DWLLinearMem_t pTableBase;
u32 numBlocks[MAX_NUMBER_OF_COMPONENTS];
u32 blocksPerRow[MAX_NUMBER_OF_COMPONENTS];
u32 useAcOffset[MAX_NUMBER_OF_COMPONENTS];
Components component[MAX_NUMBER_OF_COMPONENTS];
} FrameInfo;
typedef struct
{
u32 Ls;
u32 Ns;
u32 Cs[MAX_NUMBER_OF_COMPONENTS]; /* Scan component selector */
u32 Td[MAX_NUMBER_OF_COMPONENTS]; /* Selects table for DC */
u32 Ta[MAX_NUMBER_OF_COMPONENTS]; /* Selects table for AC */
u32 Ss;
u32 Se;
u32 Ah;
u32 Al;
u32 index;
i32 numIdctRows;
i32 pred[MAX_NUMBER_OF_COMPONENTS];
} ScanInfo;
typedef struct
{
u32 sliceHeight;
u32 amountOfQTables;
u32 yCbCrMode;
u32 yCbCr422;
u32 column;
u32 X;
u32 Y;
u32 memSize;
u32 SliceCount;
u32 SliceReadyForPause;
u32 SliceMBCutValue;
u32 pipeline;
u32 userAllocMem;
u32 sliceMbSetValue;
u32 timeout;
u32 rlcMode;
u32 lumaPos;
u32 chromaPos;
u32 sliceStartCount;
u32 amountOfSlices;
u32 noSliceIrqForUser;
u32 sliceLimitReached;
u32 inputBufferEmpty;
u32 fillRight;
u32 fillBottom;
u32 streamEnd;
u32 streamEndFlag;
u32 inputBufferLen;
u32 inputStreaming;
u32 decodedStreamLen;
u32 init;
u32 initThumb;
u32 initBufferSize;
i32 dcRes[MAX_NUMBER_OF_COMPONENTS];
DWLLinearMem_t outLuma;
DWLLinearMem_t outChroma;
DWLLinearMem_t outChroma2;
DWLLinearMem_t givenOutLuma;
DWLLinearMem_t givenOutChroma;
DWLLinearMem_t givenOutChroma2;
i32 pred[MAX_NUMBER_OF_COMPONENTS];
/* progressive parameters */
u32 nonInterleaved;
u32 componentId;
u32 operationType;
u32 operationTypeThumb;
u32 progressiveScanReady;
u32 nonInterleavedScanReady;
u32 allocated;
u32 yCbCrModeOrig;
u32 getInfoYCbCrMode;
u32 components[MAX_NUMBER_OF_COMPONENTS];
DWLLinearMem_t pCoeffBase;
u32 fillX;
u32 fillY;
u32 progressiveFinish;
u32 pfCompId;
u32 pfNeeded[MAX_NUMBER_OF_COMPONENTS];
DWLLinearMem_t tmpStrm;
} DecInfo;
typedef struct
{
DWLLinearMem_t outLumaBuffer;
DWLLinearMem_t outChromaBuffer;
DWLLinearMem_t outChromaBuffer2;
} JpegAsicBuffers;
typedef struct
{
u32 bits[16];
u32 *vals;
u32 tableLength;
u32 start;
u32 last;
} VlcTable;
typedef struct
{
u32 Lh;
VlcTable acTable0;
VlcTable acTable1;
VlcTable acTable2;
VlcTable acTable3;
VlcTable dcTable0;
VlcTable dcTable1;
VlcTable dcTable2;
VlcTable dcTable3;
VlcTable *table;
} HuffmanTables;
typedef struct
{
u32 Lq; /* Quantization table definition length */
u32 table0[64];
u32 table1[64];
u32 table2[64];
u32 table3[64];
u32 *table;
} QuantTables;
typedef struct
{
u32 jpegRegs[DEC_X170_REGISTERS];
u32 asicRunning;
StreamStorage stream;
FrameInfo frame;
ImageData image;
ScanInfo scan;
DecInfo info;
HuffmanTables vlc;
QuantTables quant;
u32 tmpData[64];
u32 is8190;
u32 fuseBurned;
u32 minSupportedWidth;
u32 minSupportedHeight;
u32 maxSupportedWidth;
u32 maxSupportedHeight;
u32 maxSupportedPixelAmount;
u32 maxSupportedSliceSize;
u32 extensionsSupported;
JpegAsicBuffers asicBuff;
DecPpInterface ppControl;
DecPpQuery ppConfigQuery; /* Decoder asks pp info about setup, info stored here */
u32 ppStatus;
const void *dwl; /* DWL instance */
const void *ppInstance;
void (*PPRun) (const void *, DecPpInterface *);
void (*PPEndCallback) (const void *);
void (*PPConfigQuery) (const void *, DecPpQuery *);
} JpegDecContainer;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
#endif /* #endif JPEGDECDATA_H */

View File

@ -0,0 +1,66 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Jpeg decoder header decoding header file
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpegdechdrs.h,v $
-- $Revision: 1.1 $
-- $Date: 2007/03/30 05:44:50 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef JPEGDECHDRS_H
#define JPEGDECHDRS_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "jpegdeccontainer.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
JpegDecRet JpegDecDecodeFrameHdr(JpegDecContainer * pDecData);
JpegDecRet JpegDecDecodeQuantTables(JpegDecContainer * pDecData);
JpegDecRet JpegDecDecodeHuffmanTables(JpegDecContainer * pDecData);
JpegDecRet JpegDecMode(JpegDecContainer * pDecData);
JpegDecRet JpegDecMode(JpegDecContainer *);
#endif /* #ifdef MODULE_H */

View File

@ -0,0 +1,82 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Jpeg Decoder Internal functions
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpegdecinternal.h,v $
-- $Revision: 1.4 $
-- $Date: 2008/09/05 06:25:37 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef JPEGDECINTERNAL_H
#define JPEGDECINTERNAL_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "jpegdecapi.h"
#include "jpegdeccontainer.h"
#ifdef JPEGDEC_ASIC_TRACE
#include <stdio.h>
#endif
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
#ifdef JPEGDEC_ASIC_TRACE
#define JPEGDEC_TRACE_INTERNAL(args) printf args
#else
#define JPEGDEC_TRACE_INTERNAL(args)
#endif
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
void JpegDecClearStructs(JpegDecContainer * pJpegDecCont);
JpegDecRet JpegDecInitHW(JpegDecContainer * pJpegDecCont);
void JpegDecInitHWContinue(JpegDecContainer * pJpegDecCont);
void JpegDecInitHWInputBuffLoad(JpegDecContainer * pJpegDecCont);
void JpegDecInitHWProgressiveContinue(JpegDecContainer * pJpegDecCont);
void JpegDecInitHWNonInterleaved(JpegDecContainer * pJpegDecCont);
JpegDecRet JpegDecAllocateResidual(JpegDecContainer * pJpegDecCont);
void JpegDecSliceSizeCalculation(JpegDecContainer * pJpegDecCont);
JpegDecRet JpegDecNextScanHdrs(JpegDecContainer * pJpegDecCont);
void JpegRefreshRegs(JpegDecContainer * pJpegDecCont);
void JpegFlushRegs(JpegDecContainer * pJpegDecCont);
void JpegDecInitHWEmptyScan(JpegDecContainer * pJpegDecCont, u32 componentId);
#endif /* #endif JPEGDECDATA_H */

View File

@ -0,0 +1,128 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : SW Jpeg Decoder
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpegdecmarkers.h,v $
-- $Revision: 1.1 $
-- $Date: 2007/03/30 05:44:50 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef JPEGDECMARKERS_H
#define JPEGDECMARKERS_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/* JPEG markers, table B.1 page 32 */
enum
{
SOF0 = 0xC0,
SOF1 = 0xC1,
SOF2 = 0xC2,
SOF3 = 0xC3,
SOF5 = 0xC5,
SOF6 = 0xC6,
SOF7 = 0xC7,
SOF9 = 0xC8,
SOF10 = 0xCA,
SOF11 = 0xCB,
SOF13 = 0xCD,
SOF14 = 0xCE,
SOF15 = 0xCF,
JPG = 0xC8,
DHT = 0xC4,
DAC = 0xCC,
SOI = 0xD8,
EOI = 0xD9,
SOS = 0xDA,
DQT = 0xDB,
DNL = 0xDC,
DRI = 0xDD,
DHP = 0xDE,
EXP = 0xDF,
APP0 = 0xE0,
APP1 = 0xE1,
APP2 = 0xE2,
APP3 = 0xE3,
APP4 = 0xE4,
APP5 = 0xE5,
APP6 = 0xE6,
APP7 = 0xE7,
APP8 = 0xE8,
APP9 = 0xE9,
APP10 = 0xEA,
APP11 = 0xEB,
APP12 = 0xEC,
APP13 = 0xED,
APP14 = 0xEE,
APP15 = 0xEF,
JPG0 = 0xF0,
JPG1 = 0xF1,
JPG2 = 0xF2,
JPG3 = 0xF3,
JPG4 = 0xF4,
JPG5 = 0xF5,
JPG6 = 0xF6,
JPG7 = 0xF7,
JPG8 = 0xF8,
JPG9 = 0xF9,
JPG10 = 0xFA,
JPG11 = 0xFB,
JPG12 = 0xFC,
JPG13 = 0xFD,
COM = 0xFE,
TEM = 0x01,
RST0 = 0xD0,
RST1 = 0xD1,
RST2 = 0xD2,
RST3 = 0xD3,
RST4 = 0xD4,
RST5 = 0xD5,
RST6 = 0xD6,
RST7 = 0xD7
};
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
#endif /* #ifdef JPEGDECMARKERS_H */

View File

@ -0,0 +1,63 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : SW Jpeg Decoder
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpegdecscan.h,v $
-- $Revision: 1.1 $
-- $Date: 2007/03/30 05:44:50 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef JPEGDECSCAN_H
#define JPEGDECSCAN_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "jpegdeccontainer.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
JpegDecRet JpegDecDecodeScan(JpegDecContainer * pDecData);
#endif /* #ifdef MODULE_H */

View File

@ -0,0 +1,76 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Jpeg Decoder utils header file
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpegdecutils.h,v $
-- $Revision: 1.1 $
-- $Date: 2007/03/30 05:44:50 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Module defines
3. Data types
4. Function prototypes
------------------------------------------------------------------------------*/
#ifndef JPEGDECUTILS_H
#define JPEGDECUTILS_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "jpegdeccontainer.h"
#include "basetype.h"
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
#define STRM_ERROR 0xFFFFFFFFU
#ifndef OK
#define OK 0
#endif
#ifndef NOK
#define NOK -1
#endif
#ifndef STATIC
#define STATIC static
#endif
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 JpegDecGet2Bytes(StreamStorage * pStream);
u32 JpegDecGetByte(StreamStorage * pStream);
u32 JpegDecShowBits(StreamStorage * pStream);
u32 JpegDecFlushBits(StreamStorage * pStream, u32 bits);
#endif /* #ifdef MODULE_H */

View File

@ -0,0 +1,45 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : X170 JPEG Decoder HW register access functions interface
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: jpegregdrv.h,v $
-- $Date: 2007/06/05 09:37:57 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
#ifndef _JPG_HWREGDRV_H_
#define _JPG_HWREGDRV_H_
#include "basetype.h"
#include "deccfg.h"
#include "regdrv.h"
#define JPEG_X170_MODE_JPEG 3
#define JPEGDEC_X170_IRQ_DEC_RDY 0x01
#define JPEGDEC_X170_IRQ_BUS_ERROR 0x02
#define JPEGDEC_X170_IRQ_BUFFER_EMPTY 0x04
#define JPEGDEC_X170_IRQ_ASO 0x08
#define JPEGDEC_X170_IRQ_STREAM_ERROR 0x10
#define JPEGDEC_X170_IRQ_SLICE_READY 0x00
#define JPEGDEC_X170_IRQ_TIMEOUT 0x40
#endif /* #define _JPG_HWREGDRV_H_ */

View File

@ -0,0 +1,86 @@
#ifndef __MFCAPI_H__
#define __MFCAPI_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "dwl.h"
#define RAW_STRM_TYPE_H264 104
#define RAW_STRM_TYPE_JPEG 110
#define RAW_STRM_TYPE_H264_NOREORDER (RAW_STRM_TYPE_H264 | (1 << 8))
#define MAX_OUTFRAME_NUM 8
#define MAX_OUTFRAME_WIDTH 1280
#define MAX_OUTFRAME_HEIGHT 720
typedef struct
{
u32 yBusAddress;
u32 cbcrBusAddress;
u32 crBusAddress;
const void *pyVirAddress;
const void *pcbcrVirAddress;
const void *pcrVirAddress;
i32 keyPicture;
}FrameBuffer;
typedef struct
{
i32 num;
i32 codedWidth;
i32 codedHeight;
i32 frameWidth;
i32 frameHeight;
i32 outputFormat; /* JPEGDEC_YCbCr400/JPEGDEC_YCbCr420/JPEGDEC_YCbCr422 */
FrameBuffer buffer[MAX_OUTFRAME_NUM];
}OutFrameBuffer;
typedef enum{
MFCDEC_RET_OK = 1,
MFCDEC_RET_DECFAIL = 0,
MFCDEC_RET_MEMFAIL = -1,
MFCDEC_RET_LOCKFAIL = -2,
}MFCDecodeRet;
typedef struct
{
void *decInst;
int streamType;
int delayInit;
int outputFormat;
}MFCHandle;
typedef struct {
MFCHandle *handle;
uint32_t jpg_addr;
uint32_t jpg_size;
uint32_t dec_addry;
uint32_t dec_addru;
uint32_t dec_addrv;
uint32_t dec_size;
uint16_t jpg_width;
uint16_t jpg_height;
uint16_t dec_width;
uint16_t dec_height;
uint32_t dec_format;
} JpegHeaderInfo;
MFCHandle *mfc_init(int streamType);
int mfc_decode(MFCHandle *handle, DWLLinearMem_t *inBuffer, OutFrameBuffer *outBuffer);
int mfc_jpegdec(JpegHeaderInfo *jpegInfo);
void mfc_uninit(MFCHandle *handle);
int mfc_pp_init(MFCHandle *handle, int outWidth, int outHeight, int outFormat);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,139 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : Hardware interface read/write
--
------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: refbuffer.h,v $
-- $Revision: 1.19 $
-- $Date: 2010/06/23 12:38:11 $
--
------------------------------------------------------------------------------*/
#ifndef __REFBUFFER_H__
#define __REFBUFFER_H__
#include "basetype.h"
typedef enum {
REFBU_FRAME,
REFBU_FIELD,
REFBU_MBAFF
} refbuMode_e;
/* Feature support flags */
#define REFBU_SUPPORT_GENERIC (1)
#define REFBU_SUPPORT_INTERLACED (2)
#define REFBU_SUPPORT_DOUBLE (4)
#define REFBU_SUPPORT_OFFSET (8)
/* Buffering info */
#define REFBU_BUFFER_SINGLE_FIELD (1)
#define REFBU_MULTIPLE_REF_FRAMES (2)
#define REFBU_DISABLE_CHECKPOINT (4)
#define REFBU_FORCE_ADAPTIVE_SINGLE (8)
#ifndef HANTRO_TRUE
#define HANTRO_TRUE (1)
#endif /* HANTRO_TRUE */
#ifndef HANTRO_FALSE
#define HANTRO_FALSE (0)
#endif /* HANTRO_FALSE*/
/* macro to get smaller of two values */
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
/* macro to get greater of two values */
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
typedef struct memAccess {
u32 latency;
u32 nonseq;
u32 seq;
} memAccess_t;
struct refBuffer;
typedef struct refBuffer {
#if 0
i32 ox[3];
#endif
i32 decModeMbWeights[2];
i32 mbWeight;
i32 oy[3];
i32 picWidthInMbs;
i32 picHeightInMbs;
i32 frmSizeInMbs;
i32 fldSizeInMbs;
i32 numIntraBlk[3];
i32 coverage[3];
i32 fldHitsP[3][2];
i32 fldHitsB[3][2];
i32 fldCnt;
i32 mvsPerMb;
i32 filterSize;
/* Thresholds */
i32 predIntraBlk;
i32 predCoverage;
i32 checkpoint;
u32 decMode;
u32 dataExcessMaxPct;
i32 busWidthInBits;
i32 prevLatency;
i32 numCyclesForBuffering;
i32 totalDataForBuffering;
i32 bufferPenalty;
i32 avgCyclesPerMb;
u32 prevWasField;
u32 prevUsedDouble;
i32 thrAdj;
u32 prevFrameHitSum;
memAccess_t currMemModel; /* Clocks per operation, modifiable from
* testbench. */
memAccess_t memAccessStats; /* Approximate counts for operations, set
* based on format */
u32 memAccessStatsFlag;
/* Support flags */
u32 interlacedSupport;
u32 doubleSupport;
u32 offsetSupport;
/* Internal test mode */
void (*testFunction)(struct refBuffer*,u32*regBase,u32 isIntra,u32 mode);
} refBuffer_t;
void RefbuInit( refBuffer_t *pRefbu, u32 decMode, u32 picWidthInMbs, u32
picHeightInMbs, u32 supportFlags );
void RefbuMvStatistics( refBuffer_t *pRefbu, u32 *regBase,
u32 *pMv, u32 directMvsAvailable,
u32 isIntraPicture );
void RefbuMvStatisticsB( refBuffer_t *pRefbu, u32 *regBase );
void RefbuSetup( refBuffer_t *pRefbu, u32 *regBase,
refbuMode_e mode,
u32 isIntraFrame, u32 isBframe,
u32 refPicId0, u32 refpicId1,
u32 flags );
i32 RefbuGetHitThreshold( refBuffer_t *pRefbu );
u32 RefbuVpxGetPrevFrameStats( refBuffer_t *pRefbu );
#endif /* __REFBUFFER_H__ */

View File

@ -0,0 +1,92 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description :
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: regdrv.h,v $
-- $Revision: 1.20 $
-- $Date: 2010/09/07 06:47:34 $
--
------------------------------------------------------------------------------*/
#ifndef REGDRV_H
#define REGDRV_H
/*------------------------------------------------------------------------------
Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
/*------------------------------------------------------------------------------
Module defines
------------------------------------------------------------------------------*/
#define DEC_8170_IRQ_RDY 0x01
#define DEC_8170_IRQ_BUS 0x02
#define DEC_8170_IRQ_BUFFER 0x04
#define DEC_8170_IRQ_ASO 0x08
#define DEC_8170_IRQ_ERROR 0x10
#define DEC_8170_IRQ_SLICE 0x20
#define DEC_8170_IRQ_TIMEOUT 0x40
#define DEC_8190_IRQ_RDY DEC_8170_IRQ_RDY
#define DEC_8190_IRQ_BUS DEC_8170_IRQ_BUS
#define DEC_8190_IRQ_BUFFER DEC_8170_IRQ_BUFFER
#define DEC_8190_IRQ_ASO DEC_8170_IRQ_ASO
#define DEC_8190_IRQ_ERROR DEC_8170_IRQ_ERROR
#define DEC_8190_IRQ_SLICE DEC_8170_IRQ_SLICE
#define DEC_8190_IRQ_TIMEOUT DEC_8170_IRQ_TIMEOUT
typedef enum
{
/* include script-generated part */
#include "8170enum.h"
HWIF_DEC_IRQ_STAT,
HWIF_PP_IRQ_STAT,
HWIF_LAST_REG,
/* aliases */
HWIF_MPEG4_DC_BASE = HWIF_I4X4_OR_DC_BASE,
HWIF_INTRA_4X4_BASE = HWIF_I4X4_OR_DC_BASE,
/* VP6 */
HWIF_VP6HWGOLDEN_BASE = HWIF_REFER4_BASE,
HWIF_VP6HWPART1_BASE = HWIF_REFER13_BASE,
HWIF_VP6HWPART2_BASE = HWIF_RLC_VLC_BASE,
HWIF_VP6HWPROBTBL_BASE = HWIF_QTABLE_BASE,
/* progressive JPEG */
HWIF_PJPEG_COEFF_BUF = HWIF_DIR_MV_BASE,
/* MVC */
HWIF_INTER_VIEW_BASE = HWIF_REFER15_BASE,
} hwIfName_e;
/*------------------------------------------------------------------------------
Data types
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Function prototypes
------------------------------------------------------------------------------*/
void SetDecRegister(u32 * regBase, u32 id, u32 value);
u32 GetDecRegister(const u32 * regBase, u32 id);
#endif /* #ifndef REGDRV_H */

View File

@ -0,0 +1,63 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : API's internal static data storage definition
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_apistorage.h,v $
-- $Date: 2010/02/05 14:24:12 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
#ifndef RV_APISTORAGE_H
#define RV_APISTORAGE_H
#include "dwl.h"
typedef struct
{
enum
{
UNINIT,
INITIALIZED,
HEADERSDECODED,
STREAMDECODING,
HW_PIC_STARTED,
HW_STRM_ERROR
} DecStat;
enum
{
NO_BUFFER = 0,
BUFFER_0,
BUFFER_1,
BUFFER_2,
BUFFER_3
} bufferForPp;
DWLLinearMem_t InternalFrameIn;
DWLLinearMem_t InternalFrameOut;
u32 firstHeaders;
u32 disableFilter;
u32 externalBuffers; /* application gives frame buffers */
} DecApiStorage;
#endif /* #ifndef RV_APISTORAGE_H */

View File

@ -0,0 +1,42 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Global configurations.
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_cfg.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef RV_CFG_H
#define RV_CFG_H
/*
* Maximum number of macro blocks in one FRAME
*/
#define RV_MIN_WIDTH 48
#define RV_MIN_HEIGHT 48
#define RVAPI_DEC_MBS 8160
#define MAX_OUTPUT_PICS 2
#endif /* already included #ifndef RV_CFG_H */

View File

@ -0,0 +1,71 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : algorithm header file
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_container.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef RV_CONTAINER_H
#define RV_CONTAINER_H
#include "basetype.h"
#include "rv_framedesc.h"
#include "rv_mbsetdesc.h"
#include "rv_strmdesc.h"
#include "rv_hdrs.h"
#include "rv_storage.h"
#include "rv_apistorage.h"
#include "rv_cfg.h"
#include "deccfg.h"
#include "decppif.h"
#include "refbuffer.h"
typedef struct
{
u32 rvRegs[DEC_X170_REGISTERS];
DecFrameDesc FrameDesc; /* Frame description */
DecMbSetDesc MbSetDesc; /* Mb set descriptor */
DecStrmDesc StrmDesc;
DecStrmStorage StrmStorage; /* StrmDec storage */
DecHdrs Hdrs;
DecHdrs tmpHdrs; /* for decoding of repeated headers */
DecApiStorage ApiStorage; /* Api's internal data storage */
DecPpInterface ppControl;
DecPpQuery ppConfigQuery; /* Decoder asks pp info about setup, info stored here */
u32 ppStatus;
u32 asicRunning;
u32 mbErrorConceal;
const void *dwl;
u32 refBufSupport;
refBuffer_t refBufferCtrl;
const void *ppInstance;
void (*PPRun) (const void *, DecPpInterface *);
void (*PPEndCallback) (const void *);
void (*PPConfigQuery) (const void *, DecPpQuery *);
void (*PPDisplayIndex)(const void *, u32);
void (*PPBufferData) (const void *, u32, u32, u32);
} DecContainer;
#endif /* #ifndef RV_CONTAINER_H */

View File

@ -0,0 +1,85 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2007 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Utility macros for debugging and tracing
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_debug.h,v $
-- $Date: 2009/03/11 14:01:07 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef RV_DEBUG_H
#define RV_DEBUG_H
#ifdef _ASSERT_USED
#ifndef ASSERT
#include <assert.h>
#define ASSERT(expr) assert(expr)
#endif
#else
#define ASSERT(expr)
#endif
#ifdef _RVAPITRACE
#include <stdio.h>
#endif
#ifdef _RV_DEBUG_TRACE
#include <stdio.h>
#endif
#ifdef _DEBUG_PRINT
#include <stdio.h>
#endif
#ifdef _RVAPITRACE
#define RVFLUSH fflush(stdout)
#endif
#ifdef _DEBUG_PRINT
#define RVFLUSH fflush(stdout)
#endif
#ifndef RVFLUSH
#define RVFLUSH
#endif
/* macro for debug printing. Note that double parenthesis has to be used, i.e.
* DEBUG(("Debug printing %d\n",%d)) */
#ifdef _RVAPITRACE
#define RVDEC_API_DEBUG(args) printf args
#else
#define RVDEC_API_DEBUG(args)
#endif
#ifdef _DEBUG_PRINT
#define RVDEC_DEBUG(args) printf args
#else
#define RVDEC_DEBUG(args)
#endif
#ifdef _DEC_PP_USAGE
#define DECPP_STAND_ALONE 0
#define DECPP_PARALLEL 1
#define DECPP_PIPELINED 2
#define DECPP_UNSPECIFIED 3
void RvDecPpUsagePrint(DecContainer * pDecCont,
u32 ppmode, u32 picIndex, u32 decStatus, u32 picId);
#endif
#endif /* #ifndef RV_DEBUG_H */

View File

@ -0,0 +1,50 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : algorithm header file
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_framedesc.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*****************************************************************************/
#ifndef RV_FRAMEDESC_H
#define RV_FRAMEDESC_H
#include "basetype.h"
typedef struct
{
u32 frameNumber;
u32 frameTimePictures;
u32 picCodingType;
u32 totalMbInFrame;
u32 frameWidth; /* in macro blocks */
u32 frameHeight; /* in macro blocks */
u32 timeCodeHours;
u32 timeCodeMinutes;
u32 timeCodeSeconds;
u32 vlcSet;
u32 qp;
} DecFrameDesc;
#endif /* #ifndef RV_FRAMEDESC_H */

View File

@ -0,0 +1,52 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract :
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_hdrs.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef RV_HDRS_H
#define RV_HDRS_H
#include "basetype.h"
typedef struct DecTimeCode_t
{
u32 dropFlag;
u32 hours;
u32 minutes;
u32 seconds;
u32 picture;
} DecTimeCode;
typedef struct
{
u32 horizontalSize;
u32 verticalSize;
u32 temporalReference;
u32 pictureCodingType;
} DecHdrs;
#endif /* #ifndef RV_HDRS_H */

View File

@ -0,0 +1,44 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract :
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_headers.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of context
1. xxx...
------------------------------------------------------------------------------*/
#ifndef RV_HEADERS_H
#define RV_HEADERS_H
#include "basetype.h"
#include "rv_container.h"
u32 rv_DecodeSliceHeader(DecContainer * pDecContainer);
#endif /* #ifndef RV_HEADERS_H */

View File

@ -0,0 +1,40 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : algorithm header file
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_mbsetdesc.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
------------------------------------------------------------------------------*/
#ifndef RV_MBSETDESC_H
#define RV_MBSETDESC_H
#include "basetype.h"
#include "dwl.h"
#include "rvdecapi.h"
typedef struct
{
RvDecOutput outData; /* Return PIC info */
} DecMbSetDesc;
#endif /* #ifndef RV_MBSETDESC_H */

View File

@ -0,0 +1,42 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : RV decoder and PP pipeline support
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_pp_pipeline.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef RV_PP_PIPELINE_H
#define RV_PP_PIPELINE_H
#include "decppif.h"
i32 rvRegisterPP(const void *decInst, const void *ppInst,
void (*PPDecSetup) (const void *, const DecPpInterface *),
void (*PPDecPipelineEndCallback) (const void *),
void (*PPConfigQuery) (const void *, DecPpQuery *),
void (*PPDisplayIndex)(const void *, u32),
void (*PPBufferData) (const void *, u32, u32, u32));
i32 rvUnregisterPP(const void *decInst, const void *ppInst);
#endif /* #ifdef RV_PP_PIPELINE_H */

View File

@ -0,0 +1,59 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract: api internal defines
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_rpr.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Internal Definitions
3. Prototypes of Decoder API internal functions
------------------------------------------------------------------------------*/
#ifndef RV_RPR_H
#define RV_RPR_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "rv_utils.h"
/*------------------------------------------------------------------------------
2. Internal Definitions
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Prototypes of functions
------------------------------------------------------------------------------*/
void rvRpr( picture_t *pSrc,
picture_t *pDst,
DWLLinearMem_t *rprWorkBuffer,
u32 round,
u32 newCodedWidth, u32 newCodedHeight );
#endif /* RV_RPR_H */

View File

@ -0,0 +1,121 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Stream decoding storage definition
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_storage.h,v $
-- $Date: 2010/03/31 08:55:00 $
-- $Revision: 1.7 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of context
1. xxx...
------------------------------------------------------------------------------*/
#ifndef RV_STRMSTORAGE_H
#define RV_STRMSTORAGE_H
#include "basetype.h"
#include "rv_cfg.h"
#include "bqueue.h"
typedef struct
{
DWLLinearMem_t data;
u32 picType;
u32 picId;
u32 tf;
u32 ff[2];
u32 rff;
u32 rfc;
u32 isInter;
u32 nbrErrMbs;
RvDecRet retVal;
u32 sendToPp;
RvDecTime timeCode;
u32 frameWidth, frameHeight;
u32 codedWidth, codedHeight;
} picture_t;
typedef struct
{
u32 status;
u32 strmDecReady;
picture_t pPicBuf[16];
picture_t pRprBuf;
u32 outBuf[16];
u32 outIndex;
u32 outCount;
u32 workOut;
u32 work0;
u32 work1;
u32 latestId; /* current pic id, used for debug */
u32 skipB;
u32 prevPicCodingType;
u32 pictureBroken;
u32 intraFreeze;
u32 rprDetected;
u32 rprNextPicType;
u32 previousB;
u32 previousModeFull;
u32 isRv8;
u32 fwdScale;
u32 bwdScale;
u32 tr;
u32 prevTr;
u32 trb;
DWLLinearMem_t vlcTables;
DWLLinearMem_t directMvs;
DWLLinearMem_t rprWorkBuffer;
DWLLinearMem_t slices;
u32 frameCodeLength;
u32 frameSizes[2*9];
u32 maxFrameWidth, maxFrameHeight;
u32 maxMbsPerFrame;
u32 numSlices;
u32 rawMode;
/* to store number of bits needed to indicate rv9 frame size */
u32 frameSizeBits;
/* used to compute timestamps for output pictures */
u32 picId;
u32 prevPicId;
u32 prevBIdx;
bufferQueue_t bq;
bufferQueue_t bqPp;
u32 maxNumBuffers;
u32 numBuffers;
u32 numPpBuffers;
} DecStrmStorage;
#endif /* #ifndef RV_STRMSTORAGE_H */

View File

@ -0,0 +1,56 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Stream decoding top header file
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_strm.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of context
1. xxx...
------------------------------------------------------------------------------*/
#ifndef RV_STRMDEC_H
#define RV_STRMDEC_H
#include "rv_container.h"
enum
{
DEC_RDY,
DEC_HDRS_RDY,
DEC_PIC_HDR_RDY,
DEC_PIC_HDR_RDY_RPR,
DEC_PIC_HDR_RDY_ERROR,
DEC_ERROR,
DEC_END_OF_STREAM
};
/* function prototypes */
u32 rv_StrmDecode(DecContainer * pDecContainer);
#endif /* #ifndef RV_STRMDEC_H */

View File

@ -0,0 +1,45 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : algorithm header file
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_strmdesc.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*****************************************************************************/
#ifndef RV_STRMDESC_H
#define RV_STRMDESC_H
#include "basetype.h"
typedef struct
{
u8 *pStrmBuffStart; /* pointer to start of stream buffer */
u8 *pStrmCurrPos; /* current read addres in stream buffer */
u32 bitPosInWord; /* bit position in stream buffer */
u32 strmBuffSize; /* size of stream buffer (bytes) */
u32 strmBuffReadBits; /* number of bits read from stream buffer */
} DecStrmDesc;
#endif /* #ifndef RV_STRMDESC_H */

View File

@ -0,0 +1,159 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Header file for stream decoding utilities
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rv_utils.h,v $
-- $Date: 2009/03/11 14:00:12 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef RV_UTILS_H
#define RV_UTILS_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "rv_container.h"
#ifdef _ASSERT_USED
#include <assert.h>
#endif
#ifdef _UTEST
#include <stdio.h>
#endif
/*------------------------------------------------------------------------------
2. Module defines
------------------------------------------------------------------------------*/
/* constant definitions */
#ifndef OK
#define OK 0
#endif
#ifndef NOK
#define NOK 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef NULL
#define NULL 0
#endif
/* decoder states */
enum
{
STATE_OK,
STATE_NOT_READY,
STATE_SYNC_LOST
};
#define HANTRO_OK 0
#define HANTRO_NOK 1
#ifndef NULL
#define NULL 0
#endif
/* Error concealment */
#define FREEZED_PIC_RDY 1
enum
{
RV_I_PIC = 0,
RV_FI_PIC = 1,
RV_P_PIC = 2,
RV_B_PIC = 3
};
enum
{
RV_SLICE
};
/* value to be returned by GetBits if stream buffer is empty */
#define END_OF_STREAM 0xFFFFFFFFU
/* macro for debug printing. Note that double parenthesis has to be used, i.e.
* DEBUG(("Debug printing %d\n",%d)) */
#ifdef _UTEST
#define DEBUG(args) printf args
#else
#define DEBUG(args)
#endif
/* macro for assertion, used only if compiler flag _ASSERT_USED is defined */
#ifdef _ASSERT_USED
#define ASSERT(expr) assert(expr)
#else
#define ASSERT(expr)
#endif
/* macro to check if stream ends */
#define IS_END_OF_STREAM(pContainer) \
( (pContainer)->StrmDesc.strmBuffReadBits == \
(8*(pContainer)->StrmDesc.strmBuffSize) )
/* macro to saturate value to range [min,max]. Note that for unsigned value
* both min and max should be positive, otherwise result will be wrong due to
* arithmetic conversion. If min > max -> value will be equal to min. */
#define SATURATE(min,value,max) \
if ((value) < (min)) (value) = (min); \
else if ((value) > (max)) (value) = (max);
#define ABS(val) (((val) < 0) ? -(val) : (val))
/*------------------------------------------------------------------------------
3. Data types
------------------------------------------------------------------------------*/
typedef struct
{
u8 *pStrmBuffStart; /* pointer to start of stream buffer */
u8 *pStrmCurrPos; /* current read address in stream buffer */
u32 bitPosInWord; /* bit position in stream buffer byte */
u32 strmBuffSize; /* size of stream buffer (bytes) */
u32 strmBuffReadBits; /* number of bits read from stream buffer */
} strmData_t;
/*------------------------------------------------------------------------------
4. Function prototypes
------------------------------------------------------------------------------*/
u32 rv_GetBits(DecContainer *, u32 numBits);
u32 rv_ShowBits(DecContainer *, u32 numBits);
u32 rv_ShowBits32(DecContainer *);
u32 rv_FlushBits(DecContainer *, u32 numBits);
u32 rv_CheckStuffing(DecContainer *);
u32 rv_NumBits(u32 value);
#endif /* RV_UTILS_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,226 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2007 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : API for the 8190 RV Decoder
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rvdecapi.h,v $
-- $Date: 2010/03/23 10:41:36 $
-- $Revision: 1.7 $
--
------------------------------------------------------------------------------*/
#ifndef __RVDECAPI_H__
#define __RVDECAPI_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "basetype.h"
#include "decapicommon.h"
/*------------------------------------------------------------------------------
API type definitions
------------------------------------------------------------------------------*/
/* Return values */
typedef enum
{
RVDEC_OK = 0,
RVDEC_STRM_PROCESSED = 1,
RVDEC_PIC_RDY = 2,
RVDEC_HDRS_RDY = 3,
RVDEC_HDRS_NOT_RDY = 4,
RVDEC_PIC_DECODED = 5,
RVDEC_PARAM_ERROR = -1,
RVDEC_STRM_ERROR = -2,
RVDEC_NOT_INITIALIZED = -3,
RVDEC_MEMFAIL = -4,
RVDEC_INITFAIL = -5,
RVDEC_STREAM_NOT_SUPPORTED = -8,
RVDEC_HW_RESERVED = -254,
RVDEC_HW_TIMEOUT = -255,
RVDEC_HW_BUS_ERROR = -256,
RVDEC_SYSTEM_ERROR = -257,
RVDEC_DWL_ERROR = -258,
RVDEC_FORMAT_NOT_SUPPORTED = -1000
} RvDecRet;
/* decoder output picture format */
typedef enum
{
RVDEC_SEMIPLANAR_YUV420 = 0x020001,
RVDEC_TILED_YUV420 = 0x020002
} RvDecOutFormat;
typedef struct
{
u32 *pVirtualAddress;
u32 busAddress;
} RvDecLinearMem;
/* Decoder instance */
typedef void *RvDecInst;
typedef struct
{
u32 offset;
u32 isValid;
} RvDecSliceInfo;
/* Input structure */
typedef struct
{
u8 *pStream; /* Pointer to stream to be decoded */
u32 streamBusAddress; /* DMA bus address of the input stream */
u32 dataLen; /* Number of bytes to be decoded */
u32 picId;
u32 timestamp; /* timestamp of current picture from rv frame header.
* NOTE: timestamp of a B-frame should be adjusted referring
* to its forward reference frame's timestamp */
u32 sliceInfoNum; /* The number of slice offset entries. */
RvDecSliceInfo *pSliceInfo; /* Pointer to the sliceInfo.
* It contains offset value of each slice
* in the data buffer, including start point "0"
* and end point "dataLen" */
} RvDecInput;
/* Time code */
typedef struct
{
u32 hours;
u32 minutes;
u32 seconds;
u32 pictures;
} RvDecTime;
typedef struct
{
u8 *pStrmCurrPos;
u32 strmCurrBusAddress; /* DMA bus address location where the decoding
* ended */
u32 dataLeft;
u32 picId; /* Identifier of the picture (in enc/dec order) */
u32 picType; /* picture coding type */
u32 timestamp; /* timestamp for media player */
u32 picWidth; /* Pixel width, up round */
u32 picHeight; /* Pixel height, up round */
RvDecOutFormat outputFormat; /* format of the output picture */
} RvDecOutput;
/* stream info filled by RvDecGetInfo */
typedef struct
{
u32 frameWidth;
u32 frameHeight;
u32 codedWidth;
u32 codedHeight;
u32 profileAndLevelIndication;
u32 sampleAspectRatio;
u32 DisplayAspectRatio;
u32 streamFormat;
u32 videoFormat;
u32 videoRange; /* ??? only [0-255] */
u32 interlacedSequence;
u32 multiBuffPpSize;
RvDecOutFormat outputFormat;
} RvDecInfo;
typedef struct
{
u8 *pOutputPicture;
u32 outputPictureBusAddress;
u32 frameWidth;
u32 frameHeight;
u32 codedWidth;
u32 codedHeight;
u32 keyPicture;
u32 picId;
u32 interlaced;
u32 fieldPicture;
u32 topField;
u32 firstField;
u32 repeatFirstField;
u32 repeatFrameCount;
u32 numberOfErrMBs;
RvDecTime timeCode;
} RvDecPicture;
/* Version information */
typedef struct
{
u32 major; /* API major version */
u32 minor; /* API minor version */
} RvDecApiVersion;
typedef struct
{
u32 swBuild; /* Software build ID */
u32 hwBuild; /* Hardware build ID */
DecHwConfig hwConfig; /* hardware supported configuration */
} RvDecBuild;
/*------------------------------------------------------------------------------
Prototypes of Decoder API functions
------------------------------------------------------------------------------*/
RvDecApiVersion RvDecGetAPIVersion(void);
RvDecBuild RvDecGetBuild(void);
RvDecRet RvDecInit(RvDecInst * pDecInst,
u32 useVideoFreezeConcealment,
u32 frameCodeLength,
u32 *frameSizes,
u32 rvVersion,
u32 maxFrameWidth, u32 maxFrameHeight,
u32 numFrameBuffers );
RvDecRet RvDecDecode(RvDecInst decInst,
RvDecInput * pInput,
RvDecOutput * pOutput);
RvDecRet RvDecGetInfo(RvDecInst decInst, RvDecInfo * pDecInfo);
RvDecRet RvDecNextPicture(RvDecInst decInst,
RvDecPicture * pPicture,
u32 endOfStream);
void RvDecRelease(RvDecInst decInst);
RvDecRet RvDecPeek(RvDecInst decInst, RvDecPicture * pPicture);
/*------------------------------------------------------------------------------
Prototype of the API trace funtion. Traces all API entries and returns.
This must be implemented by the application using the decoder API!
Argument:
string - trace message, a null terminated string
------------------------------------------------------------------------------*/
void RvDecTrace(const char *string);
#ifdef __cplusplus
}
#endif
#endif /* __RVDECAPI_H__ */

View File

@ -0,0 +1,89 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract: api internal defines
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: rvdecapi_internal.h,v $
-- $Date: 2009/05/08 07:04:48 $
-- $Revision: 1.2 $
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. Internal Definitions
3. Prototypes of Decoder API internal functions
------------------------------------------------------------------------------*/
#ifndef RV_DECAPI_INTERNAL_H
#define RV_DECAPI_INTERNAL_H
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "rv_cfg.h"
#include "rv_utils.h"
#include "rvdecapi.h"
/*------------------------------------------------------------------------------
2. Internal Definitions
------------------------------------------------------------------------------*/
#define RV_DEC_X170_IRQ_DEC_RDY 0x01
#define RV_DEC_X170_IRQ_BUS_ERROR 0x02
#define RV_DEC_X170_IRQ_BUFFER_EMPTY 0x04
#define RV_DEC_X170_IRQ_ASO 0x08
#define RV_DEC_X170_IRQ_STREAM_ERROR 0x10
#define RV_DEC_X170_IRQ_TIMEOUT 0x40
#define RV_DEC_X170_IRQ_CLEAR_ALL 0xFF
#define RV_DEC_X170_MAX_NUM_SLICES (128)
/*
* Size of internal frame buffers (in 32bit-words) per macro block
*/
#define RVAPI_DEC_FRAME_BUFF_SIZE 96
#ifndef NULL
#define NULL 0
#endif
#define SWAP_POINTERS(A, B, T) T = A; A = B; B = T;
#define INVALID_ANCHOR_PICTURE ((u32)-1)
/*------------------------------------------------------------------------------
3. Prototypes of Decoder API internal functions
------------------------------------------------------------------------------*/
void rvAPI_InitDataStructures(DecContainer * pDecCont);
void rvDecTimeCode(DecContainer * pDecCont, RvDecTime * timeCode);
RvDecRet rvAllocateBuffers(DecContainer * pDecCont);
RvDecRet rvDecCheckSupport(DecContainer * pDecCont);
void rvDecPreparePicReturn(DecContainer * pDecCont);
void rvDecAspectRatio(DecContainer * pDecCont, RvDecInfo * pDecInfo);
void rvDecBufferPicture(DecContainer * pDecCont, u32 picId, u32 bufferB,
u32 isInter, RvDecRet returnValue, u32 nbrErrMbs);
void rvFreeBuffers(DecContainer * pDecCont);
void rvInitVlcTables(DecContainer * pDecCont);
#endif /* RV_DECAPI_INTERNAL_H */

View File

@ -0,0 +1,38 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Header file for stream decoding utilities
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: tiledref.h,v $
-- $Date: 2010/12/01 12:31:03 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#ifndef TILEDREF_H_DEFINED
#define TILEDREF_H_DEFINED
#include "basetype.h"
#define TILED_REF_NONE (0)
#define TILED_REF_8x4 (1)
u32 DecSetupTiledReference( u32 *regBase, u32 tiledModeSupport, u32 interlacedStream );
#endif /* TILEDREF_H_DEFINED */

View File

@ -0,0 +1,62 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Header file for stream decoding utilities
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: workaround.h,v $
-- $Date: 2010/06/11 06:25:28 $
-- $Revision: 1.3 $
--
------------------------------------------------------------------------------*/
#ifndef WORKAROUND_H_DEFINED
#define WORKAROUND_H_DEFINED
#include "basetype.h"
/* Union containing structures to hold different formats' workarounds. */
typedef union workaround_s
{
struct {
u32 stuffing;
u32 startCode;
} mpeg;
struct {
u32 multibuffer;
} rv;
} workaround_t;
#ifndef HANTRO_TRUE
#define HANTRO_TRUE (1)
#endif /* HANTRO_TRUE */
#ifndef HANTRO_FALSE
#define HANTRO_FALSE (0)
#endif /* HANTRO_FALSE*/
void InitWorkarounds(u32 decMode, workaround_t *pWorkarounds );
void PrepareStuffingWorkaround( u8 *pDecOut, u32 vopWidth, u32 vopHeight );
u32 ProcessStuffingWorkaround( u8 * pDecOut, u8 * pRefPic, u32 vopWidth,
u32 vopHeight );
void PrepareStartCodeWorkaround( u8 *pDecOut, u32 vopWidth, u32 vopHeight,
u32 topField );
u32 ProcessStartCodeWorkaround( u8 *pDecOut, u32 vopWidth, u32 vopHeight,
u32 topField );
#endif /* WORKAROUND_H_DEFINED */

165
lib/hx170dec/src/bqueue.c Normal file
View File

@ -0,0 +1,165 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Stream decoding utilities
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: bqueue.c,v $
-- $Date: 2010/07/23 09:19:10 $
-- $Revision: 1.4 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of context
1. Include headers
2. External identifiers
3. Module defines
4. Module identifiers
5. Fuctions
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "bqueue.h"
#include "dwl.h"
#ifndef HANTRO_OK
#define HANTRO_OK (0)
#endif /* HANTRO_TRUE */
#ifndef HANTRO_NOK
#define HANTRO_NOK (1)
#endif /* HANTRO_FALSE*/
/*------------------------------------------------------------------------------
2. External identifiers
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Module indentifiers
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
BqueueInit
Initialize buffer queue
------------------------------------------------------------------------------*/
u32 BqueueInit( bufferQueue_t *bq, u32 numBuffers )
{
u32 i;
if( numBuffers == 0 )
return HANTRO_OK;
bq->picI = (u32*)DWLmalloc( sizeof(u32)*numBuffers);
if( bq->picI == NULL )
{
return HANTRO_NOK;
}
for( i = 0 ; i < numBuffers ; ++i )
{
bq->picI[i] = 0;
}
bq->queueSize = numBuffers;
bq->ctr = 1;
return HANTRO_OK;
}
/*------------------------------------------------------------------------------
BqueueRelease
------------------------------------------------------------------------------*/
void BqueueRelease( bufferQueue_t *bq )
{
if(bq->picI)
{
DWLfree(bq->picI);
bq->picI = NULL;
}
bq->prevAnchorSlot = 0;
bq->queueSize = 0;
}
/*------------------------------------------------------------------------------
BqueueNext
Return "oldest" available buffer.
------------------------------------------------------------------------------*/
u32 BqueueNext( bufferQueue_t *bq, u32 ref0, u32 ref1, u32 ref2, u32 bPic )
{
u32 minPicI = 1<<30;
u32 nextOut = (u32)0xFFFFFFFFU;
u32 i;
/* Find available buffer with smallest index number */
i = 0;
while( i < bq->queueSize )
{
if(i == ref0 || i == ref1 || i == ref2) /* Skip reserved anchor pictures */
{
i++;
continue;
}
if( bq->picI[i] < minPicI )
{
minPicI = bq->picI[i];
nextOut = i;
}
i++;
}
if( nextOut == (u32)0xFFFFFFFFU)
{
return 0; /* No buffers available, shouldn't happen */
}
/* Update queue state */
if( bPic )
{
bq->picI[nextOut] = bq->ctr-1;
bq->picI[bq->prevAnchorSlot]++;
}
else
{
bq->picI[nextOut] = bq->ctr;
}
bq->ctr++;
if( !bPic )
{
bq->prevAnchorSlot = nextOut;
}
return nextOut;
}
/*------------------------------------------------------------------------------
BqueueDiscard
"Discard" output buffer, e.g. if error concealment used and buffer
at issue is never going out.
------------------------------------------------------------------------------*/
void BqueueDiscard( bufferQueue_t *bq, u32 buffer )
{
bq->picI[buffer] = 0;
}

View File

@ -0,0 +1,941 @@
#include "FreeRTOS.h"
#include "chip.h"
#include "basetype.h"
#include "dwl_defs.h"
#include "dwl_freertos.h"
#include "dwl.h"
#include "hx170dec.h"
#define DWL_USE_DEC_IRQ
#define DWL_PJPEG_E 22 /* 1 bit */
#define DWL_REF_BUFF_E 20 /* 1 bit */
#define DWL_JPEG_EXT_E 31 /* 1 bit */
#define DWL_REF_BUFF_ILACE_E 30 /* 1 bit */
#define DWL_MPEG4_CUSTOM_E 29 /* 1 bit */
#define DWL_REF_BUFF_DOUBLE_E 28 /* 1 bit */
#define DWL_MVC_E 20 /* 2 bits */
#define DWL_DEC_TILED_L 17 /* 2 bits */
#define DWL_DEC_PIC_W_EXT 14 /* 2 bits */
#define DWL_EC_E 12 /* 2 bits */
#define DWL_STRIDE_E 11 /* 1 bit */
#define DWL_FIELD_DPB_E 10 /* 1 bit */
#define DWL_CFG_E 24 /* 4 bits */
#define DWL_PP_IN_TILED_L 14 /* 2 bits */
#define DWL_SORENSONSPARK_E 11 /* 1 bit */
#define DWL_H264_FUSE_E 31 /* 1 bit */
#define DWL_MPEG4_FUSE_E 30 /* 1 bit */
#define DWL_MPEG2_FUSE_E 29 /* 1 bit */
#define DWL_SORENSONSPARK_FUSE_E 28 /* 1 bit */
#define DWL_JPEG_FUSE_E 27 /* 1 bit */
#define DWL_VP6_FUSE_E 26 /* 1 bit */
#define DWL_VC1_FUSE_E 25 /* 1 bit */
#define DWL_PJPEG_FUSE_E 24 /* 1 bit */
#define DWL_CUSTOM_MPEG4_FUSE_E 23 /* 1 bit */
#define DWL_RV_FUSE_E 22 /* 1 bit */
#define DWL_VP7_FUSE_E 21 /* 1 bit */
#define DWL_VP8_FUSE_E 20 /* 1 bit */
#define DWL_AVS_FUSE_E 19 /* 1 bit */
#define DWL_MVC_FUSE_E 18 /* 1 bit */
#define DWL_DEC_MAX_1920_FUSE_E 15 /* 1 bit */
#define DWL_DEC_MAX_1280_FUSE_E 14 /* 1 bit */
#define DWL_DEC_MAX_720_FUSE_E 13 /* 1 bit */
#define DWL_DEC_MAX_352_FUSE_E 12 /* 1 bit */
#define DWL_REF_BUFF_FUSE_E 7 /* 1 bit */
#define DWL_PP_FUSE_E 31 /* 1 bit */
#define DWL_PP_DEINTERLACE_FUSE_E 30 /* 1 bit */
#define DWL_PP_ALPHA_BLEND_FUSE_E 29 /* 1 bit */
#define DWL_PP_MAX_4096_FUSE_E 16 /* 1 bit */
#define DWL_PP_MAX_1920_FUSE_E 15 /* 1 bit */
#define DWL_PP_MAX_1280_FUSE_E 14 /* 1 bit */
#define DWL_PP_MAX_720_FUSE_E 13 /* 1 bit */
#define DWL_PP_MAX_352_FUSE_E 12 /* 1 bit */
#define IS_PIPELINE_ENABLED(val) ((val) & 0x02)
/* shadow HW registers */
u32 dwlShadowRegs[MAX_ASIC_CORES][128];
#ifdef _DWL_DEBUG
static void PrintIrqType(u32 isPP, /*u32 coreID,*/ u32 status)
{
u32 coreID = 0;
if(isPP)
{
printf("PP[%d] IRQ %s\n", coreID,
status & PP_IRQ_RDY ? "READY" : "BUS ERROR");
}
else
{
if(status & DEC_IRQ_ABORT)
printf("DEC[%d] IRQ ABORT\n", coreID);
else if (status & DEC_IRQ_RDY)
printf("DEC[%d] IRQ READY\n", coreID);
else if (status & DEC_IRQ_BUS)
printf("DEC[%d] IRQ BUS ERROR\n", coreID);
else if (status & DEC_IRQ_BUFFER)
printf("DEC[%d] IRQ BUFFER\n", coreID);
else if (status & DEC_IRQ_ASO)
printf("DEC[%d] IRQ ASO\n", coreID);
else if (status & DEC_IRQ_ERROR)
printf("DEC[%d] IRQ STREAM ERROR\n", coreID);
else if (status & DEC_IRQ_SLICE)
printf("DEC[%d] IRQ SLICE\n", coreID);
else if (status & DEC_IRQ_TIMEOUT)
printf("DEC[%d] IRQ TIMEOUT\n", coreID);
else
printf("DEC[%d] IRQ UNKNOWN 0x%08x\n", coreID, status);
}
}
#endif
/*------------------------------------------------------------------------------
Function name : DWLReadAsicCoreCount
Description : Return the number of hardware cores available
------------------------------------------------------------------------------*/
u32 DWLReadAsicCoreCount(void)
{
unsigned int cores = 0;
/* ask module for cores */
if (vdec_ioctl(HX170DEC_IOC_MC_CORES, &cores) == -1)
{
DWL_DEBUG("ioctl failed\n");
cores = 0;
}
return (u32)cores;
}
/*------------------------------------------------------------------------------
Function name : DWLReadAsicID
Description : Read the HW ID. Does not need a DWL instance to run
Return type : u32 - the HW ID
------------------------------------------------------------------------------*/
u32 DWLReadAsicID()
{
u32 id = ~0;
unsigned long base;
DWL_DEBUG("\n");
/* ask module for base */
if(vdec_ioctl(HX170DEC_IOCGHWOFFSET, &base) == -1)
{
DWL_DEBUG("ioctl failed\n");
return id;
}
id = *(volatile unsigned int*)base;
return id;
}
static void ReadCoreFuse(const u32 *io, DWLHwFuseStatus_t *pHwFuseSts)
{
u32 configReg, fuseReg, fuseRegPp;
/* Decoder configuration */
configReg = io[HX170DEC_SYNTH_CFG];
/* Decoder fuse configuration */
fuseReg = io[HX170DEC_FUSE_CFG];
pHwFuseSts->h264SupportFuse = (fuseReg >> DWL_H264_FUSE_E) & 0x01U;
pHwFuseSts->mpeg4SupportFuse = (fuseReg >> DWL_MPEG4_FUSE_E) & 0x01U;
pHwFuseSts->mpeg2SupportFuse = (fuseReg >> DWL_MPEG2_FUSE_E) & 0x01U;
pHwFuseSts->sorensonSparkSupportFuse =
(fuseReg >> DWL_SORENSONSPARK_FUSE_E) & 0x01U;
pHwFuseSts->jpegSupportFuse = (fuseReg >> DWL_JPEG_FUSE_E) & 0x01U;
pHwFuseSts->vp6SupportFuse = (fuseReg >> DWL_VP6_FUSE_E) & 0x01U;
pHwFuseSts->vc1SupportFuse = (fuseReg >> DWL_VC1_FUSE_E) & 0x01U;
pHwFuseSts->jpegProgSupportFuse = (fuseReg >> DWL_PJPEG_FUSE_E) & 0x01U;
pHwFuseSts->rvSupportFuse = (fuseReg >> DWL_RV_FUSE_E) & 0x01U;
pHwFuseSts->avsSupportFuse = (fuseReg >> DWL_AVS_FUSE_E) & 0x01U;
pHwFuseSts->vp7SupportFuse = (fuseReg >> DWL_VP7_FUSE_E) & 0x01U;
pHwFuseSts->vp8SupportFuse = (fuseReg >> DWL_VP8_FUSE_E) & 0x01U;
pHwFuseSts->customMpeg4SupportFuse = (fuseReg >> DWL_CUSTOM_MPEG4_FUSE_E) & 0x01U;
pHwFuseSts->mvcSupportFuse = (fuseReg >> DWL_MVC_FUSE_E) & 0x01U;
/* check max. decoder output width */
if(fuseReg & 0x10000U)
pHwFuseSts->maxDecPicWidthFuse = 4096;
else if(fuseReg & 0x8000U)
pHwFuseSts->maxDecPicWidthFuse = 1920;
else if(fuseReg & 0x4000U)
pHwFuseSts->maxDecPicWidthFuse = 1280;
else if(fuseReg & 0x2000U)
pHwFuseSts->maxDecPicWidthFuse = 720;
else if(fuseReg & 0x1000U)
pHwFuseSts->maxDecPicWidthFuse = 352;
pHwFuseSts->refBufSupportFuse = (fuseReg >> DWL_REF_BUFF_FUSE_E) & 0x01U;
/* Pp configuration */
configReg = io[HX170PP_SYNTH_CFG];
if((configReg >> DWL_PP_E) & 0x01U)
{
/* Pp fuse configuration */
fuseRegPp = io[HX170PP_FUSE_CFG];
if((fuseRegPp >> DWL_PP_FUSE_E) & 0x01U)
{
pHwFuseSts->ppSupportFuse = 1;
/* check max. pp output width */
if(fuseRegPp & 0x10000U)
pHwFuseSts->maxPpOutPicWidthFuse = 4096;
else if(fuseRegPp & 0x8000U)
pHwFuseSts->maxPpOutPicWidthFuse = 1920;
else if(fuseRegPp & 0x4000U)
pHwFuseSts->maxPpOutPicWidthFuse = 1280;
else if(fuseRegPp & 0x2000U)
pHwFuseSts->maxPpOutPicWidthFuse = 720;
else if(fuseRegPp & 0x1000U)
pHwFuseSts->maxPpOutPicWidthFuse = 352;
pHwFuseSts->ppConfigFuse = fuseRegPp;
}
else
{
pHwFuseSts->ppSupportFuse = 0;
pHwFuseSts->maxPpOutPicWidthFuse = 0;
pHwFuseSts->ppConfigFuse = 0;
}
}
}
static void ReadCoreConfig(const u32 *io, DWLHwConfig_t *pHwCfg)
{
u32 configReg;
const u32 asicID = io[0];
/* Decoder configuration */
configReg = io[HX170DEC_SYNTH_CFG];
pHwCfg->h264Support = (configReg >> DWL_H264_E) & 0x3U;
/* check jpeg */
pHwCfg->jpegSupport = (configReg >> DWL_JPEG_E) & 0x01U;
if(pHwCfg->jpegSupport && ((configReg >> DWL_PJPEG_E) & 0x01U))
pHwCfg->jpegSupport = JPEG_PROGRESSIVE;
pHwCfg->mpeg4Support = (configReg >> DWL_MPEG4_E) & 0x3U;
pHwCfg->vc1Support = (configReg >> DWL_VC1_E) & 0x3U;
pHwCfg->mpeg2Support = (configReg >> DWL_MPEG2_E) & 0x01U;
pHwCfg->sorensonSparkSupport = (configReg >> DWL_SORENSONSPARK_E) & 0x01U;
#ifndef DWL_REFBUFFER_DISABLE
pHwCfg->refBufSupport = (configReg >> DWL_REF_BUFF_E) & 0x01U;
#else
pHwCfg->refBufSupport = 0;
#endif
pHwCfg->vp6Support = (configReg >> DWL_VP6_E) & 0x01U;
#ifdef DEC_X170_APF_DISABLE
if(DEC_X170_APF_DISABLE)
{
pHwCfg->tiledModeSupport = 0;
}
#endif /* DEC_X170_APF_DISABLE */
pHwCfg->maxDecPicWidth = configReg & 0x07FFU;
/* 2nd Config register */
configReg = io[HX170DEC_SYNTH_CFG_2];
if(pHwCfg->refBufSupport)
{
if((configReg >> DWL_REF_BUFF_ILACE_E) & 0x01U)
pHwCfg->refBufSupport |= 2;
if((configReg >> DWL_REF_BUFF_DOUBLE_E) & 0x01U)
pHwCfg->refBufSupport |= 4;
}
pHwCfg->customMpeg4Support = (configReg >> DWL_MPEG4_CUSTOM_E) & 0x01U;
pHwCfg->vp7Support = (configReg >> DWL_VP7_E) & 0x01U;
pHwCfg->vp8Support = (configReg >> DWL_VP8_E) & 0x01U;
pHwCfg->avsSupport = (configReg >> DWL_AVS_E) & 0x01U;
/* JPEG extensions */
if(((asicID >> 16) >= 0x8190U) || ((asicID >> 16) == 0x6731U))
pHwCfg->jpegESupport = (configReg >> DWL_JPEG_EXT_E) & 0x01U;
else
pHwCfg->jpegESupport = JPEG_EXT_NOT_SUPPORTED;
if(((asicID >> 16) >= 0x9170U) || ((asicID >> 16) == 0x6731U))
pHwCfg->rvSupport = (configReg >> DWL_RV_E) & 0x03U;
else
pHwCfg->rvSupport = RV_NOT_SUPPORTED;
pHwCfg->mvcSupport = (configReg >> DWL_MVC_E) & 0x03U;
pHwCfg->webpSupport = (configReg >> DWL_WEBP_E) & 0x01U;
pHwCfg->tiledModeSupport = (configReg >> DWL_DEC_TILED_L) & 0x03U;
pHwCfg->maxDecPicWidth += (( configReg >> DWL_DEC_PIC_W_EXT) & 0x03U ) << 11;
pHwCfg->ecSupport = (configReg >> DWL_EC_E) & 0x03U;
pHwCfg->strideSupport = (configReg >> DWL_STRIDE_E) & 0x01U;
pHwCfg->fieldDpbSupport = (configReg >> DWL_FIELD_DPB_E) & 0x01U;
if(pHwCfg->refBufSupport && ((asicID >> 16) == 0x6731U))
{
pHwCfg->refBufSupport |= 8; /* enable HW support for offset */
}
/* Pp configuration */
configReg = io[HX170PP_SYNTH_CFG];
if((configReg >> DWL_PP_E) & 0x01U)
{
pHwCfg->ppSupport = 1;
/* Theoretical max range 0...8191; actual 48...4096 */
pHwCfg->maxPpOutPicWidth = configReg & 0x1FFFU;
/*pHwCfg->ppConfig = (configReg >> DWL_CFG_E) & 0x0FU; */
pHwCfg->ppConfig = configReg;
}
else
{
pHwCfg->ppSupport = 0;
pHwCfg->maxPpOutPicWidth = 0;
pHwCfg->ppConfig = 0;
}
/* check the HW version */
if(((asicID >> 16) >= 0x8190U) || ((asicID >> 16) == 0x6731U))
{
u32 deInterlace;
u32 alphaBlend;
u32 deInterlaceFuse;
u32 alphaBlendFuse;
DWLHwFuseStatus_t hwFuseSts;
/* check fuse status */
ReadCoreFuse(io, &hwFuseSts);
/* Maximum decoding width supported by the HW */
if(pHwCfg->maxDecPicWidth > hwFuseSts.maxDecPicWidthFuse)
pHwCfg->maxDecPicWidth = hwFuseSts.maxDecPicWidthFuse;
/* Maximum output width of Post-Processor */
if(pHwCfg->maxPpOutPicWidth > hwFuseSts.maxPpOutPicWidthFuse)
pHwCfg->maxPpOutPicWidth = hwFuseSts.maxPpOutPicWidthFuse;
/* h264 */
if(!hwFuseSts.h264SupportFuse)
pHwCfg->h264Support = H264_NOT_SUPPORTED;
/* mpeg-4 */
if(!hwFuseSts.mpeg4SupportFuse)
pHwCfg->mpeg4Support = MPEG4_NOT_SUPPORTED;
/* custom mpeg-4 */
if(!hwFuseSts.customMpeg4SupportFuse)
pHwCfg->customMpeg4Support = MPEG4_CUSTOM_NOT_SUPPORTED;
/* jpeg (baseline && progressive) */
if(!hwFuseSts.jpegSupportFuse)
pHwCfg->jpegSupport = JPEG_NOT_SUPPORTED;
if((pHwCfg->jpegSupport == JPEG_PROGRESSIVE) &&
!hwFuseSts.jpegProgSupportFuse)
pHwCfg->jpegSupport = JPEG_BASELINE;
/* mpeg-2 */
if(!hwFuseSts.mpeg2SupportFuse)
pHwCfg->mpeg2Support = MPEG2_NOT_SUPPORTED;
/* vc-1 */
if(!hwFuseSts.vc1SupportFuse)
pHwCfg->vc1Support = VC1_NOT_SUPPORTED;
/* vp6 */
if(!hwFuseSts.vp6SupportFuse)
pHwCfg->vp6Support = VP6_NOT_SUPPORTED;
/* vp7 */
if(!hwFuseSts.vp7SupportFuse)
pHwCfg->vp7Support = VP7_NOT_SUPPORTED;
/* vp8 */
if(!hwFuseSts.vp8SupportFuse)
pHwCfg->vp8Support = VP8_NOT_SUPPORTED;
/* webp */
if(!hwFuseSts.vp8SupportFuse)
pHwCfg->webpSupport = WEBP_NOT_SUPPORTED;
/* pp */
if(!hwFuseSts.ppSupportFuse)
pHwCfg->ppSupport = PP_NOT_SUPPORTED;
/* check the pp config vs fuse status */
if((pHwCfg->ppConfig & 0xFC000000) &&
((hwFuseSts.ppConfigFuse & 0xF0000000) >> 5))
{
/* config */
deInterlace = ((pHwCfg->ppConfig & PP_DEINTERLACING) >> 25);
alphaBlend = ((pHwCfg->ppConfig & PP_ALPHA_BLENDING) >> 24);
/* fuse */
deInterlaceFuse =
(((hwFuseSts.ppConfigFuse >> 5) & PP_DEINTERLACING) >> 25);
alphaBlendFuse =
(((hwFuseSts.ppConfigFuse >> 5) & PP_ALPHA_BLENDING) >> 24);
/* check if */
if(deInterlace && !deInterlaceFuse)
pHwCfg->ppConfig &= 0xFD000000;
if(alphaBlend && !alphaBlendFuse)
pHwCfg->ppConfig &= 0xFE000000;
}
/* sorenson */
if(!hwFuseSts.sorensonSparkSupportFuse)
pHwCfg->sorensonSparkSupport = SORENSON_SPARK_NOT_SUPPORTED;
/* ref. picture buffer */
if(!hwFuseSts.refBufSupportFuse)
pHwCfg->refBufSupport = REF_BUF_NOT_SUPPORTED;
/* rv */
if(!hwFuseSts.rvSupportFuse)
pHwCfg->rvSupport = RV_NOT_SUPPORTED;
/* avs */
if(!hwFuseSts.avsSupportFuse)
pHwCfg->avsSupport = AVS_NOT_SUPPORTED;
/* mvc */
if(!hwFuseSts.mvcSupportFuse)
pHwCfg->mvcSupport = MVC_NOT_SUPPORTED;
}
}
/*------------------------------------------------------------------------------
Function name : DWLReadAsicConfig
Description : Read HW configuration. Does not need a DWL instance to run
Return type : DWLHwConfig_t - structure with HW configuration
------------------------------------------------------------------------------*/
void DWLReadAsicConfig(DWLHwConfig_t *pHwCfg)
{
unsigned long base;
DWL_DEBUG("\n");
/* ask module for base */
if(vdec_ioctl(HX170DEC_IOCGHWOFFSET, &base) == -1)
{
DWL_DEBUG("ioctl HX170DEC_IOCGHWOFFSET failed\n");
return;
}
/* Decoder configuration */
memset(pHwCfg, 0, sizeof(*pHwCfg));
ReadCoreConfig((const u32 *)base, pHwCfg);
}
void DWLReadMCAsicConfig(DWLHwConfig_t pHwCfg[MAX_ASIC_CORES])
{
unsigned int nCores, i;
unsigned long mcRegBase[MAX_ASIC_CORES];
DWL_DEBUG("\n");
if(vdec_ioctl(HX170DEC_IOC_MC_CORES, &nCores) == -1)
{
DWL_DEBUG("ioctl HX170DEC_IOC_MC_CORES failed\n");
return;
}
configASSERT(nCores <= MAX_ASIC_CORES);
if(vdec_ioctl(HX170DEC_IOC_MC_OFFSETS, mcRegBase) == -1)
{
DWL_DEBUG("ioctl HX170DEC_IOC_MC_OFFSETS failed\n");
return;
}
/* Decoder configuration */
memset(pHwCfg, 0, MAX_ASIC_CORES * sizeof(*pHwCfg));
for (i = 0; i < nCores; i++)
{
ReadCoreConfig((const u32 *)mcRegBase[i], pHwCfg + i);
}
}
/*------------------------------------------------------------------------------
Function name : DWLReadAsicFuseStatus
Description : Read HW fuse configuration. Does not need a DWL instance to run
Returns : DWLHwFuseStatus_t * pHwFuseSts - structure with HW fuse configuration
------------------------------------------------------------------------------*/
void DWLReadAsicFuseStatus(DWLHwFuseStatus_t * pHwFuseSts)
{
unsigned long base;
//unsigned int regSize;
DWL_DEBUG("\n");
memset(pHwFuseSts, 0, sizeof(*pHwFuseSts));
/* ask module for base */
if(vdec_ioctl(HX170DEC_IOCGHWOFFSET, &base) == -1)
{
DWL_DEBUG("ioctl failed\n");
return;
}
/* Decoder fuse configuration */
ReadCoreFuse((const u32*)base, pHwFuseSts);
}
/*------------------------------------------------------------------------------
Function name : DWLMallocRefFrm
Description : Allocate a frame buffer (contiguous linear RAM memory)
Return type : i32 - 0 for success or a negative error code
Argument : const void * instance - DWL instance
Argument : u32 size - size in bytes of the requested memory
Argument : void *info - place where the allocated memory buffer
parameters are returned
------------------------------------------------------------------------------*/
i32 DWLMallocRefFrm(const void *instance, u32 size, DWLLinearMem_t * info)
{
#ifdef MEMORY_USAGE_TRACE
printf("DWLMallocRefFrm\t%8d bytes\n", size);
#endif
return DWLMallocLinear(instance, size, info);
}
/*------------------------------------------------------------------------------
Function name : DWLFreeRefFrm
Description : Release a frame buffer previously allocated with
DWLMallocRefFrm.
Return type : void
Argument : const void * instance - DWL instance
Argument : void *info - frame buffer memory information
------------------------------------------------------------------------------*/
void DWLFreeRefFrm(const void *instance, DWLLinearMem_t * info)
{
DWLFreeLinear(instance, info);
}
/*------------------------------------------------------------------------------
Function name : DWLMallocLinear
Description : Allocate a contiguous, linear RAM memory buffer
Return type : i32 - 0 for success or a negative error code
Argument : const void * instance - DWL instance
Argument : u32 size - size in bytes of the requested memory
Argument : void *info - place where the allocated memory buffer
parameters are returned
------------------------------------------------------------------------------*/
i32 DWLMallocLinear(const void *instance, u32 size, DWLLinearMem_t * info)
{
hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
configASSERT(dec_dwl != NULL);
configASSERT(info != NULL);
#ifdef MEMORY_USAGE_TRACE
printf("DWLMallocLinear\t%8d bytes \n", size);
#endif
info->size = size;
info->virtualAddress = (u32 *)pvPortMalloc(size);
info->busAddress = (u32)info->virtualAddress;
info->virtualAddress = (u32 *)PHY_TO_UNCACHED_VIRT(info->virtualAddress);//info->virtualAddress + PHY_TO_VIR/4;
CP15_invalidate_dcache_for_dma(info->busAddress, info->busAddress + size);
#ifdef MEMORY_USAGE_TRACE
printf("DWLMallocLinear 0x%08x virtualAddress: 0x%08x\n",
info->busAddress, (unsigned) info->virtualAddress);
#endif
if(info->virtualAddress == NULL)
return DWL_ERROR;
return DWL_OK;
}
/*------------------------------------------------------------------------------
Function name : DWLFreeLinear
Description : Release a linera memory buffer, previously allocated with
DWLMallocLinear.
Return type : void
Argument : const void * instance - DWL instance
Argument : void *info - linear buffer memory information
------------------------------------------------------------------------------*/
void DWLFreeLinear(const void *instance, DWLLinearMem_t * info)
{
hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
configASSERT(dec_dwl != NULL);
configASSERT(info != NULL);
if(info->virtualAddress != NULL)
vPortFree((u32*)UNCACHED_VIRT_TO_PHT(info->virtualAddress));
}
/*------------------------------------------------------------------------------
Function name : DWLWriteReg
Description : Write a value to a hardware IO register
Return type : void
Argument : const void * instance - DWL instance
Argument : u32 offset - byte offset of the register to be written
Argument : u32 value - value to be written out
------------------------------------------------------------------------------*/
void DWLWriteReg(const void *instance, /*i32 coreID,*/ u32 offset, u32 value)
{
hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
i32 coreID = 0;
#ifndef DWL_DISABLE_REG_PRINTS
DWL_DEBUG("core[%d] swreg[%d] at offset 0x%02X = %08X\n",
coreID, offset/4, offset, value);
#endif
configASSERT((dec_dwl->clientType != DWL_CLIENT_TYPE_PP &&
offset < HX170PP_REG_START) ||
(dec_dwl->clientType == DWL_CLIENT_TYPE_PP &&
offset >= HX170PP_REG_START));
configASSERT(dec_dwl != NULL);
configASSERT(offset < dec_dwl->regSize);
configASSERT(coreID < (i32)dec_dwl->numCores);
offset = offset / 4;
dwlShadowRegs[coreID][offset] = value;
}
/*------------------------------------------------------------------------------
Function name : DWLReadReg
Description : Read the value of a hardware IO register
Return type : u32 - the value stored in the register
Argument : const void * instance - DWL instance
Argument : u32 offset - byte offset of the register to be read
------------------------------------------------------------------------------*/
u32 DWLReadReg(const void *instance, /*i32 coreID,*/ u32 offset)
{
hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
u32 val;
i32 coreID = 0;
configASSERT(dec_dwl != NULL);
configASSERT((dec_dwl->clientType != DWL_CLIENT_TYPE_PP &&
offset < HX170PP_REG_START) ||
(dec_dwl->clientType == DWL_CLIENT_TYPE_PP &&
offset >= HX170PP_REG_START) || (offset == 0) ||
(offset == HX170PP_SYNTH_CFG));
configASSERT(offset < dec_dwl->regSize);
configASSERT(coreID < (i32)dec_dwl->numCores);
offset = offset / 4;
val = dwlShadowRegs[coreID][offset];
#ifndef DWL_DISABLE_REG_PRINTS
DWL_DEBUG("core[%d] swreg[%d] at offset 0x%02X = %08X\n",
coreID, offset, offset * 4, val);
#endif
return val;
}
/*------------------------------------------------------------------------------
Function name : DWLEnableHW
Description : Enable hw by writing to register
Return type : void
Argument : const void * instance - DWL instance
Argument : u32 offset - byte offset of the register to be written
Argument : u32 value - value to be written out
------------------------------------------------------------------------------*/
void DWLEnableHW(const void *instance, /*i32 coreID,*/ u32 offset, u32 value)
{
hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
struct core_desc core;
int isPP, ioctl_req;
i32 coreID = 0;
configASSERT(dec_dwl);
isPP = dec_dwl->clientType == DWL_CLIENT_TYPE_PP ? 1 : 0;
ioctl_req = isPP ? HX170DEC_IOCS_PP_PUSH_REG : HX170DEC_IOCS_DEC_PUSH_REG;
//printf("isPP:%d\n", isPP);
DWLWriteReg(dec_dwl, /*coreID,*/ offset, value);
DWL_DEBUG("%s %d enabled by previous DWLWriteReg\n",
isPP ? "PP" : "DEC", coreID);
core.id = coreID;
core.regs = dwlShadowRegs[coreID];
core.regs += isPP ? 60 : 0;
core.size = isPP ? 41 * 4 : 60 * 4;
#if 0 //add for test.
int i;
for(i=core.size/4-1; i>=0; i--) {
printf("*(volatile unsigned int*)(0x71200000 + %d) = 0x%x;\n",
i * 4, dwlShadowRegs[coreID][i]);
}
#endif
if(vdec_ioctl(ioctl_req, &core))
{
DWL_DEBUG("ioctl HX170DEC_IOCS_*_PUSH_REG failed\n");
configASSERT(0);
}
}
/*------------------------------------------------------------------------------
Function name : DWLDisableHW
Description : Disable hw by writing to register
Return type : void
Argument : const void * instance - DWL instance
Argument : u32 offset - byte offset of the register to be written
Argument : u32 value - value to be written out
------------------------------------------------------------------------------*/
void DWLDisableHW(const void *instance, /*i32 coreID,*/ u32 offset, u32 value)
{
hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
struct core_desc core;
int isPP, ioctl_req;
i32 coreID = 0;
configASSERT(dec_dwl);
isPP = dec_dwl->clientType == DWL_CLIENT_TYPE_PP ? 1 : 0;
ioctl_req = isPP ? HX170DEC_IOCS_PP_PUSH_REG : HX170DEC_IOCS_DEC_PUSH_REG;
DWLWriteReg(dec_dwl, /*coreID,*/ offset, value);
DWL_DEBUG("%s %d disabled by previous DWLWriteReg\n",
isPP ? "PP" : "DEC", coreID);
core.id = coreID;
core.regs = dwlShadowRegs[coreID];
core.regs += isPP ? 60 : 0;
core.size = isPP ? 41 * 4 : 60 * 4;
if (vdec_ioctl(ioctl_req, &core))
{
DWL_DEBUG("ioctl HX170DEC_IOCS_*_PUSH_REG failed\n");
configASSERT(0);
}
}
/*------------------------------------------------------------------------------
Function name : DWLWaitHwReady
Description : Wait until hardware has stopped running.
Used for synchronizing software runs with the hardware.
The wait could succed, timeout, or fail with an error.
Return type : i32 - one of the values DWL_HW_WAIT_OK
DWL_HW_WAIT_TIMEOUT
DWL_HW_WAIT_ERROR
Argument : const void * instance - DWL instance
------------------------------------------------------------------------------*/
i32 DWLWaitHwReady(const void *instance, /*i32 coreID,*/ u32 timeout)
{
const hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
struct core_desc core;
int isPP, ioctl_req;
i32 ret = DWL_HW_WAIT_OK;
i32 coreID = 0;
UNUSED(timeout);
#ifndef DWL_USE_DEC_IRQ
int max_wait_time = 10000; /* 10s in ms */
#endif
configASSERT(dec_dwl);
isPP = dec_dwl->clientType == DWL_CLIENT_TYPE_PP ? 1 : 0;
DWL_DEBUG("%s %d\n", isPP ? "PP" : "DEC", coreID);
core.id = coreID;
core.regs = dwlShadowRegs[coreID];
core.regs += isPP ? 60 : 0;
core.size = isPP ? 41 * 4 : 60 * 4;
#ifdef DWL_USE_DEC_IRQ
if(isPP)
{
ioctl_req = HX170DEC_IOCX_PP_WAIT;
if (vdec_ioctl(ioctl_req, &core))
{
DWL_DEBUG("ioctl HX170DEC_IOCG_*_WAIT failed\n");
ret = DWL_HW_WAIT_ERROR;
}
}
else
{
ioctl_req = HX170DEC_IOCX_DEC_WAIT;
if (vdec_ioctl(ioctl_req, &core))
{
DWL_DEBUG("ioctl HX170DEC_IOCG_*_WAIT failed\n");
ret = DWL_HW_WAIT_ERROR;
}
}
#else /* Polling */
ret = DWL_HW_WAIT_TIMEOUT;
ioctl_req = isPP ? HX170DEC_IOCS_PP_PULL_REG : HX170DEC_IOCS_DEC_PULL_REG;
do
{
u32 irq_stats;
const unsigned int usec = 1000; /* 1 ms polling interval */
if (vdec_ioctl(ioctl_req, &core))
{
DWL_DEBUG("ioctl HX170DEC_IOCS_*_PULL_REG failed\n");
ret = DWL_HW_WAIT_ERROR;
break;
}
irq_stats = isPP ? dwlShadowRegs[coreID][HX170_IRQ_STAT_PP] :
dwlShadowRegs[coreID][HX170_IRQ_STAT_DEC];
irq_stats = (irq_stats >> 11) & 0xFF;
if(irq_stats != 0)
{
ret = DWL_HW_WAIT_OK;
break;
}
usleep(usec);
max_wait_time--;
}
while (max_wait_time > 0);
#endif
#ifdef _DWL_DEBUG
{
u32 irq_stats = isPP ? dwlShadowRegs[coreID][HX170_IRQ_STAT_PP] :
dwlShadowRegs[coreID][HX170_IRQ_STAT_DEC];
PrintIrqType(isPP, coreID, irq_stats);
}
#endif
DWL_DEBUG("%s %d done\n", isPP ? "PP" : "DEC", coreID);
return ret;
}
/*------------------------------------------------------------------------------
Function name : DWLmalloc
Description : Allocate a memory block. Same functionality as
the ANSI C malloc()
Return type : void pointer to the allocated space, or NULL if there
is insufficient memory available
Argument : u32 n - Bytes to allocate
------------------------------------------------------------------------------*/
void *DWLmalloc(u32 n)
{
#ifdef MEMORY_USAGE_TRACE
printf("DWLmalloc\t%8d bytes\n", n);
#endif
return pvPortMalloc((size_t) n);
}
/*------------------------------------------------------------------------------
Function name : DWLfree
Description : Deallocates or frees a memory block. Same functionality as
the ANSI C free()
Return type : void
Argument : void *p - Previously allocated memory block to be freed
------------------------------------------------------------------------------*/
void DWLfree(void *p)
{
if(p != NULL)
vPortFree(p);
}
/*------------------------------------------------------------------------------
Function name : DWLcalloc
Description : Allocates an array in memory with elements initialized
to 0. Same functionality as the ANSI C calloc()
Return type : void pointer to the allocated space, or NULL if there
is insufficient memory available
}
Argument : u32 n - Number of elements
Argument : u32 s - Length in bytes of each element.
------------------------------------------------------------------------------*/
void *DWLcalloc(u32 n, u32 s)
{
#ifdef MEMORY_USAGE_TRACE
printf("DWLcalloc\t%8d bytes\n", n * s);
#endif
void *p = pvPortMalloc(n * s);
if (p) memset(p, 0, n * s);
return p;
}
/*------------------------------------------------------------------------------
Function name : DWLmemcpy
Description : Copies characters between buffers. Same functionality as
the ANSI C memcpy()
Return type : The value of destination d
Argument : void *d - Destination buffer
Argument : const void *s - Buffer to copy from
Argument : u32 n - Number of bytes to copy
------------------------------------------------------------------------------*/
void *DWLmemcpy(void *d, const void *s, u32 n)
{
return memcpy(d, s, (size_t) n);
}
/*------------------------------------------------------------------------------
Function name : DWLmemset
Description : Sets buffers to a specified character. Same functionality
as the ANSI C memset()
Return type : The value of destination d
Argument : void *d - Pointer to destination
Argument : i32 c - Character to set
Argument : u32 n - Number of characters
------------------------------------------------------------------------------*/
void *DWLmemset(void *d, i32 c, u32 n)
{
return memset(d, (int) c, (size_t) n);
}
/*------------------------------------------------------------------------------
Function name : DWLSoftResetAsic
Description : Soft reset hx170dec
Return type : none
------------------------------------------------------------------------------*/
void DWLSoftResetAsic(void)
{
sys_soft_reset(softreset_jpeg);
}

View File

@ -0,0 +1,257 @@
#include <string.h>
#include "FreeRTOS.h"
#include "basetype.h"
#include "dwl_freertos.h"
#include "dwl.h"
#include "hx170dec.h"
/*------------------------------------------------------------------------------
Function name : DWLInit
Description : Initialize a DWL instance
Return type : const void * - pointer to a DWL instance
Argument : void * param - not in use, application passes NULL
------------------------------------------------------------------------------*/
const void *DWLInit(DWLInitParam_t * param)
{
hX170dwl_t *dec_dwl;
dec_dwl = (hX170dwl_t *) pvPortMalloc(sizeof(hX170dwl_t));
memset(dec_dwl, 0, sizeof(hX170dwl_t));
DWL_DEBUG("INITIALIZE\n");
if(dec_dwl == NULL)
{
DWL_DEBUG("failed to alloc hX170dwl_t struct\n");
return NULL;
}
dec_dwl->clientType = param->clientType;
switch (dec_dwl->clientType)
{
case DWL_CLIENT_TYPE_H264_DEC:
case DWL_CLIENT_TYPE_MPEG4_DEC:
case DWL_CLIENT_TYPE_JPEG_DEC:
case DWL_CLIENT_TYPE_VC1_DEC:
case DWL_CLIENT_TYPE_MPEG2_DEC:
case DWL_CLIENT_TYPE_VP6_DEC:
case DWL_CLIENT_TYPE_VP8_DEC:
case DWL_CLIENT_TYPE_RV_DEC:
case DWL_CLIENT_TYPE_AVS_DEC:
case DWL_CLIENT_TYPE_PP:
{
break;
}
default:
{
DWL_DEBUG("Unknown client type no. %d\n", dec_dwl->clientType);
goto err;
}
}
if(vdec_ioctl(HX170DEC_IOC_MC_CORES, &dec_dwl->numCores) == -1)
{
DWL_DEBUG("ioctl HX170DEC_IOC_MC_CORES failed\n");
goto err;
}
if(vdec_ioctl(HX170DEC_IOCGHWIOSIZE, &dec_dwl->regSize) == -1)
{
DWL_DEBUG("ioctl HX170DEC_IOCGHWIOSIZE failed\n");
goto err;
}
DWL_DEBUG("SUCCESS\n");
return dec_dwl;
err:
DWL_DEBUG("FAILED\n");
DWLRelease(dec_dwl);
return NULL;
}
/*------------------------------------------------------------------------------
Function name : DWLRelease
Description : Release a DWl instance
Return type : i32 - 0 for success or a negative error code
Argument : const void * instance - instance to be released
------------------------------------------------------------------------------*/
i32 DWLRelease(const void *instance)
{
hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
configASSERT(dec_dwl != NULL);
vPortFree(dec_dwl);
DWL_DEBUG("SUCCESS\n");
return (DWL_OK);
}
/*******************************************************************************
Function name : DWLSetShareRamDecoder
Description : Set share ram for decode use
Return type : void
Argument : hx280ewl_t*
*******************************************************************************/
void DWLSetShareRamDecoder(hX170dwl_t * dwl)
{
}
/* HW locking */
/*------------------------------------------------------------------------------
Function name : DWLReserveHwPipe
Description :
Return type : i32
Argument : const void *instance
Argument : i32 *coreID - ID of the reserved HW core
------------------------------------------------------------------------------*/
i32 DWLReserveHwPipe(const void *instance/*, i32 *coreID*/)
{
i32 ret;
hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
i32 id = 0;
i32 *coreID = &id;
configASSERT(dec_dwl != NULL);
configASSERT(dec_dwl->clientType != DWL_CLIENT_TYPE_PP);
DWL_DEBUG("Start\n");
/* reserve decoder */
*coreID = vdec_ioctl(HX170DEC_IOCH_DEC_RESERVE, (void*)dec_dwl->clientType);
if (*coreID != 0)
{
return DWL_ERROR;
}
/* reserve PP */
ret = vdec_ioctl(HX170DEC_IOCQ_PP_RESERVE, NULL);
/* for pipeline we expect same core for both dec and PP */
if (ret != *coreID)
{
/* release the decoder */
vdec_ioctl( HX170DEC_IOCT_DEC_RELEASE, coreID);
return DWL_ERROR;
}
dec_dwl->bPPReserved = 1;
DWL_DEBUG("Reserved DEC+PP core %d\n", *coreID);
return DWL_OK;
}
/*------------------------------------------------------------------------------
Function name : DWLReserveHw
Description :
Return type : i32
Argument : const void *instance
Argument : i32 *coreID - ID of the reserved HW core
------------------------------------------------------------------------------*/
i32 DWLReserveHw(const void *instance/*, i32 *coreID*/)
{
hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
int isPP;
i32 id = 0;
i32 *coreID = &id;
configASSERT(dec_dwl != NULL);
isPP = dec_dwl->clientType == DWL_CLIENT_TYPE_PP ? 1 : 0;
DWL_DEBUG(" %s\n", isPP ? "PP" : "DEC");
if (isPP)
{
*coreID = vdec_ioctl(HX170DEC_IOCQ_PP_RESERVE, NULL);
/* PP is single core so we expect a zero return value */
if (*coreID != 0)
{
return DWL_ERROR;
}
}
else
{
*coreID = vdec_ioctl(HX170DEC_IOCH_DEC_RESERVE,
(void*)dec_dwl->clientType);
}
/* negative value signals an error */
if (*coreID < 0)
{
DWL_DEBUG("ioctl HX170DEC_IOCS_%s_RESERVE failed\n",
isPP ? "PP" : "DEC");
return DWL_ERROR;
}
#ifdef DEC_WITH_ENC
DWLSetShareRamDecoder(dec_dwl);
#endif
DWL_DEBUG("Reserved %s core %d\n", isPP ? "PP" : "DEC", *coreID);
return DWL_OK;
}
/*------------------------------------------------------------------------------
Function name : DWLReleaseHw
Description :
Return type : void
Argument : const void *instance
------------------------------------------------------------------------------*/
void DWLReleaseHw(const void *instance/*, i32 coreID*/)
{
hX170dwl_t *dec_dwl = (hX170dwl_t *) instance;
int isPP;
i32 coreID = 0;
configASSERT((u32)coreID < dec_dwl->numCores);
configASSERT(dec_dwl != NULL);
isPP = dec_dwl->clientType == DWL_CLIENT_TYPE_PP ? 1 : 0;
if ((u32) coreID >= dec_dwl->numCores)
return;
DWL_DEBUG(" %s core %d\n", isPP ? "PP" : "DEC", coreID);
if (isPP)
{
configASSERT(coreID == 0);
vdec_ioctl(HX170DEC_IOCT_PP_RELEASE, (void*)coreID);
}
else
{
if (dec_dwl->bPPReserved)
{
/* decoder has reserved PP also => release it */
DWL_DEBUG("DEC released PP core %d\n", coreID);
dec_dwl->bPPReserved = 0;
configASSERT(coreID == 0);
vdec_ioctl(HX170DEC_IOCT_PP_RELEASE, (void*)coreID);
}
vdec_ioctl(HX170DEC_IOCT_DEC_RELEASE, (void*)coreID);
}
}

View File

@ -0,0 +1,427 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : H264 decoder and PP pipeline support
--
------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264_pp_pipeline.c,v $
-- $Revision: 1.14 $
-- $Date: 2010/03/01 13:19:08 $
--
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264_pp_pipeline.h"
#include "h264_pp_multibuffer.h"
#include "h264hwd_container.h"
#include "h264hwd_debug.h"
#include "h264hwd_util.h"
#ifndef TRACE_PP_CTRL
#define TRACE_PP_CTRL(...) do{}while(0)
#else
#undef TRACE_PP_CTRL
#define TRACE_PP_CTRL(...) printf(__VA_ARGS__)
#endif
/*------------------------------------------------------------------------------
Function name : h264RegisterPP
Description :
Return type : i32
Argument : const void * decInst
Argument : const void *ppInst
Argument : (*PPRun)(const void *)
Argument : void (*PPEndCallback)(const void *)
------------------------------------------------------------------------------*/
i32 h264RegisterPP(const void *decInst, const void *ppInst,
void (*PPDecStart) (const void *, const DecPpInterface *),
void (*PPDecWaitEnd) (const void *),
void (*PPConfigQuery) (const void *, DecPpQuery *),
void (*PPDisplayIndex) (const void *, u32))
{
decContainer_t *pDecCont;
pDecCont = (decContainer_t *) decInst;
if(decInst == NULL || pDecCont->pp.ppInstance != NULL ||
ppInst == NULL || PPDecStart == NULL || PPDecWaitEnd == NULL
|| PPConfigQuery == NULL)
{
TRACE_PP_CTRL("h264RegisterPP: Invalid parameter\n");
return -1;
}
if(pDecCont->asicRunning)
{
TRACE_PP_CTRL("h264RegisterPP: Illegal action, asicRunning\n");
return -2;
}
pDecCont->pp.ppInstance = ppInst;
pDecCont->pp.PPConfigQuery = PPConfigQuery;
pDecCont->pp.PPDecStart = PPDecStart;
pDecCont->pp.PPDecWaitEnd = PPDecWaitEnd;
pDecCont->pp.PPNextDisplayId = PPDisplayIndex;
pDecCont->pp.decPpIf.ppStatus = DECPP_IDLE;
pDecCont->pp.ppInfo.multiBuffer = 0;
h264PpMultiInit(pDecCont, 0);
pDecCont->storage.ppUsed = 1;
TRACE_PP_CTRL("h264RegisterPP: Connected to PP instance 0x%08x\n",
(size_t) ppInst);
return 0;
}
/*------------------------------------------------------------------------------
Function name : h264UnregisterPP
Description :
Return type : i32
Argument : const void * decInst
Argument : const void *ppInst
------------------------------------------------------------------------------*/
i32 h264UnregisterPP(const void *decInst, const void *ppInst)
{
decContainer_t *pDecCont;
pDecCont = (decContainer_t *) decInst;
ASSERT(decInst != NULL && ppInst == pDecCont->pp.ppInstance);
if(ppInst != pDecCont->pp.ppInstance)
{
TRACE_PP_CTRL("h264UnregisterPP: Invalid parameter\n");
return -1;
}
if(pDecCont->asicRunning)
{
TRACE_PP_CTRL("h264UnregisterPP: Illegal action, asicRunning\n");
return -2;
}
pDecCont->pp.ppInstance = NULL;
pDecCont->pp.PPConfigQuery = NULL;
pDecCont->pp.PPDecStart = NULL;
pDecCont->pp.PPDecWaitEnd = NULL;
TRACE_PP_CTRL("h264UnregisterPP: Disconnected from PP instance 0x%08x\n",
(size_t) ppInst);
return 0;
}
/*------------------------------------------------------------------------------
Function name : h264PreparePpRun
Description :
Return type : void
Argument : decContainer_t * pDecCont
------------------------------------------------------------------------------*/
void h264PreparePpRun(decContainer_t * pDecCont)
{
const storage_t *pStorage = &pDecCont->storage;
DecPpInterface *decPpIf = &pDecCont->pp.decPpIf;
const dpbStorage_t *dpb = pStorage->dpb;
/* PP not connected or still running (not waited when first field of frame
* finished */
if(pDecCont->pp.ppInstance == NULL ||
decPpIf->ppStatus == DECPP_PIC_NOT_FINISHED)
{
return;
}
if(dpb->noReordering && !dpb->numOut)
{
TRACE_PP_CTRL
("h264PreparePpRun: No reordering and no output => PP no run\n");
/* decoder could create fake pictures in DPB, which will never go to output.
* this is the case when new access unit detetcted but no valid slice decoded.
*/
return;
}
if(pDecCont->pp.ppInfo.multiBuffer == 0) /* legacy single buffer mode */
{
/* in some situations, like field decoding,
* the dpb->numOut is not reset, but, dpb->numOut == dpb->outIndex */
if(dpb->numOut != 0) /* we have output */
{
TRACE_PP_CTRL
("h264PreparePpRun: output picture => PP could run!\n");
if(dpb->outBuf[dpb->outIndexR].data == pStorage->currImage->data)
{
/* we could have pipeline */
TRACE_PP_CTRL("h264PreparePpRun: decode == output\n");
if(pStorage->activeSps->frameMbsOnlyFlag == 0 &&
pStorage->secondField)
{
TRACE_PP_CTRL
("h264PreparePpRun: first field only! Do not run PP, yet!\n");
return;
}
if(pStorage->currImage->picStruct != FRAME)
{
u32 opposit_field = pStorage->currImage->picStruct ^ 1;
if(dpb->currentOut->status[opposit_field] != EMPTY)
{
decPpIf->usePipeline = 0;
TRACE_PP_CTRL
("h264PreparePpRun: second field of frame! Pipeline cannot be used!\n");
}
}
else if(!pStorage->activeSps->mbAdaptiveFrameFieldFlag)
{
decPpIf->usePipeline =
pDecCont->pp.ppInfo.pipelineAccepted & 1;
}
else
decPpIf->usePipeline = 0;
if(decPpIf->usePipeline)
{
TRACE_PP_CTRL
("h264PreparePpRun: pipeline=ON => PP will be running\n");
decPpIf->ppStatus = DECPP_RUNNING;
if(!pStorage->prevNalUnit->nalRefIdc)
{
pDecCont->asicBuff->disableOutWriting = 1;
TRACE_PP_CTRL
("h264PreparePpRun: Not reference => Disable decoder output writing\n");
}
}
else
{
TRACE_PP_CTRL
("h264PreparePpRun: pipeline=OFF => PP has to run after DEC\n");
}
}
else
{
decPpIf->ppStatus = DECPP_RUNNING;
decPpIf->usePipeline = 0;
TRACE_PP_CTRL
("h264PreparePpRun: decode != output => pipeline=OFF => PP run in parallel\n");
}
}
else
{
TRACE_PP_CTRL
("h264PreparePpRun: no output picture => PP no run!\n");
}
return;
}
/* multibuffer mode */
TRACE_PP_CTRL("h264PreparePpRun: MULTIBUFFER!\n");
if(pDecCont->pp.queuedPicToPp == NULL &&
pStorage->activeSps->frameMbsOnlyFlag == 0 && pStorage->secondField)
{
TRACE_PP_CTRL
("h264PreparePpRun: no queued picture and first field only! Do not run PP, yet!\n");
return;
}
if(pDecCont->pp.queuedPicToPp == NULL &&
pStorage->currentMarked == HANTRO_FALSE)
{
TRACE_PP_CTRL
("h264PreparePpRun: no queued picture and current pic NOT for display! Do not run PP!\n");
return;
}
if(pStorage->currImage->picStruct != FRAME)
{
TRACE_PP_CTRL("h264PreparePpRun: 2 Fields! Pipeline cannot be used!\n");
/* we shall not have EMPTY output marked for display, missing fields are acceptable */
ASSERT((pDecCont->pp.queuedPicToPp != NULL) ||
(dpb->currentOut->status[0] != EMPTY) ||
(dpb->currentOut->status[1] != EMPTY));
decPpIf->usePipeline = 0;
}
else if(!pStorage->activeSps->mbAdaptiveFrameFieldFlag)
{
decPpIf->usePipeline = pDecCont->pp.ppInfo.pipelineAccepted & 1;
}
else
decPpIf->usePipeline = 0;
if(decPpIf->usePipeline)
{
decPpIf->ppStatus = DECPP_RUNNING;
TRACE_PP_CTRL
("h264PreparePpRun: pipeline=ON => PP will be running\n");
}
else
{
if(pDecCont->pp.queuedPicToPp != NULL)
{
decPpIf->ppStatus = DECPP_RUNNING;
TRACE_PP_CTRL
("h264PreparePpRun: pipeline=OFF, queued picture => PP run in parallel\n");
}
else
{
TRACE_PP_CTRL
("h264PreparePpRun: pipeline=OFF, no queued picture => PP no run\n");
/* do not process pictures added to DPB but not intended for display */
if(dpb->noReordering ||
dpb->currentOut->toBeDisplayed == HANTRO_TRUE)
{
if(!pStorage->secondField) /* do not queue first field */
{
pDecCont->pp.queuedPicToPp = dpb->currentOut->data;
}
}
}
}
}
/*------------------------------------------------------------------------------
Function name : h264PpMultiAddPic
Description : Add a new picture to the PP processed table (frist free place).
Return the tabel position where added.
Return type : u32
Argument : decContainer_t * pDecCont
Argument : const DWLLinearMem_t * data
------------------------------------------------------------------------------*/
u32 h264PpMultiAddPic(decContainer_t * pDecCont, const DWLLinearMem_t * data)
{
u32 nextFreeId;
ASSERT(pDecCont->pp.ppInfo.multiBuffer != 0);
for(nextFreeId = 0; nextFreeId <= pDecCont->pp.multiMaxId; nextFreeId++)
{
if(pDecCont->pp.sentPicToPp[nextFreeId] == NULL)
{
break;
}
}
ASSERT(nextFreeId <= pDecCont->pp.multiMaxId);
if(nextFreeId <= pDecCont->pp.multiMaxId)
pDecCont->pp.sentPicToPp[nextFreeId] = data;
return nextFreeId;
}
/*------------------------------------------------------------------------------
Function name : h264PpMultiRemovePic
Description : Reomove a picture form the PP processed list.
Return the position which was emptied.
Return type : u32
Argument : decContainer_t * pDecCont
Argument : const DWLLinearMem_t * data
------------------------------------------------------------------------------*/
u32 h264PpMultiRemovePic(decContainer_t * pDecCont, const DWLLinearMem_t * data)
{
u32 picId;
ASSERT(pDecCont->pp.ppInfo.multiBuffer != 0);
for(picId = 0; picId <= pDecCont->pp.multiMaxId; picId++)
{
if(pDecCont->pp.sentPicToPp[picId] == data)
{
break;
}
}
ASSERT(picId <= pDecCont->pp.multiMaxId);
if(picId <= pDecCont->pp.multiMaxId)
pDecCont->pp.sentPicToPp[picId] = NULL;
return picId;
}
/*------------------------------------------------------------------------------
Function name : h264PpMultiFindPic
Description : Find a picture in the PP processed list. If found, return
the position. If not found, return an value bigger than
the max.
Return type : u32
Argument : decContainer_t * pDecCont
Argument : const DWLLinearMem_t * data
------------------------------------------------------------------------------*/
u32 h264PpMultiFindPic(decContainer_t * pDecCont, const DWLLinearMem_t * data)
{
u32 picId;
ASSERT(pDecCont->pp.ppInfo.multiBuffer != 0);
for(picId = 0; picId <= pDecCont->pp.multiMaxId; picId++)
{
if(pDecCont->pp.sentPicToPp[picId] == data)
{
break;
}
}
return picId;
}
/*------------------------------------------------------------------------------
Function name : h264PpMultiInit
Description : Initialize the PP processed list.
Return type : void
Argument : decContainer_t * pDecCont
Argument : u32 maxBuffId - max ID in use (buffs = (maxBuffId + 1))
------------------------------------------------------------------------------*/
void h264PpMultiInit(decContainer_t * pDecCont, u32 maxBuffId)
{
u32 i;
const u32 buffs =
sizeof(pDecCont->pp.sentPicToPp) / sizeof(*pDecCont->pp.sentPicToPp);
ASSERT(maxBuffId < buffs);
pDecCont->pp.queuedPicToPp = NULL;
pDecCont->pp.multiMaxId = maxBuffId;
for(i = 0; i < buffs; i++)
{
pDecCont->pp.sentPicToPp[i] = NULL;
}
}
u32 h264UseDisplaySmoothing(const void *decInst)
{
decContainer_t *pDecCont = (decContainer_t*)decInst;
if (pDecCont->storage.useSmoothing)
return HANTRO_TRUE;
else
return HANTRO_FALSE;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,81 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Application Programming Interface (API) extension
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264decapi_e.c,v $
-- $Date: 2009/06/05 10:57:15 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "basetype.h"
#include "h264hwd_container.h"
#include "h264decapi_e.h"
/*------------------------------------------------------------------------------
Function: H264DecNextChPicture
Functional description:
Input:
decInst decoder instance.
Output:
pOutput pointer to output structure
Returns:
H264DEC_OK no pictures available for display
H264DEC_PIC_RDY picture available for display
H264DEC_PARAM_ERROR invalid parameters
------------------------------------------------------------------------------*/
H264DecRet H264DecNextChPicture(H264DecInst decInst,
u32 **pOutput, u32 *busAddr)
{
decContainer_t *pDecCont = (decContainer_t *) decInst;
if(decInst == NULL || pOutput == NULL || busAddr == NULL)
{
return (H264DEC_PARAM_ERROR);
}
/* Check for valid decoder instance */
if(pDecCont->checksum != pDecCont)
{
return (H264DEC_NOT_INITIALIZED);
}
if (pDecCont->storage.enable2ndChroma && pDecCont->storage.pCh2)
{
*pOutput = pDecCont->storage.pCh2;
*busAddr = pDecCont->storage.bCh2;
return (H264DEC_PIC_RDY);
}
else
{
return (H264DEC_OK);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,297 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Extract a NAL unit from byte stream
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_byte_stream.c,v $
-- $Date: 2008/09/11 08:32:04 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "h264hwd_byte_stream.h"
#include "h264hwd_util.h"
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
#define BYTE_STREAM_ERROR 0xFFFFFFFF
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Function name: ExtractNalUnit
Functional description:
Extracts one NAL unit from the byte stream buffer. Removes
emulation prevention bytes if present. The original stream buffer
is used directly and is therefore modified if emulation prevention
bytes are present in the stream.
Stream buffer is assumed to contain either exactly one NAL unit
and nothing else, or one or more NAL units embedded in byte
stream format described in the Annex B of the standard. Function
detects which one is used based on the first bytes in the buffer.
Inputs:
pByteStream pointer to byte stream buffer
len length of the stream buffer (in bytes)
Outputs:
pStrmData stream information is stored here
readBytes number of bytes "consumed" from the stream buffer
Returns:
HANTRO_OK success
HANTRO_NOK error in byte stream
------------------------------------------------------------------------------*/
u32 h264bsdExtractNalUnit(const u8 * pByteStream, u32 len,
strmData_t * pStrmData, u32 * readBytes, u32 rlcMode)
{
/* Variables */
u32 byteCount, initByteCount;
u32 zeroCount;
u8 byte;
u32 invalidStream = HANTRO_FALSE;
u32 hasEmulation = HANTRO_FALSE;
const u8 *readPtr;
/* Code */
ASSERT(pByteStream);
ASSERT(len);
ASSERT(len < BYTE_STREAM_ERROR);
ASSERT(pStrmData);
/* byte stream format if starts with 0x000001 or 0x000000 */
if(len > 3 && pByteStream[0] == 0x00 && pByteStream[1] == 0x00 &&
(pByteStream[2] & 0xFE) == 0x00)
{
DEBUG_PRINT(("BYTE STREAM detected\n"));
/* search for NAL unit start point, i.e. point after first start code
* prefix in the stream */
zeroCount = byteCount = 2;
readPtr = pByteStream + 2;
/*lint -e(716) while(1) used consciously */
while(1)
{
byte = *readPtr++;
byteCount++;
if(byteCount == len)
{
/* no start code prefix found -> error */
*readBytes = len;
ERROR_PRINT("NO START CODE PREFIX");
return (HANTRO_NOK);
}
if(!byte)
zeroCount++;
else if((byte == 0x01) && (zeroCount >= 2))
break;
else
zeroCount = 0;
}
initByteCount = byteCount;
#if 1
if(!rlcMode)
{
pStrmData->pStrmBuffStart = pByteStream + initByteCount;
pStrmData->pStrmCurrPos = pStrmData->pStrmBuffStart;
pStrmData->bitPosInWord = 0;
pStrmData->strmBuffReadBits = 0;
pStrmData->strmBuffSize = len - initByteCount;
*readBytes = len;
return (HANTRO_OK);
}
#endif
/* determine size of the NAL unit. Search for next start code prefix
* or end of stream and ignore possible trailing zero bytes */
zeroCount = 0;
/*lint -e(716) while(1) used consciously */
while(1)
{
byte = *readPtr++;
byteCount++;
if(!byte)
zeroCount++;
else
{
if((byte == 0x03) && (zeroCount == 2))
{
hasEmulation = HANTRO_TRUE;
}
else if((byte == 0x01) && (zeroCount >= 2))
{
pStrmData->strmBuffSize =
byteCount - initByteCount - zeroCount - 1;
zeroCount -= MIN(zeroCount, 3);
break;
}
if(zeroCount >= 3)
invalidStream = HANTRO_TRUE;
zeroCount = 0;
}
if(byteCount == len)
{
pStrmData->strmBuffSize = byteCount - initByteCount - zeroCount;
break;
}
}
}
/* separate NAL units as input -> just set stream params */
else
{
DEBUG_PRINT(("SINGLE NAL unit detected\n"));
initByteCount = 0;
zeroCount = 0;
pStrmData->strmBuffSize = len;
hasEmulation = HANTRO_TRUE;
}
pStrmData->pStrmBuffStart = pByteStream + initByteCount;
pStrmData->pStrmCurrPos = pStrmData->pStrmBuffStart;
pStrmData->bitPosInWord = 0;
pStrmData->strmBuffReadBits = 0;
/* return number of bytes "consumed" */
*readBytes = pStrmData->strmBuffSize + initByteCount + zeroCount;
if(invalidStream)
{
ERROR_PRINT("INVALID STREAM");
return (HANTRO_NOK);
}
/* remove emulation prevention bytes before rbsp processing */
if(hasEmulation && pStrmData->removeEmul3Byte)
{
i32 i = pStrmData->strmBuffSize;
u8 *writePtr = (u8 *) pStrmData->pStrmBuffStart;
readPtr = pStrmData->pStrmBuffStart;
zeroCount = 0;
while(i--)
{
if((zeroCount == 2) && (*readPtr == 0x03))
{
/* emulation prevention byte shall be followed by one of the
* following bytes: 0x00, 0x01, 0x02, 0x03. This implies that
* emulation prevention 0x03 byte shall not be the last byte
* of the stream. */
if((i == 0) || (*(readPtr + 1) > 0x03))
return (HANTRO_NOK);
DEBUG_PRINT(("EMULATION PREVENTION 3 BYTE REMOVED\n"));
/* do not write emulation prevention byte */
readPtr++;
zeroCount = 0;
}
else
{
/* NAL unit shall not contain byte sequences 0x000000,
* 0x000001 or 0x000002 */
if((zeroCount == 2) && (*readPtr <= 0x02))
return (HANTRO_NOK);
if(*readPtr == 0)
zeroCount++;
else
zeroCount = 0;
*writePtr++ = *readPtr++;
}
}
/* (readPtr - writePtr) indicates number of "removed" emulation
* prevention bytes -> subtract from stream buffer size */
pStrmData->strmBuffSize -= (u32) (readPtr - writePtr);
}
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function name : h264bsdFindNextStartCode
Description :
Return type : const u8 *
Argument : const u8 * pByteStream
Argument : u32 len
------------------------------------------------------------------------------*/
const u8 *h264bsdFindNextStartCode(const u8 * pByteStream, u32 len)
{
u32 byteCount = 0;
u32 zeroCount = 0;
const u8 *start = NULL;
/* determine size of the NAL unit. Search for next start code prefix
* or end of stream */
/* start from second byte */
pByteStream++;
len--;
while(byteCount++ < len)
{
u32 byte = *pByteStream++;
if(byte == 0)
zeroCount++;
else
{
if((byte == 0x01) && (zeroCount >= 2))
{
start = pByteStream - MIN(zeroCount, 3) - 1;
break;
}
zeroCount = 0;
}
}
return start;
}

View File

@ -0,0 +1,186 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Description : CABAC initialization tables.
--
------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_cabac.c,v $
-- $Revision: 1.1 $
-- $Date: 2008/03/13 12:48:06 $
--
------------------------------------------------------------------------------*/
#include "basetype.h"
const u32 cabacInitValues[4*460*2/4] =
{
0x14f10236, 0x034a14f1, 0x0236034a, 0xe47fe968, 0xfa35ff36, 0x07330000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x0029003f, 0x003f003f, 0xf7530456, 0x0061f948, 0x0d29033e, 0x000b0137,
0x0045ef7f, 0xf3660052, 0xf94aeb6b, 0xe57fe17f, 0xe87fee5f, 0xe57feb72,
0xe27fef7b, 0xf473f07a, 0xf573f43f, 0xfe44f154, 0xf368fd46, 0xf85df65a,
0xe27fff4a, 0xfa61f95b, 0xec7ffc38, 0xfb52f94c, 0xea7df95d, 0xf557fd4d,
0xfb47fc3f, 0xfc44f454, 0xf93ef941, 0x083d0538, 0xfe420140, 0x003dfe4e,
0x01320734, 0x0a23002c, 0x0b26012d, 0x002e052c, 0x1f110133, 0x07321c13,
0x10210e3e, 0xf36cf164, 0xf365f35b, 0xf45ef658, 0xf054f656, 0xf953f357,
0xed5e0146, 0x0048fb4a, 0x123bf866, 0xf164005f, 0xfc4b0248, 0xf54bfd47,
0x0f2ef345, 0x003e0041, 0x1525f148, 0x09391036, 0x003e0c48, 0x18000f09,
0x08190d12, 0x0f090d13, 0x0a250c12, 0x061d1421, 0x0f1e042d, 0x013a003e,
0x073d0c26, 0x0b2d0f27, 0x0b2a0d2c, 0x102d0c29, 0x0a311e22, 0x122a0a37,
0x1133112e, 0x00591aed, 0x16ef1aef, 0x1ee71cec, 0x21e925e5, 0x21e928e4,
0x26ef21f5, 0x28f129fa, 0x26012911, 0x1efa1b03, 0x1a1625f0, 0x23fc26f8,
0x26fd2503, 0x26052a00, 0x23102716, 0x0e301b25, 0x153c0c44, 0x0261fd47,
0xfa2afb32, 0xfd36fe3e, 0x003a013f, 0xfe48ff4a, 0xf75bfb43, 0xfb1bfd27,
0xfe2c002e, 0xf040f844, 0xf64efa4d, 0xf656f45c, 0xf137f63c, 0xfa3efc41,
0xf449f84c, 0xf950f758, 0xef6ef561, 0xec54f54f, 0xfa49fc4a, 0xf356f360,
0xf561ed75, 0xf84efb21, 0xfc30fe35, 0xfd3ef347, 0xf64ff456, 0xf35af261,
0x0000fa5d, 0xfa54f84f, 0x0042ff47, 0x003efe3c, 0xfe3bfb4b, 0xfd3efc3a,
0xf742ff4f, 0x00470344, 0x0a2cf93e, 0x0f240e28, 0x101b0c1d, 0x012c1424,
0x1220052a, 0x01300a3e, 0x112e0940, 0xf468f561, 0xf060f958, 0xf855f955,
0xf755f358, 0x0442fd4d, 0xfd4cfa4c, 0x0a3aff4c, 0xff53f963, 0xf25f025f,
0x004cfb4a, 0x0046f54b, 0x01440041, 0xf249033e, 0x043eff44, 0xf34b0b37,
0x05400c46, 0x0f060613, 0x07100c0e, 0x120d0d0b, 0x0d0f0f10, 0x0c170d17,
0x0f140e1a, 0x0e2c1128, 0x112f1811, 0x15151916, 0x1f1b161d, 0x13230e32,
0x0a39073f, 0xfe4dfc52, 0xfd5e0945, 0xf46d24dd, 0x24de20e6, 0x25e22ce0,
0x22ee22f1, 0x28f121f9, 0x23fb2100, 0x2602210d, 0x17230d3a, 0x1dfd1a00,
0x161e1ff9, 0x23f122fd, 0x220324ff, 0x2205200b, 0x2305220c, 0x270b1e1d,
0x221a1d27, 0x13421f15, 0x1f1f1932, 0xef78ec70, 0xee72f555, 0xf15cf259,
0xe647f151, 0xf2500044, 0xf246e838, 0xe944e832, 0xf54a17f3, 0x1af328f1,
0x31f22c03, 0x2d062c22, 0x21361352, 0xfd4bff17, 0x0122012b, 0x0036fe37,
0x003d0140, 0x0044f75c, 0xf26af361, 0xf15af45a, 0xee58f649, 0xf74ff256,
0xf649f646, 0xf645fb42, 0xf740fb3a, 0x023b15f6, 0x18f51cf8, 0x1cff1d03,
0x1d092314, 0x1d240e43, 0x14f10236, 0x034a14f1, 0x0236034a, 0xe47fe968,
0xfa35ff36, 0x07331721, 0x17021500, 0x01090031, 0xdb760539, 0xf34ef541,
0x013e0c31, 0xfc491132, 0x1240092b, 0x1d001a43, 0x105a0968, 0xd27fec68,
0x0143f34e, 0xf541013e, 0xfa56ef5f, 0xfa3d092d, 0xfd45fa51, 0xf5600637,
0x0743fb56, 0x0258003a, 0xfd4cf65e, 0x05360445, 0xfd510058, 0xf943fb4a,
0xfc4afb50, 0xf948013a, 0x0029003f, 0x003f003f, 0xf7530456, 0x0061f948,
0x0d29033e, 0x002dfc4e, 0xfd60e57e, 0xe462e765, 0xe943e452, 0xec5ef053,
0xea6eeb5b, 0xee66f35d, 0xe37ff95c, 0xfb59f960, 0xf36cfd2e, 0xff41ff39,
0xf75dfd4a, 0xf75cf857, 0xe97e0536, 0x063c063b, 0x0645ff30, 0x0044fc45,
0xf858fe55, 0xfa4eff4b, 0xf94d0236, 0x0532fd44, 0x0132062a, 0xfc51013f,
0xfc460043, 0x0239fe4c, 0x0b230440, 0x013d0b23, 0x12190c18, 0x0d1d0d24,
0xf65df949, 0xfe490d2e, 0x0931f964, 0x09350235, 0x0535fe3d, 0x00380038,
0xf33ffb3c, 0xff3e0439, 0xfa450439, 0x0e270433, 0x0d440340, 0x013d093f,
0x07321027, 0x052c0434, 0x0b30fb3c, 0xff3b003b, 0x1621052c, 0x0e2bff4e,
0x003c0945, 0x0b1c0228, 0x032c0031, 0x002e022c, 0x0233002f, 0x0427023e,
0x062e0036, 0x0336023a, 0x043f0633, 0x06390735, 0x06340637, 0x0b2d0e24,
0x0835ff52, 0x0737fd4e, 0x0f2e161f, 0xff541907, 0x1ef91c03, 0x1c042000,
0x22ff1e06, 0x1e062009, 0x1f131a1b, 0x1a1e2514, 0x1c221146, 0x0143053b,
0x0943101e, 0x12201223, 0x161d181f, 0x1726122b, 0x14290b3f, 0x093b0940,
0xff5efe59, 0xf76cfa4c, 0xfe2c002d, 0x0034fd40, 0xfe3bfc46, 0xfc4bf852,
0xef66f74d, 0x0318002a, 0x00300037, 0xfa3bf947, 0xf453f557, 0xe277013a,
0xfd1dff24, 0x0126022b, 0xfa37003a, 0x0040fd4a, 0xf65a0046, 0xfc1d051f,
0x072a013b, 0xfe3afd48, 0xfd51f561, 0x003a0805, 0x0a0e0e12, 0x0d1b0228,
0x003afd46, 0xfa4ff855, 0x0000f36a, 0xf06af657, 0xeb72ee6e, 0xf262ea6e,
0xeb6aee67, 0xeb6be96c, 0xe670f660, 0xf45ffb5b, 0xf75dea5e, 0xfb560943,
0xfc50f655, 0xff46073c, 0x093a053d, 0x0c320f32, 0x12311136, 0x0a29072e,
0xff330731, 0x08340929, 0x062f0237, 0x0d290a2c, 0x06320535, 0x0d31043f,
0x0640fe45, 0xfe3b0646, 0x0a2c091f, 0x0c2b0335, 0x0e220a26, 0xfd340d28,
0x1120072c, 0x07260d32, 0x0a391a2b, 0x0e0b0b0e, 0x090b120b, 0x150917fe,
0x20f120f1, 0x22eb27e9, 0x2adf29e1, 0x2ee426f4, 0x151d2de8, 0x35d330e6,
0x41d52bed, 0x27f61e09, 0x121a141b, 0x0039f252, 0xfb4bed61, 0xdd7d1b00,
0x1c001ffc, 0x1b062208, 0x1e0a1816, 0x21131620, 0x1a1f1529, 0x1a2c172f,
0x10410e47, 0x083c063f, 0x11411518, 0x17141a17, 0x1b201c17, 0x1c181728,
0x18201c1d, 0x172a1339, 0x1635163d, 0x0b560c28, 0x0b330e3b, 0xfc4ff947,
0xfb45f746, 0xf842f644, 0xed49f445, 0xf046f143, 0xec3eed46, 0xf042ea41,
0xec3f09fe, 0x1af721f7, 0x27f929fe, 0x2d033109, 0x2d1b243b, 0xfa42f923,
0xf92af82d, 0xfb30f438, 0xfa3cfb3e, 0xf842f84c, 0xfb55fa51, 0xf64df951,
0xef50ee49, 0xfc4af653, 0xf747f743, 0xff3df842, 0xf242003b, 0x023b15f3,
0x21f227f9, 0x2efe3302, 0x3c063d11, 0x37222a3e, 0x14f10236, 0x034a14f1,
0x0236034a, 0xe47fe968, 0xfa35ff36, 0x07331619, 0x22001000, 0xfe090429,
0xe3760241, 0xfa47f34f, 0x05340932, 0xfd460a36, 0x1a221316, 0x28003902,
0x29241a45, 0xd37ff165, 0xfc4cfa47, 0xf34f0534, 0x0645f35a, 0x0034082b,
0xfe45fb52, 0xf660023b, 0x024bfd57, 0xfd640138, 0xfd4afa55, 0x003bfd51,
0xf956fb5f, 0xff42ff4d, 0x0146fe56, 0xfb48003d, 0x0029003f, 0x003f003f,
0xf7530456, 0x0061f948, 0x0d29033e, 0x0d0f0733, 0x0250d97f, 0xee5bef60,
0xe651dd62, 0xe866e961, 0xe577e863, 0xeb6eee66, 0xdc7f0050, 0xfb59f95e,
0xfc5c0027, 0x0041f154, 0xdd7ffe49, 0xf468f75b, 0xe17f0337, 0x07380737,
0x083dfd35, 0x0044f94a, 0xf758f367, 0xf35bf759, 0xf25cf84c, 0xf457e96e,
0xe869f64e, 0xec70ef63, 0xb27fba7f, 0xce7fd27f, 0xfc42fb4e, 0xfc47f848,
0x023bff37, 0xf946fa4b, 0xf859de77, 0xfd4b2014, 0x1e16d47f, 0x0036fb3d,
0x003aff3c, 0xfd3df843, 0xe754f24a, 0xfb410534, 0x0239003d, 0xf745f546,
0x1237fc47, 0x003a073d, 0x09291219, 0x0920052b, 0x092f002c, 0x0033022e,
0x1326fc42, 0x0f260c2a, 0x09220059, 0x042d0a1c, 0x0a1f21f5, 0x34d5120f,
0x1c0023ea, 0x26e72200, 0x27ee20f4, 0x66a20000, 0x38f121fc, 0x1d0a25fb,
0x33e327f7, 0x34de45c6, 0x43c12cfb, 0x200737e3, 0x20010000, 0x1b2421e7,
0x22e224e4, 0x26e426e5, 0x22ee23f0, 0x22f220f8, 0x25fa2300, 0x1e0a1c12,
0x1a191d29, 0x004b0248, 0x084d0e23, 0x121f1123, 0x151e112d, 0x142a122d,
0x1b1a1036, 0x07421038, 0x0b490a43, 0xf674e970, 0xf147f93d, 0x0035fb42,
0xf54df750, 0xf754f657, 0xde7feb65, 0xfd27fb35, 0xf93df54b, 0xf14def5b,
0xe76be76f, 0xe47af54c, 0xf62cf634, 0xf639f73a, 0xf048f945, 0xfc45fb4a,
0xf7560242, 0xf7220120, 0x0b1f0534, 0xfe37fe43, 0x0049f859, 0x03340704,
0x0a081108, 0x10130325, 0xff3dfb49, 0xff46fc4e, 0x0000eb7e, 0xe97cec6e,
0xe67ee77c, 0xef69e579, 0xe575ef66, 0xe675e574, 0xdf7af65f, 0xf264f85f,
0xef6fe472, 0xfa59fe50, 0xfc52f755, 0xf851ff48, 0x05400143, 0x09380045,
0x01450745, 0xf945fa43, 0xf04dfe40, 0x023dfa43, 0xfd400239, 0xfd41fd42,
0x003e0933, 0xff42fe47, 0xfe4bff46, 0xf7480e3c, 0x1025002f, 0x12230b25,
0x0c290a29, 0x02300c29, 0x0d29003b, 0x03321328, 0x03421232, 0x13fa12fa,
0x0e001af4, 0x1ff021e7, 0x21ea25e4, 0x27e22ae2, 0x2fd62ddc, 0x31de29ef,
0x200945b9, 0x3fc142c0, 0x4db636d9, 0x34dd29f6, 0x240028ff, 0x1e0e1c1a,
0x17250c37, 0x0b4125df, 0x27dc28db, 0x26e22edf, 0x2ae228e8, 0x31e326f4,
0x28f626fd, 0x2efb1f14, 0x1d1e192c, 0x0c300b31, 0x1a2d1616, 0x17161b15,
0x21141a1c, 0x1e181b22, 0x122a1927, 0x12320c46, 0x15360e47, 0x0b531920,
0x15311536, 0xfb55fa51, 0xf64df951, 0xef50ee49, 0xfc4af653, 0xf747f743,
0xff3df842, 0xf242003b, 0x023b11f6, 0x20f32af7, 0x31fb3500, 0x4003440a,
0x421b2f39, 0xfb470018, 0xff24fe2a, 0xfe34f739, 0xfa3ffc41, 0xfc43f952,
0xfd51fd4c, 0xf948fa4e, 0xf448f244, 0xfd46fa4c, 0xfb42fb3e, 0x0039fc3d,
0xf73c0136, 0x023a11f6, 0x20f32af7, 0x31fb3500, 0x4003440a, 0x421b2f39,
0x14f10236, 0x034a14f1, 0x0236034a, 0xe47fe968, 0xfa35ff36, 0x07331d10,
0x19000e00, 0xf633fd3e, 0xe5631a10, 0xfc55e866, 0x05390639, 0xef490e39,
0x1428140a, 0x1d003600, 0x252a0c61, 0xe07fea75, 0xfe4afc55, 0xe8660539,
0xfa5df258, 0xfa2c0437, 0xf559f167, 0xeb741339, 0x143a0454, 0x0660013f,
0xfb55f36a, 0x053f064b, 0xfd5aff65, 0x0337fc4f, 0xfe4bf461, 0xf932013c,
0x0029003f, 0x003f003f, 0xf7530456, 0x0061f948, 0x0d29033e, 0x0722f758,
0xec7fdc7f, 0xef5bf25f, 0xe754e756, 0xf459ef5b, 0xe17ff24c, 0xee67f35a,
0xdb7f0b50, 0x054c0254, 0x054efa37, 0x043df253, 0xdb7ffb4f, 0xf568f55b,
0xe27f0041, 0xfe4f0048, 0xfc5cfa38, 0x0344f847, 0xf362fc56, 0xf458fb52,
0xfd48fc43, 0xf848f059, 0xf745ff3b, 0x05420439, 0xfc47fe47, 0x023aff4a,
0xfc2cff45, 0x003ef933, 0xfc2ffa2a, 0xfd29fa35, 0x084cf74e, 0xf5530934,
0x0043fb5a, 0x0143f148, 0xfb4bf850, 0xeb53eb40, 0xf31fe740, 0xe35e094b,
0x113ff84a, 0xfb23fe1b, 0x0d5b0341, 0xf945084d, 0xf642033e, 0xfd44ec51,
0x001e0107, 0xfd17eb4a, 0x1042e97c, 0x11252cee, 0x32deea7f, 0x0427002a,
0x07220b1d, 0x081f0625, 0x072a0328, 0x08210d2b, 0x0d24042f, 0x0337023a,
0x063c082c, 0x0b2c0e2a, 0x07300438, 0x04340d25, 0x0931133a, 0x0a300c2d,
0x00451421, 0x083f23ee, 0x21e71cfd, 0x180a1b00, 0x22f234d4, 0x27e81311,
0x1f19241d, 0x1821220f, 0x1e141649, 0x1422131f, 0x1b2c1310, 0x0f240f24,
0x151c1915, 0x1e141f0c, 0x1b10182a, 0x005d0e38, 0x0f391a26, 0xe87fe873,
0xea52f73e, 0x0035003b, 0xf255f359, 0xf35ef55c, 0xe37feb64, 0xf239f443,
0xf547f64d, 0xeb55f058, 0xe968f162, 0xdb7ff652, 0xf830f83d, 0xf842f946,
0xf24bf64f, 0xf753f45c, 0xee6cfc4f, 0xea45f04b, 0xfe3a013a, 0xf34ef753,
0xfc51f363, 0xf351fa26, 0xf33efa3a, 0xfe3bf049, 0xf64cf356, 0xf753f657,
0x0000ea7f, 0xe77fe778, 0xe57fed72, 0xe975e776, 0xe675e871, 0xe476e178,
0xdb7cf65e, 0xf166f663, 0xf36ace7f, 0xfb5c1139, 0xfb56f35e, 0xf45bfe4d,
0x0047ff49, 0x0440f951, 0x05400f39, 0x01430044, 0xf6430144, 0x004d0240,
0x0044fb4e, 0x0737053b, 0x02410e36, 0x0f2c053c, 0x0246fe4c, 0xee560c46,
0x0540f446, 0x0b370538, 0x00450241, 0xfa4a0536, 0x0736fa4c, 0xf552fe4d,
0xfe4d192a, 0x11f310f7, 0x11f41beb, 0x25e229d8, 0x2ad730d1, 0x27e02ed8,
0x34cd2ed7, 0x34d92bed, 0x200b3dc9, 0x38d23ece, 0x51bd2dec, 0x23fe1c0f,
0x22012701, 0x1e111426, 0x122d0f36, 0x004f24f0, 0x25f225ef, 0x2001220f,
0x1d0f1819, 0x22161f10, 0x23121f1c, 0x2129241c, 0x1b2f153e, 0x121f131a,
0x24181817, 0x1b10181e, 0x1f1d1629, 0x162a103c, 0x0f340e3c, 0x034ef07b,
0x15351638, 0x193d1521, 0x1332113d, 0xfd4ef84a, 0xf748f648, 0xee4bf447,
0xf53ffb46, 0xef4bf248, 0xf043f835, 0xf23bf734, 0xf54409fe, 0x1ef61ffc,
0x21ff2107, 0x1f0c2517, 0x1f261440, 0xf747f925, 0xf82cf531, 0xf638f43b,
0xf83ff743, 0xfa44f64f, 0xfd4ef84a, 0xf748f648, 0xee4bf447, 0xf53ffb46,
0xef4bf248, 0xf043f835, 0xf23bf734, 0xf54409fe, 0x1ef61ffc, 0x21ff2107,
0x1f0c2517, 0x1f261440
};

View File

@ -0,0 +1,961 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Context Adaptive Variable Lengtch Code (CAVLC) decoding
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_cavlc.c,v $
-- $Date: 2008/07/08 11:23:19 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "h264hwd_cavlc.h"
#include "h264hwd_util.h"
#include "dwl.h"
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/* Following descriptions use term "information field" to represent combination
* of certain decoded symbol value and the length of the corresponding variable
* length code word. For example, total_zeros information field consists of
* 4 bits symbol value (bits [4,7]) along with four bits to represent length
* of the VLC code word (bits [0,3]) */
/* macro to obtain length of the coeff token information field, bits [0,4] */
#define LENGTH_TC(vlc) ((vlc) & 0x1F)
/* macro to obtain length of the other information fields, bits [0,3] */
#define LENGTH(vlc) ((vlc) & 0xF)
/* macro to obtain code word from the information fields, bits [4,7] */
#define INFO(vlc) (((vlc) >> 4) & 0xF) /* 4 MSB bits contain information */
/* macro to obtain trailing ones from the coeff token information word,
* bits [5,10] */
#define TRAILING_ONES(coeffToken) ((coeffToken>>5) & 0x3F)
/* macro to obtain total coeff from the coeff token information word,
* bits [11,15] */
#define TOTAL_COEFF(coeffToken) (((coeffToken) >> 11) & 0x1F)
#define VLC_NOT_FOUND 0xFFFFFFFEU
/* VLC tables for coeff_token. Because of long codes (max. 16 bits) some of the
* tables have been splitted into multiple separate tables. Each array/table
* element has the following structure:
* [5 bits for tot.coeff.] [6 bits for tr.ones] [5 bits for VLC length]
* If there is a 0x0000 value, it means that there is not corresponding VLC
* codeword for that index. */
/* VLC lengths up to 6 bits, 0 <= nC < 2 */
static const u16 coeffToken0_0[32] = {
0x0000, 0x0000, 0x0000, 0x2066, 0x1026, 0x0806, 0x1865, 0x1865,
0x1043, 0x1043, 0x1043, 0x1043, 0x1043, 0x1043, 0x1043, 0x1043,
0x0822, 0x0822, 0x0822, 0x0822, 0x0822, 0x0822, 0x0822, 0x0822,
0x0822, 0x0822, 0x0822, 0x0822, 0x0822, 0x0822, 0x0822, 0x0822
};
/* VLC lengths up to 10 bits, 0 <= nC < 2 */
static const u16 coeffToken0_1[48] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x406a, 0x304a, 0x282a, 0x200a,
0x3869, 0x3869, 0x2849, 0x2849, 0x2029, 0x2029, 0x1809, 0x1809,
0x3068, 0x3068, 0x3068, 0x3068, 0x2048, 0x2048, 0x2048, 0x2048,
0x1828, 0x1828, 0x1828, 0x1828, 0x1008, 0x1008, 0x1008, 0x1008,
0x2867, 0x2867, 0x2867, 0x2867, 0x2867, 0x2867, 0x2867, 0x2867,
0x1847, 0x1847, 0x1847, 0x1847, 0x1847, 0x1847, 0x1847, 0x1847
};
/* VLC lengths up to 14 bits, 0 <= nC < 2 */
static const u16 coeffToken0_2[56] = {
0x606e, 0x584e, 0x502e, 0x500e, 0x586e, 0x504e, 0x482e, 0x480e,
0x400d, 0x400d, 0x484d, 0x484d, 0x402d, 0x402d, 0x380d, 0x380d,
0x506d, 0x506d, 0x404d, 0x404d, 0x382d, 0x382d, 0x300d, 0x300d,
0x486b, 0x486b, 0x486b, 0x486b, 0x486b, 0x486b, 0x486b, 0x486b,
0x384b, 0x384b, 0x384b, 0x384b, 0x384b, 0x384b, 0x384b, 0x384b,
0x302b, 0x302b, 0x302b, 0x302b, 0x302b, 0x302b, 0x302b, 0x302b,
0x280b, 0x280b, 0x280b, 0x280b, 0x280b, 0x280b, 0x280b, 0x280b
};
/* VLC lengths up to 16 bits, 0 <= nC < 2 */
static const u16 coeffToken0_3[32] = {
0x0000, 0x0000, 0x682f, 0x682f, 0x8010, 0x8050, 0x8030, 0x7810,
0x8070, 0x7850, 0x7830, 0x7010, 0x7870, 0x7050, 0x7030, 0x6810,
0x706f, 0x706f, 0x684f, 0x684f, 0x602f, 0x602f, 0x600f, 0x600f,
0x686f, 0x686f, 0x604f, 0x604f, 0x582f, 0x582f, 0x580f, 0x580f
};
/* VLC lengths up to 6 bits, 2 <= nC < 4 */
static const u16 coeffToken2_0[32] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x3866, 0x2046, 0x2026, 0x1006,
0x3066, 0x1846, 0x1826, 0x0806, 0x2865, 0x2865, 0x1025, 0x1025,
0x2064, 0x2064, 0x2064, 0x2064, 0x1864, 0x1864, 0x1864, 0x1864,
0x1043, 0x1043, 0x1043, 0x1043, 0x1043, 0x1043, 0x1043, 0x1043
};
/* VLC lengths up to 9 bits, 2 <= nC < 4 */
static const u16 coeffToken2_1[32] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x4869, 0x3849, 0x3829, 0x3009,
0x2808, 0x2808, 0x3048, 0x3048, 0x3028, 0x3028, 0x2008, 0x2008,
0x4067, 0x4067, 0x4067, 0x4067, 0x2847, 0x2847, 0x2847, 0x2847,
0x2827, 0x2827, 0x2827, 0x2827, 0x1807, 0x1807, 0x1807, 0x1807
};
/* VLC lengths up to 14 bits, 2 <= nC < 4 */
static const u16 coeffToken2_2[128] = {
0x0000, 0x0000, 0x786d, 0x786d, 0x806e, 0x804e, 0x802e, 0x800e,
0x782e, 0x780e, 0x784e, 0x702e, 0x704d, 0x704d, 0x700d, 0x700d,
0x706d, 0x706d, 0x684d, 0x684d, 0x682d, 0x682d, 0x680d, 0x680d,
0x686d, 0x686d, 0x604d, 0x604d, 0x602d, 0x602d, 0x600d, 0x600d,
0x580c, 0x580c, 0x580c, 0x580c, 0x584c, 0x584c, 0x584c, 0x584c,
0x582c, 0x582c, 0x582c, 0x582c, 0x500c, 0x500c, 0x500c, 0x500c,
0x606c, 0x606c, 0x606c, 0x606c, 0x504c, 0x504c, 0x504c, 0x504c,
0x502c, 0x502c, 0x502c, 0x502c, 0x480c, 0x480c, 0x480c, 0x480c,
0x586b, 0x586b, 0x586b, 0x586b, 0x586b, 0x586b, 0x586b, 0x586b,
0x484b, 0x484b, 0x484b, 0x484b, 0x484b, 0x484b, 0x484b, 0x484b,
0x482b, 0x482b, 0x482b, 0x482b, 0x482b, 0x482b, 0x482b, 0x482b,
0x400b, 0x400b, 0x400b, 0x400b, 0x400b, 0x400b, 0x400b, 0x400b,
0x506b, 0x506b, 0x506b, 0x506b, 0x506b, 0x506b, 0x506b, 0x506b,
0x404b, 0x404b, 0x404b, 0x404b, 0x404b, 0x404b, 0x404b, 0x404b,
0x402b, 0x402b, 0x402b, 0x402b, 0x402b, 0x402b, 0x402b, 0x402b,
0x380b, 0x380b, 0x380b, 0x380b, 0x380b, 0x380b, 0x380b, 0x380b
};
/* VLC lengths up to 6 bits, 4 <= nC < 8 */
static const u16 coeffToken4_0[64] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x1806, 0x3846, 0x3826, 0x1006, 0x4866, 0x3046, 0x3026, 0x0806,
0x2825, 0x2825, 0x2845, 0x2845, 0x2025, 0x2025, 0x2045, 0x2045,
0x1825, 0x1825, 0x4065, 0x4065, 0x1845, 0x1845, 0x1025, 0x1025,
0x3864, 0x3864, 0x3864, 0x3864, 0x3064, 0x3064, 0x3064, 0x3064,
0x2864, 0x2864, 0x2864, 0x2864, 0x2064, 0x2064, 0x2064, 0x2064,
0x1864, 0x1864, 0x1864, 0x1864, 0x1044, 0x1044, 0x1044, 0x1044,
0x0824, 0x0824, 0x0824, 0x0824, 0x0004, 0x0004, 0x0004, 0x0004
};
/* VLC lengths up to 10 bits, 4 <= nC < 8 */
static const u16 coeffToken4_1[128] = {
0x0000, 0x800a, 0x806a, 0x804a, 0x802a, 0x780a, 0x786a, 0x784a,
0x782a, 0x700a, 0x706a, 0x704a, 0x702a, 0x680a, 0x6829, 0x6829,
0x6009, 0x6009, 0x6849, 0x6849, 0x6029, 0x6029, 0x5809, 0x5809,
0x6869, 0x6869, 0x6049, 0x6049, 0x5829, 0x5829, 0x5009, 0x5009,
0x6068, 0x6068, 0x6068, 0x6068, 0x5848, 0x5848, 0x5848, 0x5848,
0x5028, 0x5028, 0x5028, 0x5028, 0x4808, 0x4808, 0x4808, 0x4808,
0x5868, 0x5868, 0x5868, 0x5868, 0x5048, 0x5048, 0x5048, 0x5048,
0x4828, 0x4828, 0x4828, 0x4828, 0x4008, 0x4008, 0x4008, 0x4008,
0x3807, 0x3807, 0x3807, 0x3807, 0x3807, 0x3807, 0x3807, 0x3807,
0x3007, 0x3007, 0x3007, 0x3007, 0x3007, 0x3007, 0x3007, 0x3007,
0x4847, 0x4847, 0x4847, 0x4847, 0x4847, 0x4847, 0x4847, 0x4847,
0x2807, 0x2807, 0x2807, 0x2807, 0x2807, 0x2807, 0x2807, 0x2807,
0x5067, 0x5067, 0x5067, 0x5067, 0x5067, 0x5067, 0x5067, 0x5067,
0x4047, 0x4047, 0x4047, 0x4047, 0x4047, 0x4047, 0x4047, 0x4047,
0x4027, 0x4027, 0x4027, 0x4027, 0x4027, 0x4027, 0x4027, 0x4027,
0x2007, 0x2007, 0x2007, 0x2007, 0x2007, 0x2007, 0x2007, 0x2007
};
/* fixed 6 bit length VLC, nC <= 8 */
static const u16 coeffToken8[64] = {
0x0806, 0x0826, 0x0000, 0x0006, 0x1006, 0x1026, 0x1046, 0x0000,
0x1806, 0x1826, 0x1846, 0x1866, 0x2006, 0x2026, 0x2046, 0x2066,
0x2806, 0x2826, 0x2846, 0x2866, 0x3006, 0x3026, 0x3046, 0x3066,
0x3806, 0x3826, 0x3846, 0x3866, 0x4006, 0x4026, 0x4046, 0x4066,
0x4806, 0x4826, 0x4846, 0x4866, 0x5006, 0x5026, 0x5046, 0x5066,
0x5806, 0x5826, 0x5846, 0x5866, 0x6006, 0x6026, 0x6046, 0x6066,
0x6806, 0x6826, 0x6846, 0x6866, 0x7006, 0x7026, 0x7046, 0x7066,
0x7806, 0x7826, 0x7846, 0x7866, 0x8006, 0x8026, 0x8046, 0x8066
};
/* VLC lengths up to 3 bits, nC == -1 */
static const u16 coeffTokenMinus1_0[8] = {
0x0000, 0x1043, 0x0002, 0x0002, 0x0821, 0x0821, 0x0821, 0x0821
};
/* VLC lengths up to 8 bits, nC == -1 */
static const u16 coeffTokenMinus1_1[32] = {
0x2067, 0x2067, 0x2048, 0x2028, 0x1847, 0x1847, 0x1827, 0x1827,
0x2006, 0x2006, 0x2006, 0x2006, 0x1806, 0x1806, 0x1806, 0x1806,
0x1006, 0x1006, 0x1006, 0x1006, 0x1866, 0x1866, 0x1866, 0x1866,
0x1026, 0x1026, 0x1026, 0x1026, 0x0806, 0x0806, 0x0806, 0x0806
};
/* VLC tables for total_zeros. One table containing longer code, totalZeros_1,
* has been broken into two separate tables. Table elements have the
* following structure:
* [4 bits for info] [4 bits for VLC length] */
/* VLC lengths up to 5 bits */
static const u8 totalZeros_1_0[32] = {
0x00, 0x00, 0x65, 0x55, 0x44, 0x44, 0x34, 0x34,
0x23, 0x23, 0x23, 0x23, 0x13, 0x13, 0x13, 0x13,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
};
/* VLC lengths up to 9 bits */
static const u8 totalZeros_1_1[32] = {
0x00, 0xf9, 0xe9, 0xd9, 0xc8, 0xc8, 0xb8, 0xb8,
0xa7, 0xa7, 0xa7, 0xa7, 0x97, 0x97, 0x97, 0x97,
0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86,
0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76
};
static const u8 totalZeros_2[64] = {
0xe6, 0xd6, 0xc6, 0xb6, 0xa5, 0xa5, 0x95, 0x95,
0x84, 0x84, 0x84, 0x84, 0x74, 0x74, 0x74, 0x74,
0x64, 0x64, 0x64, 0x64, 0x54, 0x54, 0x54, 0x54,
0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43,
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23,
0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03
};
static const u8 totalZeros_3[64] = {
0xd6, 0xb6, 0xc5, 0xc5, 0xa5, 0xa5, 0x95, 0x95,
0x84, 0x84, 0x84, 0x84, 0x54, 0x54, 0x54, 0x54,
0x44, 0x44, 0x44, 0x44, 0x04, 0x04, 0x04, 0x04,
0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23,
0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13
};
static const u8 totalZeros_4[32] = {
0xc5, 0xb5, 0xa5, 0x05, 0x94, 0x94, 0x74, 0x74,
0x34, 0x34, 0x24, 0x24, 0x83, 0x83, 0x83, 0x83,
0x63, 0x63, 0x63, 0x63, 0x53, 0x53, 0x53, 0x53,
0x43, 0x43, 0x43, 0x43, 0x13, 0x13, 0x13, 0x13
};
static const u8 totalZeros_5[32] = {
0xb5, 0x95, 0xa4, 0xa4, 0x84, 0x84, 0x24, 0x24,
0x14, 0x14, 0x04, 0x04, 0x73, 0x73, 0x73, 0x73,
0x63, 0x63, 0x63, 0x63, 0x53, 0x53, 0x53, 0x53,
0x43, 0x43, 0x43, 0x43, 0x33, 0x33, 0x33, 0x33
};
static const u8 totalZeros_6[64] = {
0xa6, 0x06, 0x15, 0x15, 0x84, 0x84, 0x84, 0x84,
0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93,
0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53,
0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43,
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23
};
static const u8 totalZeros_7[64] = {
0x96, 0x06, 0x15, 0x15, 0x74, 0x74, 0x74, 0x74,
0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43,
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23,
0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52,
0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52
};
static const u8 totalZeros_8[64] = {
0x86, 0x06, 0x25, 0x25, 0x14, 0x14, 0x14, 0x14,
0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52,
0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42
};
static const u8 totalZeros_9[64] = {
0x16, 0x06, 0x75, 0x75, 0x24, 0x24, 0x24, 0x24,
0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53,
0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62,
0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32
};
static const u8 totalZeros_10[32] = {
0x15, 0x05, 0x64, 0x64, 0x23, 0x23, 0x23, 0x23,
0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32
};
static const u8 totalZeros_11[16] = {
0x04, 0x14, 0x23, 0x23, 0x33, 0x33, 0x53, 0x53,
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41
};
static const u8 totalZeros_12[16] = {
0x04, 0x14, 0x43, 0x43, 0x22, 0x22, 0x22, 0x22,
0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31
};
static const u8 totalZeros_13[8] =
{ 0x03, 0x13, 0x32, 0x32, 0x21, 0x21, 0x21, 0x21 };
static const u8 totalZeros_14[4] = { 0x02, 0x12, 0x21, 0x21 };
/* VLC tables for run_before. Table elements have the following structure:
* [4 bits for info] [4bits for VLC length]
*/
static const u8 runBefore_6[8] =
{ 0x13, 0x23, 0x43, 0x33, 0x63, 0x53, 0x02, 0x02 };
static const u8 runBefore_5[8] =
{ 0x53, 0x43, 0x33, 0x23, 0x12, 0x12, 0x02, 0x02 };
static const u8 runBefore_4[8] =
{ 0x43, 0x33, 0x22, 0x22, 0x12, 0x12, 0x02, 0x02 };
static const u8 runBefore_3[4] = { 0x32, 0x22, 0x12, 0x02 };
static const u8 runBefore_2[4] = { 0x22, 0x12, 0x01, 0x01 };
static const u8 runBefore_1[2] = { 0x11, 0x01 };
/* following four macros are used to handle stream buffer "cache" in the CAVLC
* decoding function */
/* macro to initialize stream buffer cache, fills the buffer (32 bits) */
#define BUFFER_INIT(value, bits) \
{ \
bits = 32; \
value = h264bsdShowBits(pStrmData,32); \
}
/* macro to read numBits bits from the buffer, bits will be written to
* outVal. Refills the buffer if not enough bits left */
#define BUFFER_SHOW(value, bits, outVal, numBits) \
{ \
if (bits < (numBits)) \
{ \
if(h264bsdFlushBits(pStrmData,32-bits) == END_OF_STREAM) \
return(~0); \
value = h264bsdShowBits(pStrmData,32); \
bits = 32; \
} \
(outVal) = value >> (32 - (numBits)); \
}
/* macro to flush numBits bits from the buffer */
#define BUFFER_FLUSH(value, bits, numBits) \
{ \
value <<= (numBits); \
bits -= (numBits); \
}
/* macro to read and flush numBits bits from the buffer, bits will be written
* to outVal. Refills the buffer if not enough bits left */
#define BUFFER_GET(value, bits, outVal, numBits) \
{ \
if (bits < (numBits)) \
{ \
if(h264bsdFlushBits(pStrmData,32-bits) == END_OF_STREAM) \
return(~0); \
value = h264bsdShowBits(pStrmData,32); \
bits = 32; \
} \
(outVal) = value >> (32 - (numBits)); \
value <<= (numBits); \
bits -= (numBits); \
}
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
static u32 DecodeCoeffToken(u32 bits, u32 nc);
static u32 DecodeLevelPrefix(u32 bits);
static u32 DecodeTotalZeros(u32 bits, u32 totalCoeff, u32 isChromaDC);
static u32 DecodeRunBefore(u32 bits, u32 zerosLeft);
/*------------------------------------------------------------------------------
Function: DecodeCoeffToken
Functional description:
Function to decode coeff_token information field from the stream.
Inputs:
u32 bits next 16 stream bits
u32 nc nC, see standard for details
Outputs:
u32 information field (11 bits for value, 5 bits for length)
------------------------------------------------------------------------------*/
u32 DecodeCoeffToken(u32 bits, u32 nc)
{
/* Variables */
u32 value;
/* Code */
/* standard defines that nc for decoding of chroma dc coefficients is -1,
* represented by u32 here -> -1 maps to 2^32 - 1 */
ASSERT(nc <= 16 || nc == (u32) (-1));
if(nc < 2)
{
if(bits >= 0x8000)
{
value = 0x0001;
}
else if(bits >= 0x0C00)
value = coeffToken0_0[bits >> 10];
else if(bits >= 0x0100)
value = coeffToken0_1[bits >> 6];
else if(bits >= 0x0020)
value = coeffToken0_2[(bits >> 2) - 8];
else
value = coeffToken0_3[bits];
}
else if(nc < 4)
{
if(bits >= 0x8000)
{
value = bits & 0x4000 ? 0x0002 : 0x0822;
}
else if(bits >= 0x1000)
value = coeffToken2_0[bits >> 10];
else if(bits >= 0x0200)
value = coeffToken2_1[bits >> 7];
else
value = coeffToken2_2[bits >> 2];
}
else if(nc < 8)
{
value = coeffToken4_0[bits >> 10];
if(!value)
value = coeffToken4_1[bits >> 6];
}
else if(nc <= 16)
{
value = coeffToken8[bits >> 10];
}
else
{
value = coeffTokenMinus1_0[bits >> 13];
if(!value)
value = coeffTokenMinus1_1[bits >> 8];
}
return (value);
}
/*------------------------------------------------------------------------------
Function: DecodeLevelPrefix
Functional description:
Function to decode level_prefix information field from the stream
Inputs:
u32 bits next 16 stream bits
Outputs:
u32 level_prefix information field or VLC_NOT_FOUND
------------------------------------------------------------------------------*/
u32 DecodeLevelPrefix(u32 bits)
{
/* Variables */
u32 numZeros;
/* Code */
if(bits >= 0x8000)
numZeros = 0;
else if(bits >= 0x4000)
numZeros = 1;
else if(bits >= 0x2000)
numZeros = 2;
else if(bits >= 0x1000)
numZeros = 3;
else if(bits >= 0x0800)
numZeros = 4;
else if(bits >= 0x0400)
numZeros = 5;
else if(bits >= 0x0200)
numZeros = 6;
else if(bits >= 0x0100)
numZeros = 7;
else if(bits >= 0x0080)
numZeros = 8;
else if(bits >= 0x0040)
numZeros = 9;
else if(bits >= 0x0020)
numZeros = 10;
else if(bits >= 0x0010)
numZeros = 11;
else if(bits >= 0x0008)
numZeros = 12;
else if(bits >= 0x0004)
numZeros = 13;
else if(bits >= 0x0002)
numZeros = 14;
else if(bits >= 0x0001)
numZeros = 15;
else /* more than 15 zeros encountered which is an error */
return (VLC_NOT_FOUND);
return (numZeros);
}
/*------------------------------------------------------------------------------
Function: DecodeTotalZeros
Functional description:
Function to decode total_zeros information field from the stream
Inputs:
u32 bits next 9 stream bits
u32 totalCoeff total number of coefficients for the block
being decoded
u32 isChromaDC flag to indicate chroma DC block
Outputs:
u32 information field (4 bits value, 4 bits length)
------------------------------------------------------------------------------*/
u32 DecodeTotalZeros(u32 bits, u32 totalCoeff, u32 isChromaDC)
{
/* Variables */
u32 value = 0x0;
/* Code */
ASSERT(totalCoeff);
if(!isChromaDC)
{
ASSERT(totalCoeff < 16);
switch (totalCoeff)
{
case 1:
value = totalZeros_1_0[bits >> 4];
if(!value)
value = totalZeros_1_1[bits];
break;
case 2:
value = totalZeros_2[bits >> 3];
break;
case 3:
value = totalZeros_3[bits >> 3];
break;
case 4:
value = totalZeros_4[bits >> 4];
break;
case 5:
value = totalZeros_5[bits >> 4];
break;
case 6:
value = totalZeros_6[bits >> 3];
break;
case 7:
value = totalZeros_7[bits >> 3];
break;
case 8:
value = totalZeros_8[bits >> 3];
break;
case 9:
value = totalZeros_9[bits >> 3];
break;
case 10:
value = totalZeros_10[bits >> 4];
break;
case 11:
value = totalZeros_11[bits >> 5];
break;
case 12:
value = totalZeros_12[bits >> 5];
break;
case 13:
value = totalZeros_13[bits >> 6];
break;
case 14:
value = totalZeros_14[bits >> 7];
break;
default: /* case 15 */
value = (bits >> 8) ? 0x11 : 0x01;
break;
}
}
else
{
ASSERT(totalCoeff < 4);
bits >>= 6;
if(bits > 3)
value = 0x01;
else
{
if(totalCoeff == 3)
value = 0x11;
else if(bits > 1)
{
value = 0x12;
}
else if(totalCoeff == 2)
value = 0x22;
else if(bits)
value = 0x23;
else
value = 0x33;
}
}
return (value);
}
/*------------------------------------------------------------------------------
Function: DecodeRunBefore
Functional description:
Function to decode run_before information field from the stream
Inputs:
u32 bits next 11 stream bits
u32 zerosLeft number of zeros left for the current block
Outputs:
u32 information field (4 bits value, 4 bits length)
------------------------------------------------------------------------------*/
u32 DecodeRunBefore(u32 bits, u32 zerosLeft)
{
/* Variables */
u32 value = 0x0;
/* Code */
switch (zerosLeft)
{
case 1:
value = runBefore_1[bits >> 10];
break;
case 2:
value = runBefore_2[bits >> 9];
break;
case 3:
value = runBefore_3[bits >> 9];
break;
case 4:
value = runBefore_4[bits >> 8];
break;
case 5:
value = runBefore_5[bits >> 8];
break;
case 6:
value = runBefore_6[bits >> 8];
break;
default:
if(bits >= 0x100)
value = ((7 - (bits >> 8)) << 4) + 0x3;
else if(bits >= 0x80)
value = 0x74;
else if(bits >= 0x40)
value = 0x85;
else if(bits >= 0x20)
value = 0x96;
else if(bits >= 0x10)
value = 0xa7;
else if(bits >= 0x8)
value = 0xb8;
else if(bits >= 0x4)
value = 0xc9;
else if(bits >= 0x2)
value = 0xdA;
else if(bits)
value = 0xeB;
if(INFO(value) > zerosLeft)
value = 0;
break;
}
return (value);
}
/*------------------------------------------------------------------------------
Function: DecodeResidualBlockCavlc
Functional description:
Function to decode one CAVLC coded block. This corresponds to
syntax elements residual_block_cavlc() in the standard.
Inputs:
pStrmData pointer to stream data structure
nc nC value
maxNumCoeff maximum number of residual coefficients
Outputs:
coeffLevel stores decoded coefficient levels
Returns:
totalCoeff numebr of coeffs decoded
(~0) end of stream or error in stream
------------------------------------------------------------------------------*/
u32 h264bsdDecodeResidualBlockCavlc(strmData_t * pStrmData,
u16 * coeffLevel, i32 nc, u32 maxNumCoeff)
{
/* Variables */
u32 i, tmp, totalCoeff, trailingOnes, suffixLength, levelPrefix;
u32 levelSuffix, zerosLeft, bit;
i32 level[16];
u32 run[16];
/* stream "cache" */
u32 bufferValue;
u32 bufferBits;
/* Code */
ASSERT(pStrmData);
ASSERT(coeffLevel);
ASSERT(nc > -2);
ASSERT(maxNumCoeff == 4 || maxNumCoeff == 15 || maxNumCoeff == 16);
ASSERT(VLC_NOT_FOUND != END_OF_STREAM);
/* assume that coeffLevel array has been "cleaned" by caller */
BUFFER_INIT(bufferValue, bufferBits);
/*lint -e774 disable lint warning on always false comparison */
BUFFER_SHOW(bufferValue, bufferBits, bit, 16);
/*lint +e774 */
tmp = DecodeCoeffToken(bit, (u32) nc);
if(!tmp)
return (~0);
BUFFER_FLUSH(bufferValue, bufferBits, LENGTH_TC(tmp));
totalCoeff = TOTAL_COEFF(tmp);
if(totalCoeff > maxNumCoeff)
return (~0);
trailingOnes = TRAILING_ONES(tmp);
if(totalCoeff != 0)
{
i = 0;
/* nonzero coefficients: +/- 1 */
if(trailingOnes)
{
BUFFER_GET(bufferValue, bufferBits, bit, trailingOnes);
tmp = 1 << (trailingOnes - 1);
for(; tmp; i++)
{
level[i] = bit & tmp ? -1 : 1;
tmp >>= 1;
}
}
/* other levels */
if(totalCoeff > 10 && trailingOnes < 3)
suffixLength = 1;
else
suffixLength = 0;
for(; i < totalCoeff; i++)
{
BUFFER_SHOW(bufferValue, bufferBits, bit, 16);
levelPrefix = DecodeLevelPrefix(bit);
if(levelPrefix == VLC_NOT_FOUND)
return (~0);
BUFFER_FLUSH(bufferValue, bufferBits, levelPrefix + 1);
if(levelPrefix < 14)
tmp = suffixLength;
else if(levelPrefix == 14)
{
tmp = suffixLength ? suffixLength : 4;
}
else
{
/* setting suffixLength to 1 here corresponds to adding 15
* to levelCode value if levelPrefix == 15 and
* suffixLength == 0 */
if(!suffixLength)
suffixLength = 1;
tmp = 12;
}
if(suffixLength)
levelPrefix <<= suffixLength;
if(tmp)
{
BUFFER_GET(bufferValue, bufferBits, levelSuffix, tmp);
levelPrefix += levelSuffix;
}
tmp = levelPrefix;
if(i == trailingOnes && trailingOnes < 3)
tmp += 2;
level[i] = (tmp + 2) >> 1;
if(suffixLength == 0)
suffixLength = 1;
if((level[i] > (3 << (suffixLength - 1))) && suffixLength < 6)
suffixLength++;
if(tmp & 0x1)
level[i] = -level[i];
}
/* zero runs */
if(totalCoeff < maxNumCoeff)
{
BUFFER_SHOW(bufferValue, bufferBits, bit, 9);
zerosLeft = DecodeTotalZeros(bit, totalCoeff,
(u32) (maxNumCoeff == 4));
if(!zerosLeft)
return (~0);
BUFFER_FLUSH(bufferValue, bufferBits, LENGTH(zerosLeft));
zerosLeft = INFO(zerosLeft);
}
else
zerosLeft = 0;
if((zerosLeft + totalCoeff) > maxNumCoeff)
{
return (~0);
}
for(i = 0; i < totalCoeff - 1; i++)
{
if(zerosLeft > 0)
{
BUFFER_SHOW(bufferValue, bufferBits, bit, 11);
tmp = DecodeRunBefore(bit, zerosLeft);
if(!tmp)
return (~0);
BUFFER_FLUSH(bufferValue, bufferBits, LENGTH(tmp));
run[i] = INFO(tmp);
zerosLeft -= run[i];
}
else
{
run[i] = 0;
}
}
run[i] = zerosLeft; /* last run */
/*lint -esym(771,level,run) level and run are always initialized */
{
u16 *pTmp = coeffLevel + 2;
u16 bigLevelMask = 0;
for(i = totalCoeff; i--;)
{
bigLevelMask <<= 1;
if(level[i] < 0)
bigLevelMask |= 1;
tmp = (run[i] << 12) | (level[i] & 0x0FFF);
*pTmp++ = (u16) tmp;
}
tmp = totalCoeff << 11;
if(bigLevelMask)
{
tmp |= 1;
bigLevelMask <<= (16 - totalCoeff);
}
*coeffLevel++ = (u16) tmp;
*coeffLevel = bigLevelMask;
}
}
else
{
*coeffLevel = 0; /* no coeffs for this subBlock */
}
if(h264bsdFlushBits(pStrmData, 32 - bufferBits) != HANTRO_OK)
return (~0);
return totalCoeff;
}

View File

@ -0,0 +1,156 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Error concealment
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_conceal.c,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#include "h264hwd_container.h"
#include "h264hwd_conceal.h"
#include "h264hwd_util.h"
#include "h264hwd_dpb.h"
/*------------------------------------------------------------------------------
Function name : h264bsdConceal
Description : Performe error concelament for an erroneous picture
Return type : void
Argument : storage_t *pStorage
Argument : DecAsicBuffers_t * pAsicBuff
Argument : u32 sliceType
------------------------------------------------------------------------------*/
void h264bsdConceal(storage_t * pStorage, DecAsicBuffers_t * pAsicBuff,
u32 sliceType)
{
u32 i, tmp;
i32 refID;
u32 *pAsicCtrl = pAsicBuff->mbCtrl.virtualAddress;
mbStorage_t *pMb = pStorage->mb;
ASSERT(pStorage);
ASSERT(pAsicBuff);
DEBUG_PRINT(("h264bsdConceal: Concealing %s slice\n",
IS_I_SLICE(sliceType) ? "intra" : "inter"));
refID = -1;
/* use reference picture with smallest available index */
if(IS_P_SLICE(sliceType))
{
i = 0;
do
{
refID = h264bsdGetRefPicData(pStorage->dpb, i);
i++;
}
while(i < 16 && refID == -1);
}
i = 0;
/* find first properly decoded macroblock -> start point for concealment */
while(i < pStorage->picSizeInMbs && !pMb[i].decoded)
{
i++;
}
/* whole picture lost -> copy previous or set grey */
if(i == pStorage->picSizeInMbs)
{
DEBUG_PRINT(("h264bsdConceal: whole picture lost\n"));
if(IS_I_SLICE(sliceType) || refID == -1)
{
/* QP = 40 and all residual blocks empty */
/* DC predi. & chroma DC pred. --> grey */
tmp = ((u32) HW_I_16x16 << 29) | (2U << 27) | (40U << 15) | 0x7F;
for(i = pStorage->picSizeInMbs; i > 0; i--)
{
*pAsicCtrl++ = tmp;
*pAsicCtrl++ = 0;
}
pMb->mbType_asic = I_16x16_2_0_0;
}
else
{
/* QP = 40 and all residual blocks empty */
tmp = ((u32) HW_P_SKIP << 29) | (40U << 15) | 0x7F;
for(i = pStorage->picSizeInMbs; i > 0; i--)
{
*pAsicCtrl++ = tmp;
*pAsicCtrl++ = 0;
}
/* inter prediction using zero mv and the newest reference */
pMb->mbType_asic = P_Skip;
pMb->refID[0] = refID;
}
pStorage->numConcealedMbs = pStorage->picSizeInMbs;
return;
}
for(i = 0; i < pStorage->picSizeInMbs; i++, pMb++)
{
/* if mb was not correctly decoded, set parameters for concealment */
if(!pMb->decoded)
{
DEBUG_PRINT(("h264bsdConceal: Concealing mb #%u\n", i));
pStorage->numConcealedMbs++;
/* intra pred. if it is an intra mb or if the newest reference image
* is not available */
if(IS_I_SLICE(sliceType) || refID == -1)
{
/* QP = 40 and all residual blocks empty */
/* DC predi. & chroma DC pred. --> grey */
tmp =
((u32) HW_I_16x16 << 29) | (2U << 27) | (40U << 15) | 0x7F;
*pAsicCtrl++ = tmp;
*pAsicCtrl++ = 0;
pMb->mbType_asic = I_16x16_2_0_0;
}
else
{
DEBUG_PRINT(("h264bsdConceal: NOT I slice conceal \n"));
/* QP = 40 and all residual blocks empty */
tmp = ((u32) HW_P_SKIP << 29) | (40U << 15) | 0x7F;
*pAsicCtrl++ = tmp;
*pAsicCtrl++ = 0;
/* inter prediction using zero mv and the newest reference */
pMb->mbType_asic = P_Skip;
pMb->refID[0] = refID;
}
}
else
pAsicCtrl += 2;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,329 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Inter prediction. MV and referece frame update
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_inter_prediction.c,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#include "h264hwd_container.h"
#include "h264hwd_util.h"
#include "h264hwd_macroblock_layer.h"
#include "h264hwd_neighbour.h"
#include "h264hwd_exports.h"
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
static u32 MvPredictionSkip(mbStorage_t * pMb, dpbStorage_t * dpb);
static u32 MvPrediction16x16(mbStorage_t * pMb, dpbStorage_t * dpb);
static u32 MvPrediction16x8(mbStorage_t * pMb, dpbStorage_t * dpb);
static u32 MvPrediction8x16(mbStorage_t * pMb, dpbStorage_t * dpb);
static u32 MvPrediction8x8(mbStorage_t * pMb, subMbPred_t * subMbPred,
dpbStorage_t * dpb);
static u32 GetInterNeighbour(u32 sliceId, /*@null@ */ mbStorage_t * nMb);
/*------------------------------------------------------------------------------
Function name : PrepareInterPrediction
Description : Processes one inter macroblock. Writes MB control data
Return type : u32 - 0 for success or a negative error code
Argument : mbStorage_t * pMb - pointer to macroblock specific information
Argument : macroblockLayer_t * pMbLayer - macroblock layer data
Argument : dpbStorage_t * dpb - DPB data
Argument : DecAsicBuffers_t * pAsicBuff - SW/HW interface
------------------------------------------------------------------------------*/
u32 PrepareInterPrediction(mbStorage_t * pMb, macroblockLayer_t * pMbLayer,
dpbStorage_t * dpb, DecAsicBuffers_t * pAsicBuff)
{
ASSERT(pMb);
ASSERT(h264bsdMbPartPredMode(pMb->mbType) == PRED_MODE_INTER);
ASSERT(pMbLayer);
/* if decoded flag > 1 -> mb has already been successfully decoded and
* written to output -> do not write again */
if(pMb->decoded > 1)
goto end;
switch (pMb->mbType)
{
case P_Skip:
if(MvPredictionSkip(pMb, dpb) != HANTRO_OK)
return (HANTRO_NOK);
break;
case P_L0_16x16:
if(MvPrediction16x16(pMb, dpb) != HANTRO_OK)
return (HANTRO_NOK);
break;
case P_L0_L0_16x8:
if(MvPrediction16x8(pMb, dpb) != HANTRO_OK)
return (HANTRO_NOK);
break;
case P_L0_L0_8x16:
if(MvPrediction8x16(pMb, dpb) != HANTRO_OK)
return (HANTRO_NOK);
break;
default: /* P_8x8 and P_8x8ref0 */
if(MvPrediction8x8(pMb, &pMbLayer->subMbPred, dpb) != HANTRO_OK)
return (HANTRO_NOK);
break;
}
/* update ASIC MB control field */
{
u32 tmp;
u32 *pAsicCtrl =
pAsicBuff->mbCtrl.virtualAddress +
(pAsicBuff->currentMB * (ASIC_MB_CTRL_BUFFER_SIZE / 4));
switch (pMb->mbType)
{
case P_Skip:
tmp = (u32) HW_P_SKIP << 29;
break;
case P_L0_16x16:
tmp = (u32) HW_P_16x16 << 29;
break;
case P_L0_L0_16x8:
tmp = (u32) HW_P_16x8 << 29;
break;
case P_L0_L0_8x16:
tmp = (u32) HW_P_8x16 << 29;
break;
default: /* P_8x8 and P_8x8ref0 */
tmp = (u32) HW_P_8x8 << 29;
tmp |= pMbLayer->subMbPred.subMbType[0] << 27;
tmp |= pMbLayer->subMbPred.subMbType[1] << 25;
tmp |= pMbLayer->subMbPred.subMbType[2] << 23;
tmp |= pMbLayer->subMbPred.subMbType[3] << 21;
break;
}
tmp |= pMb->qpY << 15;
tmp |= (u32) (pMbLayer->filterOffsetA & 0x0F) << 11;
tmp |= (u32) (pMbLayer->filterOffsetB & 0x0F) << 7;
tmp |= pAsicBuff->notCodedMask;
pAsicCtrl[0] = tmp;
{
tmp = GetInterNeighbour(pMb->sliceId, pMb->mbD) << 31;
tmp |= GetInterNeighbour(pMb->sliceId, pMb->mbB) << 30;
tmp |= GetInterNeighbour(pMb->sliceId, pMb->mbC) << 29;
tmp |= GetInterNeighbour(pMb->sliceId, pMb->mbA) << 28;
tmp |= pAsicBuff->rlcWords << 19;
}
tmp |= pMbLayer->disableDeblockingFilterIdc << 17;
pAsicCtrl[1] = tmp;
}
end:
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: MvPrediction16x16
Functional description:
Motion vector prediction for 16x16 partition mode
------------------------------------------------------------------------------*/
u32 MvPrediction16x16(mbStorage_t * pMb, dpbStorage_t * dpb)
{
u32 refIndex;
i32 tmp;
refIndex = pMb->refIdxL0[0];
tmp = h264bsdGetRefPicData(dpb, refIndex);
if(tmp == -1)
return (HANTRO_NOK);
pMb->refID[0] = (u8) tmp;
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: MvPredictionSkip
Functional description:
Motion vector prediction skipped macroblock
------------------------------------------------------------------------------*/
u32 MvPredictionSkip(mbStorage_t * pMb, dpbStorage_t * dpb)
{
u32 refIndex = 0;
i32 tmp;
tmp = h264bsdGetRefPicData(dpb, refIndex);
if(tmp == -1)
return (HANTRO_NOK);
pMb->refID[0] = (u8) tmp;
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: MvPrediction16x8
Functional description:
Motion vector prediction for 16x8 partition mode
------------------------------------------------------------------------------*/
u32 MvPrediction16x8(mbStorage_t * pMb, dpbStorage_t * dpb)
{
u32 refIndex;
i32 tmp;
/* first partition */
refIndex = pMb->refIdxL0[0];
tmp = h264bsdGetRefPicData(dpb, refIndex);
if(tmp == -1)
return (HANTRO_NOK);
pMb->refID[0] = (u8) tmp;
/* second partition */
refIndex = pMb->refIdxL0[1];
tmp = h264bsdGetRefPicData(dpb, refIndex);
if(tmp == -1)
return (HANTRO_NOK);
pMb->refID[1] = (u8) tmp;
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: MvPrediction8x16
Functional description:
Motion vector prediction for 8x16 partition mode
------------------------------------------------------------------------------*/
u32 MvPrediction8x16(mbStorage_t * pMb, dpbStorage_t * dpb)
{
u32 refIndex;
i32 tmp;
/* first partition */
refIndex = pMb->refIdxL0[0];
tmp = h264bsdGetRefPicData(dpb, refIndex);
if(tmp == -1)
return (HANTRO_NOK);
pMb->refID[0] = (u8) tmp;
/* second partition */
refIndex = pMb->refIdxL0[1];
tmp = h264bsdGetRefPicData(dpb, refIndex);
if(tmp == -1)
return (HANTRO_NOK);
pMb->refID[1] = (u8) tmp;
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: MvPrediction8x8
Functional description:
Motion vector prediction for 8x8 partition mode
------------------------------------------------------------------------------*/
u32 MvPrediction8x8(mbStorage_t * pMb, subMbPred_t * subMbPred,
dpbStorage_t * dpb)
{
u32 i;
const u8 *refIdxL0 = pMb->refIdxL0;
u8 *refID = pMb->refID;
for(i = 4; i > 0; i--)
{
u32 refIndex;
i32 tmp;
refIndex = *refIdxL0++;
tmp = h264bsdGetRefPicData(dpb, refIndex);
if(tmp == -1)
return (HANTRO_NOK);
*refID++ = (u8) tmp;
}
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: GetInterNeighbour
Functional description:
Checks if macroblock 'nMb' is part of slice 'sliceId'
------------------------------------------------------------------------------*/
u32 GetInterNeighbour(u32 sliceId, mbStorage_t * nMb)
{
if(nMb && (sliceId == nMb->sliceId))
{
return 1;
}
else
{
return 0;
}
}

View File

@ -0,0 +1,467 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Intra prediction for macroblock
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_intra_prediction.c,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
#include "h264hwd_container.h"
#include "h264hwd_util.h"
#include "h264hwd_macroblock_layer.h"
#include "h264hwd_neighbour.h"
#include "h264hwd_exports.h"
static u32 Intra16x16Prediction(mbStorage_t * pMb,
macroblockLayer_t * mbLayer,
u32 constrainedIntraPred,
DecAsicBuffers_t * pAsicBuff);
static u32 Intra4x4Prediction(mbStorage_t * pMb, macroblockLayer_t * mbLayer,
u32 constrainedIntraPred,
DecAsicBuffers_t * pAsicBuff);
static u32 DetermineIntra4x4PredMode(macroblockLayer_t * pMbLayer,
u32 available, neighbour_t * nA,
neighbour_t * nB, u32 index,
/*@null@ */ mbStorage_t * nMbA,
/*@null@ */ mbStorage_t * nMbB);
static u32 GetIntraNeighbour(u32 sliceId, mbStorage_t * nMb);
static u32 CheckIntraChromaPrediction(u32 predMode, u32 availableA,
u32 availableB, u32 availableD);
/*------------------------------------------------------------------------------
Function name : PrepareIntraPrediction
Description :
Return type : u32
Argument : mbStorage_t * pMb
Argument : macroblockLayer_t * mbLayer
Argument : u32 constrainedIntraPred
Argument : DecAsicBuffers_t * pAsicBuff
------------------------------------------------------------------------------*/
u32 PrepareIntraPrediction(mbStorage_t * pMb, macroblockLayer_t * mbLayer,
u32 constrainedIntraPred,
DecAsicBuffers_t * pAsicBuff)
{
u32 tmp;
if(h264bsdMbPartPredMode(pMb->mbType) == PRED_MODE_INTRA4x4)
{
tmp = Intra4x4Prediction(pMb, mbLayer, constrainedIntraPred, pAsicBuff);
if(tmp != HANTRO_OK)
return (tmp);
}
else
{
tmp =
Intra16x16Prediction(pMb, mbLayer, constrainedIntraPred, pAsicBuff);
if(tmp != HANTRO_OK)
return (tmp);
}
return HANTRO_OK;
}
/*------------------------------------------------------------------------------
Function name : Intra16x16Prediction
Description :
Return type : u32
Argument : mbStorage_t * pMb
Argument : macroblockLayer_t * mbLayer
Argument : u32 constrainedIntraPred
Argument : DecAsicBuffers_t * pAsicBuff
------------------------------------------------------------------------------*/
u32 Intra16x16Prediction(mbStorage_t * pMb, macroblockLayer_t * mbLayer,
u32 constrainedIntraPred,
DecAsicBuffers_t * pAsicBuff)
{
u32 mode, tmp;
u32 availableA, availableB, availableD;
ASSERT(h264bsdPredModeIntra16x16(pMb->mbType) < 4);
availableA = h264bsdIsNeighbourAvailable(pMb, pMb->mbA);
if(availableA && constrainedIntraPred &&
(h264bsdMbPartPredMode(pMb->mbA->mbType) == PRED_MODE_INTER))
availableA = HANTRO_FALSE;
availableB = h264bsdIsNeighbourAvailable(pMb, pMb->mbB);
if(availableB && constrainedIntraPred &&
(h264bsdMbPartPredMode(pMb->mbB->mbType) == PRED_MODE_INTER))
availableB = HANTRO_FALSE;
availableD = h264bsdIsNeighbourAvailable(pMb, pMb->mbD);
if(availableD && constrainedIntraPred &&
(h264bsdMbPartPredMode(pMb->mbD->mbType) == PRED_MODE_INTER))
availableD = HANTRO_FALSE;
mode = h264bsdPredModeIntra16x16(pMb->mbType);
switch (mode)
{
case 0: /* Intra_16x16_Vertical */
if(!availableB)
return (HANTRO_NOK);
break;
case 1: /* Intra_16x16_Horizontal */
if(!availableA)
return (HANTRO_NOK);
break;
case 2: /* Intra_16x16_DC */
break;
default: /* case 3: Intra_16x16_Plane */
if(!availableA || !availableB || !availableD)
return (HANTRO_NOK);
break;
}
tmp = CheckIntraChromaPrediction(mbLayer->mbPred.intraChromaPredMode,
availableA, availableB, availableD);
if(tmp != HANTRO_OK)
return (tmp);
if(pMb->decoded > 1)
{
goto end;
}
/* update ASIC MB control field */
{
u32 tmp2;
u32 *pAsicCtrl =
pAsicBuff->mbCtrl.virtualAddress +
(pAsicBuff->currentMB * (ASIC_MB_CTRL_BUFFER_SIZE / 4));
tmp2 = (u32) HW_I_16x16 << 29;
tmp2 |= mode << 27;
tmp2 |= mbLayer->mbPred.intraChromaPredMode << 25;
tmp2 |= ((availableA == HANTRO_TRUE ? 1U : 0U) << 24);
tmp2 |= ((availableB == HANTRO_TRUE ? 1U : 0U) << 23);
tmp2 |= pMb->qpY << 15;
tmp2 |= (u32) (mbLayer->filterOffsetA & 0x0F) << 11;
tmp2 |= (u32) (mbLayer->filterOffsetB & 0x0F) << 7;
tmp2 |= pAsicBuff->notCodedMask;
pAsicCtrl[0] = tmp2;
tmp2 = GetIntraNeighbour(pMb->sliceId, pMb->mbD) << 31;
tmp2 |= GetIntraNeighbour(pMb->sliceId, pMb->mbB) << 30;
tmp2 |= GetIntraNeighbour(pMb->sliceId, pMb->mbC) << 29;
tmp2 |= GetIntraNeighbour(pMb->sliceId, pMb->mbA) << 28;
tmp2 |= pAsicBuff->rlcWords << 19;
tmp2 |= mbLayer->disableDeblockingFilterIdc << 17;
pAsicCtrl[1] = tmp2;
}
end:
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function name : Intra4x4Prediction
Description :
Return type : u32
Argument : mbStorage_t * pMb
Argument : macroblockLayer_t * mbLayer
Argument : u32 constrainedIntraPred
Argument : DecAsicBuffers_t * pAsicBuff
------------------------------------------------------------------------------*/
u32 Intra4x4Prediction(mbStorage_t * pMb, macroblockLayer_t * mbLayer,
u32 constrainedIntraPred, DecAsicBuffers_t * pAsicBuff)
{
u32 block;
u32 mode, tmp;
neighbour_t neighbour, neighbourB;
mbStorage_t *nMb, *nMb2;
u32 availableA, availableB, availableC, availableD;
for(block = 0; block < 16; block++)
{
ASSERT(pMb->intra4x4PredMode[block] < 9);
neighbour = *h264bsdNeighbour4x4BlockA(block);
nMb = h264bsdGetNeighbourMb(pMb, neighbour.mb);
availableA = h264bsdIsNeighbourAvailable(pMb, nMb);
if(availableA && constrainedIntraPred &&
(h264bsdMbPartPredMode(nMb->mbType) == PRED_MODE_INTER))
{
availableA = HANTRO_FALSE;
}
neighbourB = *h264bsdNeighbour4x4BlockB(block);
nMb2 = h264bsdGetNeighbourMb(pMb, neighbourB.mb);
availableB = h264bsdIsNeighbourAvailable(pMb, nMb2);
if(availableB && constrainedIntraPred &&
(h264bsdMbPartPredMode(nMb2->mbType) == PRED_MODE_INTER))
{
availableB = HANTRO_FALSE;
}
mode = DetermineIntra4x4PredMode(mbLayer,
(u32) (availableA && availableB),
&neighbour, &neighbourB, block, nMb,
nMb2);
pMb->intra4x4PredMode[block] = (u8) mode;
if(pMb->decoded == 1)
{
pMb->intra4x4PredMode_asic[block] = (u8) mode;
}
neighbour = *h264bsdNeighbour4x4BlockD(block);
nMb = h264bsdGetNeighbourMb(pMb, neighbour.mb);
availableD = h264bsdIsNeighbourAvailable(pMb, nMb);
if(availableD && constrainedIntraPred &&
(h264bsdMbPartPredMode(nMb->mbType) == PRED_MODE_INTER))
{
availableD = HANTRO_FALSE;
}
switch (mode)
{
case 0: /* Intra_4x4_Vertical */
if(!availableB)
return (HANTRO_NOK);
break;
case 1: /* Intra_4x4_Horizontal */
if(!availableA)
return (HANTRO_NOK);
break;
case 2: /* Intra_4x4_DC */
break;
case 3: /* Intra_4x4_Diagonal_Down_Left */
if(!availableB)
return (HANTRO_NOK);
break;
case 4: /* Intra_4x4_Diagonal_Down_Right */
if(!availableA || !availableB || !availableD)
return (HANTRO_NOK);
break;
case 5: /* Intra_4x4_Vertical_Right */
if(!availableA || !availableB || !availableD)
return (HANTRO_NOK);
break;
case 6: /* Intra_4x4_Horizontal_Down */
if(!availableA || !availableB || !availableD)
return (HANTRO_NOK);
break;
case 7: /* Intra_4x4_Vertical_Left */
if(!availableB)
return (HANTRO_NOK);
break;
default: /* case 8 Intra_4x4_Horizontal_Up */
if(!availableA)
return (HANTRO_NOK);
break;
}
}
availableA = h264bsdIsNeighbourAvailable(pMb, pMb->mbA);
if(availableA && constrainedIntraPred &&
(h264bsdMbPartPredMode(pMb->mbA->mbType) == PRED_MODE_INTER))
availableA = HANTRO_FALSE;
availableB = h264bsdIsNeighbourAvailable(pMb, pMb->mbB);
if(availableB && constrainedIntraPred &&
(h264bsdMbPartPredMode(pMb->mbB->mbType) == PRED_MODE_INTER))
availableB = HANTRO_FALSE;
availableC = h264bsdIsNeighbourAvailable(pMb, pMb->mbC);
if(availableC && constrainedIntraPred &&
(h264bsdMbPartPredMode(pMb->mbC->mbType) == PRED_MODE_INTER))
availableC = HANTRO_FALSE;
availableD = h264bsdIsNeighbourAvailable(pMb, pMb->mbD);
if(availableD && constrainedIntraPred &&
(h264bsdMbPartPredMode(pMb->mbD->mbType) == PRED_MODE_INTER))
availableD = HANTRO_FALSE;
tmp = CheckIntraChromaPrediction(mbLayer->mbPred.intraChromaPredMode,
availableA, availableB, availableD);
if(tmp != HANTRO_OK)
return (tmp);
if(pMb->decoded > 1)
{
goto end;
}
/* update ASIC MB control field */
{
u32 tmp2;
u32 *pAsicCtrl =
pAsicBuff->mbCtrl.virtualAddress +
(pAsicBuff->currentMB * (ASIC_MB_CTRL_BUFFER_SIZE / 4));
tmp2 = (u32) HW_I_4x4 << 29;
tmp2 |= mbLayer->mbPred.intraChromaPredMode << 25;
tmp2 |= ((availableA == HANTRO_TRUE ? 1U : 0U) << 24);
tmp2 |= ((availableB == HANTRO_TRUE ? 1U : 0U) << 23);
tmp2 |= ((availableC == HANTRO_TRUE ? 1U : 0U) << 22);
tmp2 |= pMb->qpY << 15;
tmp2 |= (u32) (mbLayer->filterOffsetA & 0x0F) << 11;
tmp2 |= (u32) (mbLayer->filterOffsetB & 0x0F) << 7;
tmp2 |= pAsicBuff->notCodedMask;
pAsicCtrl[0] = tmp2;
tmp2 = GetIntraNeighbour(pMb->sliceId, pMb->mbD) << 31;
tmp2 |= GetIntraNeighbour(pMb->sliceId, pMb->mbB) << 30;
tmp2 |= GetIntraNeighbour(pMb->sliceId, pMb->mbC) << 29;
tmp2 |= GetIntraNeighbour(pMb->sliceId, pMb->mbA) << 28;
tmp2 |= pAsicBuff->rlcWords << 19;
tmp2 |= mbLayer->disableDeblockingFilterIdc << 17;
pAsicCtrl[1] = tmp2;
}
end:
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function name : DetermineIntra4x4PredMode
Description :
Return type : u32
Argument : macroblockLayer_t * pMbLayer
Argument : u32 available
Argument : neighbour_t * nA
Argument : neighbour_t * nB
Argument : u32 index
Argument : mbStorage_t * nMbA
Argument : mbStorage_t * nMbB
------------------------------------------------------------------------------*/
u32 DetermineIntra4x4PredMode(macroblockLayer_t * pMbLayer,
u32 available, neighbour_t * nA,
neighbour_t * nB, u32 index, mbStorage_t * nMbA,
mbStorage_t * nMbB)
{
u32 mode1, mode2;
mbStorage_t *pMb;
ASSERT(pMbLayer);
if(!available) /* dc only prediction? */
mode1 = 2;
else
{
pMb = nMbA;
if(h264bsdMbPartPredMode(pMb->mbType) == PRED_MODE_INTRA4x4)
{
mode1 = (u32) pMb->intra4x4PredMode[nA->index];
}
else
mode1 = 2;
pMb = nMbB;
if(h264bsdMbPartPredMode(pMb->mbType) == PRED_MODE_INTRA4x4)
{
mode2 = (u32) pMb->intra4x4PredMode[nB->index];
}
else
mode2 = 2;
mode1 = MIN(mode1, mode2);
}
{
mbPred_t *mbPred = &pMbLayer->mbPred;
if(!mbPred->prevIntra4x4PredModeFlag[index])
{
if(mbPred->remIntra4x4PredMode[index] < mode1)
{
mode1 = mbPred->remIntra4x4PredMode[index];
}
else
{
mode1 = mbPred->remIntra4x4PredMode[index] + 1;
}
}
}
return (mode1);
}
/*------------------------------------------------------------------------------
Function: GetIntraNeighbour
Functional description:
Checks if macroblock 'nMb' is part of slice 'sliceId'
------------------------------------------------------------------------------*/
u32 GetIntraNeighbour(u32 sliceId, mbStorage_t * nMb)
{
if(nMb && (sliceId == nMb->sliceId))
{
return 1;
}
else
{
return 0;
}
}
/*------------------------------------------------------------------------------
Function: CheckIntraChromaPrediction
Functional description:
Check that the intra chroma prediction mode is valid!
------------------------------------------------------------------------------*/
u32 CheckIntraChromaPrediction(u32 predMode, u32 availableA, u32 availableB,
u32 availableD)
{
switch (predMode)
{
case 0: /* Intra_Chroma_DC */
break;
case 1: /* Intra_Chroma_Horizontal */
if(!availableA)
return (HANTRO_NOK);
break;
case 2: /* Intra_Chroma_Vertical */
if(!availableB)
return (HANTRO_NOK);
break;
case 3: /* Intra_Chroma_Plane */
if(!availableA || !availableB || !availableD)
return (HANTRO_NOK);
break;
default:
ASSERT(predMode < 4);
return HANTRO_NOK;
}
return (HANTRO_OK);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,135 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode NAL unit header
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_nal_unit.c,v $
-- $Date: 2008/05/28 11:08:48 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. External compiler flags
3. Module defines
4. Local function prototypes
5. Functions
h264bsdDecodeNalUnit
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "h264hwd_nal_unit.h"
#include "h264hwd_util.h"
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Function name: h264bsdDecodeNalUnit
Functional description:
Decode NAL unit header information
Inputs:
pStrmData pointer to stream data structure
Outputs:
pNalUnit NAL unit header information is stored here
Returns:
HANTRO_OK success
HANTRO_NOK invalid NAL unit header information
------------------------------------------------------------------------------*/
u32 h264bsdDecodeNalUnit(strmData_t *pStrmData, nalUnit_t *pNalUnit)
{
/* Variables */
u32 tmp;
/* Code */
ASSERT(pStrmData);
ASSERT(pNalUnit);
ASSERT(pStrmData->bitPosInWord == 0);
/* forbidden_zero_bit (not checked to be zero, errors ignored) */
tmp = h264bsdGetBits(pStrmData, 1);
/* Assuming that NAL unit starts from byte boundary <20>> don't have to check
* following 7 bits for END_OF_STREAM */
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
tmp = h264bsdGetBits(pStrmData, 2);
pNalUnit->nalRefIdc = tmp;
tmp = h264bsdGetBits(pStrmData, 5);
pNalUnit->nalUnitType = (nalUnitType_e)tmp;
DEBUG_PRINT(("NAL TYPE %d\n", tmp));
/* data partitioning NAL units not supported */
if ( (tmp == NAL_CODED_SLICE_DP_A) ||
(tmp == NAL_CODED_SLICE_DP_B) ||
(tmp == NAL_CODED_SLICE_DP_C) )
{
ERROR_PRINT(("DP slices not allowed!!!"));
return(HANTRO_NOK);
}
/* nal_ref_idc shall not be zero for these nal_unit_types */
if ( ( (tmp == NAL_SEQ_PARAM_SET) || (tmp == NAL_PIC_PARAM_SET) ||
(tmp == NAL_CODED_SLICE_IDR) ) && (pNalUnit->nalRefIdc == 0) )
{
ERROR_PRINT(("nal_ref_idc shall not be zero!!!"));
return(HANTRO_NOK);
}
/* nal_ref_idc shall be zero for these nal_unit_types */
else if ( ( (tmp == NAL_SEI) || (tmp == NAL_ACCESS_UNIT_DELIMITER) ||
(tmp == NAL_END_OF_SEQUENCE) || (tmp == NAL_END_OF_STREAM) ||
(tmp == NAL_FILLER_DATA) ) && (pNalUnit->nalRefIdc != 0) )
{
ERROR_PRINT(("nal_ref_idc shall be zero!!!"));
return(HANTRO_NOK);
}
return(HANTRO_OK);
}

View File

@ -0,0 +1,395 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Get neighbour blocks
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_neighbour.c,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. External compiler flags
3. Module defines
4. Local function prototypes
5. Functions
h264bsdInitMbNeighbours
h264bsdGetNeighbourMb
h264bsdNeighbour4x4BlockA
h264bsdNeighbour4x4BlockB
h264bsdNeighbour4x4BlockC
h264bsdNeighbour4x4BlockD
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "h264hwd_neighbour.h"
#include "h264hwd_util.h"
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/* Following four tables indicate neighbours of each block of a macroblock.
* First 16 values are for luma blocks, next 4 values for Cb and last 4
* values for Cr. Elements of the table indicate to which macroblock the
* neighbour block belongs and the index of the neighbour block in question.
* Indexing of the blocks goes as follows
*
* Y Cb Cr
* 0 1 4 5 16 17 20 21
* 2 3 6 7 18 19 22 23
* 8 9 12 13
* 10 11 14 15
*/
/* left neighbour for each block */
static const neighbour_t N_A_4x4B[24] = {
{MB_A,5}, {MB_CURR,0}, {MB_A,7}, {MB_CURR,2},
{MB_CURR,1}, {MB_CURR,4}, {MB_CURR,3}, {MB_CURR,6},
{MB_A,13}, {MB_CURR,8}, {MB_A,15}, {MB_CURR,10},
{MB_CURR,9}, {MB_CURR,12},{MB_CURR,11},{MB_CURR,14},
{MB_A,17}, {MB_CURR,16},{MB_A,19}, {MB_CURR,18},
{MB_A,21}, {MB_CURR,20},{MB_A,23}, {MB_CURR,22} };
/* above neighbour for each block */
static const neighbour_t N_B_4x4B[24] = {
{MB_B,10}, {MB_B,11}, {MB_CURR,0}, {MB_CURR,1},
{MB_B,14}, {MB_B,15}, {MB_CURR,4}, {MB_CURR,5},
{MB_CURR,2}, {MB_CURR,3}, {MB_CURR,8}, {MB_CURR,9},
{MB_CURR,6}, {MB_CURR,7}, {MB_CURR,12},{MB_CURR,13},
{MB_B,18}, {MB_B,19}, {MB_CURR,16},{MB_CURR,17},
{MB_B,22}, {MB_B,23}, {MB_CURR,20},{MB_CURR,21} };
#if 0 /* not in use currently */
/* above-right neighbour for each block */
static const neighbour_t N_C_4x4B[24] = {
{MB_B,11}, {MB_B,14}, {MB_CURR,1}, {MB_NA,4},
{MB_B,15}, {MB_C,10}, {MB_CURR,5}, {MB_NA,0},
{MB_CURR,3}, {MB_CURR,6}, {MB_CURR,9}, {MB_NA,12},
{MB_CURR,7}, {MB_NA,2}, {MB_CURR,13},{MB_NA,8},
{MB_B,19}, {MB_C,18}, {MB_CURR,17},{MB_NA,16},
{MB_B,23}, {MB_C,22}, {MB_CURR,21},{MB_NA,20} };
#endif
/* above-left neighbour for each block */
static const neighbour_t N_D_4x4B[24] = {
{MB_D,15}, {MB_B,10}, {MB_A,5}, {MB_CURR,0},
{MB_B,11}, {MB_B,14}, {MB_CURR,1}, {MB_CURR,4},
{MB_A,7}, {MB_CURR,2}, {MB_A,13}, {MB_CURR,8},
{MB_CURR,3}, {MB_CURR,6}, {MB_CURR,9}, {MB_CURR,12},
{MB_D,19}, {MB_B,18}, {MB_A,17}, {MB_CURR,16},
{MB_D,23}, {MB_B,22}, {MB_A,21}, {MB_CURR,20} };
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Function: h264bsdInitMbNeighbours
Functional description:
Initialize macroblock neighbours. Function sets neighbour
macroblock pointers in macroblock structures to point to
macroblocks on the left, above, above-right and above-left.
Pointers are set NULL if the neighbour does not fit into the
picture.
Inputs:
picWidth width of the picture in macroblocks
picSizeInMbs no need to clarify
Outputs:
pMbStorage neighbour pointers of each mbStorage structure
stored here
Returns:
none
------------------------------------------------------------------------------*/
void h264bsdInitMbNeighbours(mbStorage_t *pMbStorage, u32 picWidth,
u32 picSizeInMbs)
{
/* Variables */
u32 i, row, col;
/* Code */
ASSERT(pMbStorage);
ASSERT(picWidth);
ASSERT(picWidth <= picSizeInMbs);
ASSERT(((picSizeInMbs / picWidth) * picWidth) == picSizeInMbs);
row = col = 0;
for (i = 0; i < picSizeInMbs; i++)
{
if (col)
pMbStorage[i].mbA = pMbStorage + i - 1;
else
pMbStorage[i].mbA = NULL;
if (row)
pMbStorage[i].mbB = pMbStorage + i - picWidth;
else
pMbStorage[i].mbB = NULL;
if (row && (col < picWidth - 1))
pMbStorage[i].mbC = pMbStorage + i - (picWidth - 1);
else
pMbStorage[i].mbC = NULL;
if (row && col)
pMbStorage[i].mbD = pMbStorage + i - (picWidth + 1);
else
pMbStorage[i].mbD = NULL;
col++;
if (col == picWidth)
{
col = 0;
row++;
}
}
}
/*------------------------------------------------------------------------------
Function: h264bsdGetNeighbourMb
Functional description:
Get pointer to neighbour macroblock.
Inputs:
pMb pointer to macroblock structure of the macroblock
whose neighbour is wanted
neighbour indicates which neighbour is wanted
Outputs:
none
Returns:
pointer to neighbour macroblock
NULL if not available
------------------------------------------------------------------------------*/
mbStorage_t* h264bsdGetNeighbourMb(mbStorage_t *pMb, neighbourMb_e neighbour)
{
/* Variables */
/* Code */
ASSERT((neighbour <= MB_CURR) || (neighbour == MB_NA));
if (neighbour == MB_A)
return(pMb->mbA);
else if (neighbour == MB_B)
return(pMb->mbB);
else if (neighbour == MB_D)
return(pMb->mbD);
else if (neighbour == MB_CURR)
return(pMb);
else if (neighbour == MB_C)
return(pMb->mbC);
else
return(NULL);
}
/*------------------------------------------------------------------------------
Function: h264bsdNeighbour4x4BlockA
Functional description:
Get left neighbour of the block. Function returns pointer to
the table defined in the beginning of the file.
Inputs:
blockIndex indicates the block whose neighbours are wanted
Outputs:
Returns:
pointer to neighbour structure
------------------------------------------------------------------------------*/
const neighbour_t* h264bsdNeighbour4x4BlockA(u32 blockIndex)
{
/* Variables */
/* Code */
ASSERT(blockIndex < 24);
return(N_A_4x4B+blockIndex);
}
/*------------------------------------------------------------------------------
Function: h264bsdNeighbour4x4BlockB
Functional description:
Get above neighbour of the block. Function returns pointer to
the table defined in the beginning of the file.
Inputs:
blockIndex indicates the block whose neighbours are wanted
Outputs:
Returns:
pointer to neighbour structure
------------------------------------------------------------------------------*/
const neighbour_t* h264bsdNeighbour4x4BlockB(u32 blockIndex)
{
/* Variables */
/* Code */
ASSERT(blockIndex < 24);
return(N_B_4x4B+blockIndex);
}
/*------------------------------------------------------------------------------
Function: h264bsdNeighbour4x4BlockC
Functional description:
Get above-right neighbour of the block. Function returns pointer
to the table defined in the beginning of the file.
Inputs:
blockIndex indicates the block whose neighbours are wanted
Outputs:
Returns:
pointer to neighbour structure
------------------------------------------------------------------------------*/
#if 0 /* not used */
const neighbour_t* h264bsdNeighbour4x4BlockC(u32 blockIndex)
{
/* Variables */
/* Code */
ASSERT(blockIndex < 24);
return(N_C_4x4B+blockIndex);
}
#endif
/*------------------------------------------------------------------------------
Function: h264bsdNeighbour4x4BlockD
Functional description:
Get above-left neighbour of the block. Function returns pointer to
the table defined in the beginning of the file.
Inputs:
blockIndex indicates the block whose neighbours are wanted
Outputs:
Returns:
pointer to neighbour structure
------------------------------------------------------------------------------*/
const neighbour_t* h264bsdNeighbour4x4BlockD(u32 blockIndex)
{
/* Variables */
/* Code */
ASSERT(blockIndex < 24);
return(N_D_4x4B+blockIndex);
}
/*------------------------------------------------------------------------------
Function: h264bsdIsNeighbourAvailable
Functional description:
Check if neighbour macroblock is available. Neighbour macroblock
is considered available if it is within the picture and belongs
to the same slice as the current macroblock.
Inputs:
pMb pointer to the current macroblock
pNeighbour pointer to the neighbour macroblock
Outputs:
none
Returns:
HANTRO_TRUE neighbour is available
HANTRO_FALSE neighbour is not available
------------------------------------------------------------------------------*/
u32 h264bsdIsNeighbourAvailable(mbStorage_t *pMb, mbStorage_t *pNeighbour)
{
/* Variables */
/* Code */
if ( (pNeighbour == NULL) || (pMb->sliceId != pNeighbour->sliceId) )
return(HANTRO_FALSE);
else
return(HANTRO_TRUE);
}

View File

@ -0,0 +1,383 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Compute Picture Order Count (POC) for a picture
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_pic_order_cnt.c,v $
-- $Date: 2008/07/31 09:38:41 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. External compiler flags
3. Module defines
4. Local function prototypes
5. Functions
h264bsdDecodePicOrderCnt
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "h264hwd_util.h"
#include "h264hwd_pic_order_cnt.h"
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Function: h264bsdDecodePicOrderCnt
Functional description:
Compute picture order count for a picture. Function implements
computation of all POC types (0, 1 and 2), type is obtained from
sps. See standard for description of the POC types and how POC is
computed for each type.
Function returns the minimum of top field and bottom field pic
order counts.
Inputs:
poc pointer to previous results
sps pointer to sequence parameter set
slicHeader pointer to current slice header, frame number and
other params needed for POC computation
pNalUnit pointer to current NAL unit structrue, function needs
to know if this is an IDR picture and also if this is
a reference picture
Outputs:
poc results stored here for computation of next POC
Returns:
picture order count
------------------------------------------------------------------------------*/
void h264bsdDecodePicOrderCnt(pocStorage_t *poc, const seqParamSet_t *sps,
const sliceHeader_t *pSliceHeader, const nalUnit_t *pNalUnit)
{
/* Variables */
u32 i;
i32 picOrderCnt;
u32 frameNumOffset, absFrameNum, picOrderCntCycleCnt;
u32 frameNumInPicOrderCntCycle;
i32 expectedDeltaPicOrderCntCycle;
/* Code */
ASSERT(poc);
ASSERT(sps);
ASSERT(pSliceHeader);
ASSERT(pNalUnit);
ASSERT(sps->picOrderCntType <= 2);
#if 0
/* JanSa: I don't think this is necessary, don't see any reason to
* increment prevFrameNum one by one instead of one big increment.
* However, standard specifies that this should be done -> if someone
* figures out any case when the outcome would be different for step by
* step increment, this part of the code should be enabled */
/* if there was a gap in frame numbering and picOrderCntType is 1 or 2 ->
* "compute" pic order counts for non-existing frames. These are not
* actually computed, but process needs to be done to update the
* prevFrameNum and prevFrameNumOffset */
if ( sps->picOrderCntType > 0 &&
pSliceHeader->frameNum != poc->prevFrameNum &&
pSliceHeader->frameNum != ((poc->prevFrameNum + 1) % sps->maxFrameNum))
{
/* use variable i for unUsedShortTermFrameNum */
i = (poc->prevFrameNum + 1) % sps->maxFrameNum;
do
{
if (poc->prevFrameNum > i)
frameNumOffset = poc->prevFrameNumOffset + sps->maxFrameNum;
else
frameNumOffset = poc->prevFrameNumOffset;
poc->prevFrameNumOffset = frameNumOffset;
poc->prevFrameNum = i;
i = (i + 1) % sps->maxFrameNum;
} while (i != pSliceHeader->frameNum);
}
#endif
/* check if current slice includes mmco equal to 5 */
poc->containsMmco5 = HANTRO_FALSE;
if (pSliceHeader->decRefPicMarking.adaptiveRefPicMarkingModeFlag)
{
i = 0;
while (pSliceHeader->decRefPicMarking.operation[i].
memoryManagementControlOperation)
{
if (pSliceHeader->decRefPicMarking.operation[i].
memoryManagementControlOperation == 5)
{
poc->containsMmco5 = HANTRO_TRUE;
break;
}
i++;
}
}
switch (sps->picOrderCntType)
{
case 0:
/* set prevPicOrderCnt values for IDR frame */
if (IS_IDR_NAL_UNIT(pNalUnit))
{
poc->prevPicOrderCntMsb = 0;
poc->prevPicOrderCntLsb = 0;
}
/* compute picOrderCntMsb (stored in picOrderCnt variable) */
if ( (pSliceHeader->picOrderCntLsb < poc->prevPicOrderCntLsb) &&
((poc->prevPicOrderCntLsb - pSliceHeader->picOrderCntLsb) >=
sps->maxPicOrderCntLsb/2) )
{
picOrderCnt = poc->prevPicOrderCntMsb +
(i32)sps->maxPicOrderCntLsb;
}
else if ((pSliceHeader->picOrderCntLsb > poc->prevPicOrderCntLsb) &&
((pSliceHeader->picOrderCntLsb - poc->prevPicOrderCntLsb) >
sps->maxPicOrderCntLsb/2) )
{
picOrderCnt = poc->prevPicOrderCntMsb -
(i32)sps->maxPicOrderCntLsb;
}
else
picOrderCnt = poc->prevPicOrderCntMsb;
/* standard specifies that prevPicOrderCntMsb is from previous
* rererence frame -> replace old value only if current frame is
* rererence frame */
if (pNalUnit->nalRefIdc)
poc->prevPicOrderCntMsb = picOrderCnt;
/* compute top field order cnt (stored in picOrderCnt) */
picOrderCnt += (i32)pSliceHeader->picOrderCntLsb;
/* standard specifies that prevPicOrderCntLsb is from previous
* rererence frame -> replace old value only if current frame is
* rererence frame */
if (pNalUnit->nalRefIdc)
{
/* if current frame contains mmco5 -> modify values to be
* stored */
if (poc->containsMmco5)
{
poc->prevPicOrderCntMsb = 0;
/* prevPicOrderCntLsb should be the top field picOrderCnt
* if previous frame included mmco5. Top field picOrderCnt
* for frames containing mmco5 is obtained by subtracting
* the picOrderCnt from original top field order count ->
* value is zero if top field was the minimum, i.e. delta
* for bottom was positive, otherwise value is
* -deltaPicOrderCntBottom */
if (pSliceHeader->deltaPicOrderCntBottom < 0 &&
!pSliceHeader->bottomFieldFlag)
poc->prevPicOrderCntLsb =
(u32)(-pSliceHeader->deltaPicOrderCntBottom);
else
poc->prevPicOrderCntLsb = 0;
/*picOrderCnt = poc->prevPicOrderCntLsb;*/
}
else
{
poc->prevPicOrderCntLsb = pSliceHeader->picOrderCntLsb;
}
}
/*if (!pSliceHeader->fieldPicFlag || !pSliceHeader->bottomFieldFlag)*/
poc->picOrderCnt[0] = picOrderCnt;
if (!pSliceHeader->fieldPicFlag)
poc->picOrderCnt[1] = picOrderCnt +
pSliceHeader->deltaPicOrderCntBottom;
else
/*else if (pSliceHeader->bottomFieldFlag)*/
poc->picOrderCnt[1] = picOrderCnt;
break;
case 1:
/* step 1 (in the description in the standard) */
if (IS_IDR_NAL_UNIT(pNalUnit))
frameNumOffset = 0;
else if (poc->prevFrameNum > pSliceHeader->frameNum)
frameNumOffset = poc->prevFrameNumOffset + sps->maxFrameNum;
else
frameNumOffset = poc->prevFrameNumOffset;
/* step 2 */
if (sps->numRefFramesInPicOrderCntCycle)
absFrameNum = frameNumOffset + pSliceHeader->frameNum;
else
absFrameNum = 0;
if (pNalUnit->nalRefIdc == 0 && absFrameNum > 0)
absFrameNum -= 1;
/* step 4 */
expectedDeltaPicOrderCntCycle = 0;
for (i = 0; i < sps->numRefFramesInPicOrderCntCycle; i++)
expectedDeltaPicOrderCntCycle += sps->offsetForRefFrame[i];
/* step 3 */
if (absFrameNum > 0)
{
picOrderCntCycleCnt =
(absFrameNum - 1)/sps->numRefFramesInPicOrderCntCycle;
frameNumInPicOrderCntCycle =
(absFrameNum - 1)%sps->numRefFramesInPicOrderCntCycle;
/* step 5 (picOrderCnt used to store expectedPicOrderCnt) */
picOrderCnt =
(i32)picOrderCntCycleCnt * expectedDeltaPicOrderCntCycle;
for (i = 0; i <= frameNumInPicOrderCntCycle; i++)
picOrderCnt += sps->offsetForRefFrame[i];
}
else
picOrderCnt = 0;
if (pNalUnit->nalRefIdc == 0)
picOrderCnt += sps->offsetForNonRefPic;
/* if current picture contains mmco5 -> set prevFrameNumOffset and
* prevFrameNum to 0 for computation of picOrderCnt of next
* frame, otherwise store frameNum and frameNumOffset to poc
* structure */
if (!poc->containsMmco5)
{
poc->prevFrameNumOffset = frameNumOffset;
poc->prevFrameNum = pSliceHeader->frameNum;
}
else
{
poc->prevFrameNumOffset = 0;
poc->prevFrameNum = 0;
picOrderCnt = 0;
}
/* step 6 */
if (!pSliceHeader->fieldPicFlag)
{
poc->picOrderCnt[0] = picOrderCnt +
pSliceHeader->deltaPicOrderCnt[0];
poc->picOrderCnt[1] = poc->picOrderCnt[0] +
sps->offsetForTopToBottomField +
pSliceHeader->deltaPicOrderCnt[1];
}
else if (!pSliceHeader->bottomFieldFlag)
poc->picOrderCnt[0] = poc->picOrderCnt[1] =
picOrderCnt + pSliceHeader->deltaPicOrderCnt[0];
else
poc->picOrderCnt[0] = poc->picOrderCnt[1] =
picOrderCnt + sps->offsetForTopToBottomField +
pSliceHeader->deltaPicOrderCnt[0];
break;
default: /* case 2 */
/* derive frameNumOffset */
if (IS_IDR_NAL_UNIT(pNalUnit))
frameNumOffset = 0;
else if (poc->prevFrameNum > pSliceHeader->frameNum)
frameNumOffset = poc->prevFrameNumOffset + sps->maxFrameNum;
else
frameNumOffset = poc->prevFrameNumOffset;
/* derive picOrderCnt (type 2 has same value for top and bottom
* field order cnts) */
if (IS_IDR_NAL_UNIT(pNalUnit))
{
picOrderCnt = 0;
}
else if (pNalUnit->nalRefIdc == 0)
{
picOrderCnt =
2 * (i32)(frameNumOffset + pSliceHeader->frameNum) - 1;
}
else
{
picOrderCnt =
2 * (i32)(frameNumOffset + pSliceHeader->frameNum);
}
poc->picOrderCnt[0] = poc->picOrderCnt[1] = picOrderCnt;
/*
if (!pSliceHeader->fieldPicFlag)
{
poc->picOrderCnt[0] = poc->picOrderCnt[1] = picOrderCnt;
}
else if (!pSliceHeader->bottomFieldFlag)
poc->picOrderCnt[0] = picOrderCnt;
else
poc->picOrderCnt[1] = picOrderCnt;
*/
/* if current picture contains mmco5 -> set prevFrameNumOffset and
* prevFrameNum to 0 for computation of picOrderCnt of next
* frame, otherwise store frameNum and frameNumOffset to poc
* structure */
if (!poc->containsMmco5)
{
poc->prevFrameNumOffset = frameNumOffset;
poc->prevFrameNum = pSliceHeader->frameNum;
}
else
{
poc->prevFrameNumOffset = 0;
poc->prevFrameNum = 0;
picOrderCnt = 0;
}
break;
}
}

View File

@ -0,0 +1,397 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode picture parameter set information from the stream
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_pic_param_set.c,v $
-- $Date: 2008/05/28 11:10:37 $
-- $Revision: 1.5 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. External compiler flags
3. Module defines
4. Local function prototypes
5. Functions
h264bsdDecodePicParamSet
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "h264hwd_pic_param_set.h"
#include "h264hwd_util.h"
#include "h264hwd_vlc.h"
#include "h264hwd_cfg.h"
#include "dwl.h"
#ifdef ASIC_TRACE_SUPPORT
#include "trace.h"
#endif
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/* lookup table for ceil(log2(numSliceGroups)), i.e. number of bits needed to
* represent range [0, numSliceGroups)
*
* NOTE: if MAX_NUM_SLICE_GROUPS is higher than 8 this table has to be resized
* accordingly */
static const u32 CeilLog2NumSliceGroups[8] = {1, 1, 2, 2, 3, 3, 3, 3};
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Function name: h264bsdDecodePicParamSet
Functional description:
Decode picture parameter set information from the stream.
Function allocates memory for
- run lengths if slice group map type is 0
- top-left and bottom-right arrays if map type is 2
- for slice group ids if map type is 6
Validity of some of the slice group mapping information depends
on the image dimensions which are not known here. Therefore the
validity has to be checked afterwards, currently in the parameter
set activation phase.
Inputs:
pStrmData pointer to stream data structure
Outputs:
pPicParamSet decoded information is stored here
Returns:
HANTRO_OK success
HANTRO_NOK failure, invalid information or end of stream
MEMORY_ALLOCATION_ERROR for memory allocation failure
------------------------------------------------------------------------------*/
void ScalingList(u8 scalingList[][64], strmData_t *pStrmData, u32 idx);
void FallbackScaling(u8 scalingList[][64], u32 idx);
u32 h264bsdDecodePicParamSet(strmData_t *pStrmData, picParamSet_t *pPicParamSet)
{
/* Variables */
u32 tmp, i, value;
i32 itmp;
/* Code */
ASSERT(pStrmData);
ASSERT(pPicParamSet);
(void) DWLmemset(pPicParamSet, 0, sizeof(picParamSet_t));
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&pPicParamSet->picParameterSetId);
if (tmp != HANTRO_OK)
return(tmp);
if (pPicParamSet->picParameterSetId >= MAX_NUM_PIC_PARAM_SETS)
{
ERROR_PRINT("pic_parameter_set_id");
return(HANTRO_NOK);
}
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&pPicParamSet->seqParameterSetId);
if (tmp != HANTRO_OK)
return(tmp);
if (pPicParamSet->seqParameterSetId >= MAX_NUM_SEQ_PARAM_SETS)
{
ERROR_PRINT("seq_param_set_id");
return(HANTRO_NOK);
}
/* entropy_coding_mode_flag, shall be 0 for baseline profile */
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pPicParamSet->entropyCodingModeFlag = tmp;
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pPicParamSet->picOrderPresentFlag = (tmp == 1) ? HANTRO_TRUE : HANTRO_FALSE;
/* num_slice_groups_minus1 */
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
pPicParamSet->numSliceGroups = value + 1;
if (pPicParamSet->numSliceGroups > MAX_NUM_SLICE_GROUPS)
{
ERROR_PRINT("num_slice_groups_minus1");
return(HANTRO_NOK);
}
/* decode slice group mapping information if more than one slice groups */
if (pPicParamSet->numSliceGroups > 1)
{
#ifdef ASIC_TRACE_SUPPORT
trace_h264DecodingTools.sliceGroups = 1;
#endif
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&pPicParamSet->sliceGroupMapType);
if (tmp != HANTRO_OK)
return(tmp);
if (pPicParamSet->sliceGroupMapType > 6)
{
ERROR_PRINT("slice_group_map_type");
return(HANTRO_NOK);
}
if (pPicParamSet->sliceGroupMapType == 0)
{
ALLOCATE(pPicParamSet->runLength,
pPicParamSet->numSliceGroups, u32);
if (pPicParamSet->runLength == NULL)
return(MEMORY_ALLOCATION_ERROR);
for (i = 0; i < pPicParamSet->numSliceGroups; i++)
{
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
pPicParamSet->runLength[i] = value+1;
/* param values checked in CheckPps() */
}
}
else if (pPicParamSet->sliceGroupMapType == 2)
{
ALLOCATE(pPicParamSet->topLeft,
pPicParamSet->numSliceGroups - 1, u32);
ALLOCATE(pPicParamSet->bottomRight,
pPicParamSet->numSliceGroups - 1, u32);
if (pPicParamSet->topLeft == NULL ||
pPicParamSet->bottomRight == NULL)
return(MEMORY_ALLOCATION_ERROR);
for (i = 0; i < pPicParamSet->numSliceGroups - 1; i++)
{
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
pPicParamSet->topLeft[i] = value;
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
pPicParamSet->bottomRight[i] = value;
/* param values checked in CheckPps() */
}
}
else if ( (pPicParamSet->sliceGroupMapType == 3) ||
(pPicParamSet->sliceGroupMapType == 4) ||
(pPicParamSet->sliceGroupMapType == 5) )
{
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pPicParamSet->sliceGroupChangeDirectionFlag =
(tmp == 1) ? HANTRO_TRUE : HANTRO_FALSE;
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
pPicParamSet->sliceGroupChangeRate = value + 1;
/* param value checked in CheckPps() */
}
else if (pPicParamSet->sliceGroupMapType == 6)
{
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
pPicParamSet->picSizeInMapUnits = value + 1;
ALLOCATE(pPicParamSet->sliceGroupId,
pPicParamSet->picSizeInMapUnits, u32);
if (pPicParamSet->sliceGroupId == NULL)
return(MEMORY_ALLOCATION_ERROR);
/* determine number of bits needed to represent range
* [0, numSliceGroups) */
tmp = CeilLog2NumSliceGroups[pPicParamSet->numSliceGroups-1];
for (i = 0; i < pPicParamSet->picSizeInMapUnits; i++)
{
pPicParamSet->sliceGroupId[i] = h264bsdGetBits(pStrmData, tmp);
if ( pPicParamSet->sliceGroupId[i] >=
pPicParamSet->numSliceGroups )
{
ERROR_PRINT("slice_group_id");
return(HANTRO_NOK);
}
}
}
}
/* num_ref_idx_l0_active_minus1 */
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
if (value > 31)
{
ERROR_PRINT("num_ref_idx_l0_active_minus1");
return(HANTRO_NOK);
}
pPicParamSet->numRefIdxL0Active = value + 1;
/* num_ref_idx_l1_active_minus1 */
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
if (value > 31)
{
ERROR_PRINT("num_ref_idx_l1_active_minus1");
return(HANTRO_NOK);
}
pPicParamSet->numRefIdxL1Active = value + 1;
/* weighted_pred_flag, this shall be 0 for baseline profile */
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pPicParamSet->weightedPredFlag = tmp;
/* weighted_bipred_idc */
tmp = h264bsdGetBits(pStrmData, 2);
if (tmp > 2)
{
ERROR_PRINT("weighted_bipred_idc");
return(HANTRO_NOK);
}
pPicParamSet->weightedBiPredIdc = tmp;
/* pic_init_qp_minus26 */
tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp);
if (tmp != HANTRO_OK)
return(tmp);
if ((itmp < -26) || (itmp > 25))
{
ERROR_PRINT("pic_init_qp_minus26");
return(HANTRO_NOK);
}
pPicParamSet->picInitQp = (u32)(itmp + 26);
/* pic_init_qs_minus26 */
tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp);
if (tmp != HANTRO_OK)
return(tmp);
if ((itmp < -26) || (itmp > 25))
{
ERROR_PRINT("pic_init_qs_minus26");
return(HANTRO_NOK);
}
tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp);
if (tmp != HANTRO_OK)
return(tmp);
if ((itmp < -12) || (itmp > 12))
{
ERROR_PRINT("chroma_qp_index_offset");
return(HANTRO_NOK);
}
pPicParamSet->chromaQpIndexOffset = itmp;
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pPicParamSet->deblockingFilterControlPresentFlag =
(tmp == 1) ? HANTRO_TRUE : HANTRO_FALSE;
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pPicParamSet->constrainedIntraPredFlag = (tmp == 1) ? HANTRO_TRUE : HANTRO_FALSE;
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pPicParamSet->redundantPicCntPresentFlag = (tmp == 1) ? HANTRO_TRUE : HANTRO_FALSE;
if (h264bsdMoreRbspData(pStrmData))
{
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pPicParamSet->transform8x8Flag = tmp;
/* pic_scaling_matrix_present_flag */
tmp = h264bsdGetBits(pStrmData, 1);
#ifdef ASIC_TRACE_SUPPORT
if (tmp)
trace_h264DecodingTools.scalingMatrixPresentType.pic = 1;
#endif
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pPicParamSet->scalingMatrixPresentFlag = tmp;
if (tmp)
{
for (i = 0; i < 6+2*pPicParamSet->transform8x8Flag; i++)
{
tmp = h264bsdGetBits(pStrmData, 1);
pPicParamSet->scalingListPresent[i] = tmp;
if (tmp)
{
ScalingList(pPicParamSet->scalingList, pStrmData, i);
}
else
FallbackScaling(pPicParamSet->scalingList, i);
}
}
tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp);
if (tmp != HANTRO_OK)
return(tmp);
if ((itmp < -12) || (itmp > 12))
{
ERROR_PRINT("second_chroma_qp_index_offset");
return(HANTRO_NOK);
}
pPicParamSet->chromaQpIndexOffset2 = itmp;
}
else
{
pPicParamSet->scalingMatrixPresentFlag = 0;
pPicParamSet->transform8x8Flag = 0;
pPicParamSet->chromaQpIndexOffset2 = pPicParamSet->chromaQpIndexOffset;
}
tmp = h264bsdRbspTrailingBits(pStrmData);
/* ignore possible errors in trailing bits of parameters sets */
return(HANTRO_OK);
}

View File

@ -0,0 +1,800 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode seq parameter set information from the stream
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_seq_param_set.c,v $
-- $Date: 2008/11/28 11:34:21 $
-- $Revision: 1.9 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "h264hwd_seq_param_set.h"
#include "h264hwd_util.h"
#include "h264hwd_vlc.h"
#include "h264hwd_vui.h"
#include "h264hwd_cfg.h"
#include "dwl.h"
#ifdef ASIC_TRACE_SUPPORT
#include "trace.h"
#endif
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/* enumeration to indicate invalid return value from the GetDpbSize function */
enum {INVALID_DPB_SIZE = 0x7FFFFFFF};
const u32 default4x4Intra[16] =
{6,13,13,20,20,20,28,28,28,28,32,32,32,37,37,42};
const u32 default4x4Inter[16] =
{10,14,14,20,20,20,24,24,24,24,27,27,27,30,30,34};
const u32 default8x8Intra[64] =
{ 6,10,10,13,11,13,16,16,16,16,18,18,18,18,18,23,
23,23,23,23,23,25,25,25,25,25,25,25,27,27,27,27,
27,27,27,27,29,29,29,29,29,29,29,31,31,31,31,31,
31,33,33,33,33,33,36,36,36,36,38,38,38,40,40,42};
const u32 default8x8Inter[64] =
{ 9,13,13,15,13,15,17,17,17,17,19,19,19,19,19,21,
21,21,21,21,21,22,22,22,22,22,22,22,24,24,24,24,
24,24,24,24,25,25,25,25,25,25,25,27,27,27,27,27,
27,28,28,28,28,28,30,30,30,30,32,32,32,33,33,35};
static const u32 zigZag4x4[16] = {
0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15 };
static const u32 zigZag8x8[64] = {
0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 };
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
static u32 GetDpbSize(u32 picSizeInMbs, u32 levelIdc);
/*------------------------------------------------------------------------------
Function name: h264bsdDecodeSeqParamSet
Functional description:
Decode sequence parameter set information from the stream.
Function allocates memory for offsetForRefFrame array if
picture order count type is 1 and numRefFramesInPicOrderCntCycle
is greater than zero.
Inputs:
pStrmData pointer to stream data structure
Outputs:
pSeqParamSet decoded information is stored here
Returns:
HANTRO_OK success
HANTRO_NOK failure, invalid information or end of stream
MEMORY_ALLOCATION_ERROR for memory allocation failure
------------------------------------------------------------------------------*/
void ScalingList(u8 scalingList[][64], strmData_t *pStrmData, u32 idx)
{
u32 lastScale = 8, nextScale = 8;
u32 i, size;
u32 useDefault = 0;
i32 delta;
const u32 *defList[8] = {
default4x4Intra, default4x4Intra, default4x4Intra,
default4x4Inter, default4x4Inter, default4x4Inter,
default8x8Intra, default8x8Inter };
const u32 *zigZag;
size = idx < 6 ? 16 : 64;
zigZag = idx < 6 ? zigZag4x4 : zigZag8x8;
for (i = 0; i < size; i++)
{
if (nextScale)
{
u32 tmp = h264bsdDecodeExpGolombSigned(pStrmData, &delta);
(void)tmp; /* TODO: should we check for error here? */
nextScale = (lastScale + delta + 256)&0xFF;
if (!i && !nextScale)
{
useDefault = 1;
break;
}
}
scalingList[idx][zigZag[i]] = nextScale ? nextScale : lastScale;
lastScale = scalingList[idx][zigZag[i]];
}
if (useDefault)
for (i = 0; i < size; i++)
scalingList[idx][zigZag[i]] = defList[idx][i];
}
void FallbackScaling(u8 scalingList[][64], u32 idx)
{
u32 i;
ASSERT(idx < 8);
switch (idx)
{
case 0:
for (i = 0; i < 16; i++)
scalingList[idx][zigZag4x4[i]] = default4x4Intra[i];
break;
case 3:
for (i = 0; i < 16; i++)
scalingList[idx][zigZag4x4[i]] = default4x4Inter[i];
break;
case 6:
for (i = 0; i < 64; i++)
scalingList[idx][zigZag8x8[i]] = default8x8Intra[i];
break;
case 7:
for (i = 0; i < 64; i++)
scalingList[idx][zigZag8x8[i]] = default8x8Inter[i];
break;
default:
for (i = 0; i < 16; i++)
scalingList[idx][i] = scalingList[idx-1][i];
break;
}
}
u32 h264bsdDecodeSeqParamSet(strmData_t *pStrmData, seqParamSet_t *pSeqParamSet)
{
/* Variables */
u32 tmp, i, value;
/* Code */
ASSERT(pStrmData);
ASSERT(pSeqParamSet);
(void)DWLmemset(pSeqParamSet, 0, sizeof(seqParamSet_t));
/* profile_idc */
tmp = h264bsdGetBits(pStrmData, 8);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
if (tmp != 66)
{
DEBUG_PRINT(("NOT BASELINE PROFILE %d\n", tmp));
}
#ifdef ASIC_TRACE_SUPPORT
if (tmp==66)
trace_h264DecodingTools.profileType.baseline = 1;
if (tmp==77)
trace_h264DecodingTools.profileType.main = 1;
if (tmp == 100)
trace_h264DecodingTools.profileType.high = 1;
#endif
pSeqParamSet->profileIdc = tmp;
/* constrained_set0_flag */
tmp = h264bsdGetBits(pStrmData, 1);
pSeqParamSet->constrained_set0_flag = tmp;
/* constrained_set1_flag */
tmp = h264bsdGetBits(pStrmData, 1);
pSeqParamSet->constrained_set1_flag = tmp;
/* constrained_set2_flag */
tmp = h264bsdGetBits(pStrmData, 1);
pSeqParamSet->constrained_set2_flag = tmp;
/* constrained_set3_flag */
tmp = h264bsdGetBits(pStrmData, 1);
pSeqParamSet->constrained_set3_flag = tmp;
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
/* reserved_zero_4bits, values of these bits shall be ignored */
tmp = h264bsdGetBits(pStrmData, 4);
if (tmp == END_OF_STREAM)
{
ERROR_PRINT("reserved_zero_4bits");
return(HANTRO_NOK);
}
tmp = h264bsdGetBits(pStrmData, 8);
if (tmp == END_OF_STREAM)
{
ERROR_PRINT("level_idc");
return(HANTRO_NOK);
}
pSeqParamSet->levelIdc = tmp;
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&pSeqParamSet->seqParameterSetId);
if (tmp != HANTRO_OK)
return(tmp);
if (pSeqParamSet->seqParameterSetId >= MAX_NUM_SEQ_PARAM_SETS)
{
ERROR_PRINT("seq_param_set_id");
return(HANTRO_NOK);
}
if( pSeqParamSet->profileIdc >= 100 )
{
/* chroma_format_idc */
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&value);
if (tmp != HANTRO_OK)
return(tmp);
if( tmp > 1 )
return(HANTRO_NOK);
pSeqParamSet->chromaFormatIdc = value;
if (pSeqParamSet->chromaFormatIdc == 0)
pSeqParamSet->monoChrome = 1;
/* residual_colour_transform_flag (skipped) */
/* bit_depth_luma_minus8 */
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&value);
if (tmp != HANTRO_OK)
return(tmp);
/* bit_depth_chroma_minus8 */
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&value);
if (tmp != HANTRO_OK)
return(tmp);
/* qpprime_y_zero_transform_bypass_flag */
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
/* seq_scaling_matrix_present_flag */
tmp = h264bsdGetBits(pStrmData, 1);
#ifdef ASIC_TRACE_SUPPORT
if (tmp)
trace_h264DecodingTools.scalingMatrixPresentType.seq = 1;
#endif
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pSeqParamSet->scalingMatrixPresentFlag = tmp;
if (tmp)
{
for (i = 0; i < 8; i++)
{
tmp = h264bsdGetBits(pStrmData, 1);
pSeqParamSet->scalingListPresent[i] = tmp;
if (tmp)
{
ScalingList(pSeqParamSet->scalingList, pStrmData, i);
}
else
FallbackScaling(pSeqParamSet->scalingList, i);
}
}
}
else
{
pSeqParamSet->chromaFormatIdc = 1; /* 4:2:0 */
pSeqParamSet->scalingMatrixPresentFlag = 0;
}
/* log2_max_frame_num_minus4 */
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
{
ERROR_PRINT("log2_max_frame_num_minus4");
return(tmp);
}
if (value > 12)
{
ERROR_PRINT("log2_max_frame_num_minus4");
return(HANTRO_NOK);
}
/* maxFrameNum = 2^(log2_max_frame_num_minus4 + 4) */
pSeqParamSet->maxFrameNum = 1 << (value+4);
/* valid POC types are 0, 1 and 2 */
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
{
ERROR_PRINT("pic_order_cnt_type");
return(tmp);
}
if (value > 2)
{
ERROR_PRINT("pic_order_cnt_type");
return(HANTRO_NOK);
}
pSeqParamSet->picOrderCntType = value;
if (pSeqParamSet->picOrderCntType == 0)
{
/* log2_max_pic_order_cnt_lsb_minus4 */
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
if (value > 12)
{
ERROR_PRINT("log2_max_pic_order_cnt_lsb_minus4");
return(HANTRO_NOK);
}
/* maxPicOrderCntLsb = 2^(log2_max_pic_order_cnt_lsb_minus4 + 4) */
pSeqParamSet->maxPicOrderCntLsb = 1 << (value+4);
}
else if (pSeqParamSet->picOrderCntType == 1)
{
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pSeqParamSet->deltaPicOrderAlwaysZeroFlag = (tmp == 1) ? HANTRO_TRUE : HANTRO_FALSE;
tmp = h264bsdDecodeExpGolombSigned(pStrmData,
&pSeqParamSet->offsetForNonRefPic);
if (tmp != HANTRO_OK)
return(tmp);
tmp = h264bsdDecodeExpGolombSigned(pStrmData,
&pSeqParamSet->offsetForTopToBottomField);
if (tmp != HANTRO_OK)
return(tmp);
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&pSeqParamSet->numRefFramesInPicOrderCntCycle);
if (tmp != HANTRO_OK)
return(tmp);
if (pSeqParamSet->numRefFramesInPicOrderCntCycle > 255)
{
ERROR_PRINT("num_ref_frames_in_pic_order_cnt_cycle");
return(HANTRO_NOK);
}
if (pSeqParamSet->numRefFramesInPicOrderCntCycle)
{
/* NOTE: This has to be freed somewhere! */
ALLOCATE(pSeqParamSet->offsetForRefFrame,
pSeqParamSet->numRefFramesInPicOrderCntCycle, i32);
if (pSeqParamSet->offsetForRefFrame == NULL)
return(MEMORY_ALLOCATION_ERROR);
for (i = 0; i < pSeqParamSet->numRefFramesInPicOrderCntCycle; i++)
{
tmp = h264bsdDecodeExpGolombSigned(pStrmData,
pSeqParamSet->offsetForRefFrame + i);
if (tmp != HANTRO_OK)
return(tmp);
}
}
else
{
pSeqParamSet->offsetForRefFrame = NULL;
}
}
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&pSeqParamSet->numRefFrames);
if (tmp != HANTRO_OK)
return(tmp);
if (pSeqParamSet->numRefFrames > MAX_NUM_REF_PICS)
{
ERROR_PRINT("num_ref_frames");
return(HANTRO_NOK);
}
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pSeqParamSet->gapsInFrameNumValueAllowedFlag = (tmp == 1) ? HANTRO_TRUE : HANTRO_FALSE;
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
pSeqParamSet->picWidthInMbs = value + 1;
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
if (tmp != HANTRO_OK)
return(tmp);
pSeqParamSet->picHeightInMbs = value + 1;
/* frame_mbs_only_flag, shall be 1 for baseline profile */
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pSeqParamSet->frameMbsOnlyFlag = tmp;
if (!pSeqParamSet->frameMbsOnlyFlag)
{
pSeqParamSet->mbAdaptiveFrameFieldFlag =
h264bsdGetBits(pStrmData, 1);
pSeqParamSet->picHeightInMbs *= 2;
}
/* direct_8x8_inference_flag */
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pSeqParamSet->direct8x8InferenceFlag = tmp;
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pSeqParamSet->frameCroppingFlag = (tmp == 1) ? HANTRO_TRUE : HANTRO_FALSE;
#ifdef ASIC_TRACE_SUPPORT
if (tmp)
trace_h264DecodingTools.imageCropping = 1;
#endif
if (pSeqParamSet->frameCroppingFlag)
{
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&pSeqParamSet->frameCropLeftOffset);
if (tmp != HANTRO_OK)
return(tmp);
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&pSeqParamSet->frameCropRightOffset);
if (tmp != HANTRO_OK)
return(tmp);
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&pSeqParamSet->frameCropTopOffset);
if (tmp != HANTRO_OK)
return(tmp);
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData,
&pSeqParamSet->frameCropBottomOffset);
if (tmp != HANTRO_OK)
return(tmp);
/* check that frame cropping params are valid, parameters shall
* specify non-negative area within the original picture */
if ( ( (i32)pSeqParamSet->frameCropLeftOffset >
( 8 * (i32)pSeqParamSet->picWidthInMbs -
((i32)pSeqParamSet->frameCropRightOffset + 1) ) ) ||
( (i32)pSeqParamSet->frameCropTopOffset >
( 8 * (i32)pSeqParamSet->picHeightInMbs -
((i32)pSeqParamSet->frameCropBottomOffset + 1) ) ) )
{
ERROR_PRINT("frame_cropping");
return(HANTRO_NOK);
}
}
/* check that image dimensions and levelIdc match */
tmp = pSeqParamSet->picWidthInMbs * pSeqParamSet->picHeightInMbs;
value = GetDpbSize(tmp, pSeqParamSet->levelIdc);
if (value == INVALID_DPB_SIZE || pSeqParamSet->numRefFrames > value)
{
DEBUG_PRINT(("WARNING! Invalid DPB size based on SPS Level!\n"));
DEBUG_PRINT(("WARNING! Using num_ref_frames =%d for DPB size!\n",
pSeqParamSet->numRefFrames));
/* set maxDpbSize to 1 if numRefFrames is zero */
value = pSeqParamSet->numRefFrames ? pSeqParamSet->numRefFrames : 1;
}
pSeqParamSet->maxDpbSize = value;
tmp = h264bsdGetBits(pStrmData, 1);
if (tmp == END_OF_STREAM)
return(HANTRO_NOK);
pSeqParamSet->vuiParametersPresentFlag = (tmp == 1) ? HANTRO_TRUE : HANTRO_FALSE;
/* VUI */
if (pSeqParamSet->vuiParametersPresentFlag)
{
ALLOCATE(pSeqParamSet->vuiParameters, 1, vuiParameters_t);
if (pSeqParamSet->vuiParameters == NULL)
return(MEMORY_ALLOCATION_ERROR);
tmp = h264bsdDecodeVuiParameters(pStrmData,
pSeqParamSet->vuiParameters);
if (tmp == END_OF_STREAM)
{
pSeqParamSet->vuiParameters->bitstreamRestrictionFlag |= 1;
pSeqParamSet->vuiParameters->maxDecFrameBuffering =
pSeqParamSet->maxDpbSize;
}
else if (tmp != HANTRO_OK)
return(tmp);
/* check numReorderFrames and maxDecFrameBuffering */
if (pSeqParamSet->vuiParameters->bitstreamRestrictionFlag)
{
if (pSeqParamSet->vuiParameters->numReorderFrames >
pSeqParamSet->vuiParameters->maxDecFrameBuffering ||
pSeqParamSet->vuiParameters->maxDecFrameBuffering <
pSeqParamSet->numRefFrames ||
pSeqParamSet->vuiParameters->maxDecFrameBuffering >
pSeqParamSet->maxDpbSize)
{
ERROR_PRINT("Not valid vuiParameters->bitstreamRestriction");
//Add by Sim
//<2F>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Щ<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4>󷵻<EFBFBD>
//return(HANTRO_NOK);
}
/* standard says that "the sequence shall not require a DPB with
* size of more than max(1, maxDecFrameBuffering) */
pSeqParamSet->maxDpbSize =
MAX(1, pSeqParamSet->vuiParameters->maxDecFrameBuffering);
}
}
tmp = h264bsdRbspTrailingBits(pStrmData);
/* ignore possible errors in trailing bits of parameters sets */
return(HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: GetDpbSize
Functional description:
Get size of the DPB in frames. Size is determined based on the
picture size and MaxDPB for the specified level. These determine
how many pictures may fit into to the buffer. However, the size
is also limited to a maximum of 16 frames and therefore function
returns the minimum of the determined size and 16.
Inputs:
picSizeInMbs number of macroblocks in the picture
levelIdc indicates the level
Outputs:
none
Returns:
size of the DPB in frames
INVALID_DPB_SIZE when invalid levelIdc specified or picSizeInMbs
is higher than supported by the level in question
------------------------------------------------------------------------------*/
u32 GetDpbSize(u32 picSizeInMbs, u32 levelIdc)
{
/* Variables */
u32 tmp;
u32 maxPicSizeInMbs;
/* Code */
ASSERT(picSizeInMbs);
/* use tmp as the size of the DPB in bytes, computes as 1024 * MaxDPB
* (from table A-1 in Annex A) */
switch (levelIdc)
{
case 10:
tmp = 152064;
maxPicSizeInMbs = 99;
break;
case 11:
tmp = 345600;
maxPicSizeInMbs = 396;
break;
case 12:
tmp = 912384;
maxPicSizeInMbs = 396;
break;
case 13:
tmp = 912384;
maxPicSizeInMbs = 396;
break;
case 20:
tmp = 912384;
maxPicSizeInMbs = 396;
break;
case 21:
tmp = 1824768;
maxPicSizeInMbs = 792;
break;
case 22:
tmp = 3110400;
maxPicSizeInMbs = 1620;
break;
case 30:
tmp = 3110400;
maxPicSizeInMbs = 1620;
break;
case 31:
tmp = 6912000;
maxPicSizeInMbs = 3600;
break;
case 32:
tmp = 7864320;
maxPicSizeInMbs = 5120;
break;
case 40:
tmp = 12582912;
maxPicSizeInMbs = 8192;
break;
case 41:
tmp = 12582912;
maxPicSizeInMbs = 8192;
break;
case 42:
tmp = 12582912;
maxPicSizeInMbs = 8192;
break;
case 50:
/* standard says 42301440 here, but corrigendum "corrects" this to
* 42393600 */
tmp = 42393600;
maxPicSizeInMbs = 22080;
break;
case 51:
tmp = 70778880;
maxPicSizeInMbs = 36864;
break;
default:
return(INVALID_DPB_SIZE);
}
/* this is not "correct" return value! However, it results in error in
* decoding and this was easiest place to check picture size */
if (picSizeInMbs > maxPicSizeInMbs)
return(INVALID_DPB_SIZE);
tmp /= (picSizeInMbs*384);
return(MIN(tmp, 16));
}
/*------------------------------------------------------------------------------
Function name: h264bsdCompareSeqParamSets
Functional description:
Compare two sequence parameter sets.
Inputs:
pSps1 pointer to a sequence parameter set
pSps2 pointer to another sequence parameter set
Outputs:
0 sequence parameter sets are equal
1 otherwise
------------------------------------------------------------------------------*/
u32 h264bsdCompareSeqParamSets(seqParamSet_t *pSps1, seqParamSet_t *pSps2)
{
/* Variables */
u32 i;
/* Code */
ASSERT(pSps1);
ASSERT(pSps2);
/* first compare parameters whose existence does not depend on other
* parameters and only compare the rest of the params if these are equal */
if (pSps1->profileIdc == pSps2->profileIdc &&
pSps1->levelIdc == pSps2->levelIdc &&
pSps1->maxFrameNum == pSps2->maxFrameNum &&
pSps1->picOrderCntType == pSps2->picOrderCntType &&
pSps1->numRefFrames == pSps2->numRefFrames &&
pSps1->gapsInFrameNumValueAllowedFlag ==
pSps2->gapsInFrameNumValueAllowedFlag &&
pSps1->picWidthInMbs == pSps2->picWidthInMbs &&
pSps1->picHeightInMbs == pSps2->picHeightInMbs &&
pSps1->frameCroppingFlag == pSps2->frameCroppingFlag &&
pSps1->frameMbsOnlyFlag == pSps2->frameMbsOnlyFlag &&
pSps1->vuiParametersPresentFlag == pSps2->vuiParametersPresentFlag &&
pSps1->scalingMatrixPresentFlag == pSps2->scalingMatrixPresentFlag)
{
if (pSps1->picOrderCntType == 0)
{
if (pSps1->maxPicOrderCntLsb != pSps2->maxPicOrderCntLsb)
return 1;
}
else if (pSps1->picOrderCntType == 1)
{
if (pSps1->deltaPicOrderAlwaysZeroFlag !=
pSps2->deltaPicOrderAlwaysZeroFlag ||
pSps1->offsetForNonRefPic != pSps2->offsetForNonRefPic ||
pSps1->offsetForTopToBottomField !=
pSps2->offsetForTopToBottomField ||
pSps1->numRefFramesInPicOrderCntCycle !=
pSps2->numRefFramesInPicOrderCntCycle)
{
return 1;
}
else
{
for (i = 0; i < pSps1->numRefFramesInPicOrderCntCycle; i++)
if (pSps1->offsetForRefFrame[i] !=
pSps2->offsetForRefFrame[i])
{
return 1;
}
}
}
if (pSps1->frameCroppingFlag)
{
if (pSps1->frameCropLeftOffset != pSps2->frameCropLeftOffset ||
pSps1->frameCropRightOffset != pSps2->frameCropRightOffset ||
pSps1->frameCropTopOffset != pSps2->frameCropTopOffset ||
pSps1->frameCropBottomOffset != pSps2->frameCropBottomOffset)
{
return 1;
}
}
if (!pSps1->frameMbsOnlyFlag)
if (pSps1->mbAdaptiveFrameFieldFlag !=
pSps2->mbAdaptiveFrameFieldFlag)
return 1;
/* copy scaling matrices if used */
if (pSps1->scalingMatrixPresentFlag)
{
u32 i, j;
for (i = 0; i < 8; i++)
{
pSps2->scalingListPresent[i] = pSps1->scalingListPresent[i];
for (j = 0; j < 64; j++)
pSps2->scalingList[i][j] = pSps1->scalingList[i][j];
}
}
return 0;
}
return 1;
}

View File

@ -0,0 +1,329 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Decode slice data, i.e. macroblocks of a slice, from the stream
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_slice_data.c,v $
-- $Date: 2008/10/27 12:58:51 $
-- $Revision: 1.2 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "dwl.h"
#include "h264hwd_container.h"
#include "h264hwd_slice_data.h"
#include "h264hwd_util.h"
#include "h264hwd_vlc.h"
#include "h264hwd_exports.h"
/*------------------------------------------------------------------------------
5.1 Function name: h264bsdDecodeSliceData
Functional description:
Decode one slice. Function decodes stream data, i.e. macroblocks
and possible skip_run fields. h264bsdDecodeMacroblock function is
called to handle all other macroblock related processing.
Macroblock to slice group mapping is considered when next
macroblock to process is determined (h264bsdNextMbAddress function)
map
Inputs:
pStrmData pointer to stream data structure
pStorage pointer to storage structure
currImage pointer to current processed picture, needed for
intra prediction of the macroblocks
pSliceHeader pointer to slice header of the current slice
Outputs:
currImage processed macroblocks are written to current image
pStorage mbStorage structure of each processed macroblock
is updated here
Returns:
HANTRO_OK success
HANTRO_NOK invalid stream data
------------------------------------------------------------------------------*/
u32 h264bsdDecodeSliceData(decContainer_t * pDecCont, strmData_t * pStrmData,
sliceHeader_t * pSliceHeader)
{
/* Variables */
u32 tmp;
u32 skipRun;
u32 prevSkipped;
u32 currMbAddr;
u32 moreMbs;
u32 mbCount;
i32 qpY;
macroblockLayer_t *mbLayer;
storage_t *pStorage;
DecAsicBuffers_t *pAsicBuff = NULL;
sliceStorage_t *slice;
/* Code */
ASSERT(pStrmData);
ASSERT(pSliceHeader);
ASSERT(pDecCont);
pStorage = &pDecCont->storage;
mbLayer = pStorage->mbLayer;
slice = pStorage->slice;
pAsicBuff = pDecCont->asicBuff;
currMbAddr = pSliceHeader->firstMbInSlice;
ASSERT(currMbAddr < pStorage->picSizeInMbs);
skipRun = 0;
prevSkipped = HANTRO_FALSE;
/* increment slice index, will be one for decoding of the first slice of
* the picture */
slice->sliceId++;
/* lastMbAddr stores address of the macroblock that was last successfully
* decoded, needed for error handling */
slice->lastMbAddr = 0;
mbCount = 0;
/* initial quantization parameter for the slice is obtained as the sum of
* initial QP for the picture and sliceQpDelta for the current slice */
qpY = (i32) pStorage->activePps->picInitQp + pSliceHeader->sliceQpDelta;
do
{
mbStorage_t *mb = pStorage->mb + currMbAddr;
/* primary picture and already decoded macroblock -> error */
if(!pSliceHeader->redundantPicCnt && mb->decoded)
{
ERROR_PRINT("Primary and already decoded");
return (HANTRO_NOK);
}
mb->sliceId = slice->sliceId;
if(!IS_I_SLICE(pSliceHeader->sliceType))
{
{
if(!prevSkipped)
{
tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &skipRun);
if(tmp != HANTRO_OK)
return (tmp);
if(skipRun == (pStorage->picSizeInMbs << 1) &&
pSliceHeader->frameNum == 0xF)
{
skipRun = MIN(0, pStorage->picSizeInMbs - currMbAddr);
}
/* skip_run shall be less than or equal to number of
* macroblocks left */
#ifdef HANTRO_PEDANTIC_MODE
else if(skipRun > (pStorage->picSizeInMbs - currMbAddr))
{
ERROR_PRINT("skip_run");
return (HANTRO_NOK);
}
#endif /* HANTRO_PEDANTIC_MODE */
if(skipRun)
{
/*mbPred_t *mbPred = &mbLayer->mbPred; */
prevSkipped = HANTRO_TRUE;
/*DWLmemset(&mbLayer->mbPred, 0, sizeof(mbPred_t)); */
/*DWLmemset(mbPred->remIntra4x4PredMode, 0, sizeof(mbPred->remIntra4x4PredMode)); */
/*DWLmemset(mbPred->refIdxL0, 0, sizeof(mbPred->refIdxL0)); */
/* mark current macroblock skipped */
mbLayer->mbType = P_Skip;
}
}
}
}
mbLayer->mbQpDelta = 0;
{
if(skipRun)
{
/*DEBUG_PRINT(("Skipping macroblock %d\n", currMbAddr)); */
skipRun--;
}
else
{
prevSkipped = HANTRO_FALSE;
tmp = h264bsdDecodeMacroblockLayerCavlc(pStrmData, mbLayer,
mb, pSliceHeader);
if(tmp != HANTRO_OK)
{
ERROR_PRINT("macroblock_layer");
return (tmp);
}
}
}
mbLayer->filterOffsetA = pSliceHeader->sliceAlphaC0Offset;
mbLayer->filterOffsetB = pSliceHeader->sliceBetaOffset;
mbLayer->disableDeblockingFilterIdc =
pSliceHeader->disableDeblockingFilterIdc;
pAsicBuff->currentMB = currMbAddr;
tmp = h264bsdDecodeMacroblock(pStorage, currMbAddr, &qpY, pAsicBuff);
if(tmp != HANTRO_OK)
{
ERROR_PRINT("MACRO_BLOCK");
return (tmp);
}
/* increment macroblock count only for macroblocks that were decoded
* for the first time (redundant slices) */
if(mb->decoded == 1)
mbCount++;
{
/* keep on processing as long as there is stream data left or
* processing of macroblocks to be skipped based on the last skipRun is
* not finished */
moreMbs = (h264bsdMoreRbspData(pStrmData) ||
skipRun) ? HANTRO_TRUE : HANTRO_FALSE;
}
/* lastMbAddr is only updated for intra slices (all macroblocks of
* inter slices will be lost in case of an error) */
if(IS_I_SLICE(pSliceHeader->sliceType))
slice->lastMbAddr = currMbAddr;
currMbAddr = h264bsdNextMbAddress(pStorage->sliceGroupMap,
pStorage->picSizeInMbs, currMbAddr);
/* data left in the buffer but no more macroblocks for current slice
* group -> error */
if(moreMbs && !currMbAddr)
{
ERROR_PRINT("Next mb address");
return (HANTRO_NOK);
}
}
while(moreMbs);
if((slice->numDecodedMbs + mbCount) > pStorage->picSizeInMbs)
{
ERROR_PRINT("Num decoded mbs");
return (HANTRO_NOK);
}
slice->numDecodedMbs += mbCount;
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
5.3 Function name: h264bsdMarkSliceCorrupted
Functional description:
Mark macroblocks of the slice corrupted. If lastMbAddr in the slice
storage is set -> picWidhtInMbs (or at least 10) macroblocks back
from the lastMbAddr are marked corrupted. However, if lastMbAddr
is not set -> all macroblocks of the slice are marked.
Inputs:
pStorage pointer to storage structure
firstMbInSlice address of the first macroblock in the slice, this
identifies the slice to be marked corrupted
Outputs:
pStorage mbStorage for the corrupted macroblocks updated
Returns:
none
------------------------------------------------------------------------------*/
void h264bsdMarkSliceCorrupted(storage_t * pStorage, u32 firstMbInSlice)
{
/* Variables */
u32 tmp, i;
u32 sliceId;
u32 currMbAddr;
/* Code */
ASSERT(pStorage);
ASSERT(firstMbInSlice < pStorage->picSizeInMbs);
currMbAddr = firstMbInSlice;
sliceId = pStorage->slice->sliceId;
/* DecodeSliceData sets lastMbAddr for I slices -> if it was set, go back
* MAX(picWidthInMbs, 10) macroblocks and start marking from there */
if(pStorage->slice->lastMbAddr)
{
ASSERT(pStorage->mb[pStorage->slice->lastMbAddr].sliceId == sliceId);
i = pStorage->slice->lastMbAddr - 1;
tmp = 0;
while(i > currMbAddr)
{
if(pStorage->mb[i].sliceId == sliceId)
{
tmp++;
if(tmp >= MAX(pStorage->activeSps->picWidthInMbs, 10))
break;
}
i--;
}
currMbAddr = i;
}
do
{
if((pStorage->mb[currMbAddr].sliceId == sliceId) &&
(pStorage->mb[currMbAddr].decoded))
{
pStorage->mb[currMbAddr].decoded--;
}
else
{
break;
}
currMbAddr = h264bsdNextMbAddress(pStorage->sliceGroupMap,
pStorage->picSizeInMbs, currMbAddr);
}
while(currMbAddr);
}

View File

@ -0,0 +1,599 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Compute macroblock to slice group map
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_slice_group_map.c,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Table of contents
1. Include headers
2. External compiler flags
3. Module defines
4. Local function prototypes
5. Functions
DecodeInterleavedMap
DecodeDispersedMap
DecodeForegroundLeftOverMap
DecodeBoxOutMap
DecodeRasterScanMap
DecodeWipeMap
h264bsdDecodeSliceGroupMap
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "dwl.h"
#include "basetype.h"
#include "h264hwd_slice_group_map.h"
#include "h264hwd_cfg.h"
#include "h264hwd_pic_param_set.h"
#include "h264hwd_util.h"
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
static void DecodeInterleavedMap(
u32 *map,
u32 numSliceGroups,
u32 *runLength,
u32 picSize);
static void DecodeDispersedMap(
u32 *map,
u32 numSliceGroups,
u32 picWidth,
u32 picHeight);
static void DecodeForegroundLeftOverMap(
u32 *map,
u32 numSliceGroups,
u32 *topLeft,
u32 *bottomRight,
u32 picWidth,
u32 picHeight);
static void DecodeBoxOutMap(
u32 *map,
u32 sliceGroupChangeDirectionFlag,
u32 unitsInSliceGroup0,
u32 picWidth,
u32 picHeight);
static void DecodeRasterScanMap(
u32 *map,
u32 sliceGroupChangeDirectionFlag,
u32 sizeOfUpperLeftGroup,
u32 picSize);
static void DecodeWipeMap(
u32 *map,
u32 sliceGroupChangeDirectionFlag,
u32 sizeOfUpperLeftGroup,
u32 picWidth,
u32 picHeight);
/*------------------------------------------------------------------------------
Function: DecodeInterleavedMap
Functional description:
Function to decode interleaved slice group map type, i.e. slice
group map type 0.
Inputs:
map pointer to the map
numSliceGroups number of slice groups
runLength run_length[] values for each slice group
picSize picture size in macroblocks
Outputs:
map slice group map is stored here
Returns:
none
------------------------------------------------------------------------------*/
void DecodeInterleavedMap(
u32 *map,
u32 numSliceGroups,
u32 *runLength,
u32 picSize)
{
/* Variables */
u32 i,j, group;
/* Code */
ASSERT(map);
ASSERT(numSliceGroups >= 1 && numSliceGroups <= MAX_NUM_SLICE_GROUPS);
ASSERT(runLength);
i = 0;
do {
for (group = 0; group < numSliceGroups && i < picSize;
i += runLength[group++])
{
ASSERT(runLength[group] <= picSize);
for (j = 0; j < runLength[group] && i + j < picSize; j++)
map[i+j] = group;
}
} while (i < picSize);
}
/*------------------------------------------------------------------------------
Function: DecodeDispersedMap
Functional description:
Function to decode dispersed slice group map type, i.e. slice
group map type 1.
Inputs:
map pointer to the map
numSliceGroups number of slice groups
picWidth picture width in macroblocks
picHeight picture height in macroblocks
Outputs:
map slice group map is stored here
Returns:
none
------------------------------------------------------------------------------*/
void DecodeDispersedMap(
u32 *map,
u32 numSliceGroups,
u32 picWidth,
u32 picHeight)
{
/* Variables */
u32 i, picSize;
/* Code */
ASSERT(map);
ASSERT(numSliceGroups >= 1 && numSliceGroups <= MAX_NUM_SLICE_GROUPS);
ASSERT(picWidth);
ASSERT(picHeight);
picSize = picWidth * picHeight;
for (i = 0; i < picSize; i++)
map[i] = ((i % picWidth) + (((i / picWidth) * numSliceGroups) >> 1)) %
numSliceGroups;
}
/*------------------------------------------------------------------------------
Function: DecodeForegroundLeftOverMap
Functional description:
Function to decode foreground with left-over slice group map type,
i.e. slice group map type 2.
Inputs:
map pointer to the map
numSliceGroups number of slice groups
topLeft top_left[] values
bottomRight bottom_right[] values
picWidth picture width in macroblocks
picHeight picture height in macroblocks
Outputs:
map slice group map is stored here
Returns:
none
------------------------------------------------------------------------------*/
void DecodeForegroundLeftOverMap(
u32 *map,
u32 numSliceGroups,
u32 *topLeft,
u32 *bottomRight,
u32 picWidth,
u32 picHeight)
{
/* Variables */
u32 i,y,x,yTopLeft,yBottomRight,xTopLeft,xBottomRight, picSize;
u32 group;
/* Code */
ASSERT(map);
ASSERT(numSliceGroups >= 1 && numSliceGroups <= MAX_NUM_SLICE_GROUPS);
ASSERT(topLeft);
ASSERT(bottomRight);
ASSERT(picWidth);
ASSERT(picHeight);
picSize = picWidth * picHeight;
for (i = 0; i < picSize; i++)
map[i] = numSliceGroups - 1;
for (group = numSliceGroups - 1; group--; )
{
ASSERT( topLeft[group] <= bottomRight[group] &&
bottomRight[group] < picSize );
yTopLeft = topLeft[group] / picWidth;
xTopLeft = topLeft[group] % picWidth;
yBottomRight = bottomRight[group] / picWidth;
xBottomRight = bottomRight[group] % picWidth;
ASSERT(xTopLeft <= xBottomRight);
for (y = yTopLeft; y <= yBottomRight; y++)
for (x = xTopLeft; x <= xBottomRight; x++)
map[ y * picWidth + x ] = group;
}
}
/*------------------------------------------------------------------------------
Function: DecodeBoxOutMap
Functional description:
Function to decode box-out slice group map type, i.e. slice group
map type 3.
Inputs:
map pointer to the map
sliceGroupChangeDirectionFlag slice_group_change_direction_flag
unitsInSliceGroup0 mbs on slice group 0
picWidth picture width in macroblocks
picHeight picture height in macroblocks
Outputs:
map slice group map is stored here
Returns:
none
------------------------------------------------------------------------------*/
void DecodeBoxOutMap(
u32 *map,
u32 sliceGroupChangeDirectionFlag,
u32 unitsInSliceGroup0,
u32 picWidth,
u32 picHeight)
{
/* Variables */
u32 i, k, picSize;
i32 x, y, xDir, yDir, leftBound, topBound, rightBound, bottomBound;
u32 mapUnitVacant;
/* Code */
ASSERT(map);
ASSERT(picWidth);
ASSERT(picHeight);
picSize = picWidth * picHeight;
ASSERT(unitsInSliceGroup0 <= picSize);
for (i = 0; i < picSize; i++)
map[i] = 1;
x = (picWidth - (u32)sliceGroupChangeDirectionFlag) >> 1;
y = (picHeight - (u32)sliceGroupChangeDirectionFlag) >> 1;
leftBound = x;
topBound = y;
rightBound = x;
bottomBound = y;
xDir = (i32)sliceGroupChangeDirectionFlag - 1;
yDir = (i32)sliceGroupChangeDirectionFlag;
for (k = 0; k < unitsInSliceGroup0; k += mapUnitVacant ? 1 : 0)
{
mapUnitVacant = (map[ (u32)y * picWidth + (u32)x ] == 1) ? HANTRO_TRUE : HANTRO_FALSE;
if (mapUnitVacant)
map[ (u32)y * picWidth + (u32)x ] = 0;
if (xDir == -1 && x == leftBound)
{
leftBound = MAX(leftBound - 1, 0);
x = leftBound;
xDir = 0;
yDir = 2 * (i32)sliceGroupChangeDirectionFlag - 1;
}
else if (xDir == 1 && x == rightBound)
{
rightBound = MIN(rightBound + 1, (i32)picWidth - 1);
x = rightBound;
xDir = 0;
yDir = 1 - 2 * (i32)sliceGroupChangeDirectionFlag;
}
else if (yDir == -1 && y == topBound)
{
topBound = MAX(topBound - 1, 0);
y = topBound;
xDir = 1 - 2 * (i32)sliceGroupChangeDirectionFlag;
yDir = 0;
}
else if (yDir == 1 && y == bottomBound)
{
bottomBound = MIN(bottomBound + 1, (i32)picHeight - 1);
y = bottomBound;
xDir = 2 * (i32)sliceGroupChangeDirectionFlag - 1;
yDir = 0;
}
else
{
x += xDir;
y += yDir;
}
}
}
/*------------------------------------------------------------------------------
Function: DecodeRasterScanMap
Functional description:
Function to decode raster scan slice group map type, i.e. slice
group map type 4.
Inputs:
map pointer to the map
sliceGroupChangeDirectionFlag slice_group_change_direction_flag
sizeOfUpperLeftGroup mbs in upperLeftGroup
picSize picture size in macroblocks
Outputs:
map slice group map is stored here
Returns:
none
------------------------------------------------------------------------------*/
void DecodeRasterScanMap(
u32 *map,
u32 sliceGroupChangeDirectionFlag,
u32 sizeOfUpperLeftGroup,
u32 picSize)
{
/* Variables */
u32 i;
/* Code */
ASSERT(map);
ASSERT(picSize);
ASSERT(sizeOfUpperLeftGroup <= picSize);
for (i = 0; i < picSize; i++)
if (i < sizeOfUpperLeftGroup)
map[i] = (u32)sliceGroupChangeDirectionFlag;
else
map[i] = 1 - (u32)sliceGroupChangeDirectionFlag;
}
/*------------------------------------------------------------------------------
Function: DecodeWipeMap
Functional description:
Function to decode wipe slice group map type, i.e. slice group map
type 5.
Inputs:
sliceGroupChangeDirectionFlag slice_group_change_direction_flag
sizeOfUpperLeftGroup mbs in upperLeftGroup
picWidth picture width in macroblocks
picHeight picture height in macroblocks
Outputs:
map slice group map is stored here
Returns:
none
------------------------------------------------------------------------------*/
void DecodeWipeMap(
u32 *map,
u32 sliceGroupChangeDirectionFlag,
u32 sizeOfUpperLeftGroup,
u32 picWidth,
u32 picHeight)
{
/* Variables */
u32 i,j,k;
/* Code */
ASSERT(map);
ASSERT(picWidth);
ASSERT(picHeight);
ASSERT(sizeOfUpperLeftGroup <= picWidth * picHeight);
k = 0;
for (j = 0; j < picWidth; j++)
for (i = 0; i < picHeight; i++)
if (k++ < sizeOfUpperLeftGroup)
map[ i * picWidth + j ] = (u32)sliceGroupChangeDirectionFlag;
else
map[ i * picWidth + j ] = 1 -
(u32)sliceGroupChangeDirectionFlag;
}
/*------------------------------------------------------------------------------
Function: h264bsdDecodeSliceGroupMap
Functional description:
Function to decode macroblock to slice group map. Construction
of different slice group map types is handled by separate
functions defined above. See standard for details how slice group
maps are computed.
Inputs:
pps active picture parameter set
sliceGroupChangeCycle slice_group_change_cycle
picWidth picture width in macroblocks
picHeight picture height in macroblocks
Outputs:
map slice group map is stored here
Returns:
none
------------------------------------------------------------------------------*/
void h264bsdDecodeSliceGroupMap(
u32 *map,
picParamSet_t *pps,
u32 sliceGroupChangeCycle,
u32 picWidth,
u32 picHeight)
{
/* Variables */
u32 i, picSize, unitsInSliceGroup0 = 0, sizeOfUpperLeftGroup = 0;
/* Code */
ASSERT(map);
ASSERT(pps);
ASSERT(picWidth);
ASSERT(picHeight);
ASSERT(pps->sliceGroupMapType < 7);
picSize = picWidth * picHeight;
/* just one slice group -> all macroblocks belong to group 0 */
if (pps->numSliceGroups == 1)
{
(void) DWLmemset(map, 0, picSize * sizeof(u32));
return;
}
if (pps->sliceGroupMapType > 2 && pps->sliceGroupMapType < 6)
{
ASSERT(pps->sliceGroupChangeRate &&
pps->sliceGroupChangeRate <= picSize);
unitsInSliceGroup0 =
MIN(sliceGroupChangeCycle * pps->sliceGroupChangeRate, picSize);
if (pps->sliceGroupMapType == 4 || pps->sliceGroupMapType == 5)
sizeOfUpperLeftGroup = pps->sliceGroupChangeDirectionFlag ?
(picSize - unitsInSliceGroup0) : unitsInSliceGroup0;
}
switch (pps->sliceGroupMapType)
{
case 0:
DecodeInterleavedMap(map, pps->numSliceGroups,
pps->runLength, picSize);
break;
case 1:
DecodeDispersedMap(map, pps->numSliceGroups, picWidth,
picHeight);
break;
case 2:
DecodeForegroundLeftOverMap(map, pps->numSliceGroups,
pps->topLeft, pps->bottomRight, picWidth, picHeight);
break;
case 3:
DecodeBoxOutMap(map, pps->sliceGroupChangeDirectionFlag,
unitsInSliceGroup0, picWidth, picHeight);
break;
case 4:
DecodeRasterScanMap(map,
pps->sliceGroupChangeDirectionFlag, sizeOfUpperLeftGroup,
picSize);
break;
case 5:
DecodeWipeMap(map, pps->sliceGroupChangeDirectionFlag,
sizeOfUpperLeftGroup, picWidth, picHeight);
break;
default:
ASSERT(pps->sliceGroupId);
for (i = 0; i < picSize; i++)
{
ASSERT(pps->sliceGroupId[i] < pps->numSliceGroups);
map[i] = pps->sliceGroupId[i];
}
break;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,977 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Storage handling functionality
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_storage.c,v $
-- $Date: 2010/01/12 07:06:02 $
-- $Revision: 1.13 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "h264hwd_storage.h"
#include "h264hwd_util.h"
#include "h264hwd_neighbour.h"
#include "h264hwd_slice_group_map.h"
#include "h264hwd_dpb.h"
#include "h264hwd_nal_unit.h"
#include "h264hwd_slice_header.h"
#include "h264hwd_seq_param_set.h"
#include "dwl.h"
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
static u32 CheckPps(picParamSet_t * pps, seqParamSet_t * sps);
/*------------------------------------------------------------------------------
Function name: h264bsdInitStorage
Functional description:
Initialize storage structure. Sets contents of the storage to '0'
except for the active parameter set ids, which are initialized
to invalid values.
Inputs:
Outputs:
pStorage initialized data stored here
Returns:
none
------------------------------------------------------------------------------*/
void h264bsdInitStorage(storage_t * pStorage)
{
/* Variables */
/* Code */
ASSERT(pStorage);
(void) DWLmemset(pStorage, 0, sizeof(storage_t));
pStorage->activeSpsId = MAX_NUM_SEQ_PARAM_SETS;
pStorage->activePpsId = MAX_NUM_PIC_PARAM_SETS;
pStorage->oldSpsId = MAX_NUM_SEQ_PARAM_SETS;
pStorage->aub->firstCallFlag = HANTRO_TRUE;
}
/*------------------------------------------------------------------------------
Function: h264bsdStoreSeqParamSet
Functional description:
Store sequence parameter set into the storage. If active SPS is
overwritten -> check if contents changes and if it does, set
parameters to force reactivation of parameter sets
Inputs:
pStorage pointer to storage structure
pSeqParamSet pointer to param set to be stored
Outputs:
none
Returns:
HANTRO_OK success
MEMORY_ALLOCATION_ERROR failure in memory allocation
------------------------------------------------------------------------------*/
u32 h264bsdStoreSeqParamSet(storage_t * pStorage, seqParamSet_t * pSeqParamSet)
{
/* Variables */
u32 id;
/* Code */
ASSERT(pStorage);
ASSERT(pSeqParamSet);
ASSERT(pSeqParamSet->seqParameterSetId < MAX_NUM_SEQ_PARAM_SETS);
id = pSeqParamSet->seqParameterSetId;
/* seq parameter set with id not used before -> allocate memory */
if(pStorage->sps[id] == NULL)
{
ALLOCATE(pStorage->sps[id], 1, seqParamSet_t);
if(pStorage->sps[id] == NULL)
return (MEMORY_ALLOCATION_ERROR);
}
/* sequence parameter set with id equal to id of active sps */
else if(id == pStorage->activeSpsId)
{
/* if seq parameter set contents changes
* -> overwrite and re-activate when next IDR picture decoded
* ids of active param sets set to invalid values to force
* re-activation. Memories allocated for old sps freed
* otherwise free memeries allocated for just decoded sps and
* continue */
if(h264bsdCompareSeqParamSets(pSeqParamSet, pStorage->activeSps) != 0)
{
FREE(pStorage->sps[id]->offsetForRefFrame);
FREE(pStorage->sps[id]->vuiParameters);
pStorage->activeSpsId = MAX_NUM_SEQ_PARAM_SETS + 1;
pStorage->activePpsId = MAX_NUM_PIC_PARAM_SETS + 1;
pStorage->activeSps = NULL;
pStorage->activePps = NULL;
}
else
{
FREE(pSeqParamSet->offsetForRefFrame);
FREE(pSeqParamSet->vuiParameters);
return (HANTRO_OK);
}
}
/* overwrite seq param set other than active one -> free memories
* allocated for old param set */
else
{
FREE(pStorage->sps[id]->offsetForRefFrame);
FREE(pStorage->sps[id]->vuiParameters);
}
*pStorage->sps[id] = *pSeqParamSet;
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: h264bsdStorePicParamSet
Functional description:
Store picture parameter set into the storage. If active PPS is
overwritten -> check if active SPS changes and if it does -> set
parameters to force reactivation of parameter sets
Inputs:
pStorage pointer to storage structure
pPicParamSet pointer to param set to be stored
Outputs:
none
Returns:
HANTRO_OK success
MEMORY_ALLOCATION_ERROR failure in memory allocation
------------------------------------------------------------------------------*/
void h264bsdModifyScalingLists(storage_t *pStorage, picParamSet_t *pPicParamSet)
{
u32 i;
seqParamSet_t *sps;
sps = pStorage->sps[pPicParamSet->seqParameterSetId];
/* SPS not yet decoded -> cannot copy */
/* TODO: set flag to handle "missing" SPS lists properly */
if (sps == NULL)
return;
if (!pPicParamSet->scalingMatrixPresentFlag &&
sps->scalingMatrixPresentFlag)
{
pPicParamSet->scalingMatrixPresentFlag = 1;
(void)DWLmemcpy(pPicParamSet->scalingList, sps->scalingList,
sizeof(sps->scalingList));
}
else if (sps->scalingMatrixPresentFlag)
{
if (!pPicParamSet->scalingListPresent[0])
{
/* we trust our memcpy */
(void)DWLmemcpy(pPicParamSet->scalingList[0], sps->scalingList[0],
16*sizeof(u8));
for (i = 1; i < 3; i++)
if (!pPicParamSet->scalingListPresent[i])
(void)DWLmemcpy(pPicParamSet->scalingList[i],
pPicParamSet->scalingList[i-1],
16*sizeof(u8));
}
if (!pPicParamSet->scalingListPresent[3])
{
(void)DWLmemcpy(pPicParamSet->scalingList[3], sps->scalingList[3],
16*sizeof(u8));
for (i = 4; i < 6; i++)
if (!pPicParamSet->scalingListPresent[i])
(void)DWLmemcpy(pPicParamSet->scalingList[i],
pPicParamSet->scalingList[i-1],
16*sizeof(u8));
}
for (i = 6; i < 8; i++)
if (!pPicParamSet->scalingListPresent[i])
(void)DWLmemcpy(pPicParamSet->scalingList[i], sps->scalingList[i],
64*sizeof(u8));
}
}
u32 h264bsdStorePicParamSet(storage_t * pStorage, picParamSet_t * pPicParamSet)
{
/* Variables */
u32 id;
/* Code */
ASSERT(pStorage);
ASSERT(pPicParamSet);
ASSERT(pPicParamSet->picParameterSetId < MAX_NUM_PIC_PARAM_SETS);
ASSERT(pPicParamSet->seqParameterSetId < MAX_NUM_SEQ_PARAM_SETS);
id = pPicParamSet->picParameterSetId;
/* pic parameter set with id not used before -> allocate memory */
if(pStorage->pps[id] == NULL)
{
ALLOCATE(pStorage->pps[id], 1, picParamSet_t);
if(pStorage->pps[id] == NULL)
return (MEMORY_ALLOCATION_ERROR);
}
/* picture parameter set with id equal to id of active pps */
else if(id == pStorage->activePpsId)
{
/* check whether seq param set changes, force re-activation of
* param set if it does. Set activeSpsId to invalid value to
* accomplish this */
if(pPicParamSet->seqParameterSetId != pStorage->activeSpsId)
{
pStorage->activePpsId = MAX_NUM_PIC_PARAM_SETS + 1;
}
/* free memories allocated for old param set */
FREE(pStorage->pps[id]->runLength);
FREE(pStorage->pps[id]->topLeft);
FREE(pStorage->pps[id]->bottomRight);
FREE(pStorage->pps[id]->sliceGroupId);
}
/* overwrite pic param set other than active one -> free memories
* allocated for old param set */
else
{
FREE(pStorage->pps[id]->runLength);
FREE(pStorage->pps[id]->topLeft);
FREE(pStorage->pps[id]->bottomRight);
FREE(pStorage->pps[id]->sliceGroupId);
}
/* Modify scaling_lists if necessary */
h264bsdModifyScalingLists(pStorage, pPicParamSet);
*pStorage->pps[id] = *pPicParamSet;
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: h264bsdActivateParamSets
Functional description:
Activate certain SPS/PPS combination. This function shall be
called in the beginning of each picture. Picture parameter set
can be changed as wanted, but sequence parameter set may only be
changed when the starting picture is an IDR picture.
When new SPS is activated the function allocates memory for
macroblock storages and slice group map and (re-)initializes the
decoded picture buffer. If this is not the first activation the old
allocations are freed and FreeDpb called before new allocations.
Inputs:
pStorage pointer to storage data structure
ppsId identifies the PPS to be activated, SPS id obtained
from the PPS
isIdr flag to indicate if the picture is an IDR picture
Outputs:
none
Returns:
HANTRO_OK success
HANTRO_NOK non-existing or invalid param set combination,
trying to change SPS with non-IDR picture
MEMORY_ALLOCATION_ERROR failure in memory allocation
------------------------------------------------------------------------------*/
u32 h264bsdActivateParamSets(storage_t * pStorage, u32 ppsId, u32 isIdr)
{
u32 tmp;
ASSERT(pStorage);
ASSERT(ppsId < MAX_NUM_PIC_PARAM_SETS);
/* check that pps and corresponding sps exist */
if((pStorage->pps[ppsId] == NULL) ||
(pStorage->sps[pStorage->pps[ppsId]->seqParameterSetId] == NULL))
{
return (HANTRO_NOK);
}
/* check that pps parameters do not violate picture size constraints */
tmp = CheckPps(pStorage->pps[ppsId],
pStorage->sps[pStorage->pps[ppsId]->seqParameterSetId]);
if(tmp != HANTRO_OK)
return (tmp);
/* first activation */
if(pStorage->activePpsId == MAX_NUM_PIC_PARAM_SETS)
{
pStorage->activePpsId = ppsId;
pStorage->activePps = pStorage->pps[ppsId];
pStorage->activeSpsId = pStorage->activePps->seqParameterSetId;
pStorage->activeSps = pStorage->sps[pStorage->activeSpsId];
}
else if(ppsId != pStorage->activePpsId)
{
/* sequence parameter set shall not change but before an IDR picture */
if(pStorage->pps[ppsId]->seqParameterSetId != pStorage->activeSpsId)
{
DEBUG_PRINT(("SEQ PARAM SET CHANGING...\n"));
if(isIdr)
{
pStorage->activePpsId = ppsId;
pStorage->activePps = pStorage->pps[ppsId];
pStorage->activeSpsId = pStorage->activePps->seqParameterSetId;
pStorage->activeSps = pStorage->sps[pStorage->activeSpsId];
}
else
{
DEBUG_PRINT(("TRYING TO CHANGE SPS IN NON-IDR SLICE\n"));
return (HANTRO_NOK);
}
}
else
{
pStorage->activePpsId = ppsId;
pStorage->activePps = pStorage->pps[ppsId];
}
}
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: h264bsdResetStorage
Functional description:
Reset contents of the storage. This should be called before
processing of new image is started.
Inputs:
pStorage pointer to storage structure
Outputs:
none
Returns:
none
------------------------------------------------------------------------------*/
void h264bsdResetStorage(storage_t * pStorage)
{
/* Variables */
u32 i;
/* Code */
ASSERT(pStorage);
pStorage->slice->numDecodedMbs = 0;
pStorage->slice->sliceId = 0;
#ifdef FFWD_WORKAROUND
pStorage->prevIdrPicReady = HANTRO_FALSE;
#endif /* FFWD_WORKAROUND */
if(pStorage->mb != NULL)
{
for(i = 0; i < pStorage->picSizeInMbs; i++)
{
pStorage->mb[i].sliceId = 0;
pStorage->mb[i].decoded = 0;
}
}
}
/*------------------------------------------------------------------------------
Function: h264bsdIsStartOfPicture
Functional description:
Determine if the decoder is in the start of a picture. This
information is needed to decide if h264bsdActivateParamSets and
h264bsdCheckGapsInFrameNum functions should be called. Function
considers that new picture is starting if no slice headers
have been successfully decoded for the current access unit.
Inputs:
pStorage pointer to storage structure
Outputs:
none
Returns:
HANTRO_TRUE new picture is starting
HANTRO_FALSE not starting
------------------------------------------------------------------------------*/
u32 h264bsdIsStartOfPicture(storage_t * pStorage)
{
/* Variables */
/* Code */
if(pStorage->validSliceInAccessUnit == HANTRO_FALSE)
return (HANTRO_TRUE);
else
return (HANTRO_FALSE);
}
/*------------------------------------------------------------------------------
Function: h264bsdIsEndOfPicture
Functional description:
Determine if the decoder is in the end of a picture. This
information is needed to determine when deblocking filtering
and reference picture marking processes should be performed.
If the decoder is processing primary slices the return value
is determined by checking the value of numDecodedMbs in the
storage. On the other hand, if the decoder is processing
redundant slices the numDecodedMbs may not contain valid
informationa and each macroblock has to be checked separately.
Inputs:
pStorage pointer to storage structure
Outputs:
none
Returns:
HANTRO_TRUE end of picture
HANTRO_FALSE noup
------------------------------------------------------------------------------*/
u32 h264bsdIsEndOfPicture(storage_t * pStorage)
{
/* Variables */
u32 i, tmp;
/* Code */
ASSERT(pStorage != NULL);
/* primary picture */
if(!pStorage->sliceHeader[0].redundantPicCnt)
{
if(pStorage->slice->numDecodedMbs == pStorage->picSizeInMbs)
return (HANTRO_TRUE);
}
else
{
ASSERT(pStorage->mb != NULL);
for(i = 0, tmp = 0; i < pStorage->picSizeInMbs; i++)
tmp += pStorage->mb[i].decoded ? 1 : 0;
if(tmp == pStorage->picSizeInMbs)
return (HANTRO_TRUE);
}
return (HANTRO_FALSE);
}
/*------------------------------------------------------------------------------
Function: h264bsdComputeSliceGroupMap
Functional description:
Compute slice group map. Just call h264bsdDecodeSliceGroupMap with
appropriate parameters.
Inputs:
pStorage pointer to storage structure
sliceGroupChangeCycle
Outputs:
none
Returns:
none
------------------------------------------------------------------------------*/
void h264bsdComputeSliceGroupMap(storage_t * pStorage,
u32 sliceGroupChangeCycle)
{
/* Variables */
/* Code */
h264bsdDecodeSliceGroupMap(pStorage->sliceGroupMap,
pStorage->activePps, sliceGroupChangeCycle,
pStorage->activeSps->picWidthInMbs,
pStorage->activeSps->picHeightInMbs);
}
/*------------------------------------------------------------------------------
Function: h264bsdCheckAccessUnitBoundary
Functional description:
Check if next NAL unit starts a new access unit. Following
conditions specify start of a new access unit:
-NAL unit types 6-11, 13-18 (e.g. SPS, PPS)
following conditions checked only for slice NAL units, values
compared to ones obtained from previous slice:
-NAL unit type differs (slice / IDR slice)
-frame_num differs
-nal_ref_idc differs and one of the values is 0
-POC information differs
-both are IDR slices and idr_pic_id differs
Inputs:
strm pointer to stream data structure
nuNext pointer to NAL unit structure
storage pointer to storage structure
Outputs:
accessUnitBoundaryFlag the result is stored here, HANTRO_TRUE for
access unit boundary, HANTRO_FALSE otherwise
Returns:
HANTRO_OK success
HANTRO_NOK failure, invalid stream data
PARAM_SET_ERROR invalid param set usage
------------------------------------------------------------------------------*/
u32 h264bsdCheckAccessUnitBoundary(strmData_t * strm,
nalUnit_t * nuNext,
storage_t * storage,
u32 * accessUnitBoundaryFlag)
{
/* Variables */
u32 tmp, ppsId, frameNum, idrPicId, picOrderCntLsb;
u32 fieldPicFlag = 0, bottomFieldFlag = 0;
i32 deltaPicOrderCntBottom, deltaPicOrderCnt[2];
#ifdef FFWD_WORKAROUND
u32 firstMbInSlice = 0;
u32 redundantPicCnt = 0;
#endif /* FFWD_WORKAROUND */
seqParamSet_t *sps;
picParamSet_t *pps;
/* Code */
ASSERT(strm);
ASSERT(nuNext);
ASSERT(storage);
ASSERT(storage->sps);
ASSERT(storage->pps);
DEBUG_PRINT(("h264bsdCheckAccessUnitBoundary #\n"));
/* initialize default output to HANTRO_FALSE */
*accessUnitBoundaryFlag = HANTRO_FALSE;
/* TODO field_pic_flag, bottom_field_flag */
if(((nuNext->nalUnitType > 5) && (nuNext->nalUnitType < 12)) ||
((nuNext->nalUnitType > 12) && (nuNext->nalUnitType <= 18)))
{
*accessUnitBoundaryFlag = HANTRO_TRUE;
return (HANTRO_OK);
}
else if(nuNext->nalUnitType != NAL_CODED_SLICE &&
nuNext->nalUnitType != NAL_CODED_SLICE_IDR)
{
return (HANTRO_OK);
}
/* check if this is the very first call to this function */
if(storage->aub->firstCallFlag)
{
*accessUnitBoundaryFlag = HANTRO_TRUE;
storage->aub->firstCallFlag = HANTRO_FALSE;
}
/* get picture parameter set id */
tmp = h264bsdCheckPpsId(strm, &ppsId);
if(tmp != HANTRO_OK)
return (tmp);
/* store sps and pps in separate pointers just to make names shorter */
pps = storage->pps[ppsId];
if(pps == NULL || storage->sps[pps->seqParameterSetId] == NULL ||
(storage->activeSpsId != MAX_NUM_SEQ_PARAM_SETS &&
pps->seqParameterSetId != storage->activeSpsId &&
nuNext->nalUnitType != NAL_CODED_SLICE_IDR))
return (PARAM_SET_ERROR);
sps = storage->sps[pps->seqParameterSetId];
if(storage->aub->nuPrev->nalRefIdc != nuNext->nalRefIdc &&
(storage->aub->nuPrev->nalRefIdc == 0 || nuNext->nalRefIdc == 0))
{
*accessUnitBoundaryFlag = HANTRO_TRUE;
storage->aub->newPicture = HANTRO_TRUE;
}
else
storage->aub->newPicture = HANTRO_FALSE;
if((storage->aub->nuPrev->nalUnitType == NAL_CODED_SLICE_IDR &&
nuNext->nalUnitType != NAL_CODED_SLICE_IDR) ||
(storage->aub->nuPrev->nalUnitType != NAL_CODED_SLICE_IDR &&
nuNext->nalUnitType == NAL_CODED_SLICE_IDR))
*accessUnitBoundaryFlag = HANTRO_TRUE;
tmp = h264bsdCheckFrameNum(strm, sps->maxFrameNum, &frameNum);
if(tmp != HANTRO_OK)
return (HANTRO_NOK);
if(storage->aub->prevFrameNum != frameNum)
{
storage->aub->prevFrameNum = frameNum;
*accessUnitBoundaryFlag = HANTRO_TRUE;
}
tmp = h264bsdCheckFieldPicFlag(strm, sps->maxFrameNum, nuNext->nalUnitType,
!sps->frameMbsOnlyFlag, &fieldPicFlag);
if (fieldPicFlag != storage->aub->prevFieldPicFlag)
{
storage->aub->prevFieldPicFlag = fieldPicFlag;
*accessUnitBoundaryFlag = HANTRO_TRUE;
}
tmp = h264bsdCheckBottomFieldFlag(strm, sps->maxFrameNum,
nuNext->nalUnitType,
!sps->frameMbsOnlyFlag, &bottomFieldFlag);
DEBUG_PRINT(("FIELD %d bottom %d\n",fieldPicFlag, bottomFieldFlag));
if (bottomFieldFlag != storage->aub->prevBottomFieldFlag)
{
storage->aub->prevBottomFieldFlag = bottomFieldFlag;
*accessUnitBoundaryFlag = HANTRO_TRUE;
}
if(nuNext->nalUnitType == NAL_CODED_SLICE_IDR)
{
tmp = h264bsdCheckIdrPicId(strm, sps->maxFrameNum,
nuNext->nalUnitType, !sps->frameMbsOnlyFlag, &idrPicId);
if(tmp != HANTRO_OK)
return (HANTRO_NOK);
if(storage->aub->nuPrev->nalUnitType == NAL_CODED_SLICE_IDR &&
storage->aub->prevIdrPicId != idrPicId)
*accessUnitBoundaryFlag = HANTRO_TRUE;
#ifdef FFWD_WORKAROUND
/* FFWD workaround */
if(!*accessUnitBoundaryFlag )
{
/* if prev IDR pic ready and first MB is zero */
tmp = h264bsdCheckFirstMbInSlice( strm,
nuNext->nalUnitType,
&firstMbInSlice );
if( tmp != HANTRO_OK )
return (HANTRO_NOK);
if(storage->prevIdrPicReady && firstMbInSlice == 0)
{
/* Just to make sure, check that next IDR is not marked as
* redundant */
tmp = h264bsdCheckRedundantPicCnt( strm,
sps, pps, nuNext->nalUnitType,
&redundantPicCnt );
if( tmp != HANTRO_OK )
return (HANTRO_NOK);
if( redundantPicCnt == 0 )
{
*accessUnitBoundaryFlag = HANTRO_TRUE;
}
}
}
#endif /* FFWD_WORKAROUND */
storage->aub->prevIdrPicId = idrPicId;
}
if(sps->picOrderCntType == 0)
{
tmp = h264bsdCheckPicOrderCntLsb(strm, sps, nuNext->nalUnitType,
&picOrderCntLsb);
if(tmp != HANTRO_OK)
return (HANTRO_NOK);
if(storage->aub->prevPicOrderCntLsb != picOrderCntLsb)
{
storage->aub->prevPicOrderCntLsb = picOrderCntLsb;
*accessUnitBoundaryFlag = HANTRO_TRUE;
}
if(pps->picOrderPresentFlag)
{
tmp = h264bsdCheckDeltaPicOrderCntBottom(strm, sps,
nuNext->nalUnitType,
&deltaPicOrderCntBottom);
if(tmp != HANTRO_OK)
return (tmp);
if(storage->aub->prevDeltaPicOrderCntBottom !=
deltaPicOrderCntBottom)
{
storage->aub->prevDeltaPicOrderCntBottom =
deltaPicOrderCntBottom;
*accessUnitBoundaryFlag = HANTRO_TRUE;
}
}
}
else if(sps->picOrderCntType == 1 && !sps->deltaPicOrderAlwaysZeroFlag)
{
tmp = h264bsdCheckDeltaPicOrderCnt(strm, sps, nuNext->nalUnitType,
pps->picOrderPresentFlag,
deltaPicOrderCnt);
if(tmp != HANTRO_OK)
return (tmp);
if(storage->aub->prevDeltaPicOrderCnt[0] != deltaPicOrderCnt[0])
{
storage->aub->prevDeltaPicOrderCnt[0] = deltaPicOrderCnt[0];
*accessUnitBoundaryFlag = HANTRO_TRUE;
}
if(pps->picOrderPresentFlag)
if(storage->aub->prevDeltaPicOrderCnt[1] != deltaPicOrderCnt[1])
{
storage->aub->prevDeltaPicOrderCnt[1] = deltaPicOrderCnt[1];
*accessUnitBoundaryFlag = HANTRO_TRUE;
}
}
*storage->aub->nuPrev = *nuNext;
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: CheckPps
Functional description:
Check picture parameter set. Contents of the picture parameter
set information that depends on the image dimensions is checked
against the dimensions in the sps.
Inputs:
pps pointer to picture paramter set
sps pointer to sequence parameter set
Outputs:
none
Returns:
HANTRO_OK everything ok
HANTRO_NOK invalid data in picture parameter set
------------------------------------------------------------------------------*/
u32 CheckPps(picParamSet_t * pps, seqParamSet_t * sps)
{
u32 i;
u32 picSize;
picSize = sps->picWidthInMbs * sps->picHeightInMbs;
/* check slice group params */
if(pps->numSliceGroups > 1)
{
/* no FMO supported if stream may contain interlaced stuff */
if (sps->frameMbsOnlyFlag == 0)
return(HANTRO_NOK);
if(pps->sliceGroupMapType == 0)
{
ASSERT(pps->runLength);
for(i = 0; i < pps->numSliceGroups; i++)
{
if(pps->runLength[i] > picSize)
return (HANTRO_NOK);
}
}
else if(pps->sliceGroupMapType == 2)
{
ASSERT(pps->topLeft);
ASSERT(pps->bottomRight);
for(i = 0; i < pps->numSliceGroups - 1; i++)
{
if(pps->topLeft[i] > pps->bottomRight[i] ||
pps->bottomRight[i] >= picSize)
return (HANTRO_NOK);
if((pps->topLeft[i] % sps->picWidthInMbs) >
(pps->bottomRight[i] % sps->picWidthInMbs))
return (HANTRO_NOK);
}
}
else if(pps->sliceGroupMapType > 2 && pps->sliceGroupMapType < 6)
{
if(pps->sliceGroupChangeRate > picSize)
return (HANTRO_NOK);
}
else if (pps->sliceGroupMapType == 6 &&
pps->picSizeInMapUnits < picSize)
return(HANTRO_NOK);
}
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
Function: h264bsdValidParamSets
Functional description:
Check if any valid SPS/PPS combination exists in the storage.
Function tries each PPS in the buffer and checks if corresponding
SPS exists and calls CheckPps to determine if the PPS conforms
to image dimensions of the SPS.
Inputs:
pStorage pointer to storage structure
Outputs:
HANTRO_OK there is at least one valid combination
HANTRO_NOK no valid combinations found
------------------------------------------------------------------------------*/
u32 h264bsdValidParamSets(storage_t * pStorage)
{
/* Variables */
u32 i;
/* Code */
ASSERT(pStorage);
for(i = 0; i < MAX_NUM_PIC_PARAM_SETS; i++)
{
if(pStorage->pps[i] &&
pStorage->sps[pStorage->pps[i]->seqParameterSetId] &&
CheckPps(pStorage->pps[i],
pStorage->sps[pStorage->pps[i]->seqParameterSetId]) ==
HANTRO_OK)
{
return (HANTRO_OK);
}
}
return (HANTRO_NOK);
}
/*------------------------------------------------------------------------------
Function name : h264bsdAllocateSwResources
Description :
Return type : u32
Argument : const void *dwl
Argument : storage_t * pStorage
Argument : u32 isHighSupported
------------------------------------------------------------------------------*/
u32 h264bsdAllocateSwResources(const void *dwl, storage_t * pStorage,
u32 isHighSupported)
{
u32 tmp;
u32 noReorder;
const seqParamSet_t *pSps = pStorage->activeSps;
pStorage->picSizeInMbs = pSps->picWidthInMbs * pSps->picHeightInMbs;
pStorage->currImage->width = pSps->picWidthInMbs;
pStorage->currImage->height = pSps->picHeightInMbs;
/* dpb output reordering disabled if
* 1) application set noReordering flag
* 2) POC type equal to 2
* 3) num_reorder_frames in vui equal to 0 */
if(pStorage->noReordering ||
pSps->picOrderCntType == 2 ||
(pSps->vuiParametersPresentFlag &&
pSps->vuiParameters->bitstreamRestrictionFlag &&
!pSps->vuiParameters->numReorderFrames))
noReorder = HANTRO_TRUE;
else
noReorder = HANTRO_FALSE;
/* note that calling ResetDpb here results in losing all
* pictures currently in DPB -> nothing will be output from
* the buffer even if noOutputOfPriorPicsFlag is HANTRO_FALSE */
tmp = h264bsdResetDpb(dwl, pStorage->dpb, pStorage->picSizeInMbs,
pSps->maxDpbSize, pSps->numRefFrames,
pSps->maxFrameNum, noReorder, pStorage->useSmoothing,
pSps->monoChrome, isHighSupported,
pStorage->enable2ndChroma && !pSps->monoChrome);
if(tmp != HANTRO_OK)
return (tmp);
return HANTRO_OK;
}

View File

@ -0,0 +1,380 @@
/*------------------------------------------------------------------------------
-- --
-- This software is confidential and proprietary and may be used --
-- only as expressly authorized by a licensing agreement from --
-- --
-- Hantro Products Oy. --
-- --
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
-- ALL RIGHTS RESERVED --
-- --
-- The entire notice above must be reproduced --
-- on all copies and should not be removed. --
-- --
--------------------------------------------------------------------------------
--
-- Abstract : Stream buffer handling
--
--------------------------------------------------------------------------------
--
-- Version control information, please leave untouched.
--
-- $RCSfile: h264hwd_stream.c,v $
-- $Date: 2008/03/13 12:48:06 $
-- $Revision: 1.1 $
--
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "h264hwd_util.h"
#include "h264hwd_stream.h"
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Function: h264bsdGetBits
Functional description:
Read and remove bits from the stream buffer.
Input:
pStrmData pointer to stream data structure
numBits number of bits to read
Output:
none
Returns:
bits read from stream
END_OF_STREAM if not enough bits left
------------------------------------------------------------------------------*/
u32 h264bsdGetBits(strmData_t * pStrmData, u32 numBits)
{
u32 out;
ASSERT(pStrmData);
ASSERT(numBits < 32);
out = h264bsdShowBits(pStrmData, 32) >> (32 - numBits);
if(h264bsdFlushBits(pStrmData, numBits) == HANTRO_OK)
{
return (out);
}
else
{
return (END_OF_STREAM);
}
}
/*------------------------------------------------------------------------------
5.2 Function: HwShowBits
Functional description:
Read bits from input stream. Bits are located right
aligned in the 32-bit output word. In case stream ends,
function fills the word with zeros. For example, numBits = 18 and
there are 7 bits left in the stream buffer -> return
00000000000000xxxxxxx00000000000,
where 'x's represent actual bits read from buffer.
Input:
Output:
------------------------------------------------------------------------------*/
u32 h264bsdShowBits(strmData_t * pStrmData, u32 numBits)
{
i32 bits;
u32 out, outBits;
u32 tmpReadBits;
const u8 *pStrm;
ASSERT(pStrmData);
ASSERT(pStrmData->pStrmCurrPos);
ASSERT(pStrmData->bitPosInWord < 8);
ASSERT(pStrmData->bitPosInWord == (pStrmData->strmBuffReadBits & 0x7));
ASSERT(numBits <= 32);
pStrm = pStrmData->pStrmCurrPos;
/* bits left in the buffer */
bits =
(i32) pStrmData->strmBuffSize * 8 - (i32) pStrmData->strmBuffReadBits;
if(/*!numBits || */!bits) /* for the moment is always called with numBits = 32 */
{
return (0);
}
if(!pStrmData->removeEmul3Byte)
{
out = outBits = 0;
tmpReadBits = pStrmData->strmBuffReadBits;
if(pStrmData->bitPosInWord)
{
out = pStrm[0] << (24 + pStrmData->bitPosInWord);
pStrm++;
outBits = 8 - pStrmData->bitPosInWord;
bits -= outBits;
tmpReadBits += outBits;
}
while(bits && outBits < numBits)
{
/* check emulation prevention byte */
if(tmpReadBits >= 16 &&
pStrm[-2] == 0x0 && pStrm[-1] == 0x0 && pStrm[0] == 0x3)
{
pStrm++;
tmpReadBits += 8;
bits -= 8;
/* emulation prevention byte shall not be the last byte of the
* stream */
if(bits <= 0)
break;
}
tmpReadBits += 8;
if(outBits <= 24)
out |= (u32) (*pStrm++) << (24 - outBits);
else
out |= (u32) (*pStrm++) >> (outBits - 24);
outBits += 8;
bits -= 8;
}
return (out >> (32 - numBits));
}
else
{
u32 shift;
/* at least 32-bits in the buffer */
if(bits >= 32)
{
u32 bitPosInWord = pStrmData->bitPosInWord;
out = ((u32) pStrm[3]) | ((u32) pStrm[2] << 8) |
((u32) pStrm[1] << 16) | ((u32) pStrm[0] << 24);
if(bitPosInWord)
{
out <<= bitPosInWord;
out |= (u32) pStrm[4] >> (8 - bitPosInWord);
}
return (out >> (32 - numBits));
}
/* at least one bit in the buffer */
else if(bits > 0)
{
shift = (i32) (24 + pStrmData->bitPosInWord);
out = (u32) (*pStrm++) << shift;
bits -= (i32) (8 - pStrmData->bitPosInWord);
while(bits > 0)
{
shift -= 8;
out |= (u32) (*pStrm++) << shift;
bits -= 8;
}
return (out >> (32 - numBits));
}
else
return (0);
}
}
/*------------------------------------------------------------------------------
Function: h264bsdFlushBits
Functional description:
Remove bits from the stream buffer
Input:
pStrmData pointer to stream data structure
numBits number of bits to remove
Output:
none
Returns:
HANTRO_OK success
END_OF_STREAM not enough bits left
------------------------------------------------------------------------------*/
u32 h264bsdFlushBits(strmData_t * pStrmData, u32 numBits)
{
u32 bytesLeft;
const u8 *pStrm;
ASSERT(pStrmData);
ASSERT(pStrmData->pStrmBuffStart);
ASSERT(pStrmData->pStrmCurrPos);
ASSERT(pStrmData->bitPosInWord < 8);
ASSERT(pStrmData->bitPosInWord == (pStrmData->strmBuffReadBits & 0x7));
if(!pStrmData->removeEmul3Byte)
{
if((pStrmData->strmBuffReadBits + numBits) >
(8 * pStrmData->strmBuffSize))
{
pStrmData->strmBuffReadBits = 8 * pStrmData->strmBuffSize;
pStrmData->bitPosInWord = 0;
pStrmData->pStrmCurrPos =
pStrmData->pStrmBuffStart + pStrmData->strmBuffSize;
return (END_OF_STREAM);
}
else
{
bytesLeft =
(8 * pStrmData->strmBuffSize - pStrmData->strmBuffReadBits) / 8;
pStrm = pStrmData->pStrmCurrPos;
if(pStrmData->bitPosInWord)
{
if(numBits < 8 - pStrmData->bitPosInWord)
{
pStrmData->strmBuffReadBits += numBits;
pStrmData->bitPosInWord += numBits;
return (HANTRO_OK);
}
numBits -= 8 - pStrmData->bitPosInWord;
pStrmData->strmBuffReadBits += 8 - pStrmData->bitPosInWord;
pStrmData->bitPosInWord = 0;
pStrm++;
if(pStrmData->strmBuffReadBits >= 16 && bytesLeft &&
pStrm[-2] == 0x0 && pStrm[-1] == 0x0 && pStrm[0] == 0x3)
{
pStrm++;
pStrmData->strmBuffReadBits += 8;
bytesLeft--;
pStrmData->emulByteCount++;
}
}
while(numBits >= 8 && bytesLeft)
{
if(bytesLeft > 2 && pStrm[0] == 0 && pStrm[1] == 0 &&
pStrm[2] <= 1)
{
/* trying to flush part of start code prefix -> error */
return (HANTRO_NOK);
}
pStrm++;
pStrmData->strmBuffReadBits += 8;
bytesLeft--;
/* check emulation prevention byte */
if(pStrmData->strmBuffReadBits >= 16 && bytesLeft &&
pStrm[-2] == 0x0 && pStrm[-1] == 0x0 && pStrm[0] == 0x3)
{
pStrm++;
pStrmData->strmBuffReadBits += 8;
bytesLeft--;
pStrmData->emulByteCount++;
}
numBits -= 8;
}
if(numBits && bytesLeft)
{
if(bytesLeft > 2 && pStrm[0] == 0 && pStrm[1] == 0 &&
pStrm[2] <= 1)
{
/* trying to flush part of start code prefix -> error */
return (HANTRO_NOK);
}
pStrmData->strmBuffReadBits += numBits;
pStrmData->bitPosInWord = numBits;
numBits = 0;
}
pStrmData->pStrmCurrPos = pStrm;
if(numBits)
return (END_OF_STREAM);
else
return (HANTRO_OK);
}
}
else
{
pStrmData->strmBuffReadBits += numBits;
pStrmData->bitPosInWord = pStrmData->strmBuffReadBits & 0x7;
if((pStrmData->strmBuffReadBits) <= (8 * pStrmData->strmBuffSize))
{
pStrmData->pStrmCurrPos = pStrmData->pStrmBuffStart +
(pStrmData->strmBuffReadBits >> 3);
return (HANTRO_OK);
}
else
return (END_OF_STREAM);
}
}
/*------------------------------------------------------------------------------
Function: h264bsdIsByteAligned
Functional description:
Check if current stream position is byte aligned.
Inputs:
pStrmData pointer to stream data structure
Outputs:
none
Returns:
HANTRO_TRUE stream is byte aligned
HANTRO_FALSE stream is not byte aligned
------------------------------------------------------------------------------*/
u32 h264bsdIsByteAligned(strmData_t * pStrmData)
{
/* Variables */
/* Code */
if(!pStrmData->bitPosInWord)
return (HANTRO_TRUE);
else
return (HANTRO_FALSE);
}

Some files were not shown because too many files have changed in this diff Show More