Commit 7ec838ed authored by Marco Paniconi's avatar Marco Paniconi Committed by Gerrit Code Review

Revert "Layer based rate control for CBR mode."

This reverts commit 6be2b750

Change-Id: Ic52acd98b37c3ba49d4999b463389eb564f49c4b
parent 6be2b750
......@@ -64,11 +64,6 @@ vp9_spatial_scalable_encoder.SRCS += ivfenc.c ivfenc.h
vp9_spatial_scalable_encoder.SRCS += tools_common.c tools_common.h
vp9_spatial_scalable_encoder.GUID = 4A38598D-627D-4505-9C7B-D4020C84100D
vp9_spatial_scalable_encoder.DESCRIPTION = Spatial Scalable Encoder
UTILS-$(CONFIG_ENCODERS) += vpx_temporal_scalable_patterns.c
vpx_temporal_scalable_patterns.SRCS += ivfenc.c ivfenc.h
vpx_temporal_scalable_patterns.SRCS += tools_common.c tools_common.h
vpx_temporal_scalable_patterns.GUID = B18C08F2-A439-4502-A78E-849BE3D60947
vpx_temporal_scalable_patterns.DESCRIPTION = Temporal Scalability Encoder
ifeq ($(CONFIG_SHARED),no)
UTILS-$(CONFIG_VP9_ENCODER) += resize_util.c
......
......@@ -200,102 +200,21 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest,
frame_number_ = 0;
first_drop_ = 0;
num_drops_ = 0;
// For testing up to 3 layers.
for (int i = 0; i < 3; ++i) {
bits_total_[i] = 0;
}
}
//
// Frame flags and layer id for temporal layers.
//
// For two layers, test pattern is:
// 1 3
// 0 2 .....
// For three layers, test pattern is:
// 1 3 5 7
// 2 6
// 0 4 ....
// LAST is always update on base/layer 0, GOLDEN is updated on layer 1.
// For this 3 layer example, the 2rd enhancement layer (layer 2) does not
// update any reference frames.
int SetFrameFlags(int frame_num, int num_temp_layers) {
int frame_flags = 0;
if (num_temp_layers == 2) {
if (frame_num % 2 == 0) {
// Layer 0: predict from L and ARF, update L.
frame_flags = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF |
VP8_EFLAG_NO_UPD_ARF;
} else {
// Layer 1: predict from L, G and ARF, and update G.
frame_flags = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
VP8_EFLAG_NO_UPD_ENTROPY;
}
} else if (num_temp_layers == 3) {
if (frame_num % 4 == 0) {
// Layer 0: predict from L and ARF; update L.
frame_flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_REF_GF;
} else if ((frame_num - 2) % 4 == 0) {
// Layer 1: predict from L, G, ARF; update G.
frame_flags = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST;
} else if ((frame_num - 1) % 2 == 0) {
// Layer 2: predict from L, G, ARF; update none.
frame_flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
VP8_EFLAG_NO_UPD_LAST;
}
}
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;
bits_total_ = 0;
duration_ = 0.0;
}
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) {
::libvpx_test::Encoder *encoder) {
if (video->frame() == 1) {
encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
}
if (cfg_.ts_number_layers > 1) {
if (video->frame() == 1) {
encoder->Control(VP9E_SET_SVC, 1);
}
vpx_svc_layer_id_t layer_id = {0, 0};
layer_id.spatial_layer_id = 0;
frame_flags_ = SetFrameFlags(video->frame(), cfg_.ts_number_layers);
layer_id.temporal_layer_id = SetLayerId(video->frame(),
cfg_.ts_number_layers);
if (video->frame() > 0) {
encoder->Control(VP9E_SET_SVC_LAYER_ID, &layer_id);
}
}
const vpx_rational_t tb = video->timebase();
timebase_ = static_cast<double>(tb.num) / tb.den;
duration_ = 0;
}
virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
int layer = SetLayerId(frame_number_, cfg_.ts_number_layers);
// Time since last timestamp = duration.
vpx_codec_pts_t duration = pkt->data.frame.pts - last_pts_;
......@@ -308,12 +227,7 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest,
<< pkt->data.frame.pts;
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;
// If first drop not set and we have a drop set it to this time.
if (!first_drop_ && duration > 1)
......@@ -330,22 +244,19 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest,
}
virtual void EndPassHook(void) {
for (int layer = 0; layer < static_cast<int>(cfg_.ts_number_layers);
layer++) {
if (bits_total_) {
duration_ = (last_pts_ + 1) * timebase_;
if (bits_total_[layer]) {
// Effective file datarate:
effective_datarate_[layer] = (bits_total_[layer] / 1000.0) / duration_;
}
// Effective file datarate:
effective_datarate_ = ((bits_total_) / 1000.0) / duration_;
}
}
vpx_codec_pts_t last_pts_;
double timebase_;
int frame_number_;
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_;
vpx_codec_pts_t first_drop_;
......@@ -361,7 +272,6 @@ TEST_P(DatarateTestVP9, BasicRateTargeting) {
cfg_.rc_min_quantizer = 0;
cfg_.rc_max_quantizer = 63;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_lag_in_frames = 0;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 140);
......@@ -369,10 +279,12 @@ TEST_P(DatarateTestVP9, BasicRateTargeting) {
cfg_.rc_target_bitrate = i;
ResetModel();
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
ASSERT_GE(effective_datarate_[0], 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)
<< " The datarate for the file is greater than target by too much!";
ASSERT_GE(static_cast<double>(cfg_.rc_target_bitrate),
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_ * 1.15)
<< " The datarate for the file missed the target!";
}
}
......@@ -397,10 +309,10 @@ TEST_P(DatarateTestVP9, 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_;
}
......@@ -422,7 +334,6 @@ TEST_P(DatarateTestVP9, ChangingDropFrameThresh) {
cfg_.rc_max_quantizer = 50;
cfg_.rc_end_usage = VPX_CBR;
cfg_.rc_target_bitrate = 200;
cfg_.g_lag_in_frames = 0;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 140);
......@@ -434,10 +345,10 @@ TEST_P(DatarateTestVP9, ChangingDropFrameThresh) {
cfg_.rc_dropframe_thresh = i;
ResetModel();
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
ASSERT_GE(effective_datarate_[0], 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)
<< " The datarate for the file is greater than target by too much!";
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_, 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
<< " > first dropped frame for drop_thresh "
......@@ -451,81 +362,6 @@ TEST_P(DatarateTestVP9, ChangingDropFrameThresh) {
}
}
// Check basic rate targeting for 2 temporal layers.
TEST_P(DatarateTestVP9, BasicRateTargeting2TemporalLayers) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_dropframe_thresh = 1;
cfg_.rc_min_quantizer = 0;
cfg_.rc_max_quantizer = 63;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_lag_in_frames = 0;
// 2 Temporal layers, no spatial layers: Framerate decimation (2, 1).
cfg_.ss_number_layers = 1;
cfg_.ts_number_layers = 2;
cfg_.ts_rate_decimator[0] = 2;
cfg_.ts_rate_decimator[1] = 1;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 200);
for (int i = 200; i <= 800; i += 200) {
cfg_.rc_target_bitrate = i;
ResetModel();
// 60-40 bitrate allocation for 2 temporal layers.
cfg_.ts_target_bitrate[0] = 60 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[1] = cfg_.rc_target_bitrate;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
for (int j = 0; j < static_cast<int>(cfg_.ts_number_layers); ++j) {
ASSERT_GE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 0.85)
<< " The datarate for the file is lower than target by too much, "
"for layer: " << j;
ASSERT_LE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 1.15)
<< " The datarate for the file is greater than target by too much, "
"for layer: " << j;
}
}
}
// Check basic rate targeting for 3 temporal layers.
TEST_P(DatarateTestVP9, BasicRateTargeting3TemporalLayers) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_dropframe_thresh = 1;
cfg_.rc_min_quantizer = 0;
cfg_.rc_max_quantizer = 63;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_lag_in_frames = 0;
// 3 Temporal layers, no spatial layers: Framerate decimation (4, 2, 1).
cfg_.ss_number_layers = 1;
cfg_.ts_number_layers = 3;
cfg_.ts_rate_decimator[0] = 4;
cfg_.ts_rate_decimator[1] = 2;
cfg_.ts_rate_decimator[2] = 1;
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 200);
for (int i = 200; i <= 800; i += 200) {
cfg_.rc_target_bitrate = i;
ResetModel();
// 40-20-40 bitrate allocation for 3 temporal layers.
cfg_.ts_target_bitrate[0] = 40 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[1] = 60 * cfg_.rc_target_bitrate / 100;
cfg_.ts_target_bitrate[2] = cfg_.rc_target_bitrate;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
for (int j = 0; j < static_cast<int>(cfg_.ts_number_layers); ++j) {
ASSERT_GE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 0.85)
<< " The datarate for the file is lower than target by too much, "
"for layer: " << j;
ASSERT_LE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 1.15)
<< " The datarate for the file is greater than target by too much, "
"for layer: " << j;
}
}
}
VP8_INSTANTIATE_TEST_CASE(DatarateTest, ALL_TEST_MODES);
VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9,
::testing::Values(::libvpx_test::kOnePassGood),
......
......@@ -123,11 +123,6 @@ class Encoder {
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
}
void Control(int ctrl_id, struct vpx_svc_layer_id *arg) {
const vpx_codec_err_t res = vpx_codec_control_(&encoder_, ctrl_id, arg);
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
}
void set_deadline(unsigned long deadline) {
deadline_ = deadline;
}
......
......@@ -147,12 +147,8 @@ extern "C" {
// END DATARATE CONTROL OPTIONS
// ----------------------------------------------------------------
// Spatial and temporal scalability.
int ss_number_layers; // Number of spatial layers.
unsigned int ts_number_layers; // Number of temporal layers.
// Bitrate allocation (CBR mode) and framerate factor, for temporal layers.
unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS];
unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS];
// Spatial scalability
int ss_number_layers;
// these parameters aren't to be used in final build don't use!!!
int play_alternate;
......
......@@ -1158,107 +1158,6 @@ static int64_t rescale(int val, int64_t num, int denom) {
return (llval * llnum / llden);
}
// Initialize layer content data from init_config().
static void init_layer_context(VP9_COMP *const cpi) {
int temporal_layer = 0;
cpi->svc.spatial_layer_id = 0;
cpi->svc.temporal_layer_id = 0;
for (temporal_layer = 0; temporal_layer < cpi->svc.number_temporal_layers;
++temporal_layer) {
LAYER_CONTEXT *lc = &cpi->svc.layer_context[temporal_layer];
lc->rc.active_worst_quality = q_trans[cpi->oxcf.worst_allowed_q];
lc->rc.avg_frame_qindex[INTER_FRAME] = q_trans[cpi->oxcf.worst_allowed_q];
lc->rc.last_q[INTER_FRAME] = q_trans[cpi->oxcf.worst_allowed_q];
lc->rc.ni_av_qi = lc->rc.active_worst_quality;
lc->rc.total_actual_bits = 0;
lc->rc.total_target_vs_actual = 0;
lc->rc.ni_tot_qi = 0;
lc->rc.tot_q = 0.0;
lc->rc.ni_frames = 0;
lc->rc.rate_correction_factor = 1.0;
lc->rc.key_frame_rate_correction_factor = 1.0;
lc->target_bandwidth = cpi->oxcf.ts_target_bitrate[temporal_layer] *
1000;
lc->rc.buffer_level = rescale((int)(cpi->oxcf.starting_buffer_level),
lc->target_bandwidth, 1000);
lc->rc.bits_off_target = lc->rc.buffer_level;
}
}
// Update the layer context from a change_config() call.
static void update_layer_context_change_config(VP9_COMP *const cpi,
const int target_bandwidth) {
int temporal_layer = 0;
float bitrate_alloc = 1.0;
for (temporal_layer = 0; temporal_layer < cpi->svc.number_temporal_layers;
++temporal_layer) {
LAYER_CONTEXT *lc = &cpi->svc.layer_context[temporal_layer];
lc->target_bandwidth = cpi->oxcf.ts_target_bitrate[temporal_layer] * 1000;
bitrate_alloc = (float)lc->target_bandwidth / (float)target_bandwidth;
// Update buffer-related quantities.
lc->starting_buffer_level = cpi->oxcf.starting_buffer_level * bitrate_alloc;
lc->optimal_buffer_level = cpi->oxcf.optimal_buffer_level * bitrate_alloc;
lc->maximum_buffer_size = cpi->oxcf.maximum_buffer_size * bitrate_alloc;
lc->rc.bits_off_target = MIN(lc->rc.bits_off_target,
lc->maximum_buffer_size);
lc->rc.buffer_level = MIN(lc->rc.buffer_level, lc->maximum_buffer_size);
// Update framerate-related quantities.
lc->framerate = cpi->oxcf.framerate /
cpi->oxcf.ts_rate_decimator[temporal_layer];
lc->rc.av_per_frame_bandwidth = (int)(lc->target_bandwidth / lc->framerate);
lc->rc.per_frame_bandwidth = lc->rc.av_per_frame_bandwidth;
lc->rc.max_frame_bandwidth = cpi->rc.max_frame_bandwidth;
// Update qp-related quantities.
lc->rc.worst_quality = cpi->rc.worst_quality;
lc->rc.best_quality = cpi->rc.best_quality;
lc->rc.active_worst_quality = cpi->rc.active_worst_quality;
}
}
// Prior to encoding the frame, update framerate-related quantities
// for the current layer.
static void update_layer_framerate(VP9_COMP *const cpi) {
int temporal_layer = cpi->svc.temporal_layer_id;
LAYER_CONTEXT *lc = &cpi->svc.layer_context[temporal_layer];
lc->framerate = cpi->oxcf.framerate /
cpi->oxcf.ts_rate_decimator[temporal_layer];
lc->rc.av_per_frame_bandwidth = (int)(lc->target_bandwidth /
lc->framerate);
lc->rc.per_frame_bandwidth = lc->rc.av_per_frame_bandwidth;
lc->rc.max_frame_bandwidth = cpi->rc.max_frame_bandwidth;
}
// Prior to encoding the frame, set the layer context, for the current layer
// to be encoded, to the cpi struct.
static void restore_layer_context(VP9_COMP *const cpi) {
int temporal_layer = cpi->svc.temporal_layer_id;
LAYER_CONTEXT *lc = &cpi->svc.layer_context[temporal_layer];
int frame_since_key = cpi->rc.frames_since_key;
int frame_to_key = cpi->rc.frames_to_key;
memcpy(&cpi->rc, &lc->rc, sizeof(RATE_CONTROL));
cpi->target_bandwidth = lc->target_bandwidth;
cpi->oxcf.starting_buffer_level = lc->starting_buffer_level;
cpi->oxcf.optimal_buffer_level = lc->optimal_buffer_level;
cpi->oxcf.maximum_buffer_size = lc->maximum_buffer_size;
cpi->output_framerate = lc->framerate;
// Reset the frames_since_key and frames_to_key counters to their values
// before the layer restore. Keep these defined for the stream (not layer).
cpi->rc.frames_since_key = frame_since_key;
cpi->rc.frames_to_key = frame_to_key;
}
// Save the layer context after encoding the frame.
static void save_layer_context(VP9_COMP *const cpi) {
int temporal_layer = cpi->svc.temporal_layer_id;
LAYER_CONTEXT *lc = &cpi->svc.layer_context[temporal_layer];
memcpy(&lc->rc, &cpi->rc, sizeof(RATE_CONTROL));
lc->target_bandwidth = cpi->target_bandwidth;
lc->starting_buffer_level = cpi->oxcf.starting_buffer_level;
lc->optimal_buffer_level = cpi->oxcf.optimal_buffer_level;
lc->maximum_buffer_size = cpi->oxcf.maximum_buffer_size;
lc->framerate = cpi->output_framerate;
}
static void set_tile_limits(VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
......@@ -1285,16 +1184,6 @@ static void init_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
cm->subsampling_y = 0;
vp9_alloc_compressor_data(cpi);
// Spatial scalability.
cpi->svc.number_spatial_layers = oxcf->ss_number_layers;
// Temporal scalability.
cpi->svc.number_temporal_layers = oxcf->ts_number_layers;
if (cpi->svc.number_temporal_layers > 1 &&
cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
init_layer_context(cpi);
}
// change includes all joint functionality
vp9_change_config(ptr, oxcf);
......@@ -1335,6 +1224,9 @@ static void init_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
cpi->gld_fb_idx = 1;
cpi->alt_fb_idx = 2;
cpi->current_layer = 0;
cpi->use_svc = 0;
set_tile_limits(cpi);
cpi->fixed_divide[0] = 0;
......@@ -1342,6 +1234,7 @@ static void init_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
cpi->fixed_divide[i] = 0x80000 / i;
}
void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
VP9_COMP *cpi = (VP9_COMP *)(ptr);
VP9_COMMON *const cm = &cpi->common;
......@@ -1433,10 +1326,10 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
cpi->oxcf.target_bandwidth, 1000);
// Under a configuration change, where maximum_buffer_size may change,
// keep buffer level clipped to the maximum allowed buffer size.
cpi->rc.bits_off_target = MIN(cpi->rc.bits_off_target,
cpi->oxcf.maximum_buffer_size);
cpi->rc.buffer_level = MIN(cpi->rc.buffer_level,
cpi->oxcf.maximum_buffer_size);
if (cpi->rc.bits_off_target > cpi->oxcf.maximum_buffer_size) {
cpi->rc.bits_off_target = cpi->oxcf.maximum_buffer_size;
cpi->rc.buffer_level = cpi->rc.bits_off_target;
}
// Set up frame rate and related parameters rate control values.
vp9_new_framerate(cpi, cpi->oxcf.framerate);
......@@ -1473,11 +1366,6 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
}
update_frame_size(cpi);
if (cpi->svc.number_temporal_layers > 1 &&
cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
update_layer_context_change_config(cpi, cpi->oxcf.target_bandwidth);
}
cpi->speed = cpi->oxcf.cpu_used;
if (cpi->oxcf.lag_in_frames == 0) {
......@@ -1701,8 +1589,6 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
vp9_create_common(cm);
cpi->use_svc = 0;
init_config((VP9_PTR)cpi, oxcf);
init_pick_mode_context(cpi);
......@@ -1718,6 +1604,9 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
cpi->alt_is_last = 0;
cpi->gold_is_alt = 0;
// Spatial scalability
cpi->number_spatial_layers = oxcf->ss_number_layers;
// Create the encoder segmentation map and set all entries to 0
CHECK_MEM_ERROR(cm, cpi->segmentation_map,
vpx_calloc(cm->mi_rows * cm->mi_cols, 1));
......@@ -3669,12 +3558,6 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
adjust_frame_rate(cpi);
}
if (cpi->svc.number_temporal_layers > 1 &&
cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
update_layer_framerate(cpi);
restore_layer_context(cpi);
}
// start with a 0 size frame
*size = 0;
......@@ -3750,12 +3633,6 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
cpi->droppable = !frame_is_reference(cpi);
}
// Save layer specific state.
if (cpi->svc.number_temporal_layers > 1 &&
cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
save_layer_context(cpi);
}
vpx_usec_timer_mark(&cmptimer);
cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer);
......
......@@ -421,15 +421,6 @@ typedef struct {
int super_fast_rtc;
} SPEED_FEATURES;
typedef struct {
RATE_CONTROL rc;
int target_bandwidth;
int64_t starting_buffer_level;
int64_t optimal_buffer_level;
int64_t maximum_buffer_size;
double framerate;
} LAYER_CONTEXT;
typedef struct VP9_COMP {
DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]);
DECLARE_ALIGNED(16, int16_t, y_quant_shift[QINDEX_RANGE][8]);
......@@ -474,6 +465,9 @@ typedef struct VP9_COMP {
int gld_fb_idx;
int alt_fb_idx;
int current_layer;
int use_svc;
#if CONFIG_MULTIPLE_ARF
int alt_ref_fb_idx[REF_FRAMES - 3];
#endif
......@@ -690,18 +684,7 @@ typedef struct VP9_COMP {
int initial_width;
int initial_height;
int use_svc;
struct svc {
int spatial_layer_id;
int temporal_layer_id;
int number_spatial_layers;
int number_temporal_layers;
// Layer context used for rate control in CBR mode, only defined for
// temporal layers for now.
LAYER_CONTEXT layer_context[VPX_TS_MAX_LAYERS];
} svc;
int number_spatial_layers;
int enable_encode_breakout; // Default value is 1. From first pass stats,
// encode_breakout may be disabled.
......
......@@ -252,26 +252,6 @@ static void calc_iframe_target_size(VP9_COMP *cpi) {
rc->this_frame_target = target;
}
// Update the buffer level for higher layers, given the encoded current layer.
static void update_layer_buffer_level(VP9_COMP *const cpi,
int encoded_frame_size) {
int temporal_layer = 0;
int current_temporal_layer = cpi->svc.temporal_layer_id;
for (temporal_layer = current_temporal_layer + 1;
temporal_layer < cpi->svc.number_temporal_layers; ++temporal_layer) {
LAYER_CONTEXT *lc = &cpi->svc.layer_context[temporal_layer];
int bits_off_for_this_layer = (int)(lc->target_bandwidth / lc->framerate -
encoded_frame_size);
lc->rc.bits_off_target += bits_off_for_this_layer;
// Clip buffer level to maximum buffer size for the layer.
lc->rc.bits_off_target = MIN(lc->rc.bits_off_target,
lc->maximum_buffer_size);
lc->rc.buffer_level = lc->rc.bits_off_target;
}
}
// Update the buffer level: leaky bucket model.
void vp9_update_buffer_level(VP9_COMP *const cpi, int encoded_frame_size) {
const VP9_COMMON *const cm = &cpi->common;
......@@ -286,18 +266,14 @@ void vp9_update_buffer_level(VP9_COMP *const cpi, int encoded_frame_size) {
}
// Clip the buffer level to the maximum specified buffer size.
rc->bits_off_target = MIN(rc->bits_off_target, oxcf->maximum_buffer_size);
rc->buffer_level = rc->bits_off_target;
if (cpi->use_svc && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
update_layer_buffer_level(cpi, encoded_frame_size);
}
rc->buffer_level = MIN(rc->bits_off_target, oxcf->maximum_buffer_size);
}
int vp9_drop_frame(VP9_COMP *const cpi) {
const VP9_CONFIG *oxcf = &cpi->oxcf;
RATE_CONTROL *const rc = &cpi->rc;