2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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.
20 #include "vpx/internal/vpx_codec_internal.h"
21 #include "vpx_scale/yv12config.h"
22 #include "type_aliases.h"
26 /* Create/destroy static data structures. */
47 USAGE_STREAM_FROM_SERVER = 0x0,
48 USAGE_LOCAL_FILE_PLAYBACK = 0x1
55 MODE_GOODQUALITY = 0x1,
56 MODE_BESTQUALITY = 0x2,
58 MODE_SECONDPASS = 0x4,
59 MODE_SECONDPASS_BEST = 0x5,
65 FRAMEFLAGS_GOLDEN = 2,
66 FRAMEFLAGS_ALTREF = 4,
71 static __inline void Scale2Ratio(int mode, int *hr, int *hs)
101 int Version; // 4 versions of bitstream defined 0 best quality/slowest decode, 3 lowest quality/fastest decode
102 int Width; // width of data passed to the compressor
103 int Height; // height of data passed to the compressor
104 double frame_rate; // set to passed in framerate
105 int target_bandwidth; // bandwidth to be used in kilobits per second
107 int noise_sensitivity; // parameter used for applying pre processing blur: recommendation 0
108 int Sharpness; // parameter used for sharpening output: recommendation 0:
112 //(0)=Realtime/Live Encoding. This mode is optimized for realtim encoding (for example, capturing
113 // a television signal or feed from a live camera). ( speed setting controls how fast )
114 //(1)=Good Quality Fast Encoding. The encoder balances quality with the amount of time it takes to
115 // encode the output. ( speed setting controls how fast )
116 //(2)=One Pass - Best Quality. The encoder places priority on the quality of the output over encoding
117 // speed. The output is compressed at the highest possible quality. This option takes the longest
118 // amount of time to encode. ( speed setting ignored )
119 //(3)=Two Pass - First Pass. The encoder generates a file of statistics for use in the second encoding
120 // pass. ( speed setting controls how fast )
121 //(4)=Two Pass - Second Pass. The encoder uses the statistics that were generated in the first encoding
122 // pass to create the compressed output. ( speed setting controls how fast )
123 //(5)=Two Pass - Second Pass Best. The encoder uses the statistics that were generated in the first
124 // encoding pass to create the compressed output using the highest possible quality, and taking a
125 // longer amount of time to encode.. ( speed setting ignored )
128 // Key Framing Operations
129 int auto_key; // automatically detect cut scenes and set the keyframes
130 int key_freq; // maximum distance to key frame.
132 int allow_lag; // allow lagged compression (if 0 lagin frames is ignored)
133 int lag_in_frames; // how many frames lag before we start encoding
135 //----------------------------------------------------------------
136 // DATARATE CONTROL OPTIONS
138 int end_usage; // vbr or cbr
140 // shoot to keep buffer full at all times by undershooting a bit 95 recommended
143 // buffering parameters
144 int starting_buffer_level; // in seconds
145 int optimal_buffer_level;
146 int maximum_buffer_size;
148 // controlling quality
153 // allow internal resizing ( currently disabled in the build !!!!!)
154 int allow_spatial_resampling;
155 int resample_down_water_mark;
156 int resample_up_water_mark;
158 // allow internal frame rate alterations
160 int drop_frames_water_mark;
162 // two pass datarate control
163 int two_pass_vbrbias; // two pass datarate control tweaks
164 int two_pass_vbrmin_section;
165 int two_pass_vbrmax_section;
166 // END DATARATE CONTROL OPTIONS
167 //----------------------------------------------------------------
170 // these parameters aren't to be used in final build don't use!!!
178 int multi_threaded; // how many threads to run the encoder on
179 int token_partitions; // how many token partitions to create for multi core decoding
180 int encode_breakout; // early breakout encode threshold : for video conf recommend 800
182 int error_resilient_mode; // if running over udp networks provides decodable frames after a
190 struct vpx_fixed_buf two_pass_stats_in;
191 struct vpx_codec_pkt_list *output_pkt_list;
195 void vp8_initialize();
197 VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf);
198 void vp8_remove_compressor(VP8_PTR *comp);
200 void vp8_init_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
201 void vp8_change_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
203 // receive a frames worth of data caller can assume that a copy of this frame is made
204 // and not just a copy of the pointer..
205 int vp8_receive_raw_frame(VP8_PTR comp, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, INT64 time_stamp, INT64 end_time_stamp);
206 int vp8_get_compressed_data(VP8_PTR comp, unsigned int *frame_flags, unsigned long *size, unsigned char *dest, INT64 *time_stamp, INT64 *time_end, int flush);
207 int vp8_get_preview_raw_frame(VP8_PTR comp, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *flags);
209 int vp8_use_as_reference(VP8_PTR comp, int ref_frame_flags);
210 int vp8_update_reference(VP8_PTR comp, int ref_frame_flags);
211 int vp8_get_reference(VP8_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
212 int vp8_set_reference(VP8_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
213 int vp8_update_entropy(VP8_PTR comp, int update);
214 int vp8_set_roimap(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols, int delta_q[4], int delta_lf[4], unsigned int threshold[4]);
215 int vp8_set_active_map(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols);
216 int vp8_set_internal_size(VP8_PTR comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode);
217 int vp8_get_quantizer(VP8_PTR c);