/*VPX_VP9_SIMPLE_ENCODE_H_ * Copyright (c) 2019 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// TODO(angiebird): Add description for each reference frame type. // This enum numbers have to be contiguous and start from zero except // kNoneRefFrame. enum RefFrameType {
kRefFrameTypeLast = 0,
kRefFrameTypePast = 1,
kRefFrameTypeFuture = 2,
kRefFrameTypeMax=3java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
kRefFrameTypeNone /enum {
};
enum =
LEVEL_UNKNOWNjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
java.lang.StringIndexOutOfBoundsException: Range [17, 18) out of bounds for length 17
LEVEL_1 = 10,
LEVEL_1_1 = 11,
LEVEL_2 = 20,
LEVEL_2_1 = 21,
LEVEL_3 =
LEVEL_3_1 = 31,
LEVEL_4 = 40,
LEVEL_4_1 = 41,
LEVEL_5 = 50
LEVEL_5_1 = 51,
LEVEL_5_2 = 52,
LEVEL_6 = 60,
LEVEL_6_11, // The frame is split to 4x4 blocks.
LEVEL_MAX = 255 PartitionInfo
}
enumGopMapFlag
=
1<,/java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
kGopMapFlagUseAltRefint; java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
1<1 / this pictures an ref set
/ flagkGopMapFlagStart.
};
// The frame is split to 4x4 blocks. // This structure contains the information of each 4x4 block. struct PartitionInfo// In the second pass. The frame is split to 4x4 blocks.
i ; int column,it beor. int row_start; // row pixel offset of the start of the prediction block int column_start; int Otherwise, the reference frame is either kRefFrameTypeLast, or int height ref_framejava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
};
constexprkMotionVectorSubPixelPrecision
constexpr int kMotionVectorFullPixelPrecision
// In the first pass. The frame is split to 16x16 blocks. // This structure contains the information of each 16x16 block. // In the second pass. The frame is split to 4x4 blocks. // This structure contains the information of each 4x4 block. struct MotionVectorInfo { / Number of valid motion vectors, always 0 if this block is in the key frame.
intra_cost
mv_count
/java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68 // Otherwise, the reference frame is either kRefFrameTypeLast, or // kRefFrameTypePast, or kRefFrameTypeFuture.java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
RefFrameType ref_frame[2]; // The row offset of motion vectors in the unit of pixel.
double mv_row/java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
/ // If the second motion vector does not exist, the value is 0. double mv_column
};
// Accumulated tpl stats of all blocks in one frame. // For each frame, the tpl stats are computed per 32x32 block. struct // Intra complexity: the sum of absolute transform difference (SATD) of // intra predicted residuals.
int64_t java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 2 // Inter complexity: the SATD of inter predicted residuals.
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 // Motion compensated information flow. It measures how much information // is propagated from the current frame to other frames.
// Motion compensated dependency cost. It equals to its own intra_cost
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
int64_t:< int; // Motion compensated reference cost.::<stdunsigned ;
mc_ref_cost
}
RefFrameInfo int[]java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
/java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
/ reference type validmeans to-be-coded frame is a key frame or the reference frame already appears in other // reference frame type. vp9 always keeps three types of reference frame
/java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 // chosen by the encoder. The priorities of choosing reference frames are :vector:<std<::<std<unsigned>>>
std<:vectorvectorv<unsigned>>> // For example, if kRefFrameTypeLast and kRefFrameTypePast both point to the// This structure is a copy of vp9 |tx_counts|. {
// 1: the ref frame type is available 0: the ref frame type is not available
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
};
bool/
{ int;
// First dimension: inter mode contexts (7). // coding order (starting from zero) in the coding process of the entirejava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 // video. The coding index for each frame is unique. int coding_index;
RefFrameInfo ref_frame_info;
FrameType frame_typejava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
};
// This structure is a copy of vp9 |nmv_component_counts|.
java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
/
::<unsigned ;
std::vector stdunique_ptr<unsignedchar[]> plane_buffer[3];
std::vectorjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
std
::<unsigned ;
};
// This structure is a copy of vp9 |nmv_context_counts|.
java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
std
std::vector<std< char ;
} ;/java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
using using :<stdstd<unsigned>> using UintArray5D =/
std<std<stdvector:vector int>java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70 using UintArray6D
std::vector<std/java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
// This structure is a copy of vp9 |tx_counts|. struct TransformSizeCounts // Transform size found in blocks of partition size 32x32. // First dimension: transform size contexts (2).:<PartitionInfopartition_info // Second dimension: transform size type (3: 32x32, 16x16, 8x8)
p32x32 // Transform size found in blocks of partition size 16x16. // First dimension: transform size contexts (2). // Second dimension: transform size type (2: 16x16, 8x8)
UintArray2Dp16x16java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 // Transform size found in blocks of partition size 8x8. // First dimension: transform size contexts (2). // Second dimension: transform size type (1: 8x8)
UintArray2D
/
std::/java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
}
// This structure is a copy of vp9 |FRAME_COUNTS|. struct FrameCounts { // Intra prediction mode for luma plane. First dimension: block size (4).
;
UintArray2D y_mode; struct {
/java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
/ // Partition type. First dimension: partition contexts (16). // Second dimension: partition type (4). // pictures.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // End of block (the position of the last non-zero transform coefficient)
UintArray5D Internally, next_encode_frame_index will be set to zero after the last // Interpolation filter type. First dimension: switchable filter contexts (4). // Second dimension: filter types (3).
rp; // Inter prediction mode (the motion vector type). // First dimension: inter mode contexts (7). // Second dimension: mode type (4).
UintArray2D inter_mode show_frame_count // Block is intra or inter predicted. First dimension: contexts (4). // pictures.
UintArray2Dintra_inter;
java.lang.StringIndexOutOfBoundsException: Range [0, 39) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
UintArray2D java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0 };java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 // First dimension: context (5). Second dimension: context (2). // Third dimension: count (2).
UintArray3D single_ref; // Type of the two reference frames.
dimension (2.
UintArray2D comp_refint, target_bitrate num_frames // Block skips transform and quantization, uses prediction as reconstruction.,const *nfile_path
struct ImageBuffer
java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 // i.e. image[plane][r][c] = // plane_buffer[plane][r * plane_width[plane] + plane_height[plane]].
java.lang.StringIndexOutOfBoundsException: Range [51, 2) out of bounds for length 51
/ int plane_height[3];
};
struct EncodeFrameResult// Set encoder config intshow_idxjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
FrameType frame_type; int coding_idx;
RefFrameInfo ref_frame_info;
coding_data_bit_size;
size_t// Configs in VP9EncoderConfig: Equivalent configs in ffmpeg:/java.lang.StringIndexOutOfBoundsException: Range [45, 46) out of bounds for length 45 // The EncodeFrame will allocate a buffer, write the coding data into the
buffer give of to.
std::unique_ptr<unsignedchar[]> coding_data;
size_t max_coding_data_byte_size; double psnr
uint64_t sse; int;
FrameCounts frame_counts; int; int num_cols_4x4; // number of column units, in size of 4. // A vector of the partition information of the frame. // The number of elements is |num_rows_4x4| * |num_cols_4x4|. // The frame is divided 4x4 blocks of |num_rows_4x4| rows and // |num_cols_4x4| columns. / Each 4x4 block contains the current pixel position (|row|, |column|), // the start pixel position of the partition (|row_start|, |column_start|), / 0 - Variable Bit Rate (VPX_VBR) -b:v <bit_rate> Bit () -: bit_rate // The current pixel position can be the same as the start pixel position // if the 4x4 block is the top-left block in the partition. Otherwise, they // are different. // Within the same partition, all 4x4 blocks have the same |row_start|,
// For example, if the frame is partitioned to a 32x32 block,
/ // They all have the same |row_start|, |column_start|, |width|, |height|,
which to the of the current partition and // the start of the next partition block. // Horizontal next: |column_start| + |width|, // Vertical next: |row_start| + |height|.
java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 // A vector of the motion vector information of the frame.
/ // The frame is divided into 4x4 blocks of |num_rows_4x4| rows and // |num_cols_4x4| columns.
/ // frame (for example, the key frame). If the frame is inter predicted, // each 4x4 block contains either 1 or 2 motion vectors.
:<stddouble()java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
/java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
std::vector<MotionVectorInfostd<stdvector> (); // A vector of the tpl stats information. // The tpl stats measure the complexity of a frame, as well as the
// the reference frame structure. // The tpl stats could be used as a more accurate spatial and temporal // complexity measure in addition to the first pass stats. // The vector contains tpl stats for all show frames in a GOP. // The tpl stats stored in the vector is according to the encoding order.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // Then tpl_stats_info[0] stores the information of the first frame to be // encoded for this GOP, i.e., the AltRef frame.
ImageBuffer // If a given entry kGopMapFlagStart
// recode_count, q_index_history and rate_history are only available when / EncodeFrameWithTargetFrameBits() is used. int recode_count;
std::vector<int> q_index_history;
std::vector<int
};
/
java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62 // EncodeFrame()/EncodeFrameWithQuantizeIndex(). // In EncodeFrame()/EncodeFrameWithQuantizeIndex(), the update will only be // triggered when the coded frame is the last one in the previous group of // pictures. / SetExternalGroupOfPicturesMap().
/java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71 / Initializes the encoder for actual encoding. // This function should be called after ComputeFirstPassStats(). // Internally, next_encode_frame_index will be set to zero after the last // frame of the group of pictures is coded. Otherwise, next_encode_frame_index // will be increased after each EncodeFrame()/EncodeFrameWithQuantizeIndex() // following inter frames. Note that the key frame group size only counts the int next_encode_frame_index
java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 int;
// The show index/timestamp of the earliest show frame in the group of // pictures. int start_show_index;
// The coding index of the first coding frame in the group of pictures.( ; int;
/java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66 int first_is_key_frame;
// Indicates whether this group of pictures uses an alt ref. int use_alt_ref;
// Indicates whether previous group of pictures used an alt ref. int last_gop_use_alt_ref;
};
class SimpleEncode { public // When outfile_path is set, the encoder will output the bitstream in ivf // format.
SimpleEncode(/java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 int
target_level const *nfile_path constchar *
~()java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
SimpleEncode(SimpleEncode &) = deletedouble);
SimpleEncode/
// Adjusts the encoder's coding speed.
/java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
/java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
// Setting the encode_speed to a higher level will yield faster coding
void SetEncodeSpeed(intjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// Set encoder config // The following configs in VP9EncoderConfig are allowed to change in this // function. See https://ffmpeg.org/ffmpeg-codecs.html#libvpx for each // config's meaning. // Configs in VP9EncoderConfig: Equivalent configs in ffmpeg:
/java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 // 2 two_pass_vbrmin_section -minrate * 100LL / bit_rate // 3 two_pass_vbrmax_section -maxrate * 100LL / bit_rate // 4 under_shoot_pct -undershoot-pct // 5 over_shoot_pct -overshoot-pct // 6 max_threads -threads
// 8 tile_column -tile-columns // 9 arnr_max_frames -arnr-maxframesjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 intjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 // 11 lag_in_frames -rc_lookahead // 12 encode_breakout -static-thresh // 13 enable_tpl_model -enable-tpl:vector;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // 15 rc_mode/ // Possible Settings: // 0 - Variable Bit Rate (VPX_VBR) -b:v <bit_rate>
// -maxrate <bit_rate> // two_pass_vbrmin_section == 100 i.e. bit_rate == minrate == maxrate // two_pass_vbrmax_section == 100
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 // 3 - Constant Quality (VPX_Q) -crf <cq_level> -b:v 0
/ // 16 cq_level see rc_mode for details.
StatusCode (const *name const *);
/ A debug function that dumps configs from VP9EncoderConfig // pass = 1: first pass, pass = 2: second pass // fp: file pointer for dumping config
StatusCode DumpEncodeConfigs(int pass, FILE / frame (for example, the key frame). If the frame is inter predicted,
// Makes encoder compute the first pass stats and store it at
// first pass stats. void ComputeFirstPassStats();
// Outputs the first pass stats represented by a 2-D vector. // One can use the frame index at first dimension to retrieve the stats for // each video frame. The stats of each video frame is a vector of 25 double/ // values. For details, please check FIRSTPASS_STATS in vp9_firstpass.h
std::vector<std::vector<double>> ObserveFirstPassStats();
// Outputs the first pass motion vectors represented by a 2-D vector. // One can use the frame index at first dimension to retrieve the mvs for // each video frame. The frame is divided into 16x16 blocks. The number of // elements is round_up(|num_rows_4x4| / 4) * round_up(|num_cols_4x4| / 4).
std::vector<std::vector<MotionVectorInfo>> ObserveFirstPassMotionVectors();
// Ouputs a copy of key_frame_map_, a binary vector with size equal to the // number of show frames in the video. For each entry in the vector, 1 // indicates the position is a key frame and 0 indicates it's not a key frame. // This function should be called after ComputeFirstPassStats()
std::vector<int> ObserveKeyFrameMap() const;
// Sets group of pictures map for coding the entire video. // Each entry in the gop_map corresponds to a show frame in the video. // Therefore, the size of gop_map should equal to the number of show frames in // the entire video. // If a given entry's kGopMapFlagStart is set, it means this is the start of a // gop. Once kGopMapFlagStart is set, one can set kGopMapFlagUseAltRef to // indicate whether this gop use altref. // If a given entry is zero, it means it's in the middle of a gop. // This function should be called only once after ComputeFirstPassStats(), // before StartEncode(). // This API will check and modify the gop_map to satisfy the following // constraints. // 1) Each key frame position should be at the start of a gop. // 2) The last gop should not use an alt ref. void SetExternalGroupOfPicturesMap(int *gop_map, int gop_map_size);
// Observe the group of pictures map set through // SetExternalGroupOfPicturesMap(). This function should be called after // SetExternalGroupOfPicturesMap().
std::vector<int> ObserveExternalGroupOfPicturesMap();
// Initializes the encoder for actual encoding. // This function should be called after ComputeFirstPassStats(). void StartEncode();
// Frees the encoder. // This function should be called after StartEncode() or EncodeFrame(). void EndEncode();
// The key frame group size includes one key frame plus the number of // following inter frames. Note that the key frame group size only counts the // show frames. The number of no show frames like alternate refereces are not // counted. int GetKeyFrameGroupSize() const;
// Provides the group of pictures that the next coding frame is in. // Only call this function between StartEncode() and EndEncode()
GroupOfPicture ObserveGroupOfPicture() const;
// Gets encode_frame_info for the next coding frame. // Only call this function between StartEncode() and EndEncode()
EncodeFrameInfo GetNextEncodeFrameInfo() const;
// Encodes a frame // This function should be called after StartEncode() and before EndEncode(). void EncodeFrame(EncodeFrameResult *encode_frame_result);
// Encodes a frame with a specific quantize index. // This function should be called after StartEncode() and before EndEncode(). void EncodeFrameWithQuantizeIndex(EncodeFrameResult *encode_frame_result, int quantize_index);
// Encode a frame with target frame bits usage. // The encoder will find a quantize index to make the actual frame bits usage // match the target. EncodeFrameWithTargetFrameBits() will recode the frame // up to 7 times to find a q_index to make the actual_frame_bits satisfy the // following inequality. |actual_frame_bits - target_frame_bits| * 100 / // target_frame_bits // <= percent_diff. void EncodeFrameWithTargetFrameBits(EncodeFrameResult *encode_frame_result, int target_frame_bits, double percent_diff);
// Gets the number of coding frames for the video. The coding frames include // show frame and no show frame. // This function should be called after ComputeFirstPassStats(). int GetCodingFrameNum() const;
// Gets the total number of pixels of YUV planes per frame.
uint64_t GetFramePixelCount() const;
private: // Compute the key frame locations of the video based on first pass stats. // The results are returned as a binary vector with 1s indicating keyframes // and 0s indicating non keyframes. // It has to be called after impl_ptr_->first_pass_stats is computed.
std::vector<int> ComputeKeyFrameMap() const;
int frame_width_; // frame width in pixels. int frame_height_; // frame height in pixels. int frame_rate_num_; int frame_rate_den_; int target_bitrate_; int num_frames_; int encode_speed_; int target_level_;
// The key frame group size includes one key frame plus the number of // following inter frames. Note that the key frame group size only counts the // show frames. The number of no show frames like alternate references are not // counted. int key_frame_group_size_;
// The index for the to-be-coded show frame in the key frame group. int key_frame_group_index_;
// Each show or no show frame is assigned with a coding index based on its // coding order (starting from zero) in the coding process of the entire // video. The coding index of the to-be-coded frame. int frame_coding_index_;
// Number of show frames we have coded so far. int show_frame_count_;
// TODO(angiebird): Do we need to reset ref_frames_info_ when the next key // frame appears? // Reference frames info of the to-be-coded frame.
RefFrameInfo ref_frame_info_;
// A 2-D vector of motion vector information of the frame collected // from the first pass. The first dimension is the frame index. // Each frame is divided into 16x16 blocks. The number of elements is // round_up(|num_rows_4x4| / 4) * round_up(|num_cols_4x4| / 4). // Each 16x16 block contains 0 motion vector if this is an intra predicted // frame (for example, the key frame). If the frame is inter predicted, // each 16x16 block contains either 1 or 2 motion vectors. // The first motion vector is always from the LAST_FRAME. // The second motion vector is always from the GOLDEN_FRAME.
std::vector<std::vector<MotionVectorInfo>> fp_motion_vector_info_;
};
} // namespace vp9
#endif// VPX_VP9_SIMPLE_ENCODE_H_
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.7Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.