1 /* 2 * 3 * Copyright 2015 Rockchip Electronics Co. LTD 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 19 #ifndef __HAL_H264D_GLOBAL_H__ 20 #define __HAL_H264D_GLOBAL_H__ 21 22 #include "mpp_hal.h" 23 #include "mpp_debug.h" 24 #include "mpp_device.h" 25 #include "hal_bufs.h" 26 27 #include "dxva_syntax.h" 28 #include "h264d_syntax.h" 29 30 31 32 #define H264D_DBG_ERROR (0x00000001) 33 #define H264D_DBG_ASSERT (0x00000002) 34 #define H264D_DBG_WARNNING (0x00000004) 35 #define H264D_DBG_LOG (0x00000008) 36 37 #define H264D_DBG_HARD_MODE (0x00000010) 38 39 extern RK_U32 hal_h264d_debug; 40 41 42 #define H264D_DBG(level, fmt, ...)\ 43 do {\ 44 if (level & hal_h264d_debug)\ 45 { mpp_log(fmt, ## __VA_ARGS__); }\ 46 } while (0) 47 48 49 #define H264D_ERR(fmt, ...)\ 50 do {\ 51 if (H264D_DBG_ERROR & hal_h264d_debug)\ 52 { mpp_log(fmt, ## __VA_ARGS__); }\ 53 } while (0) 54 55 #define ASSERT(val)\ 56 do {\ 57 if (H264D_DBG_ASSERT & hal_h264d_debug)\ 58 { mpp_assert(val); }\ 59 } while (0) 60 61 #define H264D_WARNNING(fmt, ...)\ 62 do {\ 63 if (H264D_DBG_WARNNING & hal_h264d_debug)\ 64 { mpp_log(fmt, ## __VA_ARGS__); }\ 65 } while (0) 66 67 #define H264D_LOG(fmt, ...)\ 68 do {\ 69 if (H264D_DBG_LOG & hal_h264d_debug)\ 70 { mpp_log(fmt, ## __VA_ARGS__); }\ 71 } while (0) 72 73 74 //!< vaule check 75 #define VAL_CHECK(ret, val, ...)\ 76 do{\ 77 if (!(val)){\ 78 ret = MPP_ERR_VALUE; \ 79 H264D_WARNNING("value error(%d).\n", __LINE__); \ 80 goto __FAILED; \ 81 }} while (0) 82 //!< memory malloc check 83 #define MEM_CHECK(ret, val, ...)\ 84 do{\ 85 if (!(val)) {\ 86 ret = MPP_ERR_MALLOC; \ 87 H264D_ERR("malloc buffer error(%d).\n", __LINE__); \ 88 ASSERT(0); goto __FAILED; \ 89 }} while (0) 90 91 92 //!< input check 93 #define INP_CHECK(ret, val, ...)\ 94 do{\ 95 if ((val)) {\ 96 ret = MPP_ERR_INIT; \ 97 H264D_WARNNING("input empty(%d).\n", __LINE__); \ 98 goto __RETURN; \ 99 }} while (0) 100 //!< function return check 101 #define FUN_CHECK(val)\ 102 do{\ 103 if ((val) < 0) {\ 104 H264D_WARNNING("Function error(%d).\n", __LINE__); \ 105 goto __FAILED; \ 106 }} while (0) 107 108 109 typedef struct h264d_hal_ctx_t { 110 MppHalApi hal_api; 111 112 DXVA_PicParams_H264_MVC *pp; 113 DXVA_Qmatrix_H264 *qm; 114 RK_U32 slice_num; 115 DXVA_Slice_H264_Short *slice_short; //!< MAX_SLICES 116 DXVA_Slice_H264_Long *slice_long; //!< MAX_SLICES 117 RK_U8 *bitstream; 118 RK_U32 strm_len; 119 120 void *priv; //!< resert data for extent 121 //!< add 122 HalDecTask *in_task; 123 MppBufSlots frame_slots; 124 MppBufSlots packet_slots; 125 MppDecCfgSet *cfg; 126 MppBufferGroup buf_group; 127 HalBufs cmv_bufs; 128 RK_S32 mv_size; 129 RK_S32 mv_count; 130 131 MppCbCtx *dec_cb; 132 MppDev dev; 133 void *reg_ctx; 134 RK_U32 fast_mode; 135 136 const MppDecHwCap *hw_info; 137 } H264dHalCtx_t; 138 139 #endif /*__HAL_H264D_GLOBAL_H__*/ 140