Fix post-processor macros & remove vizualization

Make all post-processor code conditionally
compilable based on the CONFIG_VP9_POSTPROC
macro.

Also, remove the vizualization code from VP9
since it is out of date and will not compile.

Change-Id: I1e9e13a09ecd43e9a3f3704c175ae8cd258ababd
This commit is contained in:
Adrian Grange 2014-05-14 16:05:21 -07:00
Родитель 86094f22ba
Коммит 384bc5163c
3 изменённых файлов: 2 добавлений и 574 удалений

Просмотреть файл

@ -24,61 +24,7 @@
#include "vp9/common/vp9_systemdependent.h"
#include "vp9/common/vp9_textblit.h"
#define RGB_TO_YUV(t) \
( (0.257*(float)(t >> 16)) + (0.504*(float)(t >> 8 & 0xff)) + \
(0.098*(float)(t & 0xff)) + 16), \
(-(0.148*(float)(t >> 16)) - (0.291*(float)(t >> 8 & 0xff)) + \
(0.439*(float)(t & 0xff)) + 128), \
( (0.439*(float)(t >> 16)) - (0.368*(float)(t >> 8 & 0xff)) - \
(0.071*(float)(t & 0xff)) + 128)
/* global constants */
#if 0 && CONFIG_POSTPROC_VISUALIZER
static const unsigned char PREDICTION_MODE_colors[MB_MODE_COUNT][3] = {
{ RGB_TO_YUV(0x98FB98) }, /* PaleGreen */
{ RGB_TO_YUV(0x00FF00) }, /* Green */
{ RGB_TO_YUV(0xADFF2F) }, /* GreenYellow */
{ RGB_TO_YUV(0x8F0000) }, /* Dark Red */
{ RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */
{ RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */
{ RGB_TO_YUV(0x008F8F) }, /* Dark Cyan */
{ RGB_TO_YUV(0x8F0000) }, /* Dark Red */
{ RGB_TO_YUV(0x8F0000) }, /* Dark Red */
{ RGB_TO_YUV(0x228B22) }, /* ForestGreen */
{ RGB_TO_YUV(0x006400) }, /* DarkGreen */
{ RGB_TO_YUV(0x98F5FF) }, /* Cadet Blue */
{ RGB_TO_YUV(0x6CA6CD) }, /* Sky Blue */
{ RGB_TO_YUV(0x00008B) }, /* Dark blue */
{ RGB_TO_YUV(0x551A8B) }, /* Purple */
{ RGB_TO_YUV(0xFF0000) } /* Red */
{ RGB_TO_YUV(0xCC33FF) }, /* Magenta */
};
static const unsigned char B_PREDICTION_MODE_colors[INTRA_MODES][3] = {
{ RGB_TO_YUV(0x6633ff) }, /* Purple */
{ RGB_TO_YUV(0xcc33ff) }, /* Magenta */
{ RGB_TO_YUV(0xff33cc) }, /* Pink */
{ RGB_TO_YUV(0xff3366) }, /* Coral */
{ RGB_TO_YUV(0x3366ff) }, /* Blue */
{ RGB_TO_YUV(0xed00f5) }, /* Dark Blue */
{ RGB_TO_YUV(0x2e00b8) }, /* Dark Purple */
{ RGB_TO_YUV(0xff6633) }, /* Orange */
{ RGB_TO_YUV(0x33ccff) }, /* Light Blue */
{ RGB_TO_YUV(0x8ab800) }, /* Green */
{ RGB_TO_YUV(0xffcc33) }, /* Light Orange */
{ RGB_TO_YUV(0x33ffcc) }, /* Aqua */
{ RGB_TO_YUV(0x66ff33) }, /* Light Green */
{ RGB_TO_YUV(0xccff33) }, /* Yellow */
};
static const unsigned char MV_REFERENCE_FRAME_colors[MAX_REF_FRAMES][3] = {
{ RGB_TO_YUV(0x00ff00) }, /* Blue */
{ RGB_TO_YUV(0x0000ff) }, /* Green */
{ RGB_TO_YUV(0xffff00) }, /* Yellow */
{ RGB_TO_YUV(0xff0000) }, /* Red */
};
#endif
#if CONFIG_VP9_POSTPROC
static const short kernel5[] = {
1, 1, 4, 1, 1
};
@ -448,163 +394,6 @@ void vp9_plane_add_noise_c(uint8_t *start, char *noise,
}
}
/* Blend the macro block with a solid colored square. Leave the
* edges unblended to give distinction to macro blocks in areas
* filled with the same color block.
*/
void vp9_blend_mb_inner_c(uint8_t *y, uint8_t *u, uint8_t *v,
int y1, int u1, int v1, int alpha, int stride) {
int i, j;
int y1_const = y1 * ((1 << 16) - alpha);
int u1_const = u1 * ((1 << 16) - alpha);
int v1_const = v1 * ((1 << 16) - alpha);
y += 2 * stride + 2;
for (i = 0; i < 12; i++) {
for (j = 0; j < 12; j++) {
y[j] = (y[j] * alpha + y1_const) >> 16;
}
y += stride;
}
stride >>= 1;
u += stride + 1;
v += stride + 1;
for (i = 0; i < 6; i++) {
for (j = 0; j < 6; j++) {
u[j] = (u[j] * alpha + u1_const) >> 16;
v[j] = (v[j] * alpha + v1_const) >> 16;
}
u += stride;
v += stride;
}
}
/* Blend only the edge of the macro block. Leave center
* unblended to allow for other visualizations to be layered.
*/
void vp9_blend_mb_outer_c(uint8_t *y, uint8_t *u, uint8_t *v,
int y1, int u1, int v1, int alpha, int stride) {
int i, j;
int y1_const = y1 * ((1 << 16) - alpha);
int u1_const = u1 * ((1 << 16) - alpha);
int v1_const = v1 * ((1 << 16) - alpha);
for (i = 0; i < 2; i++) {
for (j = 0; j < 16; j++) {
y[j] = (y[j] * alpha + y1_const) >> 16;
}
y += stride;
}
for (i = 0; i < 12; i++) {
y[0] = (y[0] * alpha + y1_const) >> 16;
y[1] = (y[1] * alpha + y1_const) >> 16;
y[14] = (y[14] * alpha + y1_const) >> 16;
y[15] = (y[15] * alpha + y1_const) >> 16;
y += stride;
}
for (i = 0; i < 2; i++) {
for (j = 0; j < 16; j++) {
y[j] = (y[j] * alpha + y1_const) >> 16;
}
y += stride;
}
stride >>= 1;
for (j = 0; j < 8; j++) {
u[j] = (u[j] * alpha + u1_const) >> 16;
v[j] = (v[j] * alpha + v1_const) >> 16;
}
u += stride;
v += stride;
for (i = 0; i < 6; i++) {
u[0] = (u[0] * alpha + u1_const) >> 16;
v[0] = (v[0] * alpha + v1_const) >> 16;
u[7] = (u[7] * alpha + u1_const) >> 16;
v[7] = (v[7] * alpha + v1_const) >> 16;
u += stride;
v += stride;
}
for (j = 0; j < 8; j++) {
u[j] = (u[j] * alpha + u1_const) >> 16;
v[j] = (v[j] * alpha + v1_const) >> 16;
}
}
void vp9_blend_b_c(uint8_t *y, uint8_t *u, uint8_t *v,
int y1, int u1, int v1, int alpha, int stride) {
int i, j;
int y1_const = y1 * ((1 << 16) - alpha);
int u1_const = u1 * ((1 << 16) - alpha);
int v1_const = v1 * ((1 << 16) - alpha);
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
y[j] = (y[j] * alpha + y1_const) >> 16;
}
y += stride;
}
stride >>= 1;
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
u[j] = (u[j] * alpha + u1_const) >> 16;
v[j] = (v[j] * alpha + v1_const) >> 16;
}
u += stride;
v += stride;
}
}
static void constrain_line(int x0, int *x1, int y0, int *y1,
int width, int height) {
int dx;
int dy;
if (*x1 > width) {
dx = *x1 - x0;
dy = *y1 - y0;
*x1 = width;
if (dx)
*y1 = ((width - x0) * dy) / dx + y0;
}
if (*x1 < 0) {
dx = *x1 - x0;
dy = *y1 - y0;
*x1 = 0;
if (dx)
*y1 = ((0 - x0) * dy) / dx + y0;
}
if (*y1 > height) {
dx = *x1 - x0;
dy = *y1 - y0;
*y1 = height;
if (dy)
*x1 = ((height - y0) * dx) / dy + x0;
}
if (*y1 < 0) {
dx = *x1 - x0;
dy = *y1 - y0;
*y1 = 0;
if (dy)
*x1 = ((0 - y0) * dx) / dy + x0;
}
}
int vp9_post_proc_frame(struct VP9Common *cm,
YV12_BUFFER_CONFIG *dest, vp9_ppflags_t *ppflags) {
const int q = MIN(63, cm->lf.filter_level * 10 / 6);
@ -643,328 +432,6 @@ int vp9_post_proc_frame(struct VP9Common *cm,
ppbuf->y_width, ppbuf->y_height, ppbuf->y_stride);
}
#if 0 && CONFIG_POSTPROC_VISUALIZER
if (flags & VP9D_DEBUG_TXT_FRAME_INFO) {
char message[512];
snprintf(message, sizeof(message) -1,
"F%1dG%1dQ%3dF%3dP%d_s%dx%d",
(cm->frame_type == KEY_FRAME),
cm->refresh_golden_frame,
cm->base_qindex,
cm->filter_level,
flags,
cm->mb_cols, cm->mb_rows);
vp9_blit_text(message, ppbuf->y_buffer, ppbuf->y_stride);
}
if (flags & VP9D_DEBUG_TXT_MBLK_MODES) {
int i, j;
uint8_t *y_ptr;
int mb_rows = ppbuf->y_height >> 4;
int mb_cols = ppbuf->y_width >> 4;
int mb_index = 0;
MODE_INFO *mi = cm->mi;
y_ptr = post->y_buffer + 4 * post->y_stride + 4;
/* vp9_filter each macro block */
for (i = 0; i < mb_rows; i++) {
for (j = 0; j < mb_cols; j++) {
char zz[4];
snprintf(zz, sizeof(zz) - 1, "%c", mi[mb_index].mbmi.mode + 'a');
vp9_blit_text(zz, y_ptr, post->y_stride);
mb_index++;
y_ptr += 16;
}
mb_index++; /* border */
y_ptr += post->y_stride * 16 - post->y_width;
}
}
if (flags & VP9D_DEBUG_TXT_DC_DIFF) {
int i, j;
uint8_t *y_ptr;
int mb_rows = ppbuf->y_height >> 4;
int mb_cols = ppbuf->y_width >> 4;
int mb_index = 0;
MODE_INFO *mi = cm->mi;
y_ptr = post->y_buffer + 4 * post->y_stride + 4;
/* vp9_filter each macro block */
for (i = 0; i < mb_rows; i++) {
for (j = 0; j < mb_cols; j++) {
char zz[4];
int dc_diff = !(mi[mb_index].mbmi.mode != I4X4_PRED &&
mi[mb_index].mbmi.mode != SPLITMV &&
mi[mb_index].mbmi.skip);
if (cm->frame_type == KEY_FRAME)
snprintf(zz, sizeof(zz) - 1, "a");
else
snprintf(zz, sizeof(zz) - 1, "%c", dc_diff + '0');
vp9_blit_text(zz, y_ptr, post->y_stride);
mb_index++;
y_ptr += 16;
}
mb_index++; /* border */
y_ptr += post->y_stride * 16 - post->y_width;
}
}
if (flags & VP9D_DEBUG_TXT_RATE_INFO) {
char message[512];
snprintf(message, sizeof(message),
"Bitrate: %10.2f framerate: %10.2f ",
cm->bitrate, cm->framerate);
vp9_blit_text(message, ppbuf->y_buffer, ppbuf->y_stride);
}
/* Draw motion vectors */
if ((flags & VP9D_DEBUG_DRAW_MV) && ppflags->display_mv_flag) {
int width = ppbuf->y_width;
int height = ppbuf->y_height;
uint8_t *y_buffer = ppbuf->y_buffer;
int y_stride = ppbuf->y_stride;
MODE_INFO *mi = cm->mi;
int x0, y0;
for (y0 = 0; y0 < height; y0 += 16) {
for (x0 = 0; x0 < width; x0 += 16) {
int x1, y1;
if (!(ppflags->display_mv_flag & (1 << mi->mbmi.mode))) {
mi++;
continue;
}
if (mi->mbmi.mode == SPLITMV) {
switch (mi->mbmi.partitioning) {
case PARTITIONING_16X8 : { /* mv_top_bottom */
union b_mode_info *bmi = &mi->bmi[0];
MV *mv = &bmi->mv.as_mv;
x1 = x0 + 8 + (mv->col >> 3);
y1 = y0 + 4 + (mv->row >> 3);
constrain_line(x0 + 8, &x1, y0 + 4, &y1, width, height);
vp9_blit_line(x0 + 8, x1, y0 + 4, y1, y_buffer, y_stride);
bmi = &mi->bmi[8];
x1 = x0 + 8 + (mv->col >> 3);
y1 = y0 + 12 + (mv->row >> 3);
constrain_line(x0 + 8, &x1, y0 + 12, &y1, width, height);
vp9_blit_line(x0 + 8, x1, y0 + 12, y1, y_buffer, y_stride);
break;
}
case PARTITIONING_8X16 : { /* mv_left_right */
union b_mode_info *bmi = &mi->bmi[0];
MV *mv = &bmi->mv.as_mv;
x1 = x0 + 4 + (mv->col >> 3);
y1 = y0 + 8 + (mv->row >> 3);
constrain_line(x0 + 4, &x1, y0 + 8, &y1, width, height);
vp9_blit_line(x0 + 4, x1, y0 + 8, y1, y_buffer, y_stride);
bmi = &mi->bmi[2];
x1 = x0 + 12 + (mv->col >> 3);
y1 = y0 + 8 + (mv->row >> 3);
constrain_line(x0 + 12, &x1, y0 + 8, &y1, width, height);
vp9_blit_line(x0 + 12, x1, y0 + 8, y1, y_buffer, y_stride);
break;
}
case PARTITIONING_8X8 : { /* mv_quarters */
union b_mode_info *bmi = &mi->bmi[0];
MV *mv = &bmi->mv.as_mv;
x1 = x0 + 4 + (mv->col >> 3);
y1 = y0 + 4 + (mv->row >> 3);
constrain_line(x0 + 4, &x1, y0 + 4, &y1, width, height);
vp9_blit_line(x0 + 4, x1, y0 + 4, y1, y_buffer, y_stride);
bmi = &mi->bmi[2];
x1 = x0 + 12 + (mv->col >> 3);
y1 = y0 + 4 + (mv->row >> 3);
constrain_line(x0 + 12, &x1, y0 + 4, &y1, width, height);
vp9_blit_line(x0 + 12, x1, y0 + 4, y1, y_buffer, y_stride);
bmi = &mi->bmi[8];
x1 = x0 + 4 + (mv->col >> 3);
y1 = y0 + 12 + (mv->row >> 3);
constrain_line(x0 + 4, &x1, y0 + 12, &y1, width, height);
vp9_blit_line(x0 + 4, x1, y0 + 12, y1, y_buffer, y_stride);
bmi = &mi->bmi[10];
x1 = x0 + 12 + (mv->col >> 3);
y1 = y0 + 12 + (mv->row >> 3);
constrain_line(x0 + 12, &x1, y0 + 12, &y1, width, height);
vp9_blit_line(x0 + 12, x1, y0 + 12, y1, y_buffer, y_stride);
break;
}
case PARTITIONING_4X4:
default : {
union b_mode_info *bmi = mi->bmi;
int bx0, by0;
for (by0 = y0; by0 < (y0 + 16); by0 += 4) {
for (bx0 = x0; bx0 < (x0 + 16); bx0 += 4) {
MV *mv = &bmi->mv.as_mv;
x1 = bx0 + 2 + (mv->col >> 3);
y1 = by0 + 2 + (mv->row >> 3);
constrain_line(bx0 + 2, &x1, by0 + 2, &y1, width, height);
vp9_blit_line(bx0 + 2, x1, by0 + 2, y1, y_buffer, y_stride);
bmi++;
}
}
}
}
} else if (is_inter_mode(mi->mbmi.mode)) {
MV *mv = &mi->mbmi.mv.as_mv;
const int lx0 = x0 + 8;
const int ly0 = y0 + 8;
x1 = lx0 + (mv->col >> 3);
y1 = ly0 + (mv->row >> 3);
if (x1 != lx0 && y1 != ly0) {
constrain_line(lx0, &x1, ly0 - 1, &y1, width, height);
vp9_blit_line(lx0, x1, ly0 - 1, y1, y_buffer, y_stride);
constrain_line(lx0, &x1, ly0 + 1, &y1, width, height);
vp9_blit_line(lx0, x1, ly0 + 1, y1, y_buffer, y_stride);
} else {
vp9_blit_line(lx0, x1, ly0, y1, y_buffer, y_stride);
}
}
mi++;
}
mi++;
}
}
/* Color in block modes */
if ((flags & VP9D_DEBUG_CLR_BLK_MODES)
&& (ppflags->display_mb_modes_flag || ppflags->display_b_modes_flag)) {
int y, x;
int width = ppbuf->y_width;
int height = ppbuf->y_height;
uint8_t *y_ptr = ppbuf->y_buffer;
uint8_t *u_ptr = ppbuf->u_buffer;
uint8_t *v_ptr = ppbuf->v_buffer;
int y_stride = ppbuf->y_stride;
MODE_INFO *mi = cm->mi;
for (y = 0; y < height; y += 16) {
for (x = 0; x < width; x += 16) {
int Y = 0, U = 0, V = 0;
if (mi->mbmi.mode == I4X4_PRED &&
((ppflags->display_mb_modes_flag & I4X4_PRED) ||
ppflags->display_b_modes_flag)) {
int by, bx;
uint8_t *yl, *ul, *vl;
union b_mode_info *bmi = mi->bmi;
yl = y_ptr + x;
ul = u_ptr + (x >> 1);
vl = v_ptr + (x >> 1);
for (by = 0; by < 16; by += 4) {
for (bx = 0; bx < 16; bx += 4) {
if ((ppflags->display_b_modes_flag & (1 << mi->mbmi.mode))
|| (ppflags->display_mb_modes_flag & I4X4_PRED)) {
Y = B_PREDICTION_MODE_colors[bmi->as_mode][0];
U = B_PREDICTION_MODE_colors[bmi->as_mode][1];
V = B_PREDICTION_MODE_colors[bmi->as_mode][2];
vp9_blend_b(yl + bx, ul + (bx >> 1), vl + (bx >> 1), Y, U, V,
0xc000, y_stride);
}
bmi++;
}
yl += y_stride * 4;
ul += y_stride * 1;
vl += y_stride * 1;
}
} else if (ppflags->display_mb_modes_flag & (1 << mi->mbmi.mode)) {
Y = PREDICTION_MODE_colors[mi->mbmi.mode][0];
U = PREDICTION_MODE_colors[mi->mbmi.mode][1];
V = PREDICTION_MODE_colors[mi->mbmi.mode][2];
vp9_blend_mb_inner(y_ptr + x, u_ptr + (x >> 1), v_ptr + (x >> 1),
Y, U, V, 0xc000, y_stride);
}
mi++;
}
y_ptr += y_stride * 16;
u_ptr += y_stride * 4;
v_ptr += y_stride * 4;
mi++;
}
}
/* Color in frame reference blocks */
if ((flags & VP9D_DEBUG_CLR_FRM_REF_BLKS) &&
ppflags->display_ref_frame_flag) {
int y, x;
int width = ppbuf->y_width;
int height = ppbuf->y_height;
uint8_t *y_ptr = ppbuf->y_buffer;
uint8_t *u_ptr = ppbuf->u_buffer;
uint8_t *v_ptr = ppbuf->v_buffer;
int y_stride = ppbuf->y_stride;
MODE_INFO *mi = cm->mi;
for (y = 0; y < height; y += 16) {
for (x = 0; x < width; x += 16) {
int Y = 0, U = 0, V = 0;
if (ppflags->display_ref_frame_flag & (1 << mi->mbmi.ref_frame)) {
Y = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][0];
U = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][1];
V = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][2];
vp9_blend_mb_outer(y_ptr + x, u_ptr + (x >> 1), v_ptr + (x >> 1),
Y, U, V, 0xc000, y_stride);
}
mi++;
}
y_ptr += y_stride * 16;
u_ptr += y_stride * 4;
v_ptr += y_stride * 4;
mi++;
}
}
#endif
*dest = *ppbuf;
/* handle problem with extending borders */
@ -975,3 +442,4 @@ int vp9_post_proc_frame(struct VP9Common *cm,
return 0;
}
#endif

Просмотреть файл

@ -33,12 +33,6 @@ typedef struct {
int post_proc_flag;
int deblocking_level;
int noise_level;
#if CONFIG_POSTPROC_VISUALIZER
int display_ref_frame_flag;
int display_mb_modes_flag;
int display_b_modes_flag;
int display_mv_flag;
#endif // CONFIG_POSTPROC_VISUALIZER
} vp9_ppflags_t;
#ifdef __cplusplus

Просмотреть файл

@ -36,13 +36,6 @@ struct vpx_codec_alg_priv {
struct VP9Decoder *pbi;
int postproc_cfg_set;
vp8_postproc_cfg_t postproc_cfg;
#if CONFIG_POSTPROC_VISUALIZER
unsigned int dbg_postproc_flag;
int dbg_color_ref_frame_flag;
int dbg_color_mb_modes_flag;
int dbg_color_b_modes_flag;
int dbg_display_mv_flag;
#endif
vpx_decrypt_cb decrypt_cb;
void *decrypt_state;
vpx_image_t img;
@ -226,22 +219,10 @@ static void set_default_ppflags(vp8_postproc_cfg_t *cfg) {
static void set_ppflags(const vpx_codec_alg_priv_t *ctx,
vp9_ppflags_t *flags) {
flags->post_proc_flag =
#if CONFIG_POSTPROC_VISUALIZER
(ctx->dbg_color_ref_frame_flag ? VP9D_DEBUG_CLR_FRM_REF_BLKS : 0) |
(ctx->dbg_color_mb_modes_flag ? VP9D_DEBUG_CLR_BLK_MODES : 0) |
(ctx->dbg_color_b_modes_flag ? VP9D_DEBUG_CLR_BLK_MODES : 0) |
(ctx->dbg_display_mv_flag ? VP9D_DEBUG_DRAW_MV : 0) |
#endif
ctx->postproc_cfg.post_proc_flag;
flags->deblocking_level = ctx->postproc_cfg.deblocking_level;
flags->noise_level = ctx->postproc_cfg.noise_level;
#if CONFIG_POSTPROC_VISUALIZER
flags->display_ref_frame_flag = ctx->dbg_color_ref_frame_flag;
flags->display_mb_modes_flag = ctx->dbg_color_mb_modes_flag;
flags->display_b_modes_flag = ctx->dbg_color_b_modes_flag;
flags->display_mv_flag = ctx->dbg_display_mv_flag;
#endif
}
static void init_decoder(vpx_codec_alg_priv_t *ctx) {
@ -539,22 +520,7 @@ static vpx_codec_err_t ctrl_set_postproc(vpx_codec_alg_priv_t *ctx,
static vpx_codec_err_t ctrl_set_dbg_options(vpx_codec_alg_priv_t *ctx,
int ctrl_id, va_list args) {
#if CONFIG_POSTPROC_VISUALIZER && CONFIG_POSTPROC
int data = va_arg(args, int);
#define MAP(id, var) case id: var = data; break;
switch (ctrl_id) {
MAP(VP8_SET_DBG_COLOR_REF_FRAME, ctx->dbg_color_ref_frame_flag);
MAP(VP8_SET_DBG_COLOR_MB_MODES, ctx->dbg_color_mb_modes_flag);
MAP(VP8_SET_DBG_COLOR_B_MODES, ctx->dbg_color_b_modes_flag);
MAP(VP8_SET_DBG_DISPLAY_MV, ctx->dbg_display_mv_flag);
}
return VPX_CODEC_OK;
#else
return VPX_CODEC_INCAPABLE;
#endif
}
static vpx_codec_err_t ctrl_get_last_ref_updates(vpx_codec_alg_priv_t *ctx,