summaryrefslogtreecommitdiff
path: root/vp8/encoder
diff options
context:
space:
mode:
Diffstat (limited to 'vp8/encoder')
-rw-r--r--vp8/encoder/encodeframe.c6
-rw-r--r--vp8/encoder/firstpass.c3
-rw-r--r--vp8/encoder/onyx_if.c116
-rw-r--r--vp8/encoder/onyx_int.h5
-rw-r--r--vp8/encoder/ratectrl.c18
-rw-r--r--vp8/encoder/rdopt.h12
6 files changed, 64 insertions, 96 deletions
diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c
index 2cef01e4f..dce37a7ee 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -644,15 +644,15 @@ static void init_encode_frame_mb_context(VP8_COMP *cpi)
sizeof(ENTROPY_CONTEXT_PLANES) * cm->mb_cols);
// Special case treatment when GF and ARF are not sensible options for reference
- if (cpi->ref_frame_flags == VP8_LAST_FLAG)
+ if (cpi->ref_frame_flags == VP8_LAST_FRAME)
vp8_calc_ref_frame_costs(x->ref_frame_cost,
cpi->prob_intra_coded,255,128);
else if ((cpi->oxcf.number_of_layers > 1) &&
- (cpi->ref_frame_flags == VP8_GOLD_FLAG))
+ (cpi->ref_frame_flags == VP8_GOLD_FRAME))
vp8_calc_ref_frame_costs(x->ref_frame_cost,
cpi->prob_intra_coded,1,255);
else if ((cpi->oxcf.number_of_layers > 1) &&
- (cpi->ref_frame_flags == VP8_ALT_FLAG))
+ (cpi->ref_frame_flags == VP8_ALTR_FRAME))
vp8_calc_ref_frame_costs(x->ref_frame_cost,
cpi->prob_intra_coded,1,1);
else
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c
index 8de1a6a6f..36483d606 100644
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -853,7 +853,8 @@ skip_motion_search:
else
recon_file = fopen(filename, "ab");
- if(fwrite(lst_yv12->buffer_alloc, lst_yv12->frame_size, 1, recon_file));
+ (void) fwrite(lst_yv12->buffer_alloc, lst_yv12->frame_size, 1,
+ recon_file);
fclose(recon_file);
}
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index df1663792..fa8fea0d9 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -703,11 +703,11 @@ void vp8_set_speed_features(VP8_COMP *cpi)
/* Count enabled references */
ref_frames = 1;
- if (cpi->ref_frame_flags & VP8_LAST_FLAG)
+ if (cpi->ref_frame_flags & VP8_LAST_FRAME)
ref_frames++;
- if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
+ if (cpi->ref_frame_flags & VP8_GOLD_FRAME)
ref_frames++;
- if (cpi->ref_frame_flags & VP8_ALT_FLAG)
+ if (cpi->ref_frame_flags & VP8_ALTR_FRAME)
ref_frames++;
/* Convert speed to continuous range, with clamping */
@@ -1514,7 +1514,7 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf)
cpi->baseline_gf_interval =
cpi->oxcf.alt_freq ? cpi->oxcf.alt_freq : DEFAULT_GF_INTERVAL;
- cpi->ref_frame_flags = VP8_ALT_FLAG | VP8_GOLD_FLAG | VP8_LAST_FLAG;
+ cpi->ref_frame_flags = VP8_ALTR_FRAME | VP8_GOLD_FRAME | VP8_LAST_FRAME;
//cpi->use_golden_frame_only = 0;
//cpi->use_last_frame_only = 0;
@@ -1650,6 +1650,7 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf)
cm->yv12_fb[cm->lst_fb_idx].y_height ||
cm->yv12_fb[cm->lst_fb_idx].y_width == 0)
{
+ dealloc_raw_frame_buffers(cpi);
alloc_raw_frame_buffers(cpi);
vp8_alloc_compressor_data(cpi);
}
@@ -1889,9 +1890,6 @@ struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf)
cpi->total_byte_count = 0;
cpi->drop_frame = 0;
- cpi->drop_count = 0;
- cpi->max_drop_count = 0;
- cpi->max_consec_dropped_frames = 4;
cpi->rate_correction_factor = 1.0;
cpi->key_frame_rate_correction_factor = 1.0;
@@ -2486,28 +2484,28 @@ int vp8_update_reference(VP8_COMP *cpi, int ref_frame_flags)
cpi->common.refresh_alt_ref_frame = 0;
cpi->common.refresh_last_frame = 0;
- if (ref_frame_flags & VP8_LAST_FLAG)
+ if (ref_frame_flags & VP8_LAST_FRAME)
cpi->common.refresh_last_frame = 1;
- if (ref_frame_flags & VP8_GOLD_FLAG)
+ if (ref_frame_flags & VP8_GOLD_FRAME)
cpi->common.refresh_golden_frame = 1;
- if (ref_frame_flags & VP8_ALT_FLAG)
+ if (ref_frame_flags & VP8_ALTR_FRAME)
cpi->common.refresh_alt_ref_frame = 1;
return 0;
}
-int vp8_get_reference(VP8_COMP *cpi, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd)
+int vp8_get_reference(VP8_COMP *cpi, enum vpx_ref_frame_type ref_frame_flag, YV12_BUFFER_CONFIG *sd)
{
VP8_COMMON *cm = &cpi->common;
int ref_fb_idx;
- if (ref_frame_flag == VP8_LAST_FLAG)
+ if (ref_frame_flag == VP8_LAST_FRAME)
ref_fb_idx = cm->lst_fb_idx;
- else if (ref_frame_flag == VP8_GOLD_FLAG)
+ else if (ref_frame_flag == VP8_GOLD_FRAME)
ref_fb_idx = cm->gld_fb_idx;
- else if (ref_frame_flag == VP8_ALT_FLAG)
+ else if (ref_frame_flag == VP8_ALTR_FRAME)
ref_fb_idx = cm->alt_fb_idx;
else
return -1;
@@ -2516,17 +2514,17 @@ int vp8_get_reference(VP8_COMP *cpi, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CO
return 0;
}
-int vp8_set_reference(VP8_COMP *cpi, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd)
+int vp8_set_reference(VP8_COMP *cpi, enum vpx_ref_frame_type ref_frame_flag, YV12_BUFFER_CONFIG *sd)
{
VP8_COMMON *cm = &cpi->common;
int ref_fb_idx;
- if (ref_frame_flag == VP8_LAST_FLAG)
+ if (ref_frame_flag == VP8_LAST_FRAME)
ref_fb_idx = cm->lst_fb_idx;
- else if (ref_frame_flag == VP8_GOLD_FLAG)
+ else if (ref_frame_flag == VP8_GOLD_FRAME)
ref_fb_idx = cm->gld_fb_idx;
- else if (ref_frame_flag == VP8_ALT_FLAG)
+ else if (ref_frame_flag == VP8_ALTR_FRAME)
ref_fb_idx = cm->alt_fb_idx;
else
return -1;
@@ -2615,7 +2613,7 @@ static void scale_and_extend_source(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
}
-static void resize_key_frame(VP8_COMP *cpi)
+static int resize_key_frame(VP8_COMP *cpi)
{
#if CONFIG_SPATIAL_RESAMPLING
VP8_COMMON *cm = &cpi->common;
@@ -2656,10 +2654,12 @@ static void resize_key_frame(VP8_COMP *cpi)
cm->Height = new_height;
vp8_alloc_compressor_data(cpi);
scale_and_extend_source(cpi->un_scaled_source, cpi);
+ return 1;
}
}
#endif
+ return 0;
}
@@ -3033,10 +3033,10 @@ static void update_reference_frames(VP8_COMMON *cm)
if (cm->frame_type == KEY_FRAME)
{
- yv12_fb[cm->new_fb_idx].flags |= VP8_GOLD_FLAG | VP8_ALT_FLAG ;
+ yv12_fb[cm->new_fb_idx].flags |= VP8_GOLD_FRAME | VP8_ALTR_FRAME ;
- yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
- yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
+ yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FRAME;
+ yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALTR_FRAME;
cm->alt_fb_idx = cm->gld_fb_idx = cm->new_fb_idx;
}
@@ -3046,8 +3046,8 @@ static void update_reference_frames(VP8_COMMON *cm)
{
assert(!cm->copy_buffer_to_arf);
- cm->yv12_fb[cm->new_fb_idx].flags |= VP8_ALT_FLAG;
- cm->yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
+ cm->yv12_fb[cm->new_fb_idx].flags |= VP8_ALTR_FRAME;
+ cm->yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALTR_FRAME;
cm->alt_fb_idx = cm->new_fb_idx;
}
else if (cm->copy_buffer_to_arf)
@@ -3058,8 +3058,8 @@ static void update_reference_frames(VP8_COMMON *cm)
{
if(cm->alt_fb_idx != cm->lst_fb_idx)
{
- yv12_fb[cm->lst_fb_idx].flags |= VP8_ALT_FLAG;
- yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
+ yv12_fb[cm->lst_fb_idx].flags |= VP8_ALTR_FRAME;
+ yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALTR_FRAME;
cm->alt_fb_idx = cm->lst_fb_idx;
}
}
@@ -3067,8 +3067,8 @@ static void update_reference_frames(VP8_COMMON *cm)
{
if(cm->alt_fb_idx != cm->gld_fb_idx)
{
- yv12_fb[cm->gld_fb_idx].flags |= VP8_ALT_FLAG;
- yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG;
+ yv12_fb[cm->gld_fb_idx].flags |= VP8_ALTR_FRAME;
+ yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALTR_FRAME;
cm->alt_fb_idx = cm->gld_fb_idx;
}
}
@@ -3078,8 +3078,8 @@ static void update_reference_frames(VP8_COMMON *cm)
{
assert(!cm->copy_buffer_to_gf);
- cm->yv12_fb[cm->new_fb_idx].flags |= VP8_GOLD_FLAG;
- cm->yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
+ cm->yv12_fb[cm->new_fb_idx].flags |= VP8_GOLD_FRAME;
+ cm->yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FRAME;
cm->gld_fb_idx = cm->new_fb_idx;
}
else if (cm->copy_buffer_to_gf)
@@ -3090,8 +3090,8 @@ static void update_reference_frames(VP8_COMMON *cm)
{
if(cm->gld_fb_idx != cm->lst_fb_idx)
{
- yv12_fb[cm->lst_fb_idx].flags |= VP8_GOLD_FLAG;
- yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
+ yv12_fb[cm->lst_fb_idx].flags |= VP8_GOLD_FRAME;
+ yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FRAME;
cm->gld_fb_idx = cm->lst_fb_idx;
}
}
@@ -3099,8 +3099,8 @@ static void update_reference_frames(VP8_COMMON *cm)
{
if(cm->alt_fb_idx != cm->gld_fb_idx)
{
- yv12_fb[cm->alt_fb_idx].flags |= VP8_GOLD_FLAG;
- yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG;
+ yv12_fb[cm->alt_fb_idx].flags |= VP8_GOLD_FRAME;
+ yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FRAME;
cm->gld_fb_idx = cm->alt_fb_idx;
}
}
@@ -3109,8 +3109,8 @@ static void update_reference_frames(VP8_COMMON *cm)
if (cm->refresh_last_frame)
{
- cm->yv12_fb[cm->new_fb_idx].flags |= VP8_LAST_FLAG;
- cm->yv12_fb[cm->lst_fb_idx].flags &= ~VP8_LAST_FLAG;
+ cm->yv12_fb[cm->new_fb_idx].flags |= VP8_LAST_FRAME;
+ cm->yv12_fb[cm->lst_fb_idx].flags &= ~VP8_LAST_FRAME;
cm->lst_fb_idx = cm->new_fb_idx;
}
}
@@ -3815,7 +3815,17 @@ static void encode_frame_to_data_rate
if (cm->frame_type == KEY_FRAME)
{
- resize_key_frame(cpi);
+ if(resize_key_frame(cpi))
+ {
+ /* If the frame size has changed, need to reset Q, quantizer,
+ * and background refresh.
+ */
+ Q = vp8_regulate_q(cpi, cpi->this_frame_target);
+ if (cpi->cyclic_refresh_mode_enabled && (cpi->current_layer==0))
+ cyclic_background_refresh(cpi, Q, 0);
+ vp8_set_quantizer(cpi, Q);
+ }
+
vp8_setup_key_frame(cpi);
}
@@ -4313,30 +4323,6 @@ static void encode_frame_to_data_rate
}
}
-#if 0
-
- // If the frame was massively oversize and we are below optimal buffer level drop next frame
- if ((cpi->drop_frames_allowed) &&
- (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) &&
- (cpi->buffer_level < cpi->oxcf.drop_frames_water_mark * cpi->oxcf.optimal_buffer_level / 100) &&
- (cpi->projected_frame_size > (4 * cpi->this_frame_target)))
- {
- cpi->drop_frame = 1;
- }
-
-#endif
-
- // Set the count for maximum consecutive dropped frames based upon the ratio of
- // this frame size to the target average per frame bandwidth.
- // (cpi->av_per_frame_bandwidth > 0) is just a sanity check to prevent / 0.
- if (cpi->drop_frames_allowed && (cpi->av_per_frame_bandwidth > 0))
- {
- cpi->max_drop_count = cpi->projected_frame_size / cpi->av_per_frame_bandwidth;
-
- if (cpi->max_drop_count > cpi->max_consec_dropped_frames)
- cpi->max_drop_count = cpi->max_consec_dropped_frames;
- }
-
// Update the buffer level variable.
// Non-viewable frames are a special case and are treated as pure overhead.
if ( !cm->show_frame )
@@ -4527,16 +4513,16 @@ static void encode_frame_to_data_rate
else if (cm->refresh_alt_ref_frame ^ cm->refresh_golden_frame) // 1 refreshed but not the other
cpi->gold_is_alt = 0;
- cpi->ref_frame_flags = VP8_ALT_FLAG | VP8_GOLD_FLAG | VP8_LAST_FLAG;
+ cpi->ref_frame_flags = VP8_ALTR_FRAME | VP8_GOLD_FRAME | VP8_LAST_FRAME;
if (cpi->gold_is_last)
- cpi->ref_frame_flags &= ~VP8_GOLD_FLAG;
+ cpi->ref_frame_flags &= ~VP8_GOLD_FRAME;
if (cpi->alt_is_last)
- cpi->ref_frame_flags &= ~VP8_ALT_FLAG;
+ cpi->ref_frame_flags &= ~VP8_ALTR_FRAME;
if (cpi->gold_is_alt)
- cpi->ref_frame_flags &= ~VP8_ALT_FLAG;
+ cpi->ref_frame_flags &= ~VP8_ALTR_FRAME;
if (!cpi->oxcf.error_resilient_mode)
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index cf70231c4..3b202c941 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -25,6 +25,7 @@
#include "vp8/common/threading.h"
#include "vpx_ports/mem.h"
#include "vpx/internal/vpx_codec_internal.h"
+#include "vpx/vp8.h"
#include "mcomp.h"
#include "vp8/common/findnearmv.h"
#include "lookahead.h"
@@ -435,10 +436,6 @@ typedef struct VP8_COMP
int drop_frames_allowed; // Are we permitted to drop frames?
int drop_frame; // Drop this frame?
- int drop_count; // How many frames have we dropped?
- int max_drop_count; // How many frames should we drop?
- int max_consec_dropped_frames; // Limit number of consecutive frames that can be dropped.
-
int ymode_count [VP8_YMODES]; /* intra MB type cts this frame */
int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */
diff --git a/vp8/encoder/ratectrl.c b/vp8/encoder/ratectrl.c
index 04fd2d05b..f6baf4c7e 100644
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -966,7 +966,7 @@ static void calc_pframe_target_size(VP8_COMP *cpi)
// In unbufferd mode (eg vide conferencing) the descision to
// code or drop a frame is made outside the codec in response to real
// world comms or buffer considerations.
- if (cpi->drop_frames_allowed && cpi->buffered_mode &&
+ if (cpi->drop_frames_allowed &&
(cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) &&
((cpi->common.frame_type != KEY_FRAME))) //|| !cpi->oxcf.allow_spatial_resampling) )
{
@@ -984,28 +984,13 @@ static void calc_pframe_target_size(VP8_COMP *cpi)
//vpx_log("Decoder: Drop frame due to bandwidth: %d \n",cpi->buffer_level, cpi->av_per_frame_bandwidth);
cpi->drop_frame = 1;
- }
-
-#if 0
- // Check for other drop frame crtieria (Note 2 pass cbr uses decimation on whole KF sections)
- else if ((cpi->buffer_level < cpi->oxcf.drop_frames_water_mark * cpi->oxcf.optimal_buffer_level / 100) &&
- (cpi->drop_count < cpi->max_drop_count) && (cpi->pass == 0))
- {
- cpi->drop_frame = 1;
- }
-#endif
-
- if (cpi->drop_frame)
- {
// Update the buffer level variable.
cpi->bits_off_target += cpi->av_per_frame_bandwidth;
if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
cpi->bits_off_target = cpi->oxcf.maximum_buffer_size;
cpi->buffer_level = cpi->bits_off_target;
}
- else
- cpi->drop_count = 0;
}
// Adjust target frame size for Golden Frames:
@@ -1554,7 +1539,6 @@ int vp8_pick_frame_size(VP8_COMP *cpi)
if (cpi->drop_frame)
{
cpi->drop_frame = 0;
- cpi->drop_count++;
return 0;
}
}
diff --git a/vp8/encoder/rdopt.h b/vp8/encoder/rdopt.h
index db939f96c..bbcb59f67 100644
--- a/vp8/encoder/rdopt.h
+++ b/vp8/encoder/rdopt.h
@@ -86,15 +86,15 @@ static void get_predictor_pointers(const VP8_COMP *cpi,
unsigned int recon_yoffset,
unsigned int recon_uvoffset)
{
- if (cpi->ref_frame_flags & VP8_LAST_FLAG)
+ if (cpi->ref_frame_flags & VP8_LAST_FRAME)
get_plane_pointers(&cpi->common.yv12_fb[cpi->common.lst_fb_idx],
plane[LAST_FRAME], recon_yoffset, recon_uvoffset);
- if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
+ if (cpi->ref_frame_flags & VP8_GOLD_FRAME)
get_plane_pointers(&cpi->common.yv12_fb[cpi->common.gld_fb_idx],
plane[GOLDEN_FRAME], recon_yoffset, recon_uvoffset);
- if (cpi->ref_frame_flags & VP8_ALT_FLAG)
+ if (cpi->ref_frame_flags & VP8_ALTR_FRAME)
get_plane_pointers(&cpi->common.yv12_fb[cpi->common.alt_fb_idx],
plane[ALTREF_FRAME], recon_yoffset, recon_uvoffset);
}
@@ -106,11 +106,11 @@ static void get_reference_search_order(const VP8_COMP *cpi,
int i=0;
ref_frame_map[i++] = INTRA_FRAME;
- if (cpi->ref_frame_flags & VP8_LAST_FLAG)
+ if (cpi->ref_frame_flags & VP8_LAST_FRAME)
ref_frame_map[i++] = LAST_FRAME;
- if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
+ if (cpi->ref_frame_flags & VP8_GOLD_FRAME)
ref_frame_map[i++] = GOLDEN_FRAME;
- if (cpi->ref_frame_flags & VP8_ALT_FLAG)
+ if (cpi->ref_frame_flags & VP8_ALTR_FRAME)
ref_frame_map[i++] = ALTREF_FRAME;
for(; i<4; i++)
ref_frame_map[i] = -1;