blob: 015b4c4d405c93a42e44e625d68bb29cf50fb7d0 [file] [log] [blame]
John Koleszar0ea50ce2010-05-18 11:58:33 -04001/*
John Koleszarc2140b82010-09-09 08:16:39 -04002 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar0ea50ce2010-05-18 11:58:33 -04003 *
John Koleszar94c52e42010-06-18 12:39:21 -04004 * Use of this source code is governed by a BSD-style license
John Koleszar09202d82010-06-04 16:19:40 -04005 * 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
John Koleszar94c52e42010-06-18 12:39:21 -04007 * in the file PATENTS. All contributing project authors may
John Koleszar09202d82010-06-04 16:19:40 -04008 * be found in the AUTHORS file in the root of the source tree.
John Koleszar0ea50ce2010-05-18 11:58:33 -04009 */
10
11
12#ifndef __INC_VP8_H
13#define __INC_VP8_H
14
15#ifdef __cplusplus
16extern "C"
17{
18#endif
19
John Koleszarb7492342010-05-24 11:39:59 -040020#include "vpx/internal/vpx_codec_internal.h"
John Koleszarb0da9b32010-12-17 09:43:39 -050021#include "vpx/vp8cx.h"
John Koleszar0ea50ce2010-05-18 11:58:33 -040022#include "vpx_scale/yv12config.h"
23#include "type_aliases.h"
24#include "ppflags.h"
25 typedef int *VP8_PTR;
26
27 /* Create/destroy static data structures. */
28
29 typedef enum
30 {
31 NORMAL = 0,
32 FOURFIVE = 1,
33 THREEFIVE = 2,
34 ONETWO = 3
35
36 } VPX_SCALING;
37
38 typedef enum
39 {
40 VP8_LAST_FLAG = 1,
41 VP8_GOLD_FLAG = 2,
42 VP8_ALT_FLAG = 4
43 } VP8_REFFRAME;
44
45
46 typedef enum
47 {
48 USAGE_STREAM_FROM_SERVER = 0x0,
Paul Wilkinse0846c92011-01-07 18:29:37 +000049 USAGE_LOCAL_FILE_PLAYBACK = 0x1,
50 USAGE_CONSTRAINED_QUALITY = 0x2
John Koleszar0ea50ce2010-05-18 11:58:33 -040051 } END_USAGE;
52
53
54 typedef enum
55 {
56 MODE_REALTIME = 0x0,
57 MODE_GOODQUALITY = 0x1,
58 MODE_BESTQUALITY = 0x2,
59 MODE_FIRSTPASS = 0x3,
60 MODE_SECONDPASS = 0x4,
61 MODE_SECONDPASS_BEST = 0x5,
62 } MODE;
63
64 typedef enum
65 {
66 FRAMEFLAGS_KEY = 1,
67 FRAMEFLAGS_GOLDEN = 2,
68 FRAMEFLAGS_ALTREF = 4,
69 } FRAMETYPE_FLAGS;
70
71
72#include <assert.h>
73 static __inline void Scale2Ratio(int mode, int *hr, int *hs)
74 {
75 switch (mode)
76 {
77 case NORMAL:
78 *hr = 1;
79 *hs = 1;
80 break;
81 case FOURFIVE:
82 *hr = 4;
83 *hs = 5;
84 break;
85 case THREEFIVE:
86 *hr = 3;
87 *hs = 5;
88 break;
89 case ONETWO:
90 *hr = 1;
91 *hs = 2;
92 break;
93 default:
94 *hr = 1;
95 *hs = 1;
96 assert(0);
97 break;
98 }
99 }
100
101 typedef struct
102 {
103 int Version; // 4 versions of bitstream defined 0 best quality/slowest decode, 3 lowest quality/fastest decode
104 int Width; // width of data passed to the compressor
105 int Height; // height of data passed to the compressor
106 double frame_rate; // set to passed in framerate
107 int target_bandwidth; // bandwidth to be used in kilobits per second
108
109 int noise_sensitivity; // parameter used for applying pre processing blur: recommendation 0
110 int Sharpness; // parameter used for sharpening output: recommendation 0:
111 int cpu_used;
John Koleszaraa926fb2011-04-25 11:44:50 -0400112 unsigned int rc_max_intra_bitrate_pct;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400113
114 // mode ->
115 //(0)=Realtime/Live Encoding. This mode is optimized for realtim encoding (for example, capturing
116 // a television signal or feed from a live camera). ( speed setting controls how fast )
117 //(1)=Good Quality Fast Encoding. The encoder balances quality with the amount of time it takes to
118 // encode the output. ( speed setting controls how fast )
119 //(2)=One Pass - Best Quality. The encoder places priority on the quality of the output over encoding
120 // speed. The output is compressed at the highest possible quality. This option takes the longest
121 // amount of time to encode. ( speed setting ignored )
122 //(3)=Two Pass - First Pass. The encoder generates a file of statistics for use in the second encoding
123 // pass. ( speed setting controls how fast )
124 //(4)=Two Pass - Second Pass. The encoder uses the statistics that were generated in the first encoding
125 // pass to create the compressed output. ( speed setting controls how fast )
126 //(5)=Two Pass - Second Pass Best. The encoder uses the statistics that were generated in the first
127 // encoding pass to create the compressed output using the highest possible quality, and taking a
128 // longer amount of time to encode.. ( speed setting ignored )
129 int Mode; //
130
131 // Key Framing Operations
132 int auto_key; // automatically detect cut scenes and set the keyframes
133 int key_freq; // maximum distance to key frame.
134
135 int allow_lag; // allow lagged compression (if 0 lagin frames is ignored)
136 int lag_in_frames; // how many frames lag before we start encoding
137
138 //----------------------------------------------------------------
139 // DATARATE CONTROL OPTIONS
140
141 int end_usage; // vbr or cbr
142
John Koleszarc99f9d72011-04-11 11:29:23 -0400143 // buffer targeting aggressiveness
John Koleszar0ea50ce2010-05-18 11:58:33 -0400144 int under_shoot_pct;
John Koleszarc99f9d72011-04-11 11:29:23 -0400145 int over_shoot_pct;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400146
147 // buffering parameters
148 int starting_buffer_level; // in seconds
149 int optimal_buffer_level;
150 int maximum_buffer_size;
151
152 // controlling quality
153 int fixed_q;
154 int worst_allowed_q;
155 int best_allowed_q;
Paul Wilkinse0846c92011-01-07 18:29:37 +0000156 int cq_level;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400157
158 // allow internal resizing ( currently disabled in the build !!!!!)
159 int allow_spatial_resampling;
160 int resample_down_water_mark;
161 int resample_up_water_mark;
162
163 // allow internal frame rate alterations
164 int allow_df;
165 int drop_frames_water_mark;
166
167 // two pass datarate control
168 int two_pass_vbrbias; // two pass datarate control tweaks
169 int two_pass_vbrmin_section;
170 int two_pass_vbrmax_section;
171 // END DATARATE CONTROL OPTIONS
172 //----------------------------------------------------------------
173
174
175 // these parameters aren't to be used in final build don't use!!!
176 int play_alternate;
177 int alt_freq;
178 int alt_q;
179 int key_q;
180 int gold_q;
181
182
183 int multi_threaded; // how many threads to run the encoder on
184 int token_partitions; // how many token partitions to create for multi core decoding
185 int encode_breakout; // early breakout encode threshold : for video conf recommend 800
186
Stefan Holmer4cb0ebe2011-06-10 11:11:15 +0200187 unsigned int error_resilient_mode; // Bitfield defining the error
188 // resiliency features to enable. Can provide
189 // decodable frames after losses in previous
190 // frames and decodable partitions after
191 // losses in the same frame.
John Koleszar0ea50ce2010-05-18 11:58:33 -0400192
193 int arnr_max_frames;
194 int arnr_strength ;
195 int arnr_type ;
196
John Koleszar0ea50ce2010-05-18 11:58:33 -0400197 struct vpx_fixed_buf two_pass_stats_in;
198 struct vpx_codec_pkt_list *output_pkt_list;
John Koleszarb0da9b32010-12-17 09:43:39 -0500199
200 vp8e_tuning tuning;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400201 } VP8_CONFIG;
202
203
204 void vp8_initialize();
205
206 VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf);
207 void vp8_remove_compressor(VP8_PTR *comp);
208
209 void vp8_init_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
210 void vp8_change_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
211
212// receive a frames worth of data caller can assume that a copy of this frame is made
213// and not just a copy of the pointer..
James Zernb45065d2011-07-25 18:44:59 -0700214 int vp8_receive_raw_frame(VP8_PTR comp, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time_stamp);
215 int vp8_get_compressed_data(VP8_PTR comp, unsigned int *frame_flags, unsigned long *size, unsigned char *dest, int64_t *time_stamp, int64_t *time_end, int flush);
Fritz Koenig647df002010-11-04 16:03:36 -0700216 int vp8_get_preview_raw_frame(VP8_PTR comp, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *flags);
John Koleszar0ea50ce2010-05-18 11:58:33 -0400217
218 int vp8_use_as_reference(VP8_PTR comp, int ref_frame_flags);
219 int vp8_update_reference(VP8_PTR comp, int ref_frame_flags);
220 int vp8_get_reference(VP8_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
221 int vp8_set_reference(VP8_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
222 int vp8_update_entropy(VP8_PTR comp, int update);
223 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]);
224 int vp8_set_active_map(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols);
225 int vp8_set_internal_size(VP8_PTR comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode);
226 int vp8_get_quantizer(VP8_PTR c);
227
228#ifdef __cplusplus
229}
230#endif
231
232#endif