Commit 5b084ee1 authored by Imdad Sardharwalla's avatar Imdad Sardharwalla

Added HighBD support for mismatch debugging

Enabling CONFIG_MISMATCH_DEBUG with highbd streams was producing undefined
behaviour. This patch adds support for highbd frames.

BUG=aomedia:1246

Change-Id: I36ff4ddbb9b2e884e4a5b76485247a20b1f5db3c
parent 5105f7ac
...@@ -83,9 +83,9 @@ static int frame_buf_idx_w = 0; ...@@ -83,9 +83,9 @@ static int frame_buf_idx_w = 0;
static int max_frame_buf_num = 5; static int max_frame_buf_num = 5;
#define MAX_FRAME_STRIDE 1280 #define MAX_FRAME_STRIDE 1280
#define MAX_FRAME_HEIGHT 720 #define MAX_FRAME_HEIGHT 720
static uint8_t static uint16_t
frame_pre[5][3][MAX_FRAME_STRIDE * MAX_FRAME_HEIGHT]; // prediction only frame_pre[5][3][MAX_FRAME_STRIDE * MAX_FRAME_HEIGHT]; // prediction only
static uint8_t static uint16_t
frame_tx[5][3][MAX_FRAME_STRIDE * MAX_FRAME_HEIGHT]; // prediction + txfm frame_tx[5][3][MAX_FRAME_STRIDE * MAX_FRAME_HEIGHT]; // prediction + txfm
static int frame_stride = MAX_FRAME_STRIDE; static int frame_stride = MAX_FRAME_STRIDE;
static int frame_height = MAX_FRAME_HEIGHT; static int frame_height = MAX_FRAME_HEIGHT;
...@@ -116,15 +116,19 @@ void mismatch_move_frame_idx_r() { ...@@ -116,15 +116,19 @@ void mismatch_move_frame_idx_r() {
} }
void mismatch_record_block_pre(const uint8_t *src, int src_stride, int plane, void mismatch_record_block_pre(const uint8_t *src, int src_stride, int plane,
int pixel_c, int pixel_r, int blk_w, int blk_h) { int pixel_c, int pixel_r, int blk_w, int blk_h,
int highbd) {
if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) { if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
printf("frame_buf undersized\n"); printf("frame_buf undersized\n");
assert(0); assert(0);
} }
const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
for (int r = 0; r < blk_h; ++r) { for (int r = 0; r < blk_h; ++r) {
for (int c = 0; c < blk_w; ++c) { for (int c = 0; c < blk_w; ++c) {
frame_pre[frame_buf_idx_w][plane][(r + pixel_r) * frame_stride + c + frame_pre[frame_buf_idx_w][plane]
pixel_c] = src[r * src_stride + c]; [(r + pixel_r) * frame_stride + c + pixel_c] =
src16 ? src16[r * src_stride + c] : src[r * src_stride + c];
} }
} }
#if 0 #if 0
...@@ -143,15 +147,19 @@ void mismatch_record_block_pre(const uint8_t *src, int src_stride, int plane, ...@@ -143,15 +147,19 @@ void mismatch_record_block_pre(const uint8_t *src, int src_stride, int plane,
#endif #endif
} }
void mismatch_record_block_tx(const uint8_t *src, int src_stride, int plane, void mismatch_record_block_tx(const uint8_t *src, int src_stride, int plane,
int pixel_c, int pixel_r, int blk_w, int blk_h) { int pixel_c, int pixel_r, int blk_w, int blk_h,
int highbd) {
if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) { if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
printf("frame_buf undersized\n"); printf("frame_buf undersized\n");
assert(0); assert(0);
} }
const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
for (int r = 0; r < blk_h; ++r) { for (int r = 0; r < blk_h; ++r) {
for (int c = 0; c < blk_w; ++c) { for (int c = 0; c < blk_w; ++c) {
frame_tx[frame_buf_idx_w][plane][(r + pixel_r) * frame_stride + c + frame_tx[frame_buf_idx_w][plane]
pixel_c] = src[r * src_stride + c]; [(r + pixel_r) * frame_stride + c + pixel_c] =
src16 ? src16[r * src_stride + c] : src[r * src_stride + c];
} }
} }
#if 0 #if 0
...@@ -170,17 +178,21 @@ void mismatch_record_block_tx(const uint8_t *src, int src_stride, int plane, ...@@ -170,17 +178,21 @@ void mismatch_record_block_tx(const uint8_t *src, int src_stride, int plane,
#endif #endif
} }
void mismatch_check_block_pre(const uint8_t *src, int src_stride, int plane, void mismatch_check_block_pre(const uint8_t *src, int src_stride, int plane,
int pixel_c, int pixel_r, int blk_w, int blk_h) { int pixel_c, int pixel_r, int blk_w, int blk_h,
int highbd) {
if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) { if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
printf("frame_buf undersized\n"); printf("frame_buf undersized\n");
assert(0); assert(0);
} }
const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
int mismatch = 0; int mismatch = 0;
for (int r = 0; r < blk_h; ++r) { for (int r = 0; r < blk_h; ++r) {
for (int c = 0; c < blk_w; ++c) { for (int c = 0; c < blk_w; ++c) {
if (frame_pre[frame_buf_idx_r][plane] if (frame_pre[frame_buf_idx_r][plane]
[(r + pixel_r) * frame_stride + c + pixel_c] != [(r + pixel_r) * frame_stride + c + pixel_c] !=
src[r * src_stride + c]) { (uint16_t)(src16 ? src16[r * src_stride + c]
: src[r * src_stride + c])) {
mismatch = 1; mismatch = 1;
} }
} }
...@@ -202,7 +214,8 @@ void mismatch_check_block_pre(const uint8_t *src, int src_stride, int plane, ...@@ -202,7 +214,8 @@ void mismatch_check_block_pre(const uint8_t *src, int src_stride, int plane,
printf("dec\n"); printf("dec\n");
for (int rr = 0; rr < blk_h; ++rr) { for (int rr = 0; rr < blk_h; ++rr) {
for (int cc = 0; cc < blk_w; ++cc) { for (int cc = 0; cc < blk_w; ++cc) {
printf("%d ", src[rr * src_stride + cc]); printf("%d ",
src16 ? src16[rr * src_stride + cc] : src[rr * src_stride + cc]);
} }
printf("\n"); printf("\n");
} }
...@@ -210,17 +223,21 @@ void mismatch_check_block_pre(const uint8_t *src, int src_stride, int plane, ...@@ -210,17 +223,21 @@ void mismatch_check_block_pre(const uint8_t *src, int src_stride, int plane,
} }
} }
void mismatch_check_block_tx(const uint8_t *src, int src_stride, int plane, void mismatch_check_block_tx(const uint8_t *src, int src_stride, int plane,
int pixel_c, int pixel_r, int blk_w, int blk_h) { int pixel_c, int pixel_r, int blk_w, int blk_h,
int highbd) {
if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) { if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
printf("frame_buf undersized\n"); printf("frame_buf undersized\n");
assert(0); assert(0);
} }
const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
int mismatch = 0; int mismatch = 0;
for (int r = 0; r < blk_h; ++r) { for (int r = 0; r < blk_h; ++r) {
for (int c = 0; c < blk_w; ++c) { for (int c = 0; c < blk_w; ++c) {
if (frame_tx[frame_buf_idx_r][plane] if (frame_tx[frame_buf_idx_r][plane]
[(r + pixel_r) * frame_stride + c + pixel_c] != [(r + pixel_r) * frame_stride + c + pixel_c] !=
src[r * src_stride + c]) { (uint16_t)(src16 ? src16[r * src_stride + c]
: src[r * src_stride + c])) {
mismatch = 1; mismatch = 1;
} }
} }
...@@ -242,7 +259,8 @@ void mismatch_check_block_tx(const uint8_t *src, int src_stride, int plane, ...@@ -242,7 +259,8 @@ void mismatch_check_block_tx(const uint8_t *src, int src_stride, int plane,
printf("dec\n"); printf("dec\n");
for (int rr = 0; rr < blk_h; ++rr) { for (int rr = 0; rr < blk_h; ++rr) {
for (int cc = 0; cc < blk_w; ++cc) { for (int cc = 0; cc < blk_w; ++cc) {
printf("%d ", src[rr * src_stride + cc]); printf("%d ",
src16 ? src16[rr * src_stride + cc] : src[rr * src_stride + cc]);
} }
printf("\n"); printf("\n");
} }
......
...@@ -48,13 +48,17 @@ void mismatch_move_frame_idx_w(); ...@@ -48,13 +48,17 @@ void mismatch_move_frame_idx_w();
void mismatch_move_frame_idx_r(); void mismatch_move_frame_idx_r();
void mismatch_reset_frame(int num_planes); void mismatch_reset_frame(int num_planes);
void mismatch_record_block_pre(const uint8_t *src, int src_stride, int plane, void mismatch_record_block_pre(const uint8_t *src, int src_stride, int plane,
int pixel_c, int pixel_r, int blk_w, int blk_h); int pixel_c, int pixel_r, int blk_w, int blk_h,
int highbd);
void mismatch_record_block_tx(const uint8_t *src, int src_stride, int plane, void mismatch_record_block_tx(const uint8_t *src, int src_stride, int plane,
int pixel_c, int pixel_r, int blk_w, int blk_h); int pixel_c, int pixel_r, int blk_w, int blk_h,
int highbd);
void mismatch_check_block_pre(const uint8_t *src, int src_stride, int plane, void mismatch_check_block_pre(const uint8_t *src, int src_stride, int plane,
int pixel_c, int pixel_r, int blk_w, int blk_h); int pixel_c, int pixel_r, int blk_w, int blk_h,
int highbd);
void mismatch_check_block_tx(const uint8_t *src, int src_stride, int plane, void mismatch_check_block_tx(const uint8_t *src, int src_stride, int plane,
int pixel_c, int pixel_r, int blk_w, int blk_h); int pixel_c, int pixel_r, int blk_w, int blk_h,
int highbd);
#endif // CONFIG_MISMATCH_DEBUG #endif // CONFIG_MISMATCH_DEBUG
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -245,7 +245,7 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd, ...@@ -245,7 +245,7 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
mi_to_pixel_loc(&pixel_c, &pixel_r, mi_col, mi_row, blk_col, blk_row, mi_to_pixel_loc(&pixel_c, &pixel_r, mi_col, mi_row, blk_col, blk_row,
pd->subsampling_x, pd->subsampling_y); pd->subsampling_x, pd->subsampling_y);
mismatch_check_block_tx(dst, pd->dst.stride, plane, pixel_c, pixel_r, blk_w, mismatch_check_block_tx(dst, pd->dst.stride, plane, pixel_c, pixel_r, blk_w,
blk_h); blk_h, xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH);
#endif #endif
*eob_total += eob; *eob_total += eob;
} else { } else {
...@@ -478,7 +478,8 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi, ...@@ -478,7 +478,8 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
pd->subsampling_y)) pd->subsampling_y))
continue; continue;
mismatch_check_block_pre(pd->dst.buf, pd->dst.stride, plane, pixel_c, mismatch_check_block_pre(pd->dst.buf, pd->dst.stride, plane, pixel_c,
pixel_r, pd->width, pd->height); pixel_r, pd->width, pd->height,
xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH);
} }
#endif #endif
......
...@@ -4665,7 +4665,8 @@ static void encode_superblock(const AV1_COMP *const cpi, TileDataEnc *tile_data, ...@@ -4665,7 +4665,8 @@ static void encode_superblock(const AV1_COMP *const cpi, TileDataEnc *tile_data,
pd->subsampling_y)) pd->subsampling_y))
continue; continue;
mismatch_record_block_pre(pd->dst.buf, pd->dst.stride, plane, pixel_c, mismatch_record_block_pre(pd->dst.buf, pd->dst.stride, plane, pixel_c,
pixel_r, pd->width, pd->height); pixel_r, pd->width, pd->height,
xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH);
} }
} }
#else #else
......
...@@ -595,7 +595,8 @@ static void encode_block(int plane, int block, int blk_row, int blk_col, ...@@ -595,7 +595,8 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
mi_to_pixel_loc(&pixel_c, &pixel_r, mi_col, mi_row, blk_col, blk_row, mi_to_pixel_loc(&pixel_c, &pixel_r, mi_col, mi_row, blk_col, blk_row,
pd->subsampling_x, pd->subsampling_y); pd->subsampling_x, pd->subsampling_y);
mismatch_record_block_tx(dst, pd->dst.stride, plane, pixel_c, pixel_r, mismatch_record_block_tx(dst, pd->dst.stride, plane, pixel_c, pixel_r,
blk_w, blk_h); blk_w, blk_h,
xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH);
} }
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment