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: michael@0: #ifndef __INC_VP8_H michael@0: #define __INC_VP8_H michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" michael@0: { 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/vpx_encoder.h" michael@0: #include "vpx_scale/yv12config.h" michael@0: #include "ppflags.h" michael@0: michael@0: struct VP8_COMP; michael@0: michael@0: /* Create/destroy static data structures. */ michael@0: michael@0: typedef enum michael@0: { michael@0: NORMAL = 0, michael@0: FOURFIVE = 1, michael@0: THREEFIVE = 2, michael@0: ONETWO = 3 michael@0: michael@0: } VPX_SCALING; michael@0: michael@0: typedef enum michael@0: { 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: { michael@0: MODE_REALTIME = 0x0, 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: { michael@0: FRAMEFLAGS_KEY = 1, michael@0: FRAMEFLAGS_GOLDEN = 2, michael@0: FRAMEFLAGS_ALTREF = 4 michael@0: } FRAMETYPE_FLAGS; michael@0: michael@0: michael@0: #include michael@0: static void Scale2Ratio(int mode, int *hr, int *hs) michael@0: { michael@0: switch (mode) michael@0: { michael@0: case NORMAL: michael@0: *hr = 1; michael@0: *hs = 1; michael@0: break; michael@0: case FOURFIVE: michael@0: *hr = 4; michael@0: *hs = 5; michael@0: break; michael@0: case THREEFIVE: michael@0: *hr = 3; michael@0: *hs = 5; michael@0: break; michael@0: case ONETWO: michael@0: *hr = 1; michael@0: *hs = 2; michael@0: break; michael@0: default: michael@0: *hr = 1; michael@0: *hs = 1; michael@0: assert(0); michael@0: break; michael@0: } michael@0: } michael@0: michael@0: typedef struct michael@0: { michael@0: /* 4 versions of bitstream defined: michael@0: * 0 best quality/slowest decode, 3 lowest quality/fastest decode michael@0: */ michael@0: int Version; michael@0: int Width; michael@0: int Height; michael@0: struct vpx_rational timebase; michael@0: unsigned int target_bandwidth; /* kilobits per second */ michael@0: michael@0: /* parameter used for applying pre processing blur: recommendation 0 */ michael@0: int noise_sensitivity; michael@0: michael@0: /* parameter used for sharpening output: recommendation 0: */ michael@0: int Sharpness; 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 realtim michael@0: * encoding (for example, capturing a television signal or feed michael@0: * from a live camera). ( speed setting controls how fast ) michael@0: *(1)=Good Quality Fast Encoding. The encoder balances quality with michael@0: * the amount of time it takes to encode the output. ( speed michael@0: * setting 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 michael@0: * compressed at the highest possible quality. This option takes michael@0: * the longest amount of time to encode. ( speed setting ignored michael@0: * ) michael@0: *(3)=Two Pass - First Pass. The encoder generates a file of michael@0: * statistics for use in the second encoding pass. ( speed michael@0: * setting controls how fast ) michael@0: *(4)=Two Pass - Second Pass. The encoder uses the statistics that michael@0: * were generated in the first encoding pass to create the michael@0: * compressed output. ( speed setting controls how fast ) michael@0: *(5)=Two Pass - Second Pass Best. The encoder uses the statistics michael@0: * that were generated in the first encoding pass to create the michael@0: * compressed output using the highest possible quality, and michael@0: * taking a longer amount of time to encode.. ( speed setting michael@0: * ignored ) michael@0: */ michael@0: int Mode; michael@0: michael@0: /* Key Framing Operations */ michael@0: int auto_key; /* automatically detect cut scenes */ michael@0: int key_freq; /* maximum distance to key frame. */ michael@0: michael@0: /* lagged compression (if allow_lag == 0 lag_in_frames is ignored) */ michael@0: int allow_lag; 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: 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; michael@0: int64_t optimal_buffer_level; michael@0: int64_t maximum_buffer_size; michael@0: michael@0: int64_t starting_buffer_level_in_ms; michael@0: int64_t optimal_buffer_level_in_ms; michael@0: int64_t maximum_buffer_size_in_ms; 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: michael@0: /* allow internal resizing */ michael@0: int allow_spatial_resampling; michael@0: int resample_down_water_mark; michael@0: int resample_up_water_mark; michael@0: michael@0: /* allow internal frame rate alterations */ michael@0: int allow_df; michael@0: int drop_frames_water_mark; michael@0: michael@0: /* two pass datarate control */ michael@0: int two_pass_vbrbias; michael@0: int two_pass_vbrmin_section; michael@0: int two_pass_vbrmax_section; michael@0: michael@0: /* michael@0: * END DATARATE CONTROL OPTIONS michael@0: */ 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: int alt_q; michael@0: int key_q; michael@0: int gold_q; michael@0: michael@0: michael@0: int multi_threaded; /* how many threads to run the encoder on */ michael@0: int token_partitions; /* how many token partitions to create */ michael@0: michael@0: /* early breakout threshold: for video conf recommend 800 */ michael@0: int encode_breakout; 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: int arnr_max_frames; michael@0: int arnr_strength; michael@0: int arnr_type; 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: michael@0: /* Temporal scaling parameters */ michael@0: unsigned int number_of_layers; michael@0: unsigned int target_bitrate[VPX_TS_MAX_PERIODICITY]; michael@0: unsigned int rate_decimator[VPX_TS_MAX_PERIODICITY]; michael@0: unsigned int periodicity; michael@0: unsigned int layer_id[VPX_TS_MAX_PERIODICITY]; michael@0: michael@0: #if CONFIG_MULTI_RES_ENCODING michael@0: /* Number of total resolutions encoded */ michael@0: unsigned int mr_total_resolutions; michael@0: michael@0: /* Current encoder ID */ michael@0: unsigned int mr_encoder_id; michael@0: michael@0: /* Down-sampling factor */ michael@0: vpx_rational_t mr_down_sampling_factor; michael@0: michael@0: /* Memory location to store low-resolution encoder's mode info */ michael@0: void* mr_low_res_mode_info; michael@0: #endif michael@0: } VP8_CONFIG; michael@0: michael@0: michael@0: void vp8_initialize(); michael@0: michael@0: struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf); michael@0: void vp8_remove_compressor(struct VP8_COMP* *comp); michael@0: michael@0: void vp8_init_config(struct VP8_COMP* onyx, VP8_CONFIG *oxcf); michael@0: void vp8_change_config(struct VP8_COMP* onyx, VP8_CONFIG *oxcf); michael@0: michael@0: int vp8_receive_raw_frame(struct VP8_COMP* comp, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, int64_t time_stamp, int64_t end_time_stamp); michael@0: int vp8_get_compressed_data(struct VP8_COMP* comp, unsigned int *frame_flags, unsigned long *size, unsigned char *dest, unsigned char *dest_end, int64_t *time_stamp, int64_t *time_end, int flush); michael@0: int vp8_get_preview_raw_frame(struct VP8_COMP* comp, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *flags); michael@0: michael@0: int vp8_use_as_reference(struct VP8_COMP* comp, int ref_frame_flags); michael@0: int vp8_update_reference(struct VP8_COMP* comp, int ref_frame_flags); michael@0: int vp8_get_reference(struct VP8_COMP* comp, enum vpx_ref_frame_type ref_frame_flag, YV12_BUFFER_CONFIG *sd); michael@0: int vp8_set_reference(struct VP8_COMP* comp, enum vpx_ref_frame_type ref_frame_flag, YV12_BUFFER_CONFIG *sd); michael@0: int vp8_update_entropy(struct VP8_COMP* comp, int update); michael@0: int vp8_set_roimap(struct VP8_COMP* comp, unsigned char *map, unsigned int rows, unsigned int cols, int delta_q[4], int delta_lf[4], unsigned int threshold[4]); michael@0: int vp8_set_active_map(struct VP8_COMP* comp, unsigned char *map, unsigned int rows, unsigned int cols); michael@0: int vp8_set_internal_size(struct VP8_COMP* comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode); michael@0: int vp8_get_quantizer(struct VP8_COMP* c); michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: michael@0: #endif