michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: #ifndef VP9_COMMON_VP9_ONYX_H_ michael@0: #define VP9_COMMON_VP9_ONYX_H_ michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" michael@0: { // NOLINT michael@0: #endif michael@0: michael@0: #include "./vpx_config.h" michael@0: #include "vpx/internal/vpx_codec_internal.h" michael@0: #include "vpx/vp8cx.h" michael@0: #include "vpx_scale/yv12config.h" michael@0: #include "vp9/common/vp9_ppflags.h" michael@0: michael@0: #define MAX_SEGMENTS 8 michael@0: michael@0: typedef int *VP9_PTR; michael@0: michael@0: /* Create/destroy static data structures. */ michael@0: michael@0: typedef enum { michael@0: NORMAL = 0, michael@0: FOURFIVE = 1, michael@0: THREEFIVE = 2, michael@0: ONETWO = 3 michael@0: } VPX_SCALING; michael@0: michael@0: typedef enum { michael@0: VP9_LAST_FLAG = 1, michael@0: VP9_GOLD_FLAG = 2, michael@0: VP9_ALT_FLAG = 4 michael@0: } VP9_REFFRAME; michael@0: michael@0: michael@0: typedef enum { michael@0: USAGE_STREAM_FROM_SERVER = 0x0, michael@0: USAGE_LOCAL_FILE_PLAYBACK = 0x1, michael@0: USAGE_CONSTRAINED_QUALITY = 0x2, michael@0: USAGE_CONSTANT_QUALITY = 0x3, michael@0: } END_USAGE; michael@0: michael@0: michael@0: typedef enum { michael@0: MODE_GOODQUALITY = 0x1, michael@0: MODE_BESTQUALITY = 0x2, michael@0: MODE_FIRSTPASS = 0x3, michael@0: MODE_SECONDPASS = 0x4, michael@0: MODE_SECONDPASS_BEST = 0x5, michael@0: } MODE; michael@0: michael@0: typedef enum { michael@0: FRAMEFLAGS_KEY = 1, michael@0: FRAMEFLAGS_GOLDEN = 2, michael@0: FRAMEFLAGS_ALTREF = 4, michael@0: } FRAMETYPE_FLAGS; michael@0: michael@0: typedef enum { michael@0: NO_AQ = 0, michael@0: VARIANCE_AQ = 1, michael@0: AQ_MODES_COUNT // This should always be the last member of the enum michael@0: } AQ_MODES; michael@0: michael@0: typedef struct { michael@0: int version; // 4 versions of bitstream defined: michael@0: // 0 - best quality/slowest decode, michael@0: // 3 - lowest quality/fastest decode michael@0: int width; // width of data passed to the compressor michael@0: int height; // height of data passed to the compressor michael@0: double framerate; // set to passed in framerate michael@0: int64_t target_bandwidth; // bandwidth to be used in kilobits per second michael@0: michael@0: int noise_sensitivity; // pre processing blur: recommendation 0 michael@0: int Sharpness; // sharpening output: recommendation 0: michael@0: int cpu_used; michael@0: unsigned int rc_max_intra_bitrate_pct; michael@0: michael@0: // mode -> michael@0: // (0)=Realtime/Live Encoding. This mode is optimized for realtime michael@0: // encoding (for example, capturing a television signal or feed from michael@0: // a live camera). ( speed setting controls how fast ) michael@0: // (1)=Good Quality Fast Encoding. The encoder balances quality with the michael@0: // amount of time it takes to encode the output. ( speed setting michael@0: // controls how fast ) michael@0: // (2)=One Pass - Best Quality. The encoder places priority on the michael@0: // quality of the output over encoding speed. The output is compressed michael@0: // at the highest possible quality. This option takes the longest michael@0: // amount of time to encode. ( speed setting ignored ) michael@0: // (3)=Two Pass - First Pass. The encoder generates a file of statistics michael@0: // for use in the second encoding pass. ( speed setting controls how michael@0: // fast ) michael@0: // (4)=Two Pass - Second Pass. The encoder uses the statistics that were michael@0: // generated in the first encoding pass to create the compressed michael@0: // output. ( speed setting controls how fast ) michael@0: // (5)=Two Pass - Second Pass Best. The encoder uses the statistics that michael@0: // were generated in the first encoding pass to create the compressed michael@0: // output using the highest possible quality, and taking a michael@0: // longer amount of time to encode.. ( speed setting ignored ) michael@0: int Mode; michael@0: michael@0: // Key Framing Operations michael@0: int auto_key; // autodetect cut scenes and set the keyframes michael@0: int key_freq; // maximum distance to key frame. michael@0: michael@0: int allow_lag; // allow lagged compression (if 0 lagin frames is ignored) michael@0: int lag_in_frames; // how many frames lag before we start encoding michael@0: michael@0: // ---------------------------------------------------------------- michael@0: // DATARATE CONTROL OPTIONS michael@0: michael@0: int end_usage; // vbr or cbr michael@0: michael@0: // buffer targeting aggressiveness michael@0: int under_shoot_pct; michael@0: int over_shoot_pct; michael@0: michael@0: // buffering parameters michael@0: int64_t starting_buffer_level; // in seconds michael@0: int64_t optimal_buffer_level; michael@0: int64_t maximum_buffer_size; michael@0: michael@0: // controlling quality michael@0: int fixed_q; michael@0: int worst_allowed_q; michael@0: int best_allowed_q; michael@0: int cq_level; michael@0: int lossless; michael@0: int aq_mode; // Adaptive Quantization mode michael@0: michael@0: // two pass datarate control michael@0: int two_pass_vbrbias; // two pass datarate control tweaks michael@0: int two_pass_vbrmin_section; michael@0: int two_pass_vbrmax_section; michael@0: // END DATARATE CONTROL OPTIONS michael@0: // ---------------------------------------------------------------- michael@0: michael@0: // Spatial scalability michael@0: int ss_number_layers; michael@0: michael@0: // these parameters aren't to be used in final build don't use!!! michael@0: int play_alternate; michael@0: int alt_freq; michael@0: michael@0: int encode_breakout; // early breakout : for video conf recommend 800 michael@0: michael@0: /* Bitfield defining the error resiliency features to enable. michael@0: * Can provide decodable frames after losses in previous michael@0: * frames and decodable partitions after losses in the same frame. michael@0: */ michael@0: unsigned int error_resilient_mode; michael@0: michael@0: /* Bitfield defining the parallel decoding mode where the michael@0: * decoding in successive frames may be conducted in parallel michael@0: * just by decoding the frame headers. michael@0: */ michael@0: unsigned int frame_parallel_decoding_mode; michael@0: michael@0: int arnr_max_frames; michael@0: int arnr_strength; michael@0: int arnr_type; michael@0: michael@0: int tile_columns; michael@0: int tile_rows; michael@0: michael@0: struct vpx_fixed_buf two_pass_stats_in; michael@0: struct vpx_codec_pkt_list *output_pkt_list; michael@0: michael@0: vp8e_tuning tuning; michael@0: } VP9_CONFIG; michael@0: michael@0: michael@0: void vp9_initialize_enc(); michael@0: michael@0: VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf); michael@0: void vp9_remove_compressor(VP9_PTR *comp); michael@0: michael@0: void vp9_change_config(VP9_PTR onyx, VP9_CONFIG *oxcf); michael@0: michael@0: // receive a frames worth of data. caller can assume that a copy of this michael@0: // frame is made and not just a copy of the pointer.. michael@0: int vp9_receive_raw_frame(VP9_PTR comp, unsigned int frame_flags, michael@0: YV12_BUFFER_CONFIG *sd, int64_t time_stamp, michael@0: int64_t end_time_stamp); michael@0: michael@0: int vp9_get_compressed_data(VP9_PTR comp, unsigned int *frame_flags, michael@0: unsigned long *size, unsigned char *dest, michael@0: int64_t *time_stamp, int64_t *time_end, michael@0: int flush); michael@0: michael@0: int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest, michael@0: vp9_ppflags_t *flags); michael@0: michael@0: int vp9_use_as_reference(VP9_PTR comp, int ref_frame_flags); michael@0: michael@0: int vp9_update_reference(VP9_PTR comp, int ref_frame_flags); michael@0: michael@0: int vp9_copy_reference_enc(VP9_PTR comp, VP9_REFFRAME ref_frame_flag, michael@0: YV12_BUFFER_CONFIG *sd); michael@0: michael@0: int vp9_get_reference_enc(VP9_PTR ptr, int index, YV12_BUFFER_CONFIG **fb); michael@0: michael@0: int vp9_set_reference_enc(VP9_PTR comp, VP9_REFFRAME ref_frame_flag, michael@0: YV12_BUFFER_CONFIG *sd); michael@0: michael@0: int vp9_update_entropy(VP9_PTR comp, int update); michael@0: michael@0: int vp9_set_roimap(VP9_PTR comp, unsigned char *map, michael@0: unsigned int rows, unsigned int cols, michael@0: int delta_q[MAX_SEGMENTS], michael@0: int delta_lf[MAX_SEGMENTS], michael@0: unsigned int threshold[MAX_SEGMENTS]); michael@0: michael@0: int vp9_set_active_map(VP9_PTR comp, unsigned char *map, michael@0: unsigned int rows, unsigned int cols); michael@0: michael@0: int vp9_set_internal_size(VP9_PTR comp, michael@0: VPX_SCALING horiz_mode, VPX_SCALING vert_mode); michael@0: michael@0: int vp9_set_size_literal(VP9_PTR comp, unsigned int width, michael@0: unsigned int height); michael@0: michael@0: void vp9_set_svc(VP9_PTR comp, int use_svc); michael@0: michael@0: int vp9_get_quantizer(VP9_PTR c); michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: michael@0: #endif // VP9_COMMON_VP9_ONYX_H_