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