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
|
|
|
*/
|
|
|
|
|
2012-11-30 01:36:10 +01:00
|
|
|
#ifndef VP9_COMMON_VP9_ONYX_H_
|
|
|
|
#define VP9_COMMON_VP9_ONYX_H_
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
2013-09-30 02:50:18 +02:00
|
|
|
{ // NOLINT
|
2010-05-18 17:58:33 +02:00
|
|
|
#endif
|
|
|
|
|
2013-02-06 21:45:28 +01: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"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_scale/yv12config.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_ppflags.h"
|
2013-04-24 14:04:45 +02:00
|
|
|
|
2013-07-23 13:09:04 +02:00
|
|
|
#define MAX_SEGMENTS 8
|
2013-04-24 14:04:45 +02:00
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
typedef int *VP9_PTR;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
/* Create/destroy static data structures. */
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef enum {
|
|
|
|
NORMAL = 0,
|
|
|
|
FOURFIVE = 1,
|
|
|
|
THREEFIVE = 2,
|
|
|
|
ONETWO = 3
|
|
|
|
} VPX_SCALING;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef enum {
|
2012-10-31 22:40:53 +01:00
|
|
|
VP9_LAST_FLAG = 1,
|
|
|
|
VP9_GOLD_FLAG = 2,
|
|
|
|
VP9_ALT_FLAG = 4
|
|
|
|
} VP9_REFFRAME;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef enum {
|
|
|
|
USAGE_STREAM_FROM_SERVER = 0x0,
|
|
|
|
USAGE_LOCAL_FILE_PLAYBACK = 0x1,
|
2013-08-30 01:21:44 +02:00
|
|
|
USAGE_CONSTRAINED_QUALITY = 0x2,
|
|
|
|
USAGE_CONSTANT_QUALITY = 0x3,
|
2012-07-14 00:21:29 +02:00
|
|
|
} END_USAGE;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef enum {
|
|
|
|
MODE_GOODQUALITY = 0x1,
|
|
|
|
MODE_BESTQUALITY = 0x2,
|
|
|
|
MODE_FIRSTPASS = 0x3,
|
|
|
|
MODE_SECONDPASS = 0x4,
|
|
|
|
MODE_SECONDPASS_BEST = 0x5,
|
|
|
|
} MODE;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef enum {
|
|
|
|
FRAMEFLAGS_KEY = 1,
|
|
|
|
FRAMEFLAGS_GOLDEN = 2,
|
|
|
|
FRAMEFLAGS_ALTREF = 4,
|
|
|
|
} FRAMETYPE_FLAGS;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef struct {
|
2013-03-21 00:41:30 +01:00
|
|
|
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
|
2013-09-30 02:50:18 +02:00
|
|
|
double framerate; // set to passed in framerate
|
|
|
|
int64_t target_bandwidth; // bandwidth to be used in kilobits per second
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-09-30 02:50:18 +02:00
|
|
|
int noise_sensitivity; // pre processing blur: recommendation 0
|
|
|
|
int Sharpness; // sharpening output: recommendation 0:
|
2012-07-14 00:21:29 +02:00
|
|
|
int cpu_used;
|
|
|
|
unsigned int rc_max_intra_bitrate_pct;
|
|
|
|
|
|
|
|
// mode ->
|
2013-09-30 02:50:18 +02:00
|
|
|
// (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
|
2012-07-14 00:21:29 +02:00
|
|
|
// longer amount of time to encode.. ( speed setting ignored )
|
2013-09-30 02:50:18 +02:00
|
|
|
int Mode;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
// Key Framing Operations
|
2013-09-30 02:50:18 +02:00
|
|
|
int auto_key; // autodetect cut scenes and set the keyframes
|
|
|
|
int key_freq; // maximum distance to key frame.
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-09-30 02:50:18 +02:00
|
|
|
int allow_lag; // allow lagged compression (if 0 lagin frames is ignored)
|
|
|
|
int lag_in_frames; // how many frames lag before we start encoding
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------
|
|
|
|
// DATARATE CONTROL OPTIONS
|
|
|
|
|
2013-09-30 02:50:18 +02:00
|
|
|
int end_usage; // vbr or cbr
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
// buffer targeting aggressiveness
|
|
|
|
int under_shoot_pct;
|
|
|
|
int over_shoot_pct;
|
|
|
|
|
|
|
|
// buffering parameters
|
2013-02-28 02:09:12 +01:00
|
|
|
int64_t starting_buffer_level; // in seconds
|
|
|
|
int64_t optimal_buffer_level;
|
|
|
|
int64_t maximum_buffer_size;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
// controlling quality
|
|
|
|
int fixed_q;
|
|
|
|
int worst_allowed_q;
|
|
|
|
int best_allowed_q;
|
|
|
|
int cq_level;
|
|
|
|
int lossless;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// ----------------------------------------------------------------
|
|
|
|
|
2013-09-05 17:55:47 +02:00
|
|
|
// Spatial scalability
|
|
|
|
int ss_number_layers;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
// these parameters aren't to be used in final build don't use!!!
|
|
|
|
int play_alternate;
|
|
|
|
int alt_freq;
|
|
|
|
|
2013-09-30 02:50:18 +02:00
|
|
|
int encode_breakout; // early breakout : for video conf recommend 800
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-01-15 15:43:35 +01: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;
|
|
|
|
|
2013-01-25 20:30:28 +01:00
|
|
|
/* 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;
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int arnr_max_frames;
|
|
|
|
int arnr_strength;
|
|
|
|
int arnr_type;
|
|
|
|
|
[WIP] Add column-based tiling.
This patch adds column-based tiling. The idea is to make each tile
independently decodable (after reading the common frame header) and
also independendly encodable (minus within-frame cost adjustments in
the RD loop) to speed-up hardware & software en/decoders if they used
multi-threading. Column-based tiling has the added advantage (over
other tiling methods) that it minimizes realtime use-case latency,
since all threads can start encoding data as soon as the first SB-row
worth of data is available to the encoder.
There is some test code that does random tile ordering in the decoder,
to confirm that each tile is indeed independently decodable from other
tiles in the same frame. At tile edges, all contexts assume default
values (i.e. 0, 0 motion vector, no coefficients, DC intra4x4 mode),
and motion vector search and ordering do not cross tiles in the same
frame.
t log
Tile independence is not maintained between frames ATM, i.e. tile 0 of
frame 1 is free to use motion vectors that point into any tile of frame
0. We support 1 (i.e. no tiling), 2 or 4 column-tiles.
The loopfilter crosses tile boundaries. I discussed this briefly with Aki
and he says that's OK. An in-loop loopfilter would need to do some sync
between tile threads, but that shouldn't be a big issue.
Resuls: with tiling disabled, we go up slightly because of improved edge
use in the intra4x4 prediction. With 2 tiles, we lose about ~1% on derf,
~0.35% on HD and ~0.55% on STD/HD. With 4 tiles, we lose another ~1.5%
on derf ~0.77% on HD and ~0.85% on STD/HD. Most of this loss is
concentrated in the low-bitrate end of clips, and most of it is because
of the loss of edges at tile boundaries and the resulting loss of intra
predictors.
TODO:
- more tiles (perhaps allow row-based tiling also, and max. 8 tiles)?
- maybe optionally (for EC purposes), motion vectors themselves
should not cross tile edges, or we should emulate such borders as
if they were off-frame, to limit error propagation to within one
tile only. This doesn't have to be the default behaviour but could
be an optional bitstream flag.
Change-Id: I5951c3a0742a767b20bc9fb5af685d9892c2c96f
2013-02-01 18:35:28 +01:00
|
|
|
int tile_columns;
|
2013-02-08 20:33:11 +01:00
|
|
|
int tile_rows;
|
[WIP] Add column-based tiling.
This patch adds column-based tiling. The idea is to make each tile
independently decodable (after reading the common frame header) and
also independendly encodable (minus within-frame cost adjustments in
the RD loop) to speed-up hardware & software en/decoders if they used
multi-threading. Column-based tiling has the added advantage (over
other tiling methods) that it minimizes realtime use-case latency,
since all threads can start encoding data as soon as the first SB-row
worth of data is available to the encoder.
There is some test code that does random tile ordering in the decoder,
to confirm that each tile is indeed independently decodable from other
tiles in the same frame. At tile edges, all contexts assume default
values (i.e. 0, 0 motion vector, no coefficients, DC intra4x4 mode),
and motion vector search and ordering do not cross tiles in the same
frame.
t log
Tile independence is not maintained between frames ATM, i.e. tile 0 of
frame 1 is free to use motion vectors that point into any tile of frame
0. We support 1 (i.e. no tiling), 2 or 4 column-tiles.
The loopfilter crosses tile boundaries. I discussed this briefly with Aki
and he says that's OK. An in-loop loopfilter would need to do some sync
between tile threads, but that shouldn't be a big issue.
Resuls: with tiling disabled, we go up slightly because of improved edge
use in the intra4x4 prediction. With 2 tiles, we lose about ~1% on derf,
~0.35% on HD and ~0.55% on STD/HD. With 4 tiles, we lose another ~1.5%
on derf ~0.77% on HD and ~0.85% on STD/HD. Most of this loss is
concentrated in the low-bitrate end of clips, and most of it is because
of the loss of edges at tile boundaries and the resulting loss of intra
predictors.
TODO:
- more tiles (perhaps allow row-based tiling also, and max. 8 tiles)?
- maybe optionally (for EC purposes), motion vectors themselves
should not cross tile edges, or we should emulate such borders as
if they were off-frame, to limit error propagation to within one
tile only. This doesn't have to be the default behaviour but could
be an optional bitstream flag.
Change-Id: I5951c3a0742a767b20bc9fb5af685d9892c2c96f
2013-02-01 18:35:28 +01:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
struct vpx_fixed_buf two_pass_stats_in;
|
|
|
|
struct vpx_codec_pkt_list *output_pkt_list;
|
|
|
|
|
|
|
|
vp8e_tuning tuning;
|
2012-10-31 22:40:53 +01:00
|
|
|
} VP9_CONFIG;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
|
2012-10-30 22:25:33 +01:00
|
|
|
void vp9_initialize_enc();
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf);
|
2012-10-31 01:53:32 +01:00
|
|
|
void vp9_remove_compressor(VP9_PTR *comp);
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
void vp9_change_config(VP9_PTR onyx, VP9_CONFIG *oxcf);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-09-30 02:50:18 +02:00
|
|
|
// 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..
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_receive_raw_frame(VP9_PTR comp, unsigned int frame_flags,
|
2012-10-30 22:25:33 +01:00
|
|
|
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
|
|
|
|
int64_t end_time_stamp);
|
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_get_compressed_data(VP9_PTR comp, unsigned int *frame_flags,
|
2012-10-30 22:25:33 +01:00
|
|
|
unsigned long *size, unsigned char *dest,
|
|
|
|
int64_t *time_stamp, int64_t *time_end,
|
|
|
|
int flush);
|
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest,
|
2012-10-31 22:40:53 +01:00
|
|
|
vp9_ppflags_t *flags);
|
2012-10-30 20:58:42 +01:00
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_use_as_reference(VP9_PTR comp, int ref_frame_flags);
|
2012-10-30 22:25:33 +01:00
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_update_reference(VP9_PTR comp, int ref_frame_flags);
|
2012-10-30 22:25:33 +01:00
|
|
|
|
2013-03-13 20:15:43 +01:00
|
|
|
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);
|
2012-10-30 22:25:33 +01:00
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
int vp9_set_reference_enc(VP9_PTR comp, VP9_REFFRAME ref_frame_flag,
|
2012-10-30 22:25:33 +01:00
|
|
|
YV12_BUFFER_CONFIG *sd);
|
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_update_entropy(VP9_PTR comp, int update);
|
2012-10-30 22:25:33 +01:00
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_set_roimap(VP9_PTR comp, unsigned char *map,
|
2012-10-30 22:25:33 +01:00
|
|
|
unsigned int rows, unsigned int cols,
|
2013-07-23 13:09:04 +02:00
|
|
|
int delta_q[MAX_SEGMENTS],
|
|
|
|
int delta_lf[MAX_SEGMENTS],
|
|
|
|
unsigned int threshold[MAX_SEGMENTS]);
|
2012-10-30 22:25:33 +01:00
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_set_active_map(VP9_PTR comp, unsigned char *map,
|
2012-10-30 22:25:33 +01:00
|
|
|
unsigned int rows, unsigned int cols);
|
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_set_internal_size(VP9_PTR comp,
|
2012-10-30 22:25:33 +01:00
|
|
|
VPX_SCALING horiz_mode, VPX_SCALING vert_mode);
|
|
|
|
|
2013-09-05 17:55:47 +02:00
|
|
|
int vp9_set_size_literal(VP9_PTR comp, unsigned int width,
|
|
|
|
unsigned int height);
|
|
|
|
|
|
|
|
int vp9_switch_layer(VP9_PTR comp, int layer);
|
|
|
|
|
|
|
|
void vp9_set_svc(VP9_PTR comp, int use_svc);
|
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
int vp9_get_quantizer(VP9_PTR c);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-12-19 00:31:19 +01:00
|
|
|
#endif // VP9_COMMON_VP9_ONYX_H_
|