#include <limits.h>
#include <stdio.h>
#include "vpx_config.h"
#include "vp8/common/common.h"
#include "vp8/common/entropymode.h"
#include "vp8/common/extend.h"
#include "vp8/common/invtrans.h"
#include "vp8/common/quant_common.h"
#include "vp8/common/reconinter.h"
#include "vp8/common/setupintrarecon.h"
#include "vp8/common/threading.h"
#include "vp8/encoder/bitstream.h"
#include "vp8/encoder/encodeframe.h"
#include "vp8/encoder/encodeintra.h"
#include "vp8/encoder/encodemb.h"
#include "vp8/encoder/onyx_int.h"
#include "vp8/encoder/pickinter.h"
#include "vp8/encoder/rdopt.h"
#include "vp8_rtcd.h"
#include "vpx/internal/vpx_codec_internal.h"
#include "vpx_dsp_rtcd.h"
#include "vpx_mem/vpx_mem.h"
#include "vpx_ports/vpx_timer.h"
#if CONFIG_MULTITHREAD
#include "vp8/encoder/ethreading.h"
#endif
extern void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t);
static void adjust_act_zbin(VP8_COMP *cpi, MACROBLOCK *x);
#ifdef MODE_STATS
unsigned int inter_y_modes[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
unsigned int inter_uv_modes[4] = { 0, 0, 0, 0 };
unsigned int inter_b_modes[15] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
unsigned int y_modes[5] = { 0, 0, 0, 0, 0 };
unsigned int uv_modes[4] = { 0, 0, 0, 0 };
unsigned int b_modes[14] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
#endif
#define VP8_ACTIVITY_AVG_MIN …
static const unsigned char VP8_VAR_OFFS[16] = …;
static unsigned int tt_activity_measure(MACROBLOCK *x) { … }
#define ALT_ACT_MEASURE …
static unsigned int mb_activity_measure(MACROBLOCK *x, int mb_row, int mb_col) { … }
#define ACT_MEDIAN …
static void calc_av_activity(VP8_COMP *cpi, int64_t activity_sum) { … }
#define USE_ACT_INDEX …
#define OUTPUT_NORM_ACT_STATS …
#if USE_ACT_INDEX
static void calc_activity_index(VP8_COMP *cpi, MACROBLOCK *x) {
VP8_COMMON *const cm = &cpi->common;
int mb_row, mb_col;
int64_t act;
int64_t a;
int64_t b;
#if OUTPUT_NORM_ACT_STATS
FILE *f = fopen("norm_act.stt", "a");
fprintf(f, "\n%12d\n", cpi->activity_avg);
#endif
x->mb_activity_ptr = cpi->mb_activity_map;
for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) {
for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) {
act = *(x->mb_activity_ptr);
a = act + 4 * cpi->activity_avg;
b = 4 * act + cpi->activity_avg;
if (b >= a)
*(x->activity_ptr) = (int)((b + (a >> 1)) / a) - 1;
else
*(x->activity_ptr) = 1 - (int)((a + (b >> 1)) / b);
#if OUTPUT_NORM_ACT_STATS
fprintf(f, " %6d", *(x->mb_activity_ptr));
#endif
x->mb_activity_ptr++;
}
#if OUTPUT_NORM_ACT_STATS
fprintf(f, "\n");
#endif
}
#if OUTPUT_NORM_ACT_STATS
fclose(f);
#endif
}
#endif
static void build_activity_map(VP8_COMP *cpi) { … }
void vp8_activity_masking(VP8_COMP *cpi, MACROBLOCK *x) { … }
static void encode_mb_row(VP8_COMP *cpi, VP8_COMMON *cm, int mb_row,
MACROBLOCK *x, MACROBLOCKD *xd, TOKENEXTRA **tp,
int *segment_counts, int *totalrate) { … }
static void init_encode_frame_mb_context(VP8_COMP *cpi) { … }
#if CONFIG_MULTITHREAD
static void sum_coef_counts(MACROBLOCK *x, MACROBLOCK *x_thread) { … }
#endif
void vp8_encode_frame(VP8_COMP *cpi) { … }
void vp8_setup_block_ptrs(MACROBLOCK *x) { … }
void vp8_build_block_offsets(MACROBLOCK *x) { … }
static void sum_intra_stats(VP8_COMP *cpi, MACROBLOCK *x) { … }
static void adjust_act_zbin(VP8_COMP *cpi, MACROBLOCK *x) { … }
int vp8cx_encode_intra_macroblock(VP8_COMP *cpi, MACROBLOCK *x,
TOKENEXTRA **t) { … }
#ifdef SPEEDSTATS
extern int cnt_pm;
#endif
extern void vp8_fix_contexts(MACROBLOCKD *x);
int vp8cx_encode_inter_macroblock(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t,
int recon_yoffset, int recon_uvoffset,
int mb_row, int mb_col) { … }