• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
12 #ifndef __INC_VP8_H
13 #define __INC_VP8_H
14 
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19 
20 #include "vpx/internal/vpx_codec_internal.h"
21 #include "vpx_scale/yv12config.h"
22 #include "type_aliases.h"
23 #include "ppflags.h"
24     typedef int *VP8_PTR;
25 
26     /* Create/destroy static data structures. */
27 
28     typedef enum
29     {
30         NORMAL      = 0,
31         FOURFIVE    = 1,
32         THREEFIVE   = 2,
33         ONETWO      = 3
34 
35     } VPX_SCALING;
36 
37     typedef enum
38     {
39         VP8_LAST_FLAG = 1,
40         VP8_GOLD_FLAG = 2,
41         VP8_ALT_FLAG = 4
42     } VP8_REFFRAME;
43 
44 
45     typedef enum
46     {
47         USAGE_STREAM_FROM_SERVER    = 0x0,
48         USAGE_LOCAL_FILE_PLAYBACK   = 0x1
49     } END_USAGE;
50 
51 
52     typedef enum
53     {
54         MODE_REALTIME       = 0x0,
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     {
64         FRAMEFLAGS_KEY    = 1,
65         FRAMEFLAGS_GOLDEN = 2,
66         FRAMEFLAGS_ALTREF = 4,
67     } FRAMETYPE_FLAGS;
68 
69 
70 #include <assert.h>
Scale2Ratio(int mode,int * hr,int * hs)71     static __inline void Scale2Ratio(int mode, int *hr, int *hs)
72     {
73         switch (mode)
74         {
75         case    NORMAL:
76             *hr = 1;
77             *hs = 1;
78             break;
79         case    FOURFIVE:
80             *hr = 4;
81             *hs = 5;
82             break;
83         case    THREEFIVE:
84             *hr = 3;
85             *hs = 5;
86             break;
87         case    ONETWO:
88             *hr = 1;
89             *hs = 2;
90             break;
91         default:
92             *hr = 1;
93             *hs = 1;
94             assert(0);
95             break;
96         }
97     }
98 
99     typedef struct
100     {
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
106 
107         int noise_sensitivity;   // parameter used for applying pre processing blur: recommendation 0
108         int Sharpness;          // parameter used for sharpening output: recommendation 0:
109         int cpu_used;
110 
111         // mode ->
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 )
126         int Mode;               //
127 
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.
131 
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
134 
135         //----------------------------------------------------------------
136         // DATARATE CONTROL OPTIONS
137 
138         int end_usage; // vbr or cbr
139 
140         // shoot to keep buffer full at all times by undershooting a bit 95 recommended
141         int under_shoot_pct;
142 
143         // buffering parameters
144         int starting_buffer_level;  // in seconds
145         int optimal_buffer_level;
146         int maximum_buffer_size;
147 
148         // controlling quality
149         int fixed_q;
150         int worst_allowed_q;
151         int best_allowed_q;
152 
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;
157 
158         // allow internal frame rate alterations
159         int allow_df;
160         int drop_frames_water_mark;
161 
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         //----------------------------------------------------------------
168 
169 
170         // these parameters aren't to be used in final build don't use!!!
171         int play_alternate;
172         int alt_freq;
173         int alt_q;
174         int key_q;
175         int gold_q;
176 
177 
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
181 
182         int error_resilient_mode;  // if running over udp networks provides decodable frames after a
183         // dropped packet
184 
185         int arnr_max_frames;
186         int arnr_strength ;
187         int arnr_type     ;
188 
189 
190         struct vpx_fixed_buf         two_pass_stats_in;
191         struct vpx_codec_pkt_list  *output_pkt_list;
192     } VP8_CONFIG;
193 
194 
195     void vp8_initialize();
196 
197     VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf);
198     void vp8_remove_compressor(VP8_PTR *comp);
199 
200     void vp8_init_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
201     void vp8_change_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
202 
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, int deblock_level, int noise_level, int flags);
208 
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);
218 
219 #ifdef __cplusplus
220 }
221 #endif
222 
223 #endif
224