OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef VP9_COMMON_VP9_ONYX_H_ | |
12 #define VP9_COMMON_VP9_ONYX_H_ | |
13 | |
14 #include "./vpx_config.h" | |
15 #include "vpx/internal/vpx_codec_internal.h" | |
16 #include "vpx/vp8cx.h" | |
17 #include "vpx_scale/yv12config.h" | |
18 #include "vp9/common/vp9_ppflags.h" | |
19 | |
20 #ifdef __cplusplus | |
21 extern "C" { | |
22 #endif | |
23 | |
24 #define MAX_SEGMENTS 8 | |
25 | |
26 typedef int *VP9_PTR; | |
27 | |
28 /* Create/destroy static data structures. */ | |
29 | |
30 typedef enum { | |
31 NORMAL = 0, | |
32 FOURFIVE = 1, | |
33 THREEFIVE = 2, | |
34 ONETWO = 3 | |
35 } VPX_SCALING; | |
36 | |
37 typedef enum { | |
38 VP9_LAST_FLAG = 1, | |
39 VP9_GOLD_FLAG = 2, | |
40 VP9_ALT_FLAG = 4 | |
41 } VP9_REFFRAME; | |
42 | |
43 | |
44 typedef enum { | |
45 USAGE_LOCAL_FILE_PLAYBACK = 0x0, | |
46 USAGE_STREAM_FROM_SERVER = 0x1, | |
47 USAGE_CONSTRAINED_QUALITY = 0x2, | |
48 USAGE_CONSTANT_QUALITY = 0x3, | |
49 } END_USAGE; | |
50 | |
51 | |
52 typedef enum { | |
53 MODE_GOODQUALITY = 0x1, | |
54 MODE_BESTQUALITY = 0x2, | |
55 MODE_FIRSTPASS = 0x3, | |
56 MODE_SECONDPASS = 0x4, | |
57 MODE_SECONDPASS_BEST = 0x5, | |
58 MODE_REALTIME = 0x6, | |
59 } MODE; | |
60 | |
61 typedef enum { | |
62 FRAMEFLAGS_KEY = 1, | |
63 FRAMEFLAGS_GOLDEN = 2, | |
64 FRAMEFLAGS_ALTREF = 4, | |
65 } FRAMETYPE_FLAGS; | |
66 | |
67 typedef enum { | |
68 NO_AQ = 0, | |
69 VARIANCE_AQ = 1, | |
70 COMPLEXITY_AQ = 2, | |
71 AQ_MODES_COUNT // This should always be the last member of the enum | |
72 } AQ_MODES; | |
73 | |
74 typedef struct { | |
75 int version; // 4 versions of bitstream defined: | |
76 // 0 - best quality/slowest decode, | |
77 // 3 - lowest quality/fastest decode | |
78 int width; // width of data passed to the compressor | |
79 int height; // height of data passed to the compressor | |
80 double framerate; // set to passed in framerate | |
81 int64_t target_bandwidth; // bandwidth to be used in kilobits per second | |
82 | |
83 int noise_sensitivity; // pre processing blur: recommendation 0 | |
84 int sharpness; // sharpening output: recommendation 0: | |
85 int cpu_used; | |
86 unsigned int rc_max_intra_bitrate_pct; | |
87 | |
88 // mode -> | |
89 // (0)=Realtime/Live Encoding. This mode is optimized for realtime | |
90 // encoding (for example, capturing a television signal or feed from | |
91 // a live camera). ( speed setting controls how fast ) | |
92 // (1)=Good Quality Fast Encoding. The encoder balances quality with the | |
93 // amount of time it takes to encode the output. ( speed setting | |
94 // controls how fast ) | |
95 // (2)=One Pass - Best Quality. The encoder places priority on the | |
96 // quality of the output over encoding speed. The output is compressed | |
97 // at the highest possible quality. This option takes the longest | |
98 // amount of time to encode. ( speed setting ignored ) | |
99 // (3)=Two Pass - First Pass. The encoder generates a file of statistics | |
100 // for use in the second encoding pass. ( speed setting controls how | |
101 // fast ) | |
102 // (4)=Two Pass - Second Pass. The encoder uses the statistics that were | |
103 // generated in the first encoding pass to create the compressed | |
104 // output. ( speed setting controls how fast ) | |
105 // (5)=Two Pass - Second Pass Best. The encoder uses the statistics that | |
106 // were generated in the first encoding pass to create the compressed | |
107 // output using the highest possible quality, and taking a | |
108 // longer amount of time to encode.. ( speed setting ignored ) | |
109 int mode; | |
110 | |
111 // Key Framing Operations | |
112 int auto_key; // autodetect cut scenes and set the keyframes | |
113 int key_freq; // maximum distance to key frame. | |
114 | |
115 int lag_in_frames; // how many frames lag before we start encoding | |
116 | |
117 // ---------------------------------------------------------------- | |
118 // DATARATE CONTROL OPTIONS | |
119 | |
120 int end_usage; // vbr or cbr | |
121 | |
122 // buffer targeting aggressiveness | |
123 int under_shoot_pct; | |
124 int over_shoot_pct; | |
125 | |
126 // buffering parameters | |
127 int64_t starting_buffer_level; // in seconds | |
128 int64_t optimal_buffer_level; | |
129 int64_t maximum_buffer_size; | |
130 | |
131 // Frame drop threshold. | |
132 int drop_frames_water_mark; | |
133 | |
134 // controlling quality | |
135 int fixed_q; | |
136 int worst_allowed_q; | |
137 int best_allowed_q; | |
138 int cq_level; | |
139 int lossless; | |
140 int aq_mode; // Adaptive Quantization mode | |
141 | |
142 // two pass datarate control | |
143 int two_pass_vbrbias; // two pass datarate control tweaks | |
144 int two_pass_vbrmin_section; | |
145 int two_pass_vbrmax_section; | |
146 // END DATARATE CONTROL OPTIONS | |
147 // ---------------------------------------------------------------- | |
148 | |
149 // Spatial and temporal scalability. | |
150 int ss_number_layers; // Number of spatial layers. | |
151 int ts_number_layers; // Number of temporal layers. | |
152 // Bitrate allocation for spatial layers. | |
153 int ss_target_bitrate[VPX_SS_MAX_LAYERS]; | |
154 // Bitrate allocation (CBR mode) and framerate factor, for temporal layers. | |
155 int ts_target_bitrate[VPX_TS_MAX_LAYERS]; | |
156 int ts_rate_decimator[VPX_TS_MAX_LAYERS]; | |
157 | |
158 // these parameters aren't to be used in final build don't use!!! | |
159 int play_alternate; | |
160 int alt_freq; | |
161 | |
162 int encode_breakout; // early breakout : for video conf recommend 800 | |
163 | |
164 /* Bitfield defining the error resiliency features to enable. | |
165 * Can provide decodable frames after losses in previous | |
166 * frames and decodable partitions after losses in the same frame. | |
167 */ | |
168 unsigned int error_resilient_mode; | |
169 | |
170 /* Bitfield defining the parallel decoding mode where the | |
171 * decoding in successive frames may be conducted in parallel | |
172 * just by decoding the frame headers. | |
173 */ | |
174 unsigned int frame_parallel_decoding_mode; | |
175 | |
176 int arnr_max_frames; | |
177 int arnr_strength; | |
178 int arnr_type; | |
179 | |
180 int tile_columns; | |
181 int tile_rows; | |
182 | |
183 struct vpx_fixed_buf two_pass_stats_in; | |
184 struct vpx_codec_pkt_list *output_pkt_list; | |
185 | |
186 vp8e_tuning tuning; | |
187 } VP9_CONFIG; | |
188 | |
189 | |
190 void vp9_initialize_enc(); | |
191 | |
192 VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf); | |
193 void vp9_remove_compressor(VP9_PTR *comp); | |
194 | |
195 void vp9_change_config(VP9_PTR onyx, VP9_CONFIG *oxcf); | |
196 | |
197 // receive a frames worth of data. caller can assume that a copy of this | |
198 // frame is made and not just a copy of the pointer.. | |
199 int vp9_receive_raw_frame(VP9_PTR comp, unsigned int frame_flags, | |
200 YV12_BUFFER_CONFIG *sd, int64_t time_stamp, | |
201 int64_t end_time_stamp); | |
202 | |
203 int vp9_get_compressed_data(VP9_PTR comp, unsigned int *frame_flags, | |
204 size_t *size, uint8_t *dest, | |
205 int64_t *time_stamp, int64_t *time_end, | |
206 int flush); | |
207 | |
208 int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest, | |
209 vp9_ppflags_t *flags); | |
210 | |
211 int vp9_use_as_reference(VP9_PTR comp, int ref_frame_flags); | |
212 | |
213 int vp9_update_reference(VP9_PTR comp, int ref_frame_flags); | |
214 | |
215 int vp9_copy_reference_enc(VP9_PTR comp, VP9_REFFRAME ref_frame_flag, | |
216 YV12_BUFFER_CONFIG *sd); | |
217 | |
218 int vp9_get_reference_enc(VP9_PTR ptr, int index, YV12_BUFFER_CONFIG **fb); | |
219 | |
220 int vp9_set_reference_enc(VP9_PTR comp, VP9_REFFRAME ref_frame_flag, | |
221 YV12_BUFFER_CONFIG *sd); | |
222 | |
223 int vp9_update_entropy(VP9_PTR comp, int update); | |
224 | |
225 int vp9_set_roimap(VP9_PTR comp, unsigned char *map, | |
226 unsigned int rows, unsigned int cols, | |
227 int delta_q[MAX_SEGMENTS], | |
228 int delta_lf[MAX_SEGMENTS], | |
229 unsigned int threshold[MAX_SEGMENTS]); | |
230 | |
231 int vp9_set_active_map(VP9_PTR comp, unsigned char *map, | |
232 unsigned int rows, unsigned int cols); | |
233 | |
234 int vp9_set_internal_size(VP9_PTR comp, | |
235 VPX_SCALING horiz_mode, VPX_SCALING vert_mode); | |
236 | |
237 int vp9_set_size_literal(VP9_PTR comp, unsigned int width, | |
238 unsigned int height); | |
239 | |
240 void vp9_set_svc(VP9_PTR comp, int use_svc); | |
241 | |
242 int vp9_get_quantizer(VP9_PTR c); | |
243 | |
244 #ifdef __cplusplus | |
245 } // extern "C" | |
246 #endif | |
247 | |
248 #endif // VP9_COMMON_VP9_ONYX_H_ | |
OLD | NEW |