2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __INC_VP8_H
|
|
|
|
#define __INC_VP8_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2011-10-25 21:14:16 +02:00
|
|
|
#include "vpx_config.h"
|
2010-05-24 17:39:59 +02:00
|
|
|
#include "vpx/internal/vpx_codec_internal.h"
|
2010-12-17 15:43:39 +01:00
|
|
|
#include "vpx/vp8cx.h"
|
2011-10-07 00:49:11 +02:00
|
|
|
#include "vpx/vpx_encoder.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_scale/yv12config.h"
|
|
|
|
#include "ppflags.h"
|
2011-12-21 01:54:54 +01:00
|
|
|
|
|
|
|
struct VP8_COMP;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
/* Create/destroy static data structures. */
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
NORMAL = 0,
|
|
|
|
FOURFIVE = 1,
|
|
|
|
THREEFIVE = 2,
|
|
|
|
ONETWO = 3
|
|
|
|
|
|
|
|
} VPX_SCALING;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
USAGE_STREAM_FROM_SERVER = 0x0,
|
2011-01-07 19:29:37 +01:00
|
|
|
USAGE_LOCAL_FILE_PLAYBACK = 0x1,
|
|
|
|
USAGE_CONSTRAINED_QUALITY = 0x2
|
2010-05-18 17:58:33 +02:00
|
|
|
} END_USAGE;
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
MODE_REALTIME = 0x0,
|
|
|
|
MODE_GOODQUALITY = 0x1,
|
|
|
|
MODE_BESTQUALITY = 0x2,
|
|
|
|
MODE_FIRSTPASS = 0x3,
|
|
|
|
MODE_SECONDPASS = 0x4,
|
2012-05-02 19:08:10 +02:00
|
|
|
MODE_SECONDPASS_BEST = 0x5
|
2010-05-18 17:58:33 +02:00
|
|
|
} MODE;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
FRAMEFLAGS_KEY = 1,
|
|
|
|
FRAMEFLAGS_GOLDEN = 2,
|
2012-05-02 19:08:10 +02:00
|
|
|
FRAMEFLAGS_ALTREF = 4
|
2010-05-18 17:58:33 +02:00
|
|
|
} FRAMETYPE_FLAGS;
|
|
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
2012-03-21 19:11:10 +01:00
|
|
|
static void Scale2Ratio(int mode, int *hr, int *hs)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case NORMAL:
|
|
|
|
*hr = 1;
|
|
|
|
*hs = 1;
|
|
|
|
break;
|
|
|
|
case FOURFIVE:
|
|
|
|
*hr = 4;
|
|
|
|
*hs = 5;
|
|
|
|
break;
|
|
|
|
case THREEFIVE:
|
|
|
|
*hr = 3;
|
|
|
|
*hs = 5;
|
|
|
|
break;
|
|
|
|
case ONETWO:
|
|
|
|
*hr = 1;
|
|
|
|
*hs = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*hr = 1;
|
|
|
|
*hs = 1;
|
|
|
|
assert(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2012-05-21 23:30:56 +02:00
|
|
|
/* 4 versions of bitstream defined:
|
|
|
|
* 0 best quality/slowest decode, 3 lowest quality/fastest decode
|
|
|
|
*/
|
|
|
|
int Version;
|
|
|
|
int Width;
|
|
|
|
int Height;
|
2011-11-11 19:47:20 +01:00
|
|
|
struct vpx_rational timebase;
|
2012-05-21 23:30:56 +02:00
|
|
|
unsigned int target_bandwidth; /* kilobits per second */
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/* parameter used for applying pre processing blur: recommendation 0 */
|
|
|
|
int noise_sensitivity;
|
|
|
|
|
|
|
|
/* parameter used for sharpening output: recommendation 0: */
|
|
|
|
int Sharpness;
|
2010-05-18 17:58:33 +02:00
|
|
|
int cpu_used;
|
2011-04-25 17:44:50 +02:00
|
|
|
unsigned int rc_max_intra_bitrate_pct;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/* mode ->
|
|
|
|
*(0)=Realtime/Live Encoding. This mode is optimized for realtim
|
|
|
|
* 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 longer amount of time to encode.. ( speed setting
|
|
|
|
* ignored )
|
|
|
|
*/
|
|
|
|
int Mode;
|
|
|
|
|
|
|
|
/* Key Framing Operations */
|
|
|
|
int auto_key; /* automatically detect cut scenes */
|
|
|
|
int key_freq; /* maximum distance to key frame. */
|
|
|
|
|
|
|
|
/* lagged compression (if allow_lag == 0 lag_in_frames is ignored) */
|
|
|
|
int allow_lag;
|
|
|
|
int lag_in_frames; /* how many frames lag before we start encoding */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DATARATE CONTROL OPTIONS
|
|
|
|
*/
|
|
|
|
|
|
|
|
int end_usage; /* vbr or cbr */
|
|
|
|
|
|
|
|
/* buffer targeting aggressiveness */
|
2010-05-18 17:58:33 +02:00
|
|
|
int under_shoot_pct;
|
2011-04-11 17:29:23 +02:00
|
|
|
int over_shoot_pct;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/* buffering parameters */
|
|
|
|
int64_t starting_buffer_level;
|
2011-10-07 21:42:23 +02:00
|
|
|
int64_t optimal_buffer_level;
|
|
|
|
int64_t maximum_buffer_size;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
int64_t starting_buffer_level_in_ms;
|
2012-01-13 23:09:40 +01:00
|
|
|
int64_t optimal_buffer_level_in_ms;
|
|
|
|
int64_t maximum_buffer_size_in_ms;
|
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/* controlling quality */
|
2010-05-18 17:58:33 +02:00
|
|
|
int fixed_q;
|
|
|
|
int worst_allowed_q;
|
|
|
|
int best_allowed_q;
|
2011-01-07 19:29:37 +01:00
|
|
|
int cq_level;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/* allow internal resizing */
|
2010-05-18 17:58:33 +02:00
|
|
|
int allow_spatial_resampling;
|
|
|
|
int resample_down_water_mark;
|
|
|
|
int resample_up_water_mark;
|
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/* allow internal frame rate alterations */
|
2010-05-18 17:58:33 +02:00
|
|
|
int allow_df;
|
|
|
|
int drop_frames_water_mark;
|
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/* two pass datarate control */
|
|
|
|
int two_pass_vbrbias;
|
2010-05-18 17:58:33 +02:00
|
|
|
int two_pass_vbrmin_section;
|
|
|
|
int two_pass_vbrmax_section;
|
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/*
|
|
|
|
* END DATARATE CONTROL OPTIONS
|
|
|
|
*/
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/* these parameters aren't to be used in final build don't use!!! */
|
2010-05-18 17:58:33 +02:00
|
|
|
int play_alternate;
|
|
|
|
int alt_freq;
|
|
|
|
int alt_q;
|
|
|
|
int key_q;
|
|
|
|
int gold_q;
|
|
|
|
|
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
int multi_threaded; /* how many threads to run the encoder on */
|
|
|
|
int token_partitions; /* how many token partitions to create */
|
|
|
|
|
|
|
|
/* early breakout threshold: for video conf recommend 800 */
|
|
|
|
int encode_breakout;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/* 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;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
int arnr_max_frames;
|
2012-05-21 23:30:56 +02:00
|
|
|
int arnr_strength;
|
|
|
|
int arnr_type;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
struct vpx_fixed_buf two_pass_stats_in;
|
2010-05-18 17:58:33 +02:00
|
|
|
struct vpx_codec_pkt_list *output_pkt_list;
|
2010-12-17 15:43:39 +01:00
|
|
|
|
|
|
|
vp8e_tuning tuning;
|
2011-10-07 00:49:11 +02:00
|
|
|
|
2012-05-21 23:30:56 +02:00
|
|
|
/* Temporal scaling parameters */
|
2011-10-07 00:49:11 +02:00
|
|
|
unsigned int number_of_layers;
|
2012-05-03 01:21:52 +02:00
|
|
|
unsigned int target_bitrate[VPX_TS_MAX_PERIODICITY];
|
|
|
|
unsigned int rate_decimator[VPX_TS_MAX_PERIODICITY];
|
2011-10-07 00:49:11 +02:00
|
|
|
unsigned int periodicity;
|
2012-05-03 01:21:52 +02:00
|
|
|
unsigned int layer_id[VPX_TS_MAX_PERIODICITY];
|
2011-10-07 00:49:11 +02:00
|
|
|
|
2011-10-25 21:14:16 +02:00
|
|
|
#if CONFIG_MULTI_RES_ENCODING
|
|
|
|
/* Number of total resolutions encoded */
|
|
|
|
unsigned int mr_total_resolutions;
|
|
|
|
|
|
|
|
/* Current encoder ID */
|
|
|
|
unsigned int mr_encoder_id;
|
|
|
|
|
|
|
|
/* Down-sampling factor */
|
|
|
|
vpx_rational_t mr_down_sampling_factor;
|
|
|
|
|
|
|
|
/* Memory location to store low-resolution encoder's mode info */
|
|
|
|
void* mr_low_res_mode_info;
|
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
} VP8_CONFIG;
|
|
|
|
|
|
|
|
|
|
|
|
void vp8_initialize();
|
|
|
|
|
2011-12-21 01:54:54 +01:00
|
|
|
struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf);
|
|
|
|
void vp8_remove_compressor(struct VP8_COMP* *comp);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-12-21 01:54:54 +01:00
|
|
|
void vp8_init_config(struct VP8_COMP* onyx, VP8_CONFIG *oxcf);
|
|
|
|
void vp8_change_config(struct VP8_COMP* onyx, VP8_CONFIG *oxcf);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-12-21 01:54:54 +01:00
|
|
|
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);
|
|
|
|
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);
|
|
|
|
int vp8_get_preview_raw_frame(struct VP8_COMP* comp, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *flags);
|
|
|
|
|
|
|
|
int vp8_use_as_reference(struct VP8_COMP* comp, int ref_frame_flags);
|
|
|
|
int vp8_update_reference(struct VP8_COMP* comp, int ref_frame_flags);
|
2012-05-24 01:08:37 +02:00
|
|
|
int vp8_get_reference(struct VP8_COMP* comp, enum vpx_ref_frame_type ref_frame_flag, YV12_BUFFER_CONFIG *sd);
|
|
|
|
int vp8_set_reference(struct VP8_COMP* comp, enum vpx_ref_frame_type ref_frame_flag, YV12_BUFFER_CONFIG *sd);
|
2011-12-21 01:54:54 +01:00
|
|
|
int vp8_update_entropy(struct VP8_COMP* comp, int update);
|
|
|
|
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]);
|
|
|
|
int vp8_set_active_map(struct VP8_COMP* comp, unsigned char *map, unsigned int rows, unsigned int cols);
|
|
|
|
int vp8_set_internal_size(struct VP8_COMP* comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode);
|
|
|
|
int vp8_get_quantizer(struct VP8_COMP* c);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|