Remove unused APIs and skin_detection dead code
This removes the unused spatial scalability, temporal layers, and svc parameters from the aom API. There is no code implementing these APIs, and if it they are needed in the future, just resurrect them from this commit. The skin_detection code is unused and won't be used. Change-Id: I3185bad6ec58c55426953b658a12a06ed041d7cd
This commit is contained in:
Родитель
19402574a0
Коммит
0a9b36b9d7
|
@ -628,100 +628,8 @@ typedef struct aom_codec_enc_cfg {
|
|||
* equal to kf_max_dist for a fixed interval.
|
||||
*/
|
||||
unsigned int kf_max_dist;
|
||||
|
||||
/*
|
||||
* Spatial scalability settings (ss)
|
||||
*/
|
||||
|
||||
/*!\brief Number of spatial coding layers.
|
||||
*
|
||||
* This value specifies the number of spatial coding layers to be used.
|
||||
*/
|
||||
unsigned int ss_number_layers;
|
||||
|
||||
/*!\brief Enable auto alt reference flags for each spatial layer.
|
||||
*
|
||||
* These values specify if auto alt reference frame is enabled for each
|
||||
* spatial layer.
|
||||
*/
|
||||
int ss_enable_auto_alt_ref[AOM_SS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Target bitrate for each spatial layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* spatial layer.
|
||||
*/
|
||||
unsigned int ss_target_bitrate[AOM_SS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Number of temporal coding layers.
|
||||
*
|
||||
* This value specifies the number of temporal layers to be used.
|
||||
*/
|
||||
unsigned int ts_number_layers;
|
||||
|
||||
/*!\brief Target bitrate for each temporal layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* temporal layer.
|
||||
*/
|
||||
unsigned int ts_target_bitrate[AOM_TS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Frame rate decimation factor for each temporal layer.
|
||||
*
|
||||
* These values specify the frame rate decimation factors to apply
|
||||
* to each temporal layer.
|
||||
*/
|
||||
unsigned int ts_rate_decimator[AOM_TS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Length of the sequence defining frame temporal layer membership.
|
||||
*
|
||||
* This value specifies the length of the sequence that defines the
|
||||
* membership of frames to temporal layers. For example, if the
|
||||
* ts_periodicity = 8, then the frames are assigned to coding layers with a
|
||||
* repeated sequence of length 8.
|
||||
*/
|
||||
unsigned int ts_periodicity;
|
||||
|
||||
/*!\brief Template defining the membership of frames to temporal layers.
|
||||
*
|
||||
* This array defines the membership of frames to temporal coding layers.
|
||||
* For a 2-layer encoding that assigns even numbered frames to one temporal
|
||||
* layer (0) and odd numbered frames to a second temporal layer (1) with
|
||||
* ts_periodicity=8, then ts_layer_id = (0,1,0,1,0,1,0,1).
|
||||
*/
|
||||
unsigned int ts_layer_id[AOM_TS_MAX_PERIODICITY];
|
||||
|
||||
/*!\brief Target bitrate for each spatial/temporal layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* spatial/temporal layer.
|
||||
*
|
||||
*/
|
||||
unsigned int layer_target_bitrate[AOM_MAX_LAYERS];
|
||||
|
||||
/*!\brief Temporal layering mode indicating which temporal layering scheme to
|
||||
* use.
|
||||
*
|
||||
* The value (refer to AV1E_TEMPORAL_LAYERING_MODE) specifies the
|
||||
* temporal layering mode to use.
|
||||
*
|
||||
*/
|
||||
int temporal_layering_mode;
|
||||
} aom_codec_enc_cfg_t; /**< alias for struct aom_codec_enc_cfg */
|
||||
|
||||
/*!\brief av1 svc extra configure parameters
|
||||
*
|
||||
* This defines max/min quantizers and scale factors for each layer
|
||||
*
|
||||
*/
|
||||
typedef struct aom_svc_parameters {
|
||||
int max_quantizers[AOM_MAX_LAYERS]; /**< Max Q for each layer */
|
||||
int min_quantizers[AOM_MAX_LAYERS]; /**< Min Q for each layer */
|
||||
int scaling_factor_num[AOM_MAX_LAYERS]; /**< Scaling factor-numerator */
|
||||
int scaling_factor_den[AOM_MAX_LAYERS]; /**< Scaling factor-denominator */
|
||||
int temporal_layering_mode; /**< Temporal layering mode */
|
||||
} aom_svc_extra_cfg_t;
|
||||
|
||||
/*!\brief Initialize an encoder instance
|
||||
*
|
||||
* Initializes a encoder context using the given interface. Applications
|
||||
|
|
76
aom/aomcx.h
76
aom/aomcx.h
|
@ -447,32 +447,6 @@ enum aome_enc_control_id {
|
|||
*/
|
||||
AV1E_SET_NOISE_SENSITIVITY,
|
||||
|
||||
/*!\brief Codec control function to turn on/off SVC in encoder.
|
||||
* \note Return value is AOM_CODEC_INVALID_PARAM if the encoder does not
|
||||
* support SVC in its current encoding mode
|
||||
* 0: off, 1: on
|
||||
*
|
||||
* Supported in codecs: AV1
|
||||
*/
|
||||
AV1E_SET_SVC,
|
||||
|
||||
/*!\brief Codec control function to set parameters for SVC.
|
||||
* \note Parameters contain min_q, max_q, scaling factor for each of the
|
||||
* SVC layers.
|
||||
*
|
||||
* Supported in codecs: AV1
|
||||
*/
|
||||
AV1E_SET_SVC_PARAMETERS,
|
||||
|
||||
/*!\brief Codec control function to set svc layer for spatial and temporal.
|
||||
* \note Valid ranges: 0..#aom_codec_enc_cfg::ss_number_layers for spatial
|
||||
* layer and 0..#aom_codec_enc_cfg::ts_number_layers for
|
||||
* temporal layer.
|
||||
*
|
||||
* Supported in codecs: AV1
|
||||
*/
|
||||
AV1E_SET_SVC_LAYER_ID,
|
||||
|
||||
/*!\brief Codec control function to set content type.
|
||||
* \note Valid parameter range:
|
||||
* AOM_CONTENT_DEFAULT = Regular video content (Default)
|
||||
|
@ -482,14 +456,6 @@ enum aome_enc_control_id {
|
|||
*/
|
||||
AV1E_SET_TUNE_CONTENT,
|
||||
|
||||
/*!\brief Codec control function to get svc layer ID.
|
||||
* \note The layer ID returned is for the data packet from the registered
|
||||
* callback function.
|
||||
*
|
||||
* Supported in codecs: AV1
|
||||
*/
|
||||
AV1E_GET_SVC_LAYER_ID,
|
||||
|
||||
/*!\brief Codec control function to register callback to get per layer packet.
|
||||
* \note Parameter for this control function is a structure with a callback
|
||||
* function and a pointer to private data used by the callback.
|
||||
|
@ -556,14 +522,6 @@ enum aome_enc_control_id {
|
|||
*/
|
||||
AV1E_SET_COLOR_RANGE,
|
||||
|
||||
/*!\brief Codec control function to set the frame flags and buffer indices
|
||||
* for spatial layers. The frame flags and buffer indices are set using the
|
||||
* struct #aom_svc_ref_frame_config defined below.
|
||||
*
|
||||
* Supported in codecs: AV1
|
||||
*/
|
||||
AV1E_SET_SVC_REF_FRAME_CONFIG,
|
||||
|
||||
/*!\brief Codec control function to set intended rendering image size.
|
||||
*
|
||||
* By default, this is identical to the image size in pixels.
|
||||
|
@ -683,33 +641,6 @@ typedef enum {
|
|||
*/
|
||||
typedef enum { AOM_TUNE_PSNR, AOM_TUNE_SSIM } aom_tune_metric;
|
||||
|
||||
/*!\brief av1 svc layer parameters
|
||||
*
|
||||
* This defines the spatial and temporal layer id numbers for svc encoding.
|
||||
* This is used with the #AV1E_SET_SVC_LAYER_ID control to set the spatial and
|
||||
* temporal layer id for the current frame.
|
||||
*
|
||||
*/
|
||||
typedef struct aom_svc_layer_id {
|
||||
int spatial_layer_id; /**< Spatial layer id number. */
|
||||
int temporal_layer_id; /**< Temporal layer id number. */
|
||||
} aom_svc_layer_id_t;
|
||||
|
||||
/*!\brief av1 svc frame flag parameters.
|
||||
*
|
||||
* This defines the frame flags and buffer indices for each spatial layer for
|
||||
* svc encoding.
|
||||
* This is used with the #AV1E_SET_SVC_REF_FRAME_CONFIG control to set frame
|
||||
* flags and buffer indices for each spatial layer for the current (super)frame.
|
||||
*
|
||||
*/
|
||||
typedef struct aom_svc_ref_frame_config {
|
||||
int frame_flags[AOM_TS_MAX_LAYERS]; /**< Frame flags. */
|
||||
int lst_fb_idx[AOM_TS_MAX_LAYERS]; /**< Last buffer index. */
|
||||
int gld_fb_idx[AOM_TS_MAX_LAYERS]; /**< Golden buffer index. */
|
||||
int alt_fb_idx[AOM_TS_MAX_LAYERS]; /**< Altref buffer index. */
|
||||
} aom_svc_ref_frame_config_t;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief AOM encoder control function parameter type
|
||||
*
|
||||
|
@ -735,8 +666,6 @@ AOM_CTRL_USE_TYPE(AV1E_SET_SVC_PARAMETERS, void *)
|
|||
#define AOM_CTRL_AV1E_SET_SVC_PARAMETERS
|
||||
AOM_CTRL_USE_TYPE(AV1E_REGISTER_CX_CALLBACK, void *)
|
||||
#define AOM_CTRL_AV1E_REGISTER_CX_CALLBACK
|
||||
AOM_CTRL_USE_TYPE(AV1E_SET_SVC_LAYER_ID, aom_svc_layer_id_t *)
|
||||
#define AOM_CTRL_AV1E_SET_SVC_LAYER_ID
|
||||
|
||||
AOM_CTRL_USE_TYPE(AOME_SET_CPUUSED, int)
|
||||
#define AOM_CTRL_AOME_SET_CPUUSED
|
||||
|
@ -771,8 +700,6 @@ AOM_CTRL_USE_TYPE(AOME_GET_LAST_QUANTIZER, int *)
|
|||
#define AOM_CTRL_AOME_GET_LAST_QUANTIZER
|
||||
AOM_CTRL_USE_TYPE(AOME_GET_LAST_QUANTIZER_64, int *)
|
||||
#define AOM_CTRL_AOME_GET_LAST_QUANTIZER_64
|
||||
AOM_CTRL_USE_TYPE(AV1E_GET_SVC_LAYER_ID, aom_svc_layer_id_t *)
|
||||
#define AOM_CTRL_AV1E_GET_SVC_LAYER_ID
|
||||
|
||||
AOM_CTRL_USE_TYPE(AOME_SET_MAX_INTRA_BITRATE_PCT, unsigned int)
|
||||
#define AOM_CTRL_AOME_SET_MAX_INTRA_BITRATE_PCT
|
||||
|
@ -829,9 +756,6 @@ AOM_CTRL_USE_TYPE(AV1E_GET_ACTIVEMAP, aom_active_map_t *)
|
|||
AOM_CTRL_USE_TYPE(AV1E_SET_COLOR_RANGE, int)
|
||||
#define AOM_CTRL_AV1E_SET_COLOR_RANGE
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1E_SET_SVC_REF_FRAME_CONFIG, aom_svc_ref_frame_config_t *)
|
||||
#define AOM_CTRL_AV1E_SET_SVC_REF_FRAME_CONFIG
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1E_SET_RENDER_SIZE, int *)
|
||||
#define AOM_CTRL_AV1E_SET_RENDER_SIZE
|
||||
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
/**
|
||||
* SvcContext - input parameters and state to encode a multi-layered
|
||||
* spatial SVC frame
|
||||
*/
|
||||
|
||||
#ifndef AOM_SVC_CONTEXT_H_
|
||||
#define AOM_SVC_CONTEXT_H_
|
||||
|
||||
#include "./aomcx.h"
|
||||
#include "./aom_encoder.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum SVC_LOG_LEVEL {
|
||||
SVC_LOG_ERROR,
|
||||
SVC_LOG_INFO,
|
||||
SVC_LOG_DEBUG
|
||||
} SVC_LOG_LEVEL;
|
||||
|
||||
typedef struct {
|
||||
// public interface to svc_command options
|
||||
int spatial_layers; // number of spatial layers
|
||||
int temporal_layers; // number of temporal layers
|
||||
int temporal_layering_mode;
|
||||
SVC_LOG_LEVEL log_level; // amount of information to display
|
||||
int log_print; // when set, printf log messages instead of returning the
|
||||
// message with svc_get_message
|
||||
int output_rc_stat; // for outputting rc stats
|
||||
int speed; // speed setting for codec
|
||||
int threads;
|
||||
int aqmode; // turns on aq-mode=3 (cyclic_refresh): 0=off, 1=on.
|
||||
// private storage for aom_svc_encode
|
||||
void *internal;
|
||||
} SvcContext;
|
||||
|
||||
#define OPTION_BUFFER_SIZE 1024
|
||||
#define COMPONENTS 4 // psnr & sse statistics maintained for total, y, u, v
|
||||
|
||||
typedef struct SvcInternal {
|
||||
char options[OPTION_BUFFER_SIZE]; // set by aom_svc_set_options
|
||||
|
||||
// values extracted from option, quantizers
|
||||
aom_svc_extra_cfg_t svc_params;
|
||||
int enable_auto_alt_ref[AOM_SS_MAX_LAYERS];
|
||||
int bitrates[AOM_SS_MAX_LAYERS];
|
||||
|
||||
// accumulated statistics
|
||||
double psnr_sum[AOM_SS_MAX_LAYERS][COMPONENTS]; // total/Y/U/V
|
||||
uint64_t sse_sum[AOM_SS_MAX_LAYERS][COMPONENTS];
|
||||
uint32_t bytes_sum[AOM_SS_MAX_LAYERS];
|
||||
|
||||
// codec encoding values
|
||||
int width; // width of highest layer
|
||||
int height; // height of highest layer
|
||||
int kf_dist; // distance between keyframes
|
||||
|
||||
// state variables
|
||||
int psnr_pkt_received;
|
||||
int layer;
|
||||
int use_multiple_frame_contexts;
|
||||
|
||||
char message_buffer[2048];
|
||||
aom_codec_ctx_t *codec_ctx;
|
||||
} SvcInternal_t;
|
||||
|
||||
/**
|
||||
* Set SVC options
|
||||
* options are supplied as a single string separated by spaces
|
||||
* Format: encoding-mode=<i|ip|alt-ip|gf>
|
||||
* layers=<layer_count>
|
||||
* scaling-factors=<n1>/<d1>,<n2>/<d2>,...
|
||||
* quantizers=<q1>,<q2>,...
|
||||
*/
|
||||
aom_codec_err_t aom_svc_set_options(SvcContext *svc_ctx, const char *options);
|
||||
|
||||
/**
|
||||
* initialize SVC encoding
|
||||
*/
|
||||
aom_codec_err_t aom_svc_init(SvcContext *svc_ctx, aom_codec_ctx_t *codec_ctx,
|
||||
aom_codec_iface_t *iface,
|
||||
aom_codec_enc_cfg_t *cfg);
|
||||
/**
|
||||
* encode a frame of video with multiple layers
|
||||
*/
|
||||
aom_codec_err_t aom_svc_encode(SvcContext *svc_ctx, aom_codec_ctx_t *codec_ctx,
|
||||
struct aom_image *rawimg, aom_codec_pts_t pts,
|
||||
int64_t duration, int deadline);
|
||||
|
||||
/**
|
||||
* finished with svc encoding, release allocated resources
|
||||
*/
|
||||
void aom_svc_release(SvcContext *svc_ctx);
|
||||
|
||||
/**
|
||||
* dump accumulated statistics and reset accumulated values
|
||||
*/
|
||||
const char *aom_svc_dump_statistics(SvcContext *svc_ctx);
|
||||
|
||||
/**
|
||||
* get status message from previous encode
|
||||
*/
|
||||
const char *aom_svc_get_message(const SvcContext *svc_ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AOM_SVC_CONTEXT_H_
|
|
@ -75,8 +75,6 @@ AV1_CX_SRCS-yes += encoder/aq_cyclicrefresh.c
|
|||
AV1_CX_SRCS-yes += encoder/aq_cyclicrefresh.h
|
||||
AV1_CX_SRCS-yes += encoder/aq_complexity.c
|
||||
AV1_CX_SRCS-yes += encoder/aq_complexity.h
|
||||
AV1_CX_SRCS-yes += encoder/skin_detection.c
|
||||
AV1_CX_SRCS-yes += encoder/skin_detection.h
|
||||
AV1_CX_SRCS-yes += encoder/temporal_filter.c
|
||||
AV1_CX_SRCS-yes += encoder/temporal_filter.h
|
||||
AV1_CX_SRCS-yes += encoder/mbgraph.c
|
||||
|
|
|
@ -204,10 +204,6 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
|
|||
RANGE_CHECK(cfg, rc_scaled_height, 0, cfg->g_h);
|
||||
}
|
||||
|
||||
// Spatial/temporal scalability are not yet supported in AV1.
|
||||
// Only accept the default value for range checking.
|
||||
RANGE_CHECK(cfg, ss_number_layers, 1, 1);
|
||||
RANGE_CHECK(cfg, ts_number_layers, 1, 1);
|
||||
// AV1 does not support a lower bound on the keyframe interval in
|
||||
// automatic keyframe placement mode.
|
||||
if (cfg->kf_mode != AOM_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist &&
|
||||
|
@ -1332,21 +1328,7 @@ static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = {
|
|||
// keyframing settings (kf)
|
||||
AOM_KF_AUTO, // g_kfmode
|
||||
0, // kf_min_dist
|
||||
9999, // kf_max_dist
|
||||
|
||||
// TODO(yunqingwang): Spatial/temporal scalability are not supported
|
||||
// in AV1. The following 10 parameters are not used, which should
|
||||
// be removed later.
|
||||
1, // ss_number_layers
|
||||
{ 0 },
|
||||
{ 0 }, // ss_target_bitrate
|
||||
1, // ts_number_layers
|
||||
{ 0 }, // ts_target_bitrate
|
||||
{ 0 }, // ts_rate_decimator
|
||||
0, // ts_periodicity
|
||||
{ 0 }, // ts_layer_id
|
||||
{ 0 }, // layer_taget_bitrate
|
||||
0 // temporal_layering_mode
|
||||
9999 // kf_max_dist
|
||||
} },
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "av1/encoder/rd.h"
|
||||
#include "av1/encoder/resize.h"
|
||||
#include "av1/encoder/segmentation.h"
|
||||
#include "av1/encoder/skin_detection.h"
|
||||
#include "av1/encoder/speed_features.h"
|
||||
#include "av1/encoder/temporal_filter.h"
|
||||
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "av1/common/blockd.h"
|
||||
#include "av1/encoder/encoder.h"
|
||||
#include "av1/encoder/skin_detection.h"
|
||||
|
||||
// Fixed-point skin color model parameters.
|
||||
static const int skin_mean[2] = { 7463, 9614 }; // q6
|
||||
static const int skin_inv_cov[4] = { 4107, 1663, 1663, 2157 }; // q16
|
||||
static const int skin_threshold = 1570636; // q18
|
||||
|
||||
// Thresholds on luminance.
|
||||
static const int y_low = 20;
|
||||
static const int y_high = 220;
|
||||
|
||||
// Evaluates the Mahalanobis distance measure for the input CbCr values.
|
||||
static int evaluate_skin_color_difference(int cb, int cr) {
|
||||
const int cb_q6 = cb << 6;
|
||||
const int cr_q6 = cr << 6;
|
||||
const int cb_diff_q12 = (cb_q6 - skin_mean[0]) * (cb_q6 - skin_mean[0]);
|
||||
const int cbcr_diff_q12 = (cb_q6 - skin_mean[0]) * (cr_q6 - skin_mean[1]);
|
||||
const int cr_diff_q12 = (cr_q6 - skin_mean[1]) * (cr_q6 - skin_mean[1]);
|
||||
const int cb_diff_q2 = (cb_diff_q12 + (1 << 9)) >> 10;
|
||||
const int cbcr_diff_q2 = (cbcr_diff_q12 + (1 << 9)) >> 10;
|
||||
const int cr_diff_q2 = (cr_diff_q12 + (1 << 9)) >> 10;
|
||||
const int skin_diff =
|
||||
skin_inv_cov[0] * cb_diff_q2 + skin_inv_cov[1] * cbcr_diff_q2 +
|
||||
skin_inv_cov[2] * cbcr_diff_q2 + skin_inv_cov[3] * cr_diff_q2;
|
||||
return skin_diff;
|
||||
}
|
||||
|
||||
int av1_skin_pixel(const uint8_t y, const uint8_t cb, const uint8_t cr) {
|
||||
if (y < y_low || y > y_high)
|
||||
return 0;
|
||||
else
|
||||
return (evaluate_skin_color_difference(cb, cr) < skin_threshold);
|
||||
}
|
||||
|
||||
#ifdef OUTPUT_YUV_SKINMAP
|
||||
// For viewing skin map on input source.
|
||||
void av1_compute_skin_map(AV1_COMP *const cpi, FILE *yuv_skinmap_file) {
|
||||
int i, j, mi_row, mi_col;
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
uint8_t *y;
|
||||
const uint8_t *src_y = cpi->Source->y_buffer;
|
||||
const uint8_t *src_u = cpi->Source->u_buffer;
|
||||
const uint8_t *src_v = cpi->Source->v_buffer;
|
||||
const int src_ystride = cpi->Source->y_stride;
|
||||
const int src_uvstride = cpi->Source->uv_stride;
|
||||
YV12_BUFFER_CONFIG skinmap;
|
||||
memset(&skinmap, 0, sizeof(YV12_BUFFER_CONFIG));
|
||||
if (aom_alloc_frame_buffer(&skinmap, cm->width, cm->height, cm->subsampling_x,
|
||||
cm->subsampling_y, AOM_BORDER_IN_PIXELS,
|
||||
cm->byte_alignment)) {
|
||||
aom_free_frame_buffer(&skinmap);
|
||||
return;
|
||||
}
|
||||
memset(skinmap.buffer_alloc, 128, skinmap.frame_size);
|
||||
y = skinmap.y_buffer;
|
||||
// Loop through 8x8 blocks and set skin map based on center pixel of block.
|
||||
// Set y to white for skin block, otherwise set to source with gray scale.
|
||||
// Ignore rightmost/bottom boundary blocks.
|
||||
for (mi_row = 0; mi_row < cm->mi_rows - 1; ++mi_row) {
|
||||
for (mi_col = 0; mi_col < cm->mi_cols - 1; ++mi_col) {
|
||||
// Use middle pixel for each 8x8 block for skin detection.
|
||||
// If middle pixel is skin, assign whole 8x8 block to skin.
|
||||
const uint8_t ysource = src_y[4 * src_ystride + 4];
|
||||
const uint8_t usource = src_u[2 * src_uvstride + 2];
|
||||
const uint8_t vsource = src_v[2 * src_uvstride + 2];
|
||||
const int is_skin = av1_skin_pixel(ysource, usource, vsource);
|
||||
for (i = 0; i < 8; i++) {
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (is_skin)
|
||||
y[i * src_ystride + j] = 255;
|
||||
else
|
||||
y[i * src_ystride + j] = src_y[i * src_ystride + j];
|
||||
}
|
||||
}
|
||||
y += 8;
|
||||
src_y += 8;
|
||||
src_u += 4;
|
||||
src_v += 4;
|
||||
}
|
||||
y += (src_ystride << 3) - ((cm->mi_cols - 1) << 3);
|
||||
src_y += (src_ystride << 3) - ((cm->mi_cols - 1) << 3);
|
||||
src_u += (src_uvstride << 2) - ((cm->mi_cols - 1) << 2);
|
||||
src_v += (src_uvstride << 2) - ((cm->mi_cols - 1) << 2);
|
||||
}
|
||||
av1_write_yuv_frame_420(&skinmap, yuv_skinmap_file);
|
||||
aom_free_frame_buffer(&skinmap);
|
||||
}
|
||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_SKIN_MAP_H_
|
||||
#define AV1_ENCODER_SKIN_MAP_H_
|
||||
|
||||
#include "av1/common/blockd.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct AV1_COMP;
|
||||
|
||||
// #define OUTPUT_YUV_SKINMAP
|
||||
|
||||
int av1_skin_pixel(const uint8_t y, const uint8_t cb, const uint8_t cr);
|
||||
|
||||
#ifdef OUTPUT_YUV_SKINMAP
|
||||
// For viewing skin map on input source.
|
||||
void av1_compute_skin_map(AV1_COMP *const cpi, FILE *yuv_skinmap_file);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_SKIN_MAP_H_
|
|
@ -282,10 +282,7 @@ class DatarateTestAV1Large
|
|||
num_drops_ = 0;
|
||||
// Denoiser is off by default.
|
||||
denoiser_on_ = 0;
|
||||
// For testing up to 3 layers.
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
bits_total_[i] = 0;
|
||||
}
|
||||
bits_total_ = 0;
|
||||
denoiser_offon_test_ = 0;
|
||||
denoiser_offon_period_ = -1;
|
||||
}
|
||||
|
@ -328,9 +325,6 @@ class DatarateTestAV1Large
|
|||
tot_frame_number_ += static_cast<int>(duration - 1);
|
||||
}
|
||||
|
||||
int layer = 0;
|
||||
|
||||
// Add to the buffer the bits we'd expect from a constant bitrate server.
|
||||
bits_in_buffer_model_ += static_cast<int64_t>(
|
||||
duration * timebase_ * cfg_.rc_target_bitrate * 1000);
|
||||
|
||||
|
@ -340,11 +334,8 @@ class DatarateTestAV1Large
|
|||
|
||||
const size_t frame_size_in_bits = pkt->data.frame.sz * 8;
|
||||
|
||||
// Update the total encoded bits. For temporal layers, update the cumulative
|
||||
// encoded bits per layer.
|
||||
for (int i = layer; i < static_cast<int>(cfg_.ts_number_layers); ++i) {
|
||||
bits_total_[i] += frame_size_in_bits;
|
||||
}
|
||||
// Update the total encoded bits.
|
||||
bits_total_ += frame_size_in_bits;
|
||||
|
||||
// Update the most recent pts.
|
||||
last_pts_ = pkt->data.frame.pts;
|
||||
|
@ -353,13 +344,10 @@ class DatarateTestAV1Large
|
|||
}
|
||||
|
||||
virtual void EndPassHook(void) {
|
||||
for (int layer = 0; layer < static_cast<int>(cfg_.ts_number_layers);
|
||||
++layer) {
|
||||
duration_ = (last_pts_ + 1) * timebase_;
|
||||
if (bits_total_[layer]) {
|
||||
// Effective file datarate:
|
||||
effective_datarate_[layer] = (bits_total_[layer] / 1000.0) / duration_;
|
||||
}
|
||||
duration_ = (last_pts_ + 1) * timebase_;
|
||||
if (bits_total_) {
|
||||
// Effective file datarate:
|
||||
effective_datarate_ = (bits_total_ / 1000.0) / duration_;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,9 +355,9 @@ class DatarateTestAV1Large
|
|||
double timebase_;
|
||||
int frame_number_; // Counter for number of non-dropped/encoded frames.
|
||||
int tot_frame_number_; // Counter for total number of input frames.
|
||||
int64_t bits_total_[3];
|
||||
int64_t bits_total_;
|
||||
double duration_;
|
||||
double effective_datarate_[3];
|
||||
double effective_datarate_;
|
||||
int set_cpu_used_;
|
||||
int64_t bits_in_buffer_model_;
|
||||
aom_codec_pts_t first_drop_;
|
||||
|
@ -396,9 +384,9 @@ TEST_P(DatarateTestAV1Large, BasicRateTargeting) {
|
|||
cfg_.rc_target_bitrate = i;
|
||||
ResetModel();
|
||||
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
||||
ASSERT_GE(effective_datarate_[0], cfg_.rc_target_bitrate * 0.85)
|
||||
ASSERT_GE(effective_datarate_, cfg_.rc_target_bitrate * 0.85)
|
||||
<< " The datarate for the file is lower than target by too much!";
|
||||
ASSERT_LE(effective_datarate_[0], cfg_.rc_target_bitrate * 1.15)
|
||||
ASSERT_LE(effective_datarate_, cfg_.rc_target_bitrate * 1.15)
|
||||
<< " The datarate for the file is greater than target by too much!";
|
||||
}
|
||||
}
|
||||
|
@ -423,10 +411,10 @@ TEST_P(DatarateTestAV1Large, BasicRateTargeting444) {
|
|||
ResetModel();
|
||||
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
||||
ASSERT_GE(static_cast<double>(cfg_.rc_target_bitrate),
|
||||
effective_datarate_[0] * 0.85)
|
||||
effective_datarate_ * 0.85)
|
||||
<< " The datarate for the file exceeds the target by too much!";
|
||||
ASSERT_LE(static_cast<double>(cfg_.rc_target_bitrate),
|
||||
effective_datarate_[0] * 1.15)
|
||||
effective_datarate_ * 1.15)
|
||||
<< " The datarate for the file missed the target!"
|
||||
<< cfg_.rc_target_bitrate << " " << effective_datarate_;
|
||||
}
|
||||
|
@ -459,9 +447,9 @@ TEST_P(DatarateTestAV1Large, ChangingDropFrameThresh) {
|
|||
cfg_.rc_dropframe_thresh = i;
|
||||
ResetModel();
|
||||
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
|
||||
ASSERT_GE(effective_datarate_[0], cfg_.rc_target_bitrate * 0.85)
|
||||
ASSERT_GE(effective_datarate_, cfg_.rc_target_bitrate * 0.85)
|
||||
<< " The datarate for the file is lower than target by too much!";
|
||||
ASSERT_LE(effective_datarate_[0], cfg_.rc_target_bitrate * 1.15)
|
||||
ASSERT_LE(effective_datarate_, cfg_.rc_target_bitrate * 1.15)
|
||||
<< " The datarate for the file is greater than target by too much!";
|
||||
ASSERT_LE(first_drop_, last_drop)
|
||||
<< " The first dropped frame for drop_thresh " << i
|
||||
|
|
|
@ -129,10 +129,6 @@ class Encoder {
|
|||
ASSERT_EQ(AOM_CODEC_OK, res) << EncoderError();
|
||||
}
|
||||
|
||||
void Control(int ctrl_id, struct aom_svc_parameters *arg) {
|
||||
const aom_codec_err_t res = aom_codec_control_(&encoder_, ctrl_id, arg);
|
||||
ASSERT_EQ(AOM_CODEC_OK, res) << EncoderError();
|
||||
}
|
||||
#if CONFIG_AV1_ENCODER
|
||||
void Control(int ctrl_id, aom_active_map_t *arg) {
|
||||
const aom_codec_err_t res = aom_codec_control_(&encoder_, ctrl_id, arg);
|
||||
|
|
|
@ -55,66 +55,20 @@ class ErrorResilienceTestLarge
|
|||
nframes_++;
|
||||
}
|
||||
|
||||
//
|
||||
// Frame flags and layer id for temporal layers.
|
||||
// For two layers, test pattern is:
|
||||
// 1 3
|
||||
// 0 2 .....
|
||||
// LAST is updated on base/layer 0, GOLDEN updated on layer 1.
|
||||
// Non-zero pattern_switch parameter means pattern will switch to
|
||||
// not using LAST for frame_num >= pattern_switch.
|
||||
int SetFrameFlags(int frame_num, int num_temp_layers, int pattern_switch) {
|
||||
int frame_flags = 0;
|
||||
if (num_temp_layers == 2) {
|
||||
if (frame_num % 2 == 0) {
|
||||
if (frame_num < pattern_switch || pattern_switch == 0) {
|
||||
// Layer 0: predict from LAST and ARF, update LAST.
|
||||
frame_flags =
|
||||
AOM_EFLAG_NO_REF_GF | AOM_EFLAG_NO_UPD_GF | AOM_EFLAG_NO_UPD_ARF;
|
||||
} else {
|
||||
// Layer 0: predict from GF and ARF, update GF.
|
||||
frame_flags = AOM_EFLAG_NO_REF_LAST | AOM_EFLAG_NO_UPD_LAST |
|
||||
AOM_EFLAG_NO_UPD_ARF;
|
||||
}
|
||||
} else {
|
||||
if (frame_num < pattern_switch || pattern_switch == 0) {
|
||||
// Layer 1: predict from L, GF, and ARF, update GF.
|
||||
frame_flags = AOM_EFLAG_NO_UPD_ARF | AOM_EFLAG_NO_UPD_LAST;
|
||||
} else {
|
||||
// Layer 1: predict from GF and ARF, update GF.
|
||||
frame_flags = AOM_EFLAG_NO_REF_LAST | AOM_EFLAG_NO_UPD_LAST |
|
||||
AOM_EFLAG_NO_UPD_ARF;
|
||||
}
|
||||
}
|
||||
}
|
||||
return frame_flags;
|
||||
}
|
||||
|
||||
virtual void PreEncodeFrameHook(libaom_test::VideoSource *video,
|
||||
::libaom_test::Encoder *encoder) {
|
||||
frame_flags_ &=
|
||||
~(AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF | AOM_EFLAG_NO_UPD_ARF);
|
||||
// For temporal layer case.
|
||||
if (cfg_.ts_number_layers > 1) {
|
||||
frame_flags_ =
|
||||
SetFrameFlags(video->frame(), cfg_.ts_number_layers, pattern_switch_);
|
||||
if (droppable_nframes_ > 0 &&
|
||||
(cfg_.g_pass == AOM_RC_LAST_PASS || cfg_.g_pass == AOM_RC_ONE_PASS)) {
|
||||
for (unsigned int i = 0; i < droppable_nframes_; ++i) {
|
||||
if (droppable_frames_[i] == video->frame()) {
|
||||
std::cout << "Encoding droppable frame: " << droppable_frames_[i]
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (droppable_nframes_ > 0 &&
|
||||
(cfg_.g_pass == AOM_RC_LAST_PASS || cfg_.g_pass == AOM_RC_ONE_PASS)) {
|
||||
for (unsigned int i = 0; i < droppable_nframes_; ++i) {
|
||||
if (droppable_frames_[i] == video->frame()) {
|
||||
std::cout << "Encoding droppable frame: " << droppable_frames_[i]
|
||||
<< "\n";
|
||||
frame_flags_ |= (AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF |
|
||||
AOM_EFLAG_NO_UPD_ARF);
|
||||
return;
|
||||
}
|
||||
frame_flags_ |= (AOM_EFLAG_NO_UPD_LAST | AOM_EFLAG_NO_UPD_GF |
|
||||
AOM_EFLAG_NO_UPD_ARF);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,10 +246,7 @@ class ErrorResilienceTestLargeCodecControls
|
|||
void Reset() {
|
||||
last_pts_ = 0;
|
||||
tot_frame_number_ = 0;
|
||||
// For testing up to 3 layers.
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
bits_total_[i] = 0;
|
||||
}
|
||||
bits_total_ = 0;
|
||||
duration_ = 0.0;
|
||||
}
|
||||
|
||||
|
@ -346,42 +297,6 @@ class ErrorResilienceTestLargeCodecControls
|
|||
return frame_flags;
|
||||
}
|
||||
|
||||
int SetLayerId(int frame_num, int num_temp_layers) {
|
||||
int layer_id = 0;
|
||||
if (num_temp_layers == 2) {
|
||||
if (frame_num % 2 == 0) {
|
||||
layer_id = 0;
|
||||
} else {
|
||||
layer_id = 1;
|
||||
}
|
||||
} else if (num_temp_layers == 3) {
|
||||
if (frame_num % 4 == 0) {
|
||||
layer_id = 0;
|
||||
} else if ((frame_num - 2) % 4 == 0) {
|
||||
layer_id = 1;
|
||||
} else if ((frame_num - 1) % 2 == 0) {
|
||||
layer_id = 2;
|
||||
}
|
||||
}
|
||||
return layer_id;
|
||||
}
|
||||
|
||||
virtual void PreEncodeFrameHook(libaom_test::VideoSource *video,
|
||||
libaom_test::Encoder *encoder) {
|
||||
if (cfg_.ts_number_layers > 1) {
|
||||
int layer_id = SetLayerId(video->frame(), cfg_.ts_number_layers);
|
||||
int frame_flags = SetFrameFlags(video->frame(), cfg_.ts_number_layers);
|
||||
if (video->frame() > 0) {
|
||||
encoder->Control(AOME_SET_TEMPORAL_LAYER_ID, layer_id);
|
||||
encoder->Control(AOME_SET_FRAME_FLAGS, frame_flags);
|
||||
}
|
||||
const aom_rational_t tb = video->timebase();
|
||||
timebase_ = static_cast<double>(tb.num) / tb.den;
|
||||
duration_ = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void FramePktHook(const aom_codec_cx_pkt_t *pkt) {
|
||||
// Time since last timestamp = duration.
|
||||
aom_codec_pts_t duration = pkt->data.frame.pts - last_pts_;
|
||||
|
@ -390,39 +305,22 @@ class ErrorResilienceTestLargeCodecControls
|
|||
// Needed for setting the proper layer_id below.
|
||||
tot_frame_number_ += static_cast<int>(duration - 1);
|
||||
}
|
||||
int layer = SetLayerId(tot_frame_number_, cfg_.ts_number_layers);
|
||||
const size_t frame_size_in_bits = pkt->data.frame.sz * 8;
|
||||
// Update the total encoded bits. For temporal layers, update the cumulative
|
||||
// encoded bits per layer.
|
||||
for (int i = layer; i < static_cast<int>(cfg_.ts_number_layers); ++i) {
|
||||
bits_total_[i] += frame_size_in_bits;
|
||||
}
|
||||
bits_total_ += frame_size_in_bits;
|
||||
// Update the most recent pts.
|
||||
last_pts_ = pkt->data.frame.pts;
|
||||
++tot_frame_number_;
|
||||
}
|
||||
|
||||
virtual void EndPassHook(void) {
|
||||
duration_ = (last_pts_ + 1) * timebase_;
|
||||
if (cfg_.ts_number_layers > 1) {
|
||||
for (int layer = 0; layer < static_cast<int>(cfg_.ts_number_layers);
|
||||
++layer) {
|
||||
if (bits_total_[layer]) {
|
||||
// Effective file datarate:
|
||||
effective_datarate_[layer] =
|
||||
(bits_total_[layer] / 1000.0) / duration_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double effective_datarate_[3];
|
||||
virtual void EndPassHook(void) { duration_ = (last_pts_ + 1) * timebase_; }
|
||||
|
||||
private:
|
||||
libaom_test::TestMode encoding_mode_;
|
||||
aom_codec_pts_t last_pts_;
|
||||
double timebase_;
|
||||
int64_t bits_total_[3];
|
||||
int64_t bits_total_;
|
||||
double duration_;
|
||||
int tot_frame_number_;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче