summaryrefslogtreecommitdiff
path: root/drivers/amvdec_ports/utils/common.h (plain)
blob: 9540e28471e28319210ee4d7cf92f40d453e6b11
1#ifndef UTILS_COMMON_H
2#define UTILS_COMMON_H
3
4#include "pixfmt.h"
5
6#define AV_INPUT_BUFFER_PADDING_SIZE 64
7#define MIN_CACHE_BITS 64
8
9#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
10#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
11#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
12#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
13
14#define AV_WL32(p, val) \
15 do { \
16 u32 d = (val); \
17 ((u8*)(p))[0] = (d); \
18 ((u8*)(p))[1] = (d) >> 8; \
19 ((u8*)(p))[2] = (d) >> 16; \
20 ((u8*)(p))[3] = (d) >> 24; \
21 } while(0)
22
23#define AV_WB32(p, val) \
24 do { u32 d = (val); \
25 ((u8*)(p))[3] = (d); \
26 ((u8*)(p))[2] = (d) >> 8; \
27 ((u8*)(p))[1] = (d) >> 16; \
28 ((u8*)(p))[0] = (d) >> 24; \
29 } while(0)
30
31#define AV_RB32(x) \
32 (((u32)((const u8*)(x))[0] << 24) | \
33 (((const u8*)(x))[1] << 16) | \
34 (((const u8*)(x))[2] << 8) | \
35 ((const u8*)(x))[3])
36
37#define AV_RL32(x) \
38 (((u32)((const u8*)(x))[3] << 24) | \
39 (((const u8*)(x))[2] << 16) | \
40 (((const u8*)(x))[1] << 8) | \
41 ((const u8*)(x))[0])
42
43#define NEG_SSR32(a, s) (((int)(a)) >> ((s < 32) ? (32 - (s)) : 0))
44#define NEG_USR32(a, s) (((u32)(a)) >> ((s < 32) ? (32 - (s)) : 0))
45
46//rounded division & shift
47#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
48/* assume b>0 */
49#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
50
51struct AVRational{
52 int num; ///< numerator
53 int den; ///< denominator
54};
55
56//fmt
57const char *av_color_space_name(enum AVColorSpace space);
58const char *av_color_primaries_name(enum AVColorPrimaries primaries);
59const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer);
60
61//math
62int av_log2(u32 v);
63
64//bitstream
65int find_start_code(u8 *data, int data_sz);
66int calc_nal_len(u8 *data, int len);
67u8 *nal_unit_extract_rbsp(const u8 *src, u32 src_len, u32 *dst_len);
68
69//debug
70void print_hex_debug(u8 *data, u32 len, int max);
71
72#endif