summaryrefslogtreecommitdiff
path: root/vp8/encoder
diff options
context:
space:
mode:
authorJohn Koleszar <jkoleszar@google.com>2011-04-22 00:05:08 -0400
committerJohn Koleszar <jkoleszar@google.com>2011-04-22 00:05:08 -0400
commit5dfd6f51cbdbfb6d37e3ec8f67f1d0ffc246e0ab (patch)
tree2761299d30474aafdad2913415030a2ac878d73e /vp8/encoder
parentb59bd22cc0f89bc13c0b53b1ef618cc405e5dd1f (diff)
parent73c3d327058b1850da4fbfc9819d1265be70965a (diff)
downloadlibvpx-5dfd6f51cbdbfb6d37e3ec8f67f1d0ffc246e0ab.tar
libvpx-5dfd6f51cbdbfb6d37e3ec8f67f1d0ffc246e0ab.tar.gz
libvpx-5dfd6f51cbdbfb6d37e3ec8f67f1d0ffc246e0ab.tar.bz2
libvpx-5dfd6f51cbdbfb6d37e3ec8f67f1d0ffc246e0ab.zip
Merge remote branch 'origin/master' into experimental
Change-Id: I6f77e7c10a54c54b26126b8acd5edd0a03358a41
Diffstat (limited to 'vp8/encoder')
-rw-r--r--vp8/encoder/encodeframe.c4
-rw-r--r--vp8/encoder/encodemb.c35
-rw-r--r--vp8/encoder/encodemb.h2
-rw-r--r--vp8/encoder/onyx_if.c21
-rw-r--r--vp8/encoder/onyx_int.h3
-rw-r--r--vp8/encoder/ratectrl.c106
-rw-r--r--vp8/encoder/rdopt.c8
-rw-r--r--vp8/encoder/tokenize.c10
8 files changed, 62 insertions, 127 deletions
diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c
index e5d7c674d..e09f95b19 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -1381,7 +1381,7 @@ int vp8cx_encode_inter_macroblock
cpi->MVcount[1][mv_max+((xd->block[0].bmi.mv.as_mv.col - best_ref_mv.col) >> 1)]++;
}
- if (!x->skip && !x->e_mbd.mode_info_context->mbmi.force_no_skip)
+ if (!x->skip)
{
vp8_encode_inter16x16(IF_RTCD(&cpi->rtcd), x);
@@ -1391,7 +1391,7 @@ int vp8cx_encode_inter_macroblock
}
else
- vp8_stuff_inter16x16(x);
+ vp8_build_inter_predictors_mb_s(xd);
}
if (!x->skip)
diff --git a/vp8/encoder/encodemb.c b/vp8/encoder/encodemb.c
index 86fe247e1..cb8e9aeb9 100644
--- a/vp8/encoder/encodemb.c
+++ b/vp8/encoder/encodemb.c
@@ -196,39 +196,6 @@ static void transform_mby(MACROBLOCK *x)
}
-void vp8_stuff_inter16x16(MACROBLOCK *x)
-{
- vp8_build_inter_predictors_mb_s(&x->e_mbd);
- /*
- // recon = copy from predictors to destination
- {
- BLOCKD *b = &x->e_mbd.block[0];
- unsigned char *pred_ptr = b->predictor;
- unsigned char *dst_ptr = *(b->base_dst) + b->dst;
- int stride = b->dst_stride;
-
- int i;
- for(i=0;i<16;i++)
- vpx_memcpy(dst_ptr+i*stride,pred_ptr+16*i,16);
-
- b = &x->e_mbd.block[16];
- pred_ptr = b->predictor;
- dst_ptr = *(b->base_dst) + b->dst;
- stride = b->dst_stride;
-
- for(i=0;i<8;i++)
- vpx_memcpy(dst_ptr+i*stride,pred_ptr+8*i,8);
-
- b = &x->e_mbd.block[20];
- pred_ptr = b->predictor;
- dst_ptr = *(b->base_dst) + b->dst;
- stride = b->dst_stride;
-
- for(i=0;i<8;i++)
- vpx_memcpy(dst_ptr+i*stride,pred_ptr+8*i,8);
- }
- */
-}
#define RDTRUNC(RM,DM,R,D) ( (128+(R)*(RM)) & 0xFF )
@@ -635,7 +602,7 @@ void vp8_encode_inter16x16(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
/* this funciton is used by first pass only */
void vp8_encode_inter16x16y(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
{
- vp8_build_inter_predictors_mby(&x->e_mbd);
+ vp8_build_inter16x16_predictors_mby(&x->e_mbd);
ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, x->src.y_buffer, x->e_mbd.predictor, x->src.y_stride);
diff --git a/vp8/encoder/encodemb.h b/vp8/encoder/encodemb.h
index 8c93aa180..47fc72dad 100644
--- a/vp8/encoder/encodemb.h
+++ b/vp8/encoder/encodemb.h
@@ -95,8 +95,6 @@ typedef struct
struct VP8_ENCODER_RTCD;
void vp8_encode_inter16x16(const struct VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x);
-extern void vp8_stuff_inter16x16(MACROBLOCK *x);
-
void vp8_build_dcblock(MACROBLOCK *b);
void vp8_transform_mb(MACROBLOCK *mb);
void vp8_transform_mbuv(MACROBLOCK *x);
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index a2fb8c160..9798805b6 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -1768,9 +1768,6 @@ void vp8_change_config(VP8_PTR ptr, VP8_CONFIG *oxcf)
cm->horiz_scale = cpi->horiz_scale;
cm->vert_scale = cpi->vert_scale ;
- // As per VP8
- cpi->intra_frame_target = (4 * (cm->Width + cm->Height) / 15) * 1000;
-
// VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs)
if (cpi->oxcf.Sharpness > 7)
cpi->oxcf.Sharpness = 7;
@@ -1800,10 +1797,6 @@ void vp8_change_config(VP8_PTR ptr, VP8_CONFIG *oxcf)
vp8_alloc_compressor_data(cpi);
}
- // Clamp KF frame size to quarter of data rate
- if (cpi->intra_frame_target > cpi->target_bandwidth >> 2)
- cpi->intra_frame_target = cpi->target_bandwidth >> 2;
-
if (cpi->oxcf.fixed_q >= 0)
{
cpi->last_q[0] = cpi->oxcf.fixed_q;
@@ -2029,7 +2022,6 @@ VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf)
cpi->frames_till_gf_update_due = 0;
cpi->key_frame_count = 1;
- cpi->tot_key_frame_bits = 0;
cpi->ni_av_qi = cpi->oxcf.worst_allowed_q;
cpi->ni_tot_qi = 0;
@@ -2055,7 +2047,6 @@ VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf)
for (i = 0; i < KEY_FRAME_CONTEXT; i++)
{
- cpi->prior_key_frame_size[i] = cpi->intra_frame_target;
cpi->prior_key_frame_distance[i] = (int)cpi->output_frame_rate;
}
@@ -4456,9 +4447,9 @@ static void encode_frame_to_data_rate
vp8_clear_system_state(); //__asm emms;
if (cpi->total_coded_error_left != 0.0)
- fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6ld %6ld"
- "%6ld %6ld %6ld %5ld %5ld %5ld %8ld %8.2f %10d %10.3f"
- "%10.3f %8ld\n",
+ fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6d %6d"
+ "%6d %6d %6d %5d %5d %5d %8d %8.2f %10d %10.3f"
+ "%10.3f %8d\n",
cpi->common.current_video_frame, cpi->this_frame_target,
cpi->projected_frame_size,
(cpi->projected_frame_size - cpi->this_frame_target),
@@ -4475,9 +4466,9 @@ static void encode_frame_to_data_rate
(double)cpi->bits_left / cpi->total_coded_error_left,
cpi->tot_recode_hits);
else
- fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6ld %6ld"
- "%6ld %6ld %6ld %5ld %5ld %5ld %8ld %8.2f %10d %10.3f"
- "%8ld\n",
+ fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6d %6d"
+ "%6d %6d %6d %5d %5d %5d %8d %8.2f %10d %10.3f"
+ "%8d\n",
cpi->common.current_video_frame,
cpi->this_frame_target, cpi->projected_frame_size,
(cpi->projected_frame_size - cpi->this_frame_target),
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index 4c1854244..fdd3b99bb 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -385,14 +385,11 @@ typedef struct
int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames
INT64 key_frame_count;
- INT64 tot_key_frame_bits;
- int prior_key_frame_size[KEY_FRAME_CONTEXT];
int prior_key_frame_distance[KEY_FRAME_CONTEXT];
int per_frame_bandwidth; // Current section per frame bandwidth target
int av_per_frame_bandwidth; // Average frame size target for clip
int min_frame_bandwidth; // Minimum allocation that should be used for any frame
int last_key_frame_size;
- int intra_frame_target;
int inter_frame_target;
double output_frame_rate;
long long last_time_stamp_seen;
diff --git a/vp8/encoder/ratectrl.c b/vp8/encoder/ratectrl.c
index f3bcf9921..8d639ee28 100644
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -1497,86 +1497,83 @@ static int estimate_min_frame_size(VP8_COMP *cpi)
return (bits_per_mb_at_max_q * cpi->common.MBs) >> BPER_MB_NORMBITS;
}
-void vp8_adjust_key_frame_context(VP8_COMP *cpi)
+
+static int estimate_keyframe_frequency(VP8_COMP *cpi)
{
int i;
- int av_key_frames_per_second;
-
- // Average key frame frequency and size
- unsigned int total_weight = 0;
- unsigned int av_key_frame_frequency = 0;
- unsigned int av_key_frame_bits = 0;
-
- unsigned int output_frame_rate = (unsigned int)(100 * cpi->output_frame_rate);
- unsigned int target_bandwidth = (unsigned int)(100 * cpi->target_bandwidth);
-
- // Clear down mmx registers to allow floating point in what follows
- vp8_clear_system_state(); //__asm emms;
- // Update the count of total key frame bits
- cpi->tot_key_frame_bits += cpi->projected_frame_size;
+ // Average key frame frequency
+ int av_key_frame_frequency = 0;
- // First key frame at start of sequence is a special case. We have no frequency data.
+ /* First key frame at start of sequence is a special case. We have no
+ * frequency data.
+ */
if (cpi->key_frame_count == 1)
{
- av_key_frame_frequency = (int)cpi->output_frame_rate * 2; // Assume a default of 1 kf every 2 seconds
- av_key_frame_bits = cpi->projected_frame_size;
- av_key_frames_per_second = output_frame_rate / av_key_frame_frequency; // Note output_frame_rate not cpi->output_frame_rate
+ /* Assume a default of 1 kf every 2 seconds, or the max kf interval,
+ * whichever is smaller.
+ */
+ av_key_frame_frequency = (int)cpi->output_frame_rate * 2;
+ if (av_key_frame_frequency > cpi->oxcf.key_freq)
+ av_key_frame_frequency = cpi->oxcf.key_freq;
+
+ cpi->prior_key_frame_distance[KEY_FRAME_CONTEXT - 1]
+ = av_key_frame_frequency;
}
else
{
+ unsigned int total_weight = 0;
int last_kf_interval =
(cpi->frames_since_key > 0) ? cpi->frames_since_key : 1;
- // reset keyframe context and calculate weighted average of last KEY_FRAME_CONTEXT keyframes
+ /* reset keyframe context and calculate weighted average of last
+ * KEY_FRAME_CONTEXT keyframes
+ */
for (i = 0; i < KEY_FRAME_CONTEXT; i++)
{
if (i < KEY_FRAME_CONTEXT - 1)
- {
- cpi->prior_key_frame_size[i] = cpi->prior_key_frame_size[i+1];
- cpi->prior_key_frame_distance[i] = cpi->prior_key_frame_distance[i+1];
- }
+ cpi->prior_key_frame_distance[i]
+ = cpi->prior_key_frame_distance[i+1];
else
- {
- cpi->prior_key_frame_size[i] = cpi->projected_frame_size;
cpi->prior_key_frame_distance[i] = last_kf_interval;
- }
- av_key_frame_bits += prior_key_frame_weight[i] * cpi->prior_key_frame_size[i];
- av_key_frame_frequency += prior_key_frame_weight[i] * cpi->prior_key_frame_distance[i];
- total_weight += prior_key_frame_weight[i];
+ av_key_frame_frequency += prior_key_frame_weight[i]
+ * cpi->prior_key_frame_distance[i];
+ total_weight += prior_key_frame_weight[i];
}
- av_key_frame_bits /= total_weight;
av_key_frame_frequency /= total_weight;
- av_key_frames_per_second = output_frame_rate / av_key_frame_frequency;
}
+ return av_key_frame_frequency;
+}
+
+
+void vp8_adjust_key_frame_context(VP8_COMP *cpi)
+{
+ // Clear down mmx registers to allow floating point in what follows
+ vp8_clear_system_state();
// Do we have any key frame overspend to recover?
- if ((cpi->pass != 2) && (cpi->projected_frame_size > cpi->per_frame_bandwidth))
+ // Two-pass overspend handled elsewhere.
+ if ((cpi->pass != 2)
+ && (cpi->projected_frame_size > cpi->per_frame_bandwidth))
{
- // Update the count of key frame overspend to be recovered in subsequent frames
- // A portion of the KF overspend is treated as gf overspend (and hence recovered more quickly)
- // as the kf is also a gf. Otherwise the few frames following each kf tend to get more bits
- // allocated than those following other gfs.
- cpi->kf_overspend_bits += (cpi->projected_frame_size - cpi->per_frame_bandwidth) * 7 / 8;
- cpi->gf_overspend_bits += (cpi->projected_frame_size - cpi->per_frame_bandwidth) * 1 / 8;
- if(!av_key_frame_frequency)
- av_key_frame_frequency = 60;
-
- // Work out how much to try and recover per frame.
- // For one pass we estimate the number of frames to spread it over based upon past history.
- // For two pass we know how many frames there will be till the next kf.
- if (cpi->pass == 2)
- {
- if (cpi->frames_to_key > 16)
- cpi->kf_bitrate_adjustment = cpi->kf_overspend_bits / (int)cpi->frames_to_key;
- else
- cpi->kf_bitrate_adjustment = cpi->kf_overspend_bits / 16;
- }
- else
- cpi->kf_bitrate_adjustment = cpi->kf_overspend_bits / (int)av_key_frame_frequency;
+ int overspend;
+
+ /* Update the count of key frame overspend to be recovered in
+ * subsequent frames. A portion of the KF overspend is treated as gf
+ * overspend (and hence recovered more quickly) as the kf is also a
+ * gf. Otherwise the few frames following each kf tend to get more
+ * bits allocated than those following other gfs.
+ */
+ overspend = (cpi->projected_frame_size - cpi->per_frame_bandwidth);
+ cpi->kf_overspend_bits += overspend * 7 / 8;
+ cpi->gf_overspend_bits += overspend * 1 / 8;
+
+ /* Work out how much to try and recover per frame. */
+ cpi->kf_bitrate_adjustment = cpi->kf_overspend_bits
+ / estimate_keyframe_frequency(cpi);
}
cpi->frames_since_key = 0;
@@ -1584,6 +1581,7 @@ void vp8_adjust_key_frame_context(VP8_COMP *cpi)
cpi->key_frame_count++;
}
+
void vp8_compute_frame_size_bounds(VP8_COMP *cpi, int *frame_under_shoot_limit, int *frame_over_shoot_limit)
{
// Set-up bounds on acceptable frame size:
diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c
index 9ff00c9a6..54cfab8c5 100644
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -1818,9 +1818,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
//int intermodecost[MAX_MODES];
MB_PREDICTION_MODE uv_intra_mode;
-
- int force_no_skip = 0;
-
MV mvp;
int near_sadidx[8] = {0, 1, 2, 3, 4, 5, 6, 7};
int saddone=0;
@@ -1923,8 +1920,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
int disable_skip = 0;
int other_cost = 0;
- force_no_skip = 0;
-
// Experimental debug code.
// Record of rd values recorded for this MB. -1 indicates not measured
//all_rds[mode_index] = -1;
@@ -2299,7 +2294,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
continue;
vp8_set_mbmode_and_mvs(x, this_mode, &mode_mv[this_mode]);
- vp8_build_inter_predictors_mby(&x->e_mbd);
+ vp8_build_inter16x16_predictors_mby(&x->e_mbd);
if (cpi->active_map_enabled && x->active_ptr[0] == 0) {
x->skip = 1;
@@ -2435,7 +2430,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
{
// Note index of best mode so far
best_mode_index = mode_index;
- x->e_mbd.mode_info_context->mbmi.force_no_skip = force_no_skip;
if (this_mode <= B_PRED)
{
diff --git a/vp8/encoder/tokenize.c b/vp8/encoder/tokenize.c
index e3f423f8a..ccf0c7f34 100644
--- a/vp8/encoder/tokenize.c
+++ b/vp8/encoder/tokenize.c
@@ -229,16 +229,6 @@ void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
x->mode_info_context->mbmi.dc_diff = 1;
-#if 0
-
- if (x->mbmi.force_no_skip)
- {
- x->mbmi.mb_skip_coeff = 1;
- //reset for next_mb.
- x->mbmi.force_no_skip = 0;
- }
-
-#endif
#if 1