1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp8/common/onyx.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,270 @@ 1.4 +/* 1.5 + * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 + 1.15 +#ifndef __INC_VP8_H 1.16 +#define __INC_VP8_H 1.17 + 1.18 +#ifdef __cplusplus 1.19 +extern "C" 1.20 +{ 1.21 +#endif 1.22 + 1.23 +#include "vpx_config.h" 1.24 +#include "vpx/internal/vpx_codec_internal.h" 1.25 +#include "vpx/vp8cx.h" 1.26 +#include "vpx/vpx_encoder.h" 1.27 +#include "vpx_scale/yv12config.h" 1.28 +#include "ppflags.h" 1.29 + 1.30 + struct VP8_COMP; 1.31 + 1.32 + /* Create/destroy static data structures. */ 1.33 + 1.34 + typedef enum 1.35 + { 1.36 + NORMAL = 0, 1.37 + FOURFIVE = 1, 1.38 + THREEFIVE = 2, 1.39 + ONETWO = 3 1.40 + 1.41 + } VPX_SCALING; 1.42 + 1.43 + typedef enum 1.44 + { 1.45 + USAGE_STREAM_FROM_SERVER = 0x0, 1.46 + USAGE_LOCAL_FILE_PLAYBACK = 0x1, 1.47 + USAGE_CONSTRAINED_QUALITY = 0x2, 1.48 + USAGE_CONSTANT_QUALITY = 0x3 1.49 + } END_USAGE; 1.50 + 1.51 + 1.52 + typedef enum 1.53 + { 1.54 + MODE_REALTIME = 0x0, 1.55 + MODE_GOODQUALITY = 0x1, 1.56 + MODE_BESTQUALITY = 0x2, 1.57 + MODE_FIRSTPASS = 0x3, 1.58 + MODE_SECONDPASS = 0x4, 1.59 + MODE_SECONDPASS_BEST = 0x5 1.60 + } MODE; 1.61 + 1.62 + typedef enum 1.63 + { 1.64 + FRAMEFLAGS_KEY = 1, 1.65 + FRAMEFLAGS_GOLDEN = 2, 1.66 + FRAMEFLAGS_ALTREF = 4 1.67 + } FRAMETYPE_FLAGS; 1.68 + 1.69 + 1.70 +#include <assert.h> 1.71 + static void Scale2Ratio(int mode, int *hr, int *hs) 1.72 + { 1.73 + switch (mode) 1.74 + { 1.75 + case NORMAL: 1.76 + *hr = 1; 1.77 + *hs = 1; 1.78 + break; 1.79 + case FOURFIVE: 1.80 + *hr = 4; 1.81 + *hs = 5; 1.82 + break; 1.83 + case THREEFIVE: 1.84 + *hr = 3; 1.85 + *hs = 5; 1.86 + break; 1.87 + case ONETWO: 1.88 + *hr = 1; 1.89 + *hs = 2; 1.90 + break; 1.91 + default: 1.92 + *hr = 1; 1.93 + *hs = 1; 1.94 + assert(0); 1.95 + break; 1.96 + } 1.97 + } 1.98 + 1.99 + typedef struct 1.100 + { 1.101 + /* 4 versions of bitstream defined: 1.102 + * 0 best quality/slowest decode, 3 lowest quality/fastest decode 1.103 + */ 1.104 + int Version; 1.105 + int Width; 1.106 + int Height; 1.107 + struct vpx_rational timebase; 1.108 + unsigned int target_bandwidth; /* kilobits per second */ 1.109 + 1.110 + /* parameter used for applying pre processing blur: recommendation 0 */ 1.111 + int noise_sensitivity; 1.112 + 1.113 + /* parameter used for sharpening output: recommendation 0: */ 1.114 + int Sharpness; 1.115 + int cpu_used; 1.116 + unsigned int rc_max_intra_bitrate_pct; 1.117 + 1.118 + /* mode -> 1.119 + *(0)=Realtime/Live Encoding. This mode is optimized for realtim 1.120 + * encoding (for example, capturing a television signal or feed 1.121 + * from a live camera). ( speed setting controls how fast ) 1.122 + *(1)=Good Quality Fast Encoding. The encoder balances quality with 1.123 + * the amount of time it takes to encode the output. ( speed 1.124 + * setting controls how fast ) 1.125 + *(2)=One Pass - Best Quality. The encoder places priority on the 1.126 + * quality of the output over encoding speed. The output is 1.127 + * compressed at the highest possible quality. This option takes 1.128 + * the longest amount of time to encode. ( speed setting ignored 1.129 + * ) 1.130 + *(3)=Two Pass - First Pass. The encoder generates a file of 1.131 + * statistics for use in the second encoding pass. ( speed 1.132 + * setting controls how fast ) 1.133 + *(4)=Two Pass - Second Pass. The encoder uses the statistics that 1.134 + * were generated in the first encoding pass to create the 1.135 + * compressed output. ( speed setting controls how fast ) 1.136 + *(5)=Two Pass - Second Pass Best. The encoder uses the statistics 1.137 + * that were generated in the first encoding pass to create the 1.138 + * compressed output using the highest possible quality, and 1.139 + * taking a longer amount of time to encode.. ( speed setting 1.140 + * ignored ) 1.141 + */ 1.142 + int Mode; 1.143 + 1.144 + /* Key Framing Operations */ 1.145 + int auto_key; /* automatically detect cut scenes */ 1.146 + int key_freq; /* maximum distance to key frame. */ 1.147 + 1.148 + /* lagged compression (if allow_lag == 0 lag_in_frames is ignored) */ 1.149 + int allow_lag; 1.150 + int lag_in_frames; /* how many frames lag before we start encoding */ 1.151 + 1.152 + /* 1.153 + * DATARATE CONTROL OPTIONS 1.154 + */ 1.155 + 1.156 + int end_usage; /* vbr or cbr */ 1.157 + 1.158 + /* buffer targeting aggressiveness */ 1.159 + int under_shoot_pct; 1.160 + int over_shoot_pct; 1.161 + 1.162 + /* buffering parameters */ 1.163 + int64_t starting_buffer_level; 1.164 + int64_t optimal_buffer_level; 1.165 + int64_t maximum_buffer_size; 1.166 + 1.167 + int64_t starting_buffer_level_in_ms; 1.168 + int64_t optimal_buffer_level_in_ms; 1.169 + int64_t maximum_buffer_size_in_ms; 1.170 + 1.171 + /* controlling quality */ 1.172 + int fixed_q; 1.173 + int worst_allowed_q; 1.174 + int best_allowed_q; 1.175 + int cq_level; 1.176 + 1.177 + /* allow internal resizing */ 1.178 + int allow_spatial_resampling; 1.179 + int resample_down_water_mark; 1.180 + int resample_up_water_mark; 1.181 + 1.182 + /* allow internal frame rate alterations */ 1.183 + int allow_df; 1.184 + int drop_frames_water_mark; 1.185 + 1.186 + /* two pass datarate control */ 1.187 + int two_pass_vbrbias; 1.188 + int two_pass_vbrmin_section; 1.189 + int two_pass_vbrmax_section; 1.190 + 1.191 + /* 1.192 + * END DATARATE CONTROL OPTIONS 1.193 + */ 1.194 + 1.195 + /* these parameters aren't to be used in final build don't use!!! */ 1.196 + int play_alternate; 1.197 + int alt_freq; 1.198 + int alt_q; 1.199 + int key_q; 1.200 + int gold_q; 1.201 + 1.202 + 1.203 + int multi_threaded; /* how many threads to run the encoder on */ 1.204 + int token_partitions; /* how many token partitions to create */ 1.205 + 1.206 + /* early breakout threshold: for video conf recommend 800 */ 1.207 + int encode_breakout; 1.208 + 1.209 + /* Bitfield defining the error resiliency features to enable. 1.210 + * Can provide decodable frames after losses in previous 1.211 + * frames and decodable partitions after losses in the same frame. 1.212 + */ 1.213 + unsigned int error_resilient_mode; 1.214 + 1.215 + int arnr_max_frames; 1.216 + int arnr_strength; 1.217 + int arnr_type; 1.218 + 1.219 + struct vpx_fixed_buf two_pass_stats_in; 1.220 + struct vpx_codec_pkt_list *output_pkt_list; 1.221 + 1.222 + vp8e_tuning tuning; 1.223 + 1.224 + /* Temporal scaling parameters */ 1.225 + unsigned int number_of_layers; 1.226 + unsigned int target_bitrate[VPX_TS_MAX_PERIODICITY]; 1.227 + unsigned int rate_decimator[VPX_TS_MAX_PERIODICITY]; 1.228 + unsigned int periodicity; 1.229 + unsigned int layer_id[VPX_TS_MAX_PERIODICITY]; 1.230 + 1.231 +#if CONFIG_MULTI_RES_ENCODING 1.232 + /* Number of total resolutions encoded */ 1.233 + unsigned int mr_total_resolutions; 1.234 + 1.235 + /* Current encoder ID */ 1.236 + unsigned int mr_encoder_id; 1.237 + 1.238 + /* Down-sampling factor */ 1.239 + vpx_rational_t mr_down_sampling_factor; 1.240 + 1.241 + /* Memory location to store low-resolution encoder's mode info */ 1.242 + void* mr_low_res_mode_info; 1.243 +#endif 1.244 + } VP8_CONFIG; 1.245 + 1.246 + 1.247 + void vp8_initialize(); 1.248 + 1.249 + struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf); 1.250 + void vp8_remove_compressor(struct VP8_COMP* *comp); 1.251 + 1.252 + void vp8_init_config(struct VP8_COMP* onyx, VP8_CONFIG *oxcf); 1.253 + void vp8_change_config(struct VP8_COMP* onyx, VP8_CONFIG *oxcf); 1.254 + 1.255 + int vp8_receive_raw_frame(struct VP8_COMP* comp, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time_stamp); 1.256 + 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 *time_stamp, int64_t *time_end, int flush); 1.257 + int vp8_get_preview_raw_frame(struct VP8_COMP* comp, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *flags); 1.258 + 1.259 + int vp8_use_as_reference(struct VP8_COMP* comp, int ref_frame_flags); 1.260 + int vp8_update_reference(struct VP8_COMP* comp, int ref_frame_flags); 1.261 + int vp8_get_reference(struct VP8_COMP* comp, enum vpx_ref_frame_type ref_frame_flag, YV12_BUFFER_CONFIG *sd); 1.262 + int vp8_set_reference(struct VP8_COMP* comp, enum vpx_ref_frame_type ref_frame_flag, YV12_BUFFER_CONFIG *sd); 1.263 + int vp8_update_entropy(struct VP8_COMP* comp, int update); 1.264 + int vp8_set_roimap(struct VP8_COMP* comp, unsigned char *map, unsigned int rows, unsigned int cols, int delta_q[4], int delta_lf[4], unsigned int threshold[4]); 1.265 + int vp8_set_active_map(struct VP8_COMP* comp, unsigned char *map, unsigned int rows, unsigned int cols); 1.266 + int vp8_set_internal_size(struct VP8_COMP* comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode); 1.267 + int vp8_get_quantizer(struct VP8_COMP* c); 1.268 + 1.269 +#ifdef __cplusplus 1.270 +} 1.271 +#endif 1.272 + 1.273 +#endif