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