vp9_onyx.h 7.75 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5 6
 *  that can be found in the LICENSE file in the root of the source
 *  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.
John Koleszar's avatar
John Koleszar committed
9 10
 */

11 12
#ifndef VP9_COMMON_VP9_ONYX_H_
#define VP9_COMMON_VP9_ONYX_H_
John Koleszar's avatar
John Koleszar committed
13 14 15

#ifdef __cplusplus
extern "C"
Jim Bankoski's avatar
Jim Bankoski committed
16
{ // NOLINT
John Koleszar's avatar
John Koleszar committed
17 18
#endif

19
#include "./vpx_config.h"
20
#include "vpx/internal/vpx_codec_internal.h"
John Koleszar's avatar
John Koleszar committed
21
#include "vpx/vp8cx.h"
John Koleszar's avatar
John Koleszar committed
22
#include "vpx_scale/yv12config.h"
23
#include "vp9/common/vp9_ppflags.h"
24

Paul Wilkins's avatar
Paul Wilkins committed
25
#define MAX_SEGMENTS 8
26

27
  typedef int *VP9_PTR;
John Koleszar's avatar
John Koleszar committed
28

John Koleszar's avatar
John Koleszar committed
29
  /* Create/destroy static data structures. */
John Koleszar's avatar
John Koleszar committed
30

John Koleszar's avatar
John Koleszar committed
31 32 33 34 35 36
  typedef enum {
    NORMAL      = 0,
    FOURFIVE    = 1,
    THREEFIVE   = 2,
    ONETWO      = 3
  } VPX_SCALING;
John Koleszar's avatar
John Koleszar committed
37

John Koleszar's avatar
John Koleszar committed
38
  typedef enum {
39 40 41 42
    VP9_LAST_FLAG = 1,
    VP9_GOLD_FLAG = 2,
    VP9_ALT_FLAG = 4
  } VP9_REFFRAME;
John Koleszar's avatar
John Koleszar committed
43 44


John Koleszar's avatar
John Koleszar committed
45 46 47
  typedef enum {
    USAGE_STREAM_FROM_SERVER    = 0x0,
    USAGE_LOCAL_FILE_PLAYBACK   = 0x1,
48 49
    USAGE_CONSTRAINED_QUALITY   = 0x2,
    USAGE_CONSTANT_QUALITY      = 0x3,
John Koleszar's avatar
John Koleszar committed
50
  } END_USAGE;
John Koleszar's avatar
John Koleszar committed
51 52


John Koleszar's avatar
John Koleszar committed
53 54 55 56 57 58 59
  typedef enum {
    MODE_GOODQUALITY    = 0x1,
    MODE_BESTQUALITY    = 0x2,
    MODE_FIRSTPASS      = 0x3,
    MODE_SECONDPASS     = 0x4,
    MODE_SECONDPASS_BEST = 0x5,
  } MODE;
John Koleszar's avatar
John Koleszar committed
60

John Koleszar's avatar
John Koleszar committed
61 62 63 64 65
  typedef enum {
    FRAMEFLAGS_KEY    = 1,
    FRAMEFLAGS_GOLDEN = 2,
    FRAMEFLAGS_ALTREF = 4,
  } FRAMETYPE_FLAGS;
John Koleszar's avatar
John Koleszar committed
66

67 68 69 70 71 72
  typedef enum {
    NO_AQ = 0,
    VARIANCE_AQ = 1,
    AQ_MODES_COUNT  // This should always be the last member of the enum
  } AQ_MODES;

John Koleszar's avatar
John Koleszar committed
73
  typedef struct {
74 75 76 77 78
    int version;  // 4 versions of bitstream defined:
                  //   0 - best quality/slowest decode,
                  //   3 - lowest quality/fastest decode
    int width;  // width of data passed to the compressor
    int height;  // height of data passed to the compressor
Jim Bankoski's avatar
Jim Bankoski committed
79 80
    double framerate;  // set to passed in framerate
    int64_t target_bandwidth;  // bandwidth to be used in kilobits per second
John Koleszar's avatar
John Koleszar committed
81

Jim Bankoski's avatar
Jim Bankoski committed
82 83
    int noise_sensitivity;  // pre processing blur: recommendation 0
    int Sharpness;  // sharpening output: recommendation 0:
John Koleszar's avatar
John Koleszar committed
84 85 86 87
    int cpu_used;
    unsigned int rc_max_intra_bitrate_pct;

    // mode ->
Jim Bankoski's avatar
Jim Bankoski committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
    // (0)=Realtime/Live Encoding. This mode is optimized for realtime
    //     encoding (for example, capturing a television signal or feed from
    //     a live camera). ( speed setting controls how fast )
    // (1)=Good Quality Fast Encoding. The encoder balances quality with the
    //     amount of time it takes to encode the output. ( speed setting
    //     controls how fast )
    // (2)=One Pass - Best Quality. The encoder places priority on the
    //     quality of the output over encoding speed. The output is compressed
    //     at the highest possible quality. This option takes the longest
    //     amount of time to encode. ( speed setting ignored )
    // (3)=Two Pass - First Pass. The encoder generates a file of statistics
    //     for use in the second encoding pass. ( speed setting controls how
    //     fast )
    // (4)=Two Pass - Second Pass. The encoder uses the statistics that were
    //     generated in the first encoding pass to create the compressed
    //     output. ( speed setting controls how fast )
    // (5)=Two Pass - Second Pass Best.  The encoder uses the statistics that
    //     were generated in the first encoding pass to create the compressed
    //     output using the highest possible quality, and taking a
John Koleszar's avatar
John Koleszar committed
107
    //    longer amount of time to encode.. ( speed setting ignored )
Jim Bankoski's avatar
Jim Bankoski committed
108
    int Mode;
John Koleszar's avatar
John Koleszar committed
109 110

    // Key Framing Operations
Jim Bankoski's avatar
Jim Bankoski committed
111 112
    int auto_key;  // autodetect cut scenes and set the keyframes
    int key_freq;  // maximum distance to key frame.
John Koleszar's avatar
John Koleszar committed
113

Jim Bankoski's avatar
Jim Bankoski committed
114 115
    int allow_lag;  // allow lagged compression (if 0 lagin frames is ignored)
    int lag_in_frames;  // how many frames lag before we start encoding
John Koleszar's avatar
John Koleszar committed
116 117 118 119

    // ----------------------------------------------------------------
    // DATARATE CONTROL OPTIONS

Jim Bankoski's avatar
Jim Bankoski committed
120
    int end_usage;  // vbr or cbr
John Koleszar's avatar
John Koleszar committed
121 122 123 124 125 126

    // buffer targeting aggressiveness
    int under_shoot_pct;
    int over_shoot_pct;

    // buffering parameters
Jingning Han's avatar
Jingning Han committed
127 128 129
    int64_t starting_buffer_level;  // in seconds
    int64_t optimal_buffer_level;
    int64_t maximum_buffer_size;
John Koleszar's avatar
John Koleszar committed
130 131 132 133 134 135 136

    // controlling quality
    int fixed_q;
    int worst_allowed_q;
    int best_allowed_q;
    int cq_level;
    int lossless;
137
    int aq_mode;  // Adaptive Quantization mode
John Koleszar's avatar
John Koleszar committed
138 139 140 141 142 143 144 145

    // two pass datarate control
    int two_pass_vbrbias;        // two pass datarate control tweaks
    int two_pass_vbrmin_section;
    int two_pass_vbrmax_section;
    // END DATARATE CONTROL OPTIONS
    // ----------------------------------------------------------------

146 147
    // Spatial scalability
    int ss_number_layers;
John Koleszar's avatar
John Koleszar committed
148 149 150 151 152

    // these parameters aren't to be used in final build don't use!!!
    int play_alternate;
    int alt_freq;

Jim Bankoski's avatar
Jim Bankoski committed
153
    int encode_breakout;  // early breakout : for video conf recommend 800
John Koleszar's avatar
John Koleszar committed
154

155 156 157 158 159 160
    /* Bitfield defining the error resiliency features to enable.
     * Can provide decodable frames after losses in previous
     * frames and decodable partitions after losses in the same frame.
     */
    unsigned int error_resilient_mode;

161 162 163 164 165 166
    /* Bitfield defining the parallel decoding mode where the
     * decoding in successive frames may be conducted in parallel
     * just by decoding the frame headers.
     */
    unsigned int frame_parallel_decoding_mode;

John Koleszar's avatar
John Koleszar committed
167 168 169 170
    int arnr_max_frames;
    int arnr_strength;
    int arnr_type;

171
    int tile_columns;
Ronald S. Bultje's avatar
Ronald S. Bultje committed
172
    int tile_rows;
173

John Koleszar's avatar
John Koleszar committed
174 175 176 177
    struct vpx_fixed_buf         two_pass_stats_in;
    struct vpx_codec_pkt_list  *output_pkt_list;

    vp8e_tuning tuning;
178
  } VP9_CONFIG;
John Koleszar's avatar
John Koleszar committed
179 180


181
  void vp9_initialize_enc();
John Koleszar's avatar
John Koleszar committed
182

183
  VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf);
184
  void vp9_remove_compressor(VP9_PTR *comp);
John Koleszar's avatar
John Koleszar committed
185

186
  void vp9_change_config(VP9_PTR onyx, VP9_CONFIG *oxcf);
John Koleszar's avatar
John Koleszar committed
187

Jim Bankoski's avatar
Jim Bankoski committed
188 189
  // receive a frames worth of data. caller can assume that a copy of this
  // frame is made and not just a copy of the pointer..
190
  int vp9_receive_raw_frame(VP9_PTR comp, unsigned int frame_flags,
191 192 193
                            YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
                            int64_t end_time_stamp);

194
  int vp9_get_compressed_data(VP9_PTR comp, unsigned int *frame_flags,
195 196 197 198
                              unsigned long *size, unsigned char *dest,
                              int64_t *time_stamp, int64_t *time_end,
                              int flush);

199
  int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest,
200
                                vp9_ppflags_t *flags);
201

202
  int vp9_use_as_reference(VP9_PTR comp, int ref_frame_flags);
203

204
  int vp9_update_reference(VP9_PTR comp, int ref_frame_flags);
205

John Koleszar's avatar
John Koleszar committed
206 207 208 209
  int vp9_copy_reference_enc(VP9_PTR comp, VP9_REFFRAME ref_frame_flag,
                             YV12_BUFFER_CONFIG *sd);

  int vp9_get_reference_enc(VP9_PTR ptr, int index, YV12_BUFFER_CONFIG **fb);
210

211
  int vp9_set_reference_enc(VP9_PTR comp, VP9_REFFRAME ref_frame_flag,
212 213
                            YV12_BUFFER_CONFIG *sd);

214
  int vp9_update_entropy(VP9_PTR comp, int update);
215

216
  int vp9_set_roimap(VP9_PTR comp, unsigned char *map,
217
                     unsigned int rows, unsigned int cols,
Paul Wilkins's avatar
Paul Wilkins committed
218 219 220
                     int delta_q[MAX_SEGMENTS],
                     int delta_lf[MAX_SEGMENTS],
                     unsigned int threshold[MAX_SEGMENTS]);
221

222
  int vp9_set_active_map(VP9_PTR comp, unsigned char *map,
223 224
                         unsigned int rows, unsigned int cols);

225
  int vp9_set_internal_size(VP9_PTR comp,
226 227
                            VPX_SCALING horiz_mode, VPX_SCALING vert_mode);

228 229 230 231 232
  int vp9_set_size_literal(VP9_PTR comp, unsigned int width,
                           unsigned int height);

  void vp9_set_svc(VP9_PTR comp, int use_svc);

233
  int vp9_get_quantizer(VP9_PTR c);
John Koleszar's avatar
John Koleszar committed
234 235 236 237 238

#ifdef __cplusplus
}
#endif

239
#endif  // VP9_COMMON_VP9_ONYX_H_