2
#ifndef __COG_FRAME_H__
3
#define __COG_FRAME_H__
5
#include <cog/cogutils.h>
9
typedef struct _CogFrame CogFrame;
10
typedef struct _CogFrameData CogFrameData;
11
typedef struct _CogUpsampledFrame CogUpsampledFrame;
13
typedef void (*CogFrameFreeFunc)(CogFrame *frame, void *priv);
14
typedef void (*CogFrameRenderFunc)(CogFrame *frame, void *dest, int component, int i);
16
typedef enum _CogColorMatrix {
17
COG_COLOR_MATRIX_UNKNOWN = 0,
18
COG_COLOR_MATRIX_HDTV,
23
* 0x100 - 0: normal, 1: indirect (packed)
24
* 0x001 - horizontal chroma subsampling: 0: 1, 1: 2
25
* 0x002 - vertical chroma subsampling: 0: 1, 1: 2
26
* 0x00c - depth: 0: u8, 1: s16, 2: s32
28
typedef enum _CogFrameFormat {
29
COG_FRAME_FORMAT_U8_444 = 0x00,
30
COG_FRAME_FORMAT_U8_422 = 0x01,
31
COG_FRAME_FORMAT_U8_420 = 0x03,
33
COG_FRAME_FORMAT_S16_444 = 0x04,
34
COG_FRAME_FORMAT_S16_422 = 0x05,
35
COG_FRAME_FORMAT_S16_420 = 0x07,
37
COG_FRAME_FORMAT_S32_444 = 0x08,
38
COG_FRAME_FORMAT_S32_422 = 0x09,
39
COG_FRAME_FORMAT_S32_420 = 0x0b,
41
/* indirectly supported */
42
COG_FRAME_FORMAT_YUYV = 0x100, /* YUYV order */
43
COG_FRAME_FORMAT_UYVY = 0x101, /* UYVY order */
44
COG_FRAME_FORMAT_AYUV = 0x102,
45
COG_FRAME_FORMAT_RGB = 0x104,
46
COG_FRAME_FORMAT_v216 = 0x105,
47
COG_FRAME_FORMAT_v210 = 0x106,
48
COG_FRAME_FORMAT_RGBx = 0x110,
49
COG_FRAME_FORMAT_xRGB = 0x111,
50
COG_FRAME_FORMAT_BGRx = 0x112,
51
COG_FRAME_FORMAT_xBGR = 0x113,
52
COG_FRAME_FORMAT_RGBA = 0x114,
53
COG_FRAME_FORMAT_ARGB = 0x115,
54
COG_FRAME_FORMAT_BGRA = 0x116,
55
COG_FRAME_FORMAT_ABGR = 0x117,
58
#define COG_FRAME_FORMAT_DEPTH(format) ((format) & 0xc)
59
#define COG_FRAME_FORMAT_DEPTH_U8 0x00
60
#define COG_FRAME_FORMAT_DEPTH_S16 0x04
61
#define COG_FRAME_FORMAT_DEPTH_S32 0x08
63
#define COG_FRAME_FORMAT_H_SHIFT(format) ((format) & 0x1)
64
#define COG_FRAME_FORMAT_V_SHIFT(format) (((format)>>1) & 0x1)
66
#define COG_FRAME_IS_PACKED(format) (((format)>>8) & 0x1)
68
#define COG_FRAME_CACHE_SIZE 8
70
struct _CogFrameData {
71
CogFrameFormat format;
83
CogFrameFreeFunc free;
84
CogMemoryDomain *domain;
88
CogFrameFormat format;
92
CogFrameData components[3];
96
int cached_lines[3][COG_FRAME_CACHE_SIZE];
97
CogFrame *virt_frame1;
98
CogFrame *virt_frame2;
99
void (*render_line) (CogFrame *frame, void *dest, int component, int i);
108
struct _CogUpsampledFrame {
113
#define COG_FRAME_DATA_GET_LINE(fd,i) (COG_OFFSET((fd)->data,(fd)->stride*(i)))
114
#define COG_FRAME_DATA_GET_PIXEL_U8(fd,i,j) ((uint8_t *)COG_OFFSET((fd)->data,(fd)->stride*(j)+(i)))
115
#define COG_FRAME_DATA_GET_PIXEL_S16(fd,i,j) ((int16_t *)COG_OFFSET((fd)->data,(fd)->stride*(j)+(i)*sizeof(int16_t)))
117
CogFrame * cog_frame_new (void);
118
CogFrame * cog_frame_new_and_alloc (CogMemoryDomain *domain,
119
CogFrameFormat format, int width, int height);
120
CogFrame * cog_frame_new_from_data_I420 (void *data, int width, int height);
121
CogFrame * cog_frame_new_from_data_YV12 (void *data, int width, int height);
122
CogFrame * cog_frame_new_from_data_YUY2 (void *data, int width, int height);
123
CogFrame * cog_frame_new_from_data_UYVY (void *data, int width, int height);
124
CogFrame * cog_frame_new_from_data_UYVY_full (void *data, int width, int height, int stride);
125
CogFrame * cog_frame_new_from_data_AYUV (void *data, int width, int height);
126
CogFrame * cog_frame_new_from_data_v216 (void *data, int width, int height);
127
CogFrame * cog_frame_new_from_data_v210 (void *data, int width, int height);
128
CogFrame * cog_frame_new_from_data_Y42B (void *data, int width, int height);
129
CogFrame * cog_frame_new_from_data_Y444 (void *data, int width, int height);
130
CogFrame * cog_frame_new_from_data_RGB (void *data, int width, int height);
131
CogFrame * cog_frame_new_from_data_RGBx (void *data, int width, int height);
132
CogFrame * cog_frame_new_from_data_xRGB (void *data, int width, int height);
133
CogFrame * cog_frame_new_from_data_BGRx (void *data, int width, int height);
134
CogFrame * cog_frame_new_from_data_xBGR (void *data, int width, int height);
135
CogFrame * cog_frame_new_from_data_RGBA (void *data, int width, int height);
136
CogFrame * cog_frame_new_from_data_ARGB (void *data, int width, int height);
137
CogFrame * cog_frame_new_from_data_BGRA (void *data, int width, int height);
138
CogFrame * cog_frame_new_from_data_ABGR (void *data, int width, int height);
139
void cog_frame_set_free_callback (CogFrame *frame,
140
CogFrameFreeFunc free_func, void *priv);
141
void cog_frame_unref (CogFrame *frame);
142
CogFrame *cog_frame_ref (CogFrame *frame);
143
CogFrame *cog_frame_dup (CogFrame *frame);
144
CogFrame *cog_frame_clone (CogMemoryDomain *domain, CogFrame *frame);
146
void cog_frame_convert (CogFrame *dest, CogFrame *src);
147
void cog_frame_add (CogFrame *dest, CogFrame *src);
148
void cog_frame_subtract (CogFrame *dest, CogFrame *src);
149
void cog_frame_shift_left (CogFrame *frame, int shift);
150
void cog_frame_shift_right (CogFrame *frame, int shift);
152
//void cog_frame_downsample (CogFrame *dest, CogFrame *src);
153
void cog_frame_upsample_horiz (CogFrame *dest, CogFrame *src);
154
void cog_frame_upsample_vert (CogFrame *dest, CogFrame *src);
155
double cog_frame_calculate_average_luma (CogFrame *frame);
157
CogFrame * cog_frame_convert_to_444 (CogFrame *frame);
158
void cog_frame_md5 (CogFrame *frame, uint32_t *state);
160
CogFrame * cog_frame_new_and_alloc_extended (CogMemoryDomain *domain,
161
CogFrameFormat format, int width, int height, int extension);
162
CogFrame *cog_frame_dup_extended (CogFrame *frame, int extension);
163
void cog_frame_edge_extend (CogFrame *frame, int width, int height);
164
void cog_frame_zero_extend (CogFrame *frame, int width, int height);
165
void cog_frame_mark (CogFrame *frame, int value);
166
void cog_frame_mc_edgeextend (CogFrame *frame);
168
void cog_frame_data_get_codeblock (CogFrameData *dest, CogFrameData *src,
169
int x, int y, int horiz_codeblocks, int vert_codeblocks);
171
CogUpsampledFrame * cog_upsampled_frame_new (CogFrame *frame);
172
void cog_upsampled_frame_free (CogUpsampledFrame *df);
173
void cog_upsampled_frame_upsample (CogUpsampledFrame *df);
174
#ifdef ENABLE_MOTION_REF
175
int cog_upsampled_frame_get_pixel_prec0 (CogUpsampledFrame *upframe, int k,
177
int cog_upsampled_frame_get_pixel_prec1 (CogUpsampledFrame *upframe, int k,
179
int cog_upsampled_frame_get_pixel_prec3 (CogUpsampledFrame *upframe, int k,
181
int cog_upsampled_frame_get_pixel_precN (CogUpsampledFrame *upframe, int k,
182
int x, int y, int mv_precision);
184
void cog_upsampled_frame_get_block_precN (CogUpsampledFrame *upframe, int k,
185
int x, int y, int prec, CogFrameData *dest);
186
void cog_upsampled_frame_get_block_fast_precN (CogUpsampledFrame *upframe, int k,
187
int x, int y, int prec, CogFrameData *dest, CogFrameData *fd);
188
void cog_upsampled_frame_get_subdata_prec0 (CogUpsampledFrame *upframe,
189
int k, int x, int y, CogFrameData *fd);
190
void cog_upsampled_frame_get_subdata_prec1 (CogUpsampledFrame *upframe,
191
int k, int x, int y, CogFrameData *fd);
193
void cog_frame_get_subdata (CogFrame *frame, CogFrameData *fd,
194
int comp, int x, int y);
196
void cog_frame_split_fields (CogFrame *dest1, CogFrame *dest2, CogFrame *src);