Moved gf_active code to encoder only

The gf_active code is only used by the encoder, so it was moved from
common and decoder.

Change-Id: Iada15acd5b2b33ff70c34668ca87d4cfd0d05025
This commit is contained in:
Scott LaVarnway 2010-08-11 11:02:31 -04:00
parent c404fa42ac
commit 99f46d62d9
14 changed files with 53 additions and 67 deletions

View File

@ -54,11 +54,6 @@ void vp8_de_alloc_frame_buffers(VP8_COMMON *oci)
oci->above_context[Y2CONTEXT] = 0;
oci->mip = 0;
// Structure used to minitor GF useage
if (oci->gf_active_flags != 0)
vpx_free(oci->gf_active_flags);
oci->gf_active_flags = 0;
}
int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height)
@ -157,20 +152,6 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height)
vp8_update_mode_info_border(oci->mi, oci->mb_rows, oci->mb_cols);
// Structures used to minitor GF usage
if (oci->gf_active_flags != 0)
vpx_free(oci->gf_active_flags);
oci->gf_active_flags = (unsigned char *)vpx_calloc(oci->mb_rows * oci->mb_cols, 1);
if (!oci->gf_active_flags)
{
vp8_de_alloc_frame_buffers(oci);
return ALLOC_FAILURE;
}
oci->gf_active_count = oci->mb_rows * oci->mb_cols;
return 0;
}
void vp8_setup_version(VP8_COMMON *cm)

View File

@ -275,9 +275,6 @@ typedef struct
int mb_to_top_edge;
int mb_to_bottom_edge;
//char * gf_active_ptr;
signed char *gf_active_ptr;
unsigned int frames_since_golden;
unsigned int frames_till_alt_ref_frame;
vp8_subpix_fn_t subpixel_predict;

View File

@ -133,8 +133,6 @@ typedef struct VP8Common
unsigned int frames_since_golden;
unsigned int frames_till_alt_ref_frame;
unsigned char *gf_active_flags; // Record of which MBs still refer to last golden frame either directly or through 0,0
int gf_active_count;
/* We allocate a MODE_INFO struct for each macroblock, together with
an extra row on top and column on the left to simplify prediction. */

View File

@ -12,19 +12,19 @@
#include "segmentation_common.h"
#include "vpx_mem/vpx_mem.h"
void vp8_update_gf_useage_maps(VP8_COMMON *cm, MACROBLOCKD *xd)
void vp8_update_gf_useage_maps(VP8_COMP *cpi, VP8_COMMON *cm, MACROBLOCK *x)
{
int mb_row, mb_col;
MODE_INFO *this_mb_mode_info = cm->mi;
xd->gf_active_ptr = (signed char *)cm->gf_active_flags;
x->gf_active_ptr = (signed char *)cpi->gf_active_flags;
if ((cm->frame_type == KEY_FRAME) || (cm->refresh_golden_frame))
{
// Reset Gf useage monitors
vpx_memset(cm->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
cm->gf_active_count = cm->mb_rows * cm->mb_cols;
vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
}
else
{
@ -40,19 +40,19 @@ void vp8_update_gf_useage_maps(VP8_COMMON *cm, MACROBLOCKD *xd)
// else if using non 0,0 motion or intra modes then clear flag if it is currently set
if ((this_mb_mode_info->mbmi.ref_frame == GOLDEN_FRAME) || (this_mb_mode_info->mbmi.ref_frame == ALTREF_FRAME))
{
if (*(xd->gf_active_ptr) == 0)
if (*(x->gf_active_ptr) == 0)
{
*(xd->gf_active_ptr) = 1;
cm->gf_active_count ++;
*(x->gf_active_ptr) = 1;
cpi->gf_active_count ++;
}
}
else if ((this_mb_mode_info->mbmi.mode != ZEROMV) && *(xd->gf_active_ptr))
else if ((this_mb_mode_info->mbmi.mode != ZEROMV) && *(x->gf_active_ptr))
{
*(xd->gf_active_ptr) = 0;
cm->gf_active_count--;
*(x->gf_active_ptr) = 0;
cpi->gf_active_count--;
}
xd->gf_active_ptr++; // Step onto next entry
x->gf_active_ptr++; // Step onto next entry
this_mb_mode_info++; // skip to next mb
}

View File

@ -11,6 +11,6 @@
#include "string.h"
#include "blockd.h"
#include "onyxc_int.h"
#include "onyx_int.h"
extern void vp8_update_gf_useage_maps(VP8_COMMON *cm, MACROBLOCKD *xd);
extern void vp8_update_gf_useage_maps(VP8_COMP *cpi, VP8_COMMON *cm, MACROBLOCK *x);

View File

@ -21,7 +21,7 @@
#include "alloccommon.h"
#include "entropymode.h"
#include "quant_common.h"
#include "segmentation_common.h"
#include "setupintrarecon.h"
#include "demode.h"
#include "decodemv.h"
@ -447,8 +447,6 @@ void vp8_decode_mb_row(VP8D_COMP *pbi,
++xd->mode_info_context; /* next mb */
xd->gf_active_ptr++; // GF useage flag for next MB
xd->above_context[Y1CONTEXT] += 4;
xd->above_context[UCONTEXT ] += 2;
xd->above_context[VCONTEXT ] += 2;
@ -901,9 +899,6 @@ int vp8_decode_frame(VP8D_COMP *pbi)
vpx_memset(pc->above_context[VCONTEXT ], 0, sizeof(ENTROPY_CONTEXT) * pc->mb_cols * 2);
vpx_memset(pc->above_context[Y2CONTEXT], 0, sizeof(ENTROPY_CONTEXT) * pc->mb_cols);
xd->gf_active_ptr = (signed char *)pc->gf_active_flags; // Point to base of GF active flags data structure
vpx_memcpy(&xd->block[0].bmi, &xd->mode_info_context->bmi[0], sizeof(B_MODE_INFO));

View File

@ -24,7 +24,7 @@
#include "threading.h"
#include "decoderthreading.h"
#include <stdio.h>
#include "segmentation_common.h"
#include "quant_common.h"
#include "vpx_scale/vpxscale.h"
#include "systemdependent.h"
@ -354,9 +354,6 @@ int vp8dx_receive_compressed_data(VP8D_PTR ptr, unsigned long size, const unsign
return retcode;
}
// Update the GF useage maps.
vp8_update_gf_useage_maps(cm, &pbi->mb);
if (pbi->b_multithreaded_lf && pbi->common.filter_level != 0)
vp8_stop_lfthread(pbi);

View File

@ -51,7 +51,6 @@ void vp8_setup_decoding_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd, MB_ROW_DEC
mbd->subpixel_predict8x4 = xd->subpixel_predict8x4;
mbd->subpixel_predict8x8 = xd->subpixel_predict8x8;
mbd->subpixel_predict16x16 = xd->subpixel_predict16x16;
mbd->gf_active_ptr = xd->gf_active_ptr;
mbd->mode_info = pc->mi - 1;
mbd->mode_info_context = pc->mi + pc->mode_info_stride * (i + 1);
@ -108,7 +107,6 @@ void vp8_setup_loop_filter_thread_data(VP8D_COMP *pbi, MACROBLOCKD *xd, MB_ROW_D
//mbd->subpixel_predict8x4 = xd->subpixel_predict8x4;
//mbd->subpixel_predict8x8 = xd->subpixel_predict8x8;
//mbd->subpixel_predict16x16 = xd->subpixel_predict16x16;
//mbd->gf_active_ptr = xd->gf_active_ptr;
mbd->mode_info = pc->mi - 1;
mbd->mode_info_context = pc->mi + pc->mode_info_stride * (i + 1);
@ -270,8 +268,6 @@ THREAD_FUNCTION vp8_thread_decoding_proc(void *p_data)
++xd->mode_info_context; /* next mb */
xd->gf_active_ptr++; // GF useage flag for next MB
xd->above_context[Y1CONTEXT] += 4;
xd->above_context[UCONTEXT ] += 2;
xd->above_context[VCONTEXT ] += 2;
@ -689,8 +685,6 @@ void vp8_mtdecode_mb_rows(VP8D_COMP *pbi,
++xd->mode_info_context; /* next mb */
xd->gf_active_ptr++; // GF useage flag for next MB
xd->above_context[Y1CONTEXT] += 4;
xd->above_context[UCONTEXT ] += 2;
xd->above_context[VCONTEXT ] += 2;

View File

@ -93,6 +93,9 @@ typedef struct
int encode_breakout;
//char * gf_active_ptr;
signed char *gf_active_ptr;
unsigned char *active_ptr;
MV_CONTEXT *mvc;

View File

@ -454,7 +454,7 @@ void encode_mb_row(VP8_COMP *cpi,
cpi->tplist[mb_row].stop = *tp;
xd->gf_active_ptr++; // Increment pointer into gf useage flags structure for next mb
x->gf_active_ptr++; // Increment pointer into gf useage flags structure for next mb
// store macroblock mode info into context array
vpx_memcpy(&xd->mode_info_context->mbmi, &xd->mbmi, sizeof(xd->mbmi));
@ -536,7 +536,7 @@ void vp8_encode_frame(VP8_COMP *cpi)
//}
xd->gf_active_ptr = (signed char *)cm->gf_active_flags; // Point to base of GF active flags data structure
x->gf_active_ptr = (signed char *)cpi->gf_active_flags; // Point to base of GF active flags data structure
x->vector_range = 32;

View File

@ -164,7 +164,7 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
cpi->tplist[mb_row].stop = *tp;
xd->gf_active_ptr++; // Increment pointer into gf useage flags structure for next mb
x->gf_active_ptr++; // Increment pointer into gf useage flags structure for next mb
// store macroblock mode info into context array
vpx_memcpy(&xd->mode_info_context->mbmi, &xd->mbmi, sizeof(xd->mbmi));
@ -371,7 +371,7 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
#if CONFIG_RUNTIME_CPU_DETECT
mbd->rtcd = xd->rtcd;
#endif
mbd->gf_active_ptr = xd->gf_active_ptr;
mb->gf_active_ptr = x->gf_active_ptr;
mb->vector_range = 32;

View File

@ -224,6 +224,12 @@ void vp8_dealloc_compressor_data(VP8_COMP *cpi)
vpx_free(cpi->tok);
cpi->tok = 0;
// Structure used to minitor GF useage
if (cpi->gf_active_flags != 0)
vpx_free(cpi->gf_active_flags);
cpi->gf_active_flags = 0;
}
static void enable_segmentation(VP8_PTR ptr)
@ -1256,6 +1262,15 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
cpi->inter_zz_count = 0;
cpi->gf_bad_count = 0;
cpi->gf_update_recommended = 0;
// Structures used to minitor GF usage
if (cpi->gf_active_flags != 0)
vpx_free(cpi->gf_active_flags);
CHECK_MEM_ERROR(cpi->gf_active_flags, vpx_calloc(1, cm->mb_rows * cm->mb_cols));
cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
}
@ -2862,8 +2877,8 @@ static void update_alt_ref_frame_and_stats(VP8_COMP *cpi)
}
// Update data structure that monitors level of reference to last GF
vpx_memset(cm->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
cm->gf_active_count = cm->mb_rows * cm->mb_cols;
vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
// this frame refreshes means next frames don't unless specified by user
cpi->common.frames_since_golden = 0;
@ -2910,8 +2925,8 @@ static void update_golden_frame_and_stats(VP8_COMP *cpi)
}
// Update data structure that monitors level of reference to last GF
vpx_memset(cm->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
cm->gf_active_count = cm->mb_rows * cm->mb_cols;
vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
// this frame refreshes means next frames don't unless specified by user
cm->refresh_golden_frame = 0;
@ -3415,7 +3430,7 @@ static void vp8cx_temp_filter_c
{
if ((frames_to_blur_backward + frames_to_blur_forward) >= max_frames)
{
frames_to_blur_backward
frames_to_blur_backward
= max_frames - frames_to_blur_forward - 1;
}
}
@ -4298,7 +4313,7 @@ static void encode_frame_to_data_rate(VP8_COMP *cpi, unsigned long *size, unsign
// Update the GF useage maps.
// This is done after completing the compression of a frame when all modes etc. are finalized but before loop filter
vp8_update_gf_useage_maps(cm, &cpi->mb.e_mbd);
vp8_update_gf_useage_maps(cpi, cm, &cpi->mb);
if (cm->frame_type == KEY_FRAME)
cm->refresh_last_frame = 1;
@ -4306,7 +4321,7 @@ static void encode_frame_to_data_rate(VP8_COMP *cpi, unsigned long *size, unsign
if (0)
{
FILE *f = fopen("gfactive.stt", "a");
fprintf(f, "%8d %8d %8d %8d %8d\n", cm->current_video_frame, (100 * cpi->common.gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols), cpi->this_iiratio, cpi->next_iiratio, cm->refresh_golden_frame);
fprintf(f, "%8d %8d %8d %8d %8d\n", cm->current_video_frame, (100 * cpi->gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols), cpi->this_iiratio, cpi->next_iiratio, cm->refresh_golden_frame);
fclose(f);
}
@ -4710,7 +4725,7 @@ int vp8_is_gf_update_needed(VP8_PTR ptr)
void vp8_check_gf_quality(VP8_COMP *cpi)
{
VP8_COMMON *cm = &cpi->common;
int gf_active_pct = (100 * cm->gf_active_count) / (cm->mb_rows * cm->mb_cols);
int gf_active_pct = (100 * cpi->gf_active_count) / (cm->mb_rows * cm->mb_cols);
int gf_ref_usage_pct = (cpi->count_mb_ref_frame_usage[GOLDEN_FRAME] * 100) / (cm->mb_rows * cm->mb_cols);
int last_ref_zz_useage = (cpi->inter_zz_count * 100) / (cm->mb_rows * cm->mb_cols);

View File

@ -646,6 +646,12 @@ typedef struct
int b_calculate_ssimg;
#endif
int b_calculate_psnr;
unsigned char *gf_active_flags; // Record of which MBs still refer to last golden frame either directly or through 0,0
int gf_active_count;
} VP8_COMP;
void control_data_rate(VP8_COMP *cpi);

View File

@ -408,7 +408,7 @@ static void calc_gf_params(VP8_COMP *cpi)
cpi->recent_ref_frame_usage[GOLDEN_FRAME] +
cpi->recent_ref_frame_usage[ALTREF_FRAME];
int pct_gf_active = (100 * cpi->common.gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols);
int pct_gf_active = (100 * cpi->gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols);
// Reset the last boost indicator
//cpi->last_boost = 100;
@ -1022,7 +1022,7 @@ void vp8_calc_pframe_target_size(VP8_COMP *cpi)
cpi->recent_ref_frame_usage[GOLDEN_FRAME] +
cpi->recent_ref_frame_usage[ALTREF_FRAME];
int pct_gf_active = (100 * cpi->common.gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols);
int pct_gf_active = (100 * cpi->gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols);
// Reset the last boost indicator
//cpi->last_boost = 100;