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