| 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 |
| 12 #ifndef VP8_COMMON_ONYX_H_ |
| 13 #define VP8_COMMON_ONYX_H_ |
| 14 |
| 15 #ifdef __cplusplus |
| 16 extern "C" |
| 17 { |
| 18 #endif |
| 19 |
| 20 #include "vpx_config.h" |
| 21 #include "vpx/internal/vpx_codec_internal.h" |
| 22 #include "vpx/vp8cx.h" |
| 23 #include "vpx/vpx_encoder.h" |
| 24 #include "vpx_scale/yv12config.h" |
| 25 #include "ppflags.h" |
| 26 |
| 27 struct VP8_COMP; |
| 28 |
| 29 /* Create/destroy static data structures. */ |
| 30 |
| 31 typedef enum |
| 32 { |
| 33 NORMAL = 0, |
| 34 FOURFIVE = 1, |
| 35 THREEFIVE = 2, |
| 36 ONETWO = 3 |
| 37 |
| 38 } VPX_SCALING; |
| 39 |
| 40 typedef enum |
| 41 { |
| 42 USAGE_LOCAL_FILE_PLAYBACK = 0x0, |
| 43 USAGE_STREAM_FROM_SERVER = 0x1, |
| 44 USAGE_CONSTRAINED_QUALITY = 0x2, |
| 45 USAGE_CONSTANT_QUALITY = 0x3 |
| 46 } END_USAGE; |
| 47 |
| 48 |
| 49 typedef enum |
| 50 { |
| 51 MODE_REALTIME = 0x0, |
| 52 MODE_GOODQUALITY = 0x1, |
| 53 MODE_BESTQUALITY = 0x2, |
| 54 MODE_FIRSTPASS = 0x3, |
| 55 MODE_SECONDPASS = 0x4, |
| 56 MODE_SECONDPASS_BEST = 0x5 |
| 57 } MODE; |
| 58 |
| 59 typedef enum |
| 60 { |
| 61 FRAMEFLAGS_KEY = 1, |
| 62 FRAMEFLAGS_GOLDEN = 2, |
| 63 FRAMEFLAGS_ALTREF = 4 |
| 64 } FRAMETYPE_FLAGS; |
| 65 |
| 66 |
| 67 #include <assert.h> |
| 68 static void Scale2Ratio(int mode, int *hr, int *hs) |
| 69 { |
| 70 switch (mode) |
| 71 { |
| 72 case NORMAL: |
| 73 *hr = 1; |
| 74 *hs = 1; |
| 75 break; |
| 76 case FOURFIVE: |
| 77 *hr = 4; |
| 78 *hs = 5; |
| 79 break; |
| 80 case THREEFIVE: |
| 81 *hr = 3; |
| 82 *hs = 5; |
| 83 break; |
| 84 case ONETWO: |
| 85 *hr = 1; |
| 86 *hs = 2; |
| 87 break; |
| 88 default: |
| 89 *hr = 1; |
| 90 *hs = 1; |
| 91 assert(0); |
| 92 break; |
| 93 } |
| 94 } |
| 95 |
| 96 typedef struct |
| 97 { |
| 98 /* 4 versions of bitstream defined: |
| 99 * 0 best quality/slowest decode, 3 lowest quality/fastest decode |
| 100 */ |
| 101 int Version; |
| 102 int Width; |
| 103 int Height; |
| 104 struct vpx_rational timebase; |
| 105 unsigned int target_bandwidth; /* kilobits per second */ |
| 106 |
| 107 /* Parameter used for applying denoiser. |
| 108 * For temporal denoiser: noise_sensitivity = 0 means off, |
| 109 * noise_sensitivity = 1 means temporal denoiser on for Y channel only, |
| 110 * noise_sensitivity = 2 means temporal denoiser on for all channels. |
| 111 * noise_sensitivity = 3 means aggressive denoising mode. |
| 112 * noise_sensitivity >= 4 means adaptive denoising mode. |
| 113 * Temporal denoiser is enabled via the configuration option: |
| 114 * CONFIG_TEMPORAL_DENOISING. |
| 115 * For spatial denoiser: noise_sensitivity controls the amount of |
| 116 * pre-processing blur: noise_sensitivity = 0 means off. |
| 117 * Spatial denoiser invoked under !CONFIG_TEMPORAL_DENOISING. |
| 118 */ |
| 119 int noise_sensitivity; |
| 120 |
| 121 /* parameter used for sharpening output: recommendation 0: */ |
| 122 int Sharpness; |
| 123 int cpu_used; |
| 124 unsigned int rc_max_intra_bitrate_pct; |
| 125 unsigned int screen_content_mode; |
| 126 |
| 127 /* mode -> |
| 128 *(0)=Realtime/Live Encoding. This mode is optimized for realtim |
| 129 * encoding (for example, capturing a television signal or feed |
| 130 * from a live camera). ( speed setting controls how fast ) |
| 131 *(1)=Good Quality Fast Encoding. The encoder balances quality with |
| 132 * the amount of time it takes to encode the output. ( speed |
| 133 * setting controls how fast ) |
| 134 *(2)=One Pass - Best Quality. The encoder places priority on the |
| 135 * quality of the output over encoding speed. The output is |
| 136 * compressed at the highest possible quality. This option takes |
| 137 * the longest amount of time to encode. ( speed setting ignored |
| 138 * ) |
| 139 *(3)=Two Pass - First Pass. The encoder generates a file of |
| 140 * statistics for use in the second encoding pass. ( speed |
| 141 * setting controls how fast ) |
| 142 *(4)=Two Pass - Second Pass. The encoder uses the statistics that |
| 143 * were generated in the first encoding pass to create the |
| 144 * compressed output. ( speed setting controls how fast ) |
| 145 *(5)=Two Pass - Second Pass Best. The encoder uses the statistics |
| 146 * that were generated in the first encoding pass to create the |
| 147 * compressed output using the highest possible quality, and |
| 148 * taking a longer amount of time to encode.. ( speed setting |
| 149 * ignored ) |
| 150 */ |
| 151 int Mode; |
| 152 |
| 153 /* Key Framing Operations */ |
| 154 int auto_key; /* automatically detect cut scenes */ |
| 155 int key_freq; /* maximum distance to key frame. */ |
| 156 |
| 157 /* lagged compression (if allow_lag == 0 lag_in_frames is ignored) */ |
| 158 int allow_lag; |
| 159 int lag_in_frames; /* how many frames lag before we start encoding */ |
| 160 |
| 161 /* |
| 162 * DATARATE CONTROL OPTIONS |
| 163 */ |
| 164 |
| 165 int end_usage; /* vbr or cbr */ |
| 166 |
| 167 /* buffer targeting aggressiveness */ |
| 168 int under_shoot_pct; |
| 169 int over_shoot_pct; |
| 170 |
| 171 /* buffering parameters */ |
| 172 int64_t starting_buffer_level; |
| 173 int64_t optimal_buffer_level; |
| 174 int64_t maximum_buffer_size; |
| 175 |
| 176 int64_t starting_buffer_level_in_ms; |
| 177 int64_t optimal_buffer_level_in_ms; |
| 178 int64_t maximum_buffer_size_in_ms; |
| 179 |
| 180 /* controlling quality */ |
| 181 int fixed_q; |
| 182 int worst_allowed_q; |
| 183 int best_allowed_q; |
| 184 int cq_level; |
| 185 |
| 186 /* allow internal resizing */ |
| 187 int allow_spatial_resampling; |
| 188 int resample_down_water_mark; |
| 189 int resample_up_water_mark; |
| 190 |
| 191 /* allow internal frame rate alterations */ |
| 192 int allow_df; |
| 193 int drop_frames_water_mark; |
| 194 |
| 195 /* two pass datarate control */ |
| 196 int two_pass_vbrbias; |
| 197 int two_pass_vbrmin_section; |
| 198 int two_pass_vbrmax_section; |
| 199 |
| 200 /* |
| 201 * END DATARATE CONTROL OPTIONS |
| 202 */ |
| 203 |
| 204 /* these parameters aren't to be used in final build don't use!!! */ |
| 205 int play_alternate; |
| 206 int alt_freq; |
| 207 int alt_q; |
| 208 int key_q; |
| 209 int gold_q; |
| 210 |
| 211 |
| 212 int multi_threaded; /* how many threads to run the encoder on */ |
| 213 int token_partitions; /* how many token partitions to create */ |
| 214 |
| 215 /* early breakout threshold: for video conf recommend 800 */ |
| 216 int encode_breakout; |
| 217 |
| 218 /* Bitfield defining the error resiliency features to enable. |
| 219 * Can provide decodable frames after losses in previous |
| 220 * frames and decodable partitions after losses in the same frame. |
| 221 */ |
| 222 unsigned int error_resilient_mode; |
| 223 |
| 224 int arnr_max_frames; |
| 225 int arnr_strength; |
| 226 int arnr_type; |
| 227 |
| 228 vpx_fixed_buf_t two_pass_stats_in; |
| 229 struct vpx_codec_pkt_list *output_pkt_list; |
| 230 |
| 231 vp8e_tuning tuning; |
| 232 |
| 233 /* Temporal scaling parameters */ |
| 234 unsigned int number_of_layers; |
| 235 unsigned int target_bitrate[VPX_TS_MAX_PERIODICITY]; |
| 236 unsigned int rate_decimator[VPX_TS_MAX_PERIODICITY]; |
| 237 unsigned int periodicity; |
| 238 unsigned int layer_id[VPX_TS_MAX_PERIODICITY]; |
| 239 |
| 240 #if CONFIG_MULTI_RES_ENCODING |
| 241 /* Number of total resolutions encoded */ |
| 242 unsigned int mr_total_resolutions; |
| 243 |
| 244 /* Current encoder ID */ |
| 245 unsigned int mr_encoder_id; |
| 246 |
| 247 /* Down-sampling factor */ |
| 248 vpx_rational_t mr_down_sampling_factor; |
| 249 |
| 250 /* Memory location to store low-resolution encoder's mode info */ |
| 251 void* mr_low_res_mode_info; |
| 252 #endif |
| 253 } VP8_CONFIG; |
| 254 |
| 255 |
| 256 void vp8_initialize(); |
| 257 |
| 258 struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf); |
| 259 void vp8_remove_compressor(struct VP8_COMP* *comp); |
| 260 |
| 261 void vp8_init_config(struct VP8_COMP* onyx, VP8_CONFIG *oxcf); |
| 262 void vp8_change_config(struct VP8_COMP* onyx, VP8_CONFIG *oxcf); |
| 263 |
| 264 int vp8_receive_raw_frame(struct VP8_COMP* comp, unsigned int frame_flags, Y
V12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time_stamp); |
| 265 int vp8_get_compressed_data(struct VP8_COMP* comp, unsigned int *frame_flags
, unsigned long *size, unsigned char *dest, unsigned char *dest_end, int64_t *ti
me_stamp, int64_t *time_end, int flush); |
| 266 int vp8_get_preview_raw_frame(struct VP8_COMP* comp, YV12_BUFFER_CONFIG *des
t, vp8_ppflags_t *flags); |
| 267 |
| 268 int vp8_use_as_reference(struct VP8_COMP* comp, int ref_frame_flags); |
| 269 int vp8_update_reference(struct VP8_COMP* comp, int ref_frame_flags); |
| 270 int vp8_get_reference(struct VP8_COMP* comp, enum vpx_ref_frame_type ref_fra
me_flag, YV12_BUFFER_CONFIG *sd); |
| 271 int vp8_set_reference(struct VP8_COMP* comp, enum vpx_ref_frame_type ref_fra
me_flag, YV12_BUFFER_CONFIG *sd); |
| 272 int vp8_update_entropy(struct VP8_COMP* comp, int update); |
| 273 int vp8_set_roimap(struct VP8_COMP* comp, unsigned char *map, unsigned int r
ows, unsigned int cols, int delta_q[4], int delta_lf[4], unsigned int threshold[
4]); |
| 274 int vp8_set_active_map(struct VP8_COMP* comp, unsigned char *map, unsigned i
nt rows, unsigned int cols); |
| 275 int vp8_set_internal_size(struct VP8_COMP* comp, VPX_SCALING horiz_mode, VPX
_SCALING vert_mode); |
| 276 int vp8_get_quantizer(struct VP8_COMP* c); |
| 277 |
| 278 #ifdef __cplusplus |
| 279 } |
| 280 #endif |
| 281 |
| 282 #endif // VP8_COMMON_ONYX_H_ |
| OLD | NEW |