XenevaOS
Loading...
Searching...
No Matches
h264bsd_util.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 * Modified for use by h264bsd standalone library
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
20 Table of contents
21
22 1. Include headers
23 2. Module defines
24 3. Data types
25 4. Function prototypes
26
27------------------------------------------------------------------------------*/
28
29#ifndef H264SWDEC_UTIL_H
30#define H264SWDEC_UTIL_H
31
32/*------------------------------------------------------------------------------
33 1. Include headers
34------------------------------------------------------------------------------*/
35
36#include <stdint.h>
37#include "basetype.h"
38#include "h264bsd_cfg.h"
39#include "h264bsd_stream.h"
40#include "h264bsd_image.h"
41#include <string.h>
42#include <stdlib.h>
43
44#ifdef _ASSERT_USED
45#include <assert.h>
46#endif
47
48#if defined(_RANGE_CHECK) || defined(_DEBUG_PRINT) || defined(_ERROR_PRINT)
49#include <stdio.h>
50#endif
51
52/*------------------------------------------------------------------------------
53 2. Module defines
54------------------------------------------------------------------------------*/
55
56#define HANTRO_OK 0
57#define HANTRO_NOK 1
58
59#define HANTRO_TRUE (1)
60#define HANTRO_FALSE (0)
61
62#ifndef NULL
63#define NULL 0
64#endif
65
66#define MEMORY_ALLOCATION_ERROR 0xFFFF
67#define PARAM_SET_ERROR 0xFFF0
68
69/* value to be returned by GetBits if stream buffer is empty */
70#define END_OF_STREAM 0xFFFFFFFFU
71
72#define EMPTY_RESIDUAL_INDICATOR 0xFFFFFF
73
74/* macro to mark a residual block empty, i.e. contain zero coefficients */
75#define MARK_RESIDUAL_EMPTY(residual) ((residual)[0] = EMPTY_RESIDUAL_INDICATOR)
76/* macro to check if residual block is empty */
77#define IS_RESIDUAL_EMPTY(residual) ((residual)[0] == EMPTY_RESIDUAL_INDICATOR)
78
79/* macro for assertion, used only if compiler flag _ASSERT_USED is defined */
80#ifdef _ASSERT_USED
81#define ASSERT(expr) assert(expr)
82#else
83#define ASSERT(expr)
84#endif
85
86/* macro for range checking an value, used only if compiler flag _RANGE_CHECK
87 * is defined */
88#ifdef _RANGE_CHECK
89#define RANGE_CHECK(value, minBound, maxBound) \
90{ \
91 if ((value) < (minBound) || (value) > (maxBound)) \
92 fprintf(stderr, "Warning: Value exceeds given limit(s)!\n"); \
93}
94#else
95#define RANGE_CHECK(value, minBound, maxBound)
96#endif
97
98/* macro for range checking an array, used only if compiler flag _RANGE_CHECK
99 * is defined */
100#ifdef _RANGE_CHECK
101#define RANGE_CHECK_ARRAY(array, minBound, maxBound, length) \
102{ \
103 i32 i; \
104 for (i = 0; i < (length); i++) \
105 if ((array)[i] < (minBound) || (array)[i] > (maxBound)) \
106 fprintf(stderr,"Warning: Value [%d] exceeds given limit(s)!\n",i); \
107}
108#else
109#define RANGE_CHECK_ARRAY(array, minBound, maxBound, length)
110#endif
111
112/* macro for debug printing, used only if compiler flag _DEBUG_PRINT is
113 * defined */
114#ifdef _DEBUG_PRINT
115#define DEBUG(args) printf args
116#else
117#define DEBUG(args) // _KePrint(args)
118#endif
119
120/* macro for error printing, used only if compiler flag _ERROR_PRINT is
121 * defined */
122#ifdef _ERROR_PRINT
123#define EPRINT(msg) fprintf(stderr,"ERROR: %s\n",msg)
124#else
125#define EPRINT(msg) //printf(msg)
126#endif
127
128/* macro to get smaller of two values */
129#define MIN(a, b) (((a) < (b)) ? (a) : (b))
130
131/* macro to get greater of two values */
132#define MAX(a, b) (((a) > (b)) ? (a) : (b))
133
134/* macro to get absolute value */
135#define ABS(a) (((a) < 0) ? -(a) : (a))
136
137/* macro to clip a value z, so that x <= z =< y */
138#define CLIP3(x,y,z) (((z) < (x)) ? (x) : (((z) > (y)) ? (y) : (z)))
139
140/* macro to clip a value z, so that 0 <= z =< 255 */
141#define CLIP1(z) (((z) < 0) ? 0 : (((z) > 255) ? 255 : (z)))
142
143/* macro to allocate memory */
144#define ALLOCATE(ptr, count, type) \
145{ \
146 (ptr) = malloc((count) * sizeof(type)); \
147}
148
149/* macro to free allocated memory */
150#define FREE(ptr) \
151{ \
152 free((ptr)); (ptr) = NULL; \
153}
154
155#define ALIGN(ptr, bytePos) \
156 (ptr + ( ((bytePos - (uintptr_t)ptr) & (bytePos - 1)) / sizeof(*ptr) ))
157
158extern const u32 h264bsdQpC[52];
159
160/*------------------------------------------------------------------------------
161 3. Data types
162------------------------------------------------------------------------------*/
163
164/*------------------------------------------------------------------------------
165 4. Function prototypes
166------------------------------------------------------------------------------*/
167#ifndef H264DEC_NEON
168u32 h264bsdCountLeadingZeros(u32 value, u32 length);
169#else
171#endif
173
175
176u32 h264bsdNextMbAddress(u32 *pSliceGroupMap, u32 picSizeInMbs, u32 currMbAddr);
177
179
181i32 clip(i32 x, i32 y, i32 z);
182
183#endif /* #ifdef H264SWDEC_UTIL_H */
184
#define abs(x)
Definition math.h:146
size_t a
Definition main.cpp:156
signed int i32
Definition basetype.h:34
u32 h264bsdMoreRbspData(strmData_t *strmData)
Definition h264bsd_util.c:172
const u32 h264bsdQpC[52]
Definition h264bsd_util.c:53
void h264bsdSetCurrImageMbPointers(image_t *image, u32 mbNum)
Definition h264bsd_util.c:265
i32 clip(i32 x, i32 y, i32 z)
u32 h264bsdNextMbAddress(u32 *pSliceGroupMap, u32 picSizeInMbs, u32 currMbAddr)
Definition h264bsd_util.c:219
u32 h264bsdRbspTrailingBits(strmData_t *strmData)
Definition h264bsd_util.c:124
u32 h264bsdCountLeadingZeros(u32 value, u32 length)
Definition h264bsd_util.c:81
__u64 image
Definition i915_drm.h:14
uint32_t u32
Definition kernel.h:16
Definition h264bsd_image.h:47
Definition h264bsd_stream.h:47