2 #ifndef __SCHRO_FRAME_H__
3 #define __SCHRO_FRAME_H__
5 #include <schroedinger/schroutils.h>
6 #include <schroedinger/schrodomain.h>
10 typedef struct _SchroFrame SchroFrame
;
11 typedef struct _SchroFrameData SchroFrameData
;
13 typedef void (*SchroFrameFreeFunc
)(SchroFrame
*frame
, void *priv
);
14 typedef void (*SchroFrameRenderFunc
)(SchroFrame
*frame
, void *dest
, int component
, int i
);
17 * 0x100 - 0: normal, 1: indirect (packed)
18 * 0x001 - horizontal chroma subsampling: 0: 1, 1: 2
19 * 0x002 - vertical chroma subsampling: 0: 1, 1: 2
20 * 0x00c - depth: 0: u8, 1: s16, 2: s32
22 typedef enum _SchroFrameFormat
{
23 SCHRO_FRAME_FORMAT_U8_444
= 0x00,
24 SCHRO_FRAME_FORMAT_U8_422
= 0x01,
25 SCHRO_FRAME_FORMAT_U8_420
= 0x03,
27 SCHRO_FRAME_FORMAT_S16_444
= 0x04,
28 SCHRO_FRAME_FORMAT_S16_422
= 0x05,
29 SCHRO_FRAME_FORMAT_S16_420
= 0x07,
31 SCHRO_FRAME_FORMAT_S32_444
= 0x08,
32 SCHRO_FRAME_FORMAT_S32_422
= 0x09,
33 SCHRO_FRAME_FORMAT_S32_420
= 0x0b,
35 /* indirectly supported */
36 SCHRO_FRAME_FORMAT_YUYV
= 0x100, /* YUYV order */
37 SCHRO_FRAME_FORMAT_UYVY
= 0x101, /* UYVY order */
38 SCHRO_FRAME_FORMAT_AYUV
= 0x102,
39 SCHRO_FRAME_FORMAT_ARGB
= 0x103,
40 SCHRO_FRAME_FORMAT_RGB
= 0x104,
41 SCHRO_FRAME_FORMAT_v216
= 0x105,
42 SCHRO_FRAME_FORMAT_v210
= 0x106,
43 SCHRO_FRAME_FORMAT_AY64
= 0x107
46 #define SCHRO_FRAME_FORMAT_DEPTH(format) ((format) & 0xc)
47 #define SCHRO_FRAME_FORMAT_DEPTH_U8 0x00
48 #define SCHRO_FRAME_FORMAT_DEPTH_S16 0x04
49 #define SCHRO_FRAME_FORMAT_DEPTH_S32 0x08
51 #define SCHRO_FRAME_FORMAT_H_SHIFT(format) ((format) & 0x1)
52 #define SCHRO_FRAME_FORMAT_V_SHIFT(format) (((format)>>1) & 0x1)
54 #define SCHRO_FRAME_IS_PACKED(format) (((format)>>8) & 0x1)
56 #define SCHRO_FRAME_CACHE_SIZE 32
58 struct _SchroFrameData
{
59 SchroFrameFormat format
;
71 SchroFrameFreeFunc free
;
72 SchroMemoryDomain
*domain
;
76 SchroFrameFormat format
;
80 SchroFrameData components
[3];
83 int cached_lines
[3][SCHRO_FRAME_CACHE_SIZE
];
84 SchroFrame
*virt_frame1
;
85 SchroFrame
*virt_frame2
;
86 void (*render_line
) (SchroFrame
*frame
, void *dest
, int component
, int i
);
93 schro_bool upsample_done
;
96 #define SCHRO_FRAME_DATA_GET_LINE(fd,i) (SCHRO_OFFSET((fd)->data,(fd)->stride*(i)))
97 #define SCHRO_FRAME_DATA_GET_PIXEL_U8(fd,i,j) ((uint8_t *)SCHRO_OFFSET((fd)->data,(fd)->stride*(j)+(i)))
98 #define SCHRO_FRAME_DATA_GET_PIXEL_S16(fd,i,j) ((int16_t *)SCHRO_OFFSET((fd)->data,(fd)->stride*(j)+(i)*sizeof(int16_t)))
99 #define SCHRO_FRAME_DATA_GET_PIXEL_S32(fd,i,j) ((int32_t *)SCHRO_OFFSET((fd)->data,(fd)->stride*(j)+(i)*sizeof(int32_t)))
101 SchroFrame
* schro_frame_new (void);
102 SchroFrame
* schro_frame_new_and_alloc (SchroMemoryDomain
*domain
,
103 SchroFrameFormat format
, int width
, int height
);
104 SchroFrame
* schro_frame_new_from_data_I420 (void *data
, int width
, int height
);
105 SchroFrame
* schro_frame_new_from_data_Y42B (void *data
, int width
, int height
);
106 SchroFrame
* schro_frame_new_from_data_Y444 (void *data
, int width
, int height
);
107 SchroFrame
* schro_frame_new_from_data_YV12 (void *data
, int width
, int height
);
108 SchroFrame
* schro_frame_new_from_data_YUY2 (void *data
, int width
, int height
);
109 SchroFrame
* schro_frame_new_from_data_UYVY (void *data
, int width
, int height
);
110 SchroFrame
* schro_frame_new_from_data_UYVY_full (void *data
, int width
, int height
, int stride
);
111 SchroFrame
* schro_frame_new_from_data_AYUV (void *data
, int width
, int height
);
112 SchroFrame
* schro_frame_new_from_data_ARGB (void *data
, int width
, int height
);
113 SchroFrame
* schro_frame_new_from_data_v216 (void *data
, int width
, int height
);
114 SchroFrame
* schro_frame_new_from_data_v210 (void *data
, int width
, int height
);
115 SchroFrame
* schro_frame_new_from_data_AY64 (void *data
, int width
, int height
);
116 void schro_frame_set_free_callback (SchroFrame
*frame
,
117 SchroFrameFreeFunc free_func
, void *priv
);
118 void schro_frame_unref (SchroFrame
*frame
);
119 SchroFrame
*schro_frame_ref (SchroFrame
*frame
);
120 SchroFrame
*schro_frame_dup (SchroFrame
*frame
);
121 SchroFrame
*schro_frame_clone (SchroMemoryDomain
*domain
, SchroFrame
*frame
);
123 void schro_frame_convert (SchroFrame
*dest
, SchroFrame
*src
);
124 void schro_frame_add (SchroFrame
*dest
, SchroFrame
*src
);
125 void schro_frame_subtract (SchroFrame
*dest
, SchroFrame
*src
);
126 void schro_frame_shift_left (SchroFrame
*frame
, int shift
);
127 void schro_frame_shift_right (SchroFrame
*frame
, int shift
);
128 void schro_frame_clear (SchroFrame
*frame
);
130 void schro_frame_downsample (SchroFrame
*dest
, SchroFrame
*src
);
131 void schro_frame_upsample_horiz (SchroFrameData
*dest
, SchroFrameData
*src
);
132 void schro_frame_upsample_vert (SchroFrameData
*dest
, SchroFrameData
*src
);
133 double schro_frame_calculate_average_luma (SchroFrame
*frame
);
135 SchroFrame
* schro_frame_convert_to_444 (SchroFrame
*frame
);
136 void schro_frame_md5 (SchroFrame
*frame
, uint32_t *state
);
138 #ifdef SCHRO_ENABLE_UNSTABLE_API
140 SchroFrame
* schro_frame_new_and_alloc_extended (SchroMemoryDomain
*domain
,
141 SchroFrameFormat format
, int width
, int height
, int extension
);
142 SchroFrame
* schro_frame_new_and_alloc_full (SchroMemoryDomain
* domain
,
143 SchroFrameFormat format
, int width
, int height
, int extension
,
145 SchroFrame
*schro_frame_dup_extended (SchroFrame
*frame
, int extension
);
146 SchroFrame
*schro_frame_dup_full (SchroFrame
*frame
, int extension
,
148 void schro_frame_edge_extend (SchroFrame
*frame
, int width
, int height
);
149 void schro_frame_zero_extend (SchroFrame
*frame
, int width
, int height
);
150 void schro_frame_mark (SchroFrame
*frame
, int value
);
151 void schro_frame_mc_edgeextend (SchroFrame
*frame
);
153 void schro_frame_data_get_codeblock (SchroFrameData
*dest
, SchroFrameData
*src
,
154 int x
, int y
, int horiz_codeblocks
, int vert_codeblocks
);
156 void schro_upsampled_frame_get_framedata (SchroFrame
*upframe
,
157 SchroFrameData
*fd
, int up_index
, int component
);
158 SchroFrame
* schro_upsampled_frame_get_frame (SchroFrame
*upframe
,
160 void schro_upsampled_frame_upsample (SchroFrame
*df
);
161 #ifdef ENABLE_MOTION_REF
162 int schro_upsampled_frame_get_pixel_prec0 (SchroFrame
*upframe
, int k
,
164 int schro_upsampled_frame_get_pixel_prec1 (SchroFrame
*upframe
, int k
,
166 int schro_upsampled_frame_get_pixel_prec3 (SchroFrame
*upframe
, int k
,
168 int schro_upsampled_frame_get_pixel_precN (SchroFrame
*upframe
, int k
,
169 int x
, int y
, int mv_precision
);
171 void schro_upsampled_frame_get_block_precN (SchroFrame
*upframe
, int k
,
172 int x
, int y
, int prec
, SchroFrameData
*dest
);
173 void schro_upsampled_frame_get_block_fast_precN (SchroFrame
*upframe
, int k
,
174 int x
, int y
, int prec
, SchroFrameData
*dest
, SchroFrameData
*fd
);
175 void schro_upsampled_frame_get_subdata_prec0 (SchroFrame
*upframe
,
176 int k
, int x
, int y
, SchroFrameData
*fd
);
177 void schro_upsampled_frame_get_subdata_prec1 (SchroFrame
*upframe
,
178 int k
, int x
, int y
, SchroFrameData
*fd
);
180 /* it extracts a block of data from a frame, if possible */
181 int schro_frame_get_data (SchroFrame
* frame
, SchroFrameData
* fd
, int comp
184 void schro_frame_get_subdata (SchroFrame
*frame
, SchroFrameData
*fd
,
185 int comp
, int x
, int y
);
186 void schro_frame_get_reference_subdata (SchroFrame
* frame
, SchroFrameData
* fd
187 , int comp
, int x
, int y
);
189 void schro_frame_split_fields (SchroFrame
*dest1
, SchroFrame
*dest2
, SchroFrame
*src
);
191 int schro_frame_get_bit_depth (SchroFrame
*frame
);