1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include <assert.h>
13*77c1e3ccSAndroid Build Coastguard Worker #include <stdbool.h>
14*77c1e3ccSAndroid Build Coastguard Worker #include <stdio.h>
15*77c1e3ccSAndroid Build Coastguard Worker #include <string.h>
16*77c1e3ccSAndroid Build Coastguard Worker #include "aom_util/debug_util.h"
17*77c1e3ccSAndroid Build Coastguard Worker
18*77c1e3ccSAndroid Build Coastguard Worker static int frame_idx_w = 0;
19*77c1e3ccSAndroid Build Coastguard Worker
20*77c1e3ccSAndroid Build Coastguard Worker static int frame_idx_r = 0;
21*77c1e3ccSAndroid Build Coastguard Worker
aom_bitstream_queue_set_frame_write(int frame_idx)22*77c1e3ccSAndroid Build Coastguard Worker void aom_bitstream_queue_set_frame_write(int frame_idx) {
23*77c1e3ccSAndroid Build Coastguard Worker frame_idx_w = frame_idx;
24*77c1e3ccSAndroid Build Coastguard Worker }
25*77c1e3ccSAndroid Build Coastguard Worker
aom_bitstream_queue_get_frame_write(void)26*77c1e3ccSAndroid Build Coastguard Worker int aom_bitstream_queue_get_frame_write(void) { return frame_idx_w; }
27*77c1e3ccSAndroid Build Coastguard Worker
aom_bitstream_queue_set_frame_read(int frame_idx)28*77c1e3ccSAndroid Build Coastguard Worker void aom_bitstream_queue_set_frame_read(int frame_idx) {
29*77c1e3ccSAndroid Build Coastguard Worker frame_idx_r = frame_idx;
30*77c1e3ccSAndroid Build Coastguard Worker }
31*77c1e3ccSAndroid Build Coastguard Worker
aom_bitstream_queue_get_frame_read(void)32*77c1e3ccSAndroid Build Coastguard Worker int aom_bitstream_queue_get_frame_read(void) { return frame_idx_r; }
33*77c1e3ccSAndroid Build Coastguard Worker
34*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_BITSTREAM_DEBUG
35*77c1e3ccSAndroid Build Coastguard Worker #define QUEUE_MAX_SIZE 4000000
36*77c1e3ccSAndroid Build Coastguard Worker static int result_queue[QUEUE_MAX_SIZE];
37*77c1e3ccSAndroid Build Coastguard Worker static int nsymbs_queue[QUEUE_MAX_SIZE];
38*77c1e3ccSAndroid Build Coastguard Worker static aom_cdf_prob cdf_queue[QUEUE_MAX_SIZE][16];
39*77c1e3ccSAndroid Build Coastguard Worker
40*77c1e3ccSAndroid Build Coastguard Worker static int queue_r = 0;
41*77c1e3ccSAndroid Build Coastguard Worker static int queue_w = 0;
42*77c1e3ccSAndroid Build Coastguard Worker static int queue_prev_w = -1;
43*77c1e3ccSAndroid Build Coastguard Worker static int skip_r = 0;
44*77c1e3ccSAndroid Build Coastguard Worker static int skip_w = 0;
45*77c1e3ccSAndroid Build Coastguard Worker
bitstream_queue_set_skip_write(int skip)46*77c1e3ccSAndroid Build Coastguard Worker void bitstream_queue_set_skip_write(int skip) { skip_w = skip; }
47*77c1e3ccSAndroid Build Coastguard Worker
bitstream_queue_set_skip_read(int skip)48*77c1e3ccSAndroid Build Coastguard Worker void bitstream_queue_set_skip_read(int skip) { skip_r = skip; }
49*77c1e3ccSAndroid Build Coastguard Worker
bitstream_queue_record_write(void)50*77c1e3ccSAndroid Build Coastguard Worker void bitstream_queue_record_write(void) { queue_prev_w = queue_w; }
51*77c1e3ccSAndroid Build Coastguard Worker
bitstream_queue_reset_write(void)52*77c1e3ccSAndroid Build Coastguard Worker void bitstream_queue_reset_write(void) { queue_w = queue_prev_w; }
53*77c1e3ccSAndroid Build Coastguard Worker
bitstream_queue_get_write(void)54*77c1e3ccSAndroid Build Coastguard Worker int bitstream_queue_get_write(void) { return queue_w; }
55*77c1e3ccSAndroid Build Coastguard Worker
bitstream_queue_get_read(void)56*77c1e3ccSAndroid Build Coastguard Worker int bitstream_queue_get_read(void) { return queue_r; }
57*77c1e3ccSAndroid Build Coastguard Worker
bitstream_queue_pop(int * result,aom_cdf_prob * cdf,int * nsymbs)58*77c1e3ccSAndroid Build Coastguard Worker void bitstream_queue_pop(int *result, aom_cdf_prob *cdf, int *nsymbs) {
59*77c1e3ccSAndroid Build Coastguard Worker if (!skip_r) {
60*77c1e3ccSAndroid Build Coastguard Worker if (queue_w == queue_r) {
61*77c1e3ccSAndroid Build Coastguard Worker printf("buffer underflow queue_w %d queue_r %d\n", queue_w, queue_r);
62*77c1e3ccSAndroid Build Coastguard Worker assert(0);
63*77c1e3ccSAndroid Build Coastguard Worker }
64*77c1e3ccSAndroid Build Coastguard Worker *result = result_queue[queue_r];
65*77c1e3ccSAndroid Build Coastguard Worker *nsymbs = nsymbs_queue[queue_r];
66*77c1e3ccSAndroid Build Coastguard Worker memcpy(cdf, cdf_queue[queue_r], *nsymbs * sizeof(*cdf));
67*77c1e3ccSAndroid Build Coastguard Worker queue_r = (queue_r + 1) % QUEUE_MAX_SIZE;
68*77c1e3ccSAndroid Build Coastguard Worker }
69*77c1e3ccSAndroid Build Coastguard Worker }
70*77c1e3ccSAndroid Build Coastguard Worker
bitstream_queue_push(int result,const aom_cdf_prob * cdf,int nsymbs)71*77c1e3ccSAndroid Build Coastguard Worker void bitstream_queue_push(int result, const aom_cdf_prob *cdf, int nsymbs) {
72*77c1e3ccSAndroid Build Coastguard Worker // If you observe a CDF error:
73*77c1e3ccSAndroid Build Coastguard Worker // - Set 'debug_cdf_mismatch' to true
74*77c1e3ccSAndroid Build Coastguard Worker // - Set target_frame_idx_r and target_queue_r to where CDF error was reported
75*77c1e3ccSAndroid Build Coastguard Worker // - Set a breakpoint in debugger at the 'fprintf' below.
76*77c1e3ccSAndroid Build Coastguard Worker const bool debug_cdf_mismatch = false;
77*77c1e3ccSAndroid Build Coastguard Worker if (debug_cdf_mismatch) {
78*77c1e3ccSAndroid Build Coastguard Worker int target_frame_idx_r = 1;
79*77c1e3ccSAndroid Build Coastguard Worker int target_queue_r = 18005;
80*77c1e3ccSAndroid Build Coastguard Worker if (frame_idx_w == target_frame_idx_r && queue_w == target_queue_r) {
81*77c1e3ccSAndroid Build Coastguard Worker fprintf(stderr, "\n *** bitstream queue at frame_idx_w %d queue_w %d\n",
82*77c1e3ccSAndroid Build Coastguard Worker frame_idx_w, queue_w);
83*77c1e3ccSAndroid Build Coastguard Worker }
84*77c1e3ccSAndroid Build Coastguard Worker }
85*77c1e3ccSAndroid Build Coastguard Worker if (!skip_w) {
86*77c1e3ccSAndroid Build Coastguard Worker result_queue[queue_w] = result;
87*77c1e3ccSAndroid Build Coastguard Worker nsymbs_queue[queue_w] = nsymbs;
88*77c1e3ccSAndroid Build Coastguard Worker memcpy(cdf_queue[queue_w], cdf, nsymbs * sizeof(*cdf));
89*77c1e3ccSAndroid Build Coastguard Worker queue_w = (queue_w + 1) % QUEUE_MAX_SIZE;
90*77c1e3ccSAndroid Build Coastguard Worker if (queue_w == queue_r) {
91*77c1e3ccSAndroid Build Coastguard Worker printf("buffer overflow queue_w %d queue_r %d\n", queue_w, queue_r);
92*77c1e3ccSAndroid Build Coastguard Worker assert(0);
93*77c1e3ccSAndroid Build Coastguard Worker }
94*77c1e3ccSAndroid Build Coastguard Worker }
95*77c1e3ccSAndroid Build Coastguard Worker }
96*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_BITSTREAM_DEBUG
97*77c1e3ccSAndroid Build Coastguard Worker
98*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_MISMATCH_DEBUG
99*77c1e3ccSAndroid Build Coastguard Worker static int frame_buf_idx_r = 0;
100*77c1e3ccSAndroid Build Coastguard Worker static int frame_buf_idx_w = 0;
101*77c1e3ccSAndroid Build Coastguard Worker static int max_frame_buf_num = 5;
102*77c1e3ccSAndroid Build Coastguard Worker #define MAX_FRAME_STRIDE 1280
103*77c1e3ccSAndroid Build Coastguard Worker #define MAX_FRAME_HEIGHT 720
104*77c1e3ccSAndroid Build Coastguard Worker static uint16_t
105*77c1e3ccSAndroid Build Coastguard Worker frame_pre[5][3][MAX_FRAME_STRIDE * MAX_FRAME_HEIGHT]; // prediction only
106*77c1e3ccSAndroid Build Coastguard Worker static uint16_t
107*77c1e3ccSAndroid Build Coastguard Worker frame_tx[5][3][MAX_FRAME_STRIDE * MAX_FRAME_HEIGHT]; // prediction + txfm
108*77c1e3ccSAndroid Build Coastguard Worker static int frame_stride = MAX_FRAME_STRIDE;
109*77c1e3ccSAndroid Build Coastguard Worker static int frame_height = MAX_FRAME_HEIGHT;
110*77c1e3ccSAndroid Build Coastguard Worker static int frame_size = MAX_FRAME_STRIDE * MAX_FRAME_HEIGHT;
mismatch_move_frame_idx_w(void)111*77c1e3ccSAndroid Build Coastguard Worker void mismatch_move_frame_idx_w(void) {
112*77c1e3ccSAndroid Build Coastguard Worker frame_buf_idx_w = (frame_buf_idx_w + 1) % max_frame_buf_num;
113*77c1e3ccSAndroid Build Coastguard Worker if (frame_buf_idx_w == frame_buf_idx_r) {
114*77c1e3ccSAndroid Build Coastguard Worker printf("frame_buf overflow\n");
115*77c1e3ccSAndroid Build Coastguard Worker assert(0);
116*77c1e3ccSAndroid Build Coastguard Worker }
117*77c1e3ccSAndroid Build Coastguard Worker }
118*77c1e3ccSAndroid Build Coastguard Worker
mismatch_reset_frame(int num_planes)119*77c1e3ccSAndroid Build Coastguard Worker void mismatch_reset_frame(int num_planes) {
120*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < num_planes; ++plane) {
121*77c1e3ccSAndroid Build Coastguard Worker memset(frame_pre[frame_buf_idx_w][plane], 0,
122*77c1e3ccSAndroid Build Coastguard Worker sizeof(frame_pre[frame_buf_idx_w][plane][0]) * frame_size);
123*77c1e3ccSAndroid Build Coastguard Worker memset(frame_tx[frame_buf_idx_w][plane], 0,
124*77c1e3ccSAndroid Build Coastguard Worker sizeof(frame_tx[frame_buf_idx_w][plane][0]) * frame_size);
125*77c1e3ccSAndroid Build Coastguard Worker }
126*77c1e3ccSAndroid Build Coastguard Worker }
127*77c1e3ccSAndroid Build Coastguard Worker
mismatch_move_frame_idx_r(void)128*77c1e3ccSAndroid Build Coastguard Worker void mismatch_move_frame_idx_r(void) {
129*77c1e3ccSAndroid Build Coastguard Worker if (frame_buf_idx_w == frame_buf_idx_r) {
130*77c1e3ccSAndroid Build Coastguard Worker printf("frame_buf underflow\n");
131*77c1e3ccSAndroid Build Coastguard Worker assert(0);
132*77c1e3ccSAndroid Build Coastguard Worker }
133*77c1e3ccSAndroid Build Coastguard Worker frame_buf_idx_r = (frame_buf_idx_r + 1) % max_frame_buf_num;
134*77c1e3ccSAndroid Build Coastguard Worker }
135*77c1e3ccSAndroid Build Coastguard Worker
mismatch_record_block_pre(const uint8_t * src,int src_stride,int frame_offset,int plane,int pixel_c,int pixel_r,int blk_w,int blk_h,int highbd)136*77c1e3ccSAndroid Build Coastguard Worker void mismatch_record_block_pre(const uint8_t *src, int src_stride,
137*77c1e3ccSAndroid Build Coastguard Worker int frame_offset, int plane, int pixel_c,
138*77c1e3ccSAndroid Build Coastguard Worker int pixel_r, int blk_w, int blk_h, int highbd) {
139*77c1e3ccSAndroid Build Coastguard Worker if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
140*77c1e3ccSAndroid Build Coastguard Worker printf("frame_buf undersized\n");
141*77c1e3ccSAndroid Build Coastguard Worker assert(0);
142*77c1e3ccSAndroid Build Coastguard Worker }
143*77c1e3ccSAndroid Build Coastguard Worker
144*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
145*77c1e3ccSAndroid Build Coastguard Worker for (int r = 0; r < blk_h; ++r) {
146*77c1e3ccSAndroid Build Coastguard Worker for (int c = 0; c < blk_w; ++c) {
147*77c1e3ccSAndroid Build Coastguard Worker frame_pre[frame_buf_idx_w][plane]
148*77c1e3ccSAndroid Build Coastguard Worker [(r + pixel_r) * frame_stride + c + pixel_c] =
149*77c1e3ccSAndroid Build Coastguard Worker src16 ? src16[r * src_stride + c] : src[r * src_stride + c];
150*77c1e3ccSAndroid Build Coastguard Worker }
151*77c1e3ccSAndroid Build Coastguard Worker }
152*77c1e3ccSAndroid Build Coastguard Worker #if 0
153*77c1e3ccSAndroid Build Coastguard Worker int ref_frame_idx = 3;
154*77c1e3ccSAndroid Build Coastguard Worker int ref_frame_offset = 4;
155*77c1e3ccSAndroid Build Coastguard Worker int ref_plane = 1;
156*77c1e3ccSAndroid Build Coastguard Worker int ref_pixel_c = 162;
157*77c1e3ccSAndroid Build Coastguard Worker int ref_pixel_r = 16;
158*77c1e3ccSAndroid Build Coastguard Worker if (frame_idx_w == ref_frame_idx && plane == ref_plane &&
159*77c1e3ccSAndroid Build Coastguard Worker frame_offset == ref_frame_offset && ref_pixel_c >= pixel_c &&
160*77c1e3ccSAndroid Build Coastguard Worker ref_pixel_c < pixel_c + blk_w && ref_pixel_r >= pixel_r &&
161*77c1e3ccSAndroid Build Coastguard Worker ref_pixel_r < pixel_r + blk_h) {
162*77c1e3ccSAndroid Build Coastguard Worker printf(
163*77c1e3ccSAndroid Build Coastguard Worker "\nrecord_block_pre frame_idx %d frame_offset %d plane %d pixel_c %d pixel_r %d blk_w "
164*77c1e3ccSAndroid Build Coastguard Worker "%d blk_h %d\n",
165*77c1e3ccSAndroid Build Coastguard Worker frame_idx_w, frame_offset, plane, pixel_c, pixel_r, blk_w, blk_h);
166*77c1e3ccSAndroid Build Coastguard Worker }
167*77c1e3ccSAndroid Build Coastguard Worker #endif
168*77c1e3ccSAndroid Build Coastguard Worker }
mismatch_record_block_tx(const uint8_t * src,int src_stride,int frame_offset,int plane,int pixel_c,int pixel_r,int blk_w,int blk_h,int highbd)169*77c1e3ccSAndroid Build Coastguard Worker void mismatch_record_block_tx(const uint8_t *src, int src_stride,
170*77c1e3ccSAndroid Build Coastguard Worker int frame_offset, int plane, int pixel_c,
171*77c1e3ccSAndroid Build Coastguard Worker int pixel_r, int blk_w, int blk_h, int highbd) {
172*77c1e3ccSAndroid Build Coastguard Worker if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
173*77c1e3ccSAndroid Build Coastguard Worker printf("frame_buf undersized\n");
174*77c1e3ccSAndroid Build Coastguard Worker assert(0);
175*77c1e3ccSAndroid Build Coastguard Worker }
176*77c1e3ccSAndroid Build Coastguard Worker
177*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
178*77c1e3ccSAndroid Build Coastguard Worker for (int r = 0; r < blk_h; ++r) {
179*77c1e3ccSAndroid Build Coastguard Worker for (int c = 0; c < blk_w; ++c) {
180*77c1e3ccSAndroid Build Coastguard Worker frame_tx[frame_buf_idx_w][plane]
181*77c1e3ccSAndroid Build Coastguard Worker [(r + pixel_r) * frame_stride + c + pixel_c] =
182*77c1e3ccSAndroid Build Coastguard Worker src16 ? src16[r * src_stride + c] : src[r * src_stride + c];
183*77c1e3ccSAndroid Build Coastguard Worker }
184*77c1e3ccSAndroid Build Coastguard Worker }
185*77c1e3ccSAndroid Build Coastguard Worker #if 0
186*77c1e3ccSAndroid Build Coastguard Worker int ref_frame_idx = 3;
187*77c1e3ccSAndroid Build Coastguard Worker int ref_frame_offset = 4;
188*77c1e3ccSAndroid Build Coastguard Worker int ref_plane = 1;
189*77c1e3ccSAndroid Build Coastguard Worker int ref_pixel_c = 162;
190*77c1e3ccSAndroid Build Coastguard Worker int ref_pixel_r = 16;
191*77c1e3ccSAndroid Build Coastguard Worker if (frame_idx_w == ref_frame_idx && plane == ref_plane && frame_offset == ref_frame_offset &&
192*77c1e3ccSAndroid Build Coastguard Worker ref_pixel_c >= pixel_c && ref_pixel_c < pixel_c + blk_w &&
193*77c1e3ccSAndroid Build Coastguard Worker ref_pixel_r >= pixel_r && ref_pixel_r < pixel_r + blk_h) {
194*77c1e3ccSAndroid Build Coastguard Worker printf(
195*77c1e3ccSAndroid Build Coastguard Worker "\nrecord_block_tx frame_idx %d frame_offset %d plane %d pixel_c %d pixel_r %d blk_w "
196*77c1e3ccSAndroid Build Coastguard Worker "%d blk_h %d\n",
197*77c1e3ccSAndroid Build Coastguard Worker frame_idx_w, frame_offset, plane, pixel_c, pixel_r, blk_w, blk_h);
198*77c1e3ccSAndroid Build Coastguard Worker }
199*77c1e3ccSAndroid Build Coastguard Worker #endif
200*77c1e3ccSAndroid Build Coastguard Worker }
mismatch_check_block_pre(const uint8_t * src,int src_stride,int frame_offset,int plane,int pixel_c,int pixel_r,int blk_w,int blk_h,int highbd)201*77c1e3ccSAndroid Build Coastguard Worker void mismatch_check_block_pre(const uint8_t *src, int src_stride,
202*77c1e3ccSAndroid Build Coastguard Worker int frame_offset, int plane, int pixel_c,
203*77c1e3ccSAndroid Build Coastguard Worker int pixel_r, int blk_w, int blk_h, int highbd) {
204*77c1e3ccSAndroid Build Coastguard Worker if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
205*77c1e3ccSAndroid Build Coastguard Worker printf("frame_buf undersized\n");
206*77c1e3ccSAndroid Build Coastguard Worker assert(0);
207*77c1e3ccSAndroid Build Coastguard Worker }
208*77c1e3ccSAndroid Build Coastguard Worker
209*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
210*77c1e3ccSAndroid Build Coastguard Worker int mismatch = 0;
211*77c1e3ccSAndroid Build Coastguard Worker for (int r = 0; r < blk_h; ++r) {
212*77c1e3ccSAndroid Build Coastguard Worker for (int c = 0; c < blk_w; ++c) {
213*77c1e3ccSAndroid Build Coastguard Worker if (frame_pre[frame_buf_idx_r][plane]
214*77c1e3ccSAndroid Build Coastguard Worker [(r + pixel_r) * frame_stride + c + pixel_c] !=
215*77c1e3ccSAndroid Build Coastguard Worker (uint16_t)(src16 ? src16[r * src_stride + c]
216*77c1e3ccSAndroid Build Coastguard Worker : src[r * src_stride + c])) {
217*77c1e3ccSAndroid Build Coastguard Worker mismatch = 1;
218*77c1e3ccSAndroid Build Coastguard Worker }
219*77c1e3ccSAndroid Build Coastguard Worker }
220*77c1e3ccSAndroid Build Coastguard Worker }
221*77c1e3ccSAndroid Build Coastguard Worker if (mismatch) {
222*77c1e3ccSAndroid Build Coastguard Worker printf(
223*77c1e3ccSAndroid Build Coastguard Worker "\ncheck_block_pre failed frame_idx %d frame_offset %d plane %d "
224*77c1e3ccSAndroid Build Coastguard Worker "pixel_c %d pixel_r "
225*77c1e3ccSAndroid Build Coastguard Worker "%d blk_w %d blk_h %d\n",
226*77c1e3ccSAndroid Build Coastguard Worker frame_idx_r, frame_offset, plane, pixel_c, pixel_r, blk_w, blk_h);
227*77c1e3ccSAndroid Build Coastguard Worker printf("enc\n");
228*77c1e3ccSAndroid Build Coastguard Worker for (int rr = 0; rr < blk_h; ++rr) {
229*77c1e3ccSAndroid Build Coastguard Worker for (int cc = 0; cc < blk_w; ++cc) {
230*77c1e3ccSAndroid Build Coastguard Worker printf("%d ", frame_pre[frame_buf_idx_r][plane]
231*77c1e3ccSAndroid Build Coastguard Worker [(rr + pixel_r) * frame_stride + cc + pixel_c]);
232*77c1e3ccSAndroid Build Coastguard Worker }
233*77c1e3ccSAndroid Build Coastguard Worker printf("\n");
234*77c1e3ccSAndroid Build Coastguard Worker }
235*77c1e3ccSAndroid Build Coastguard Worker
236*77c1e3ccSAndroid Build Coastguard Worker printf("dec\n");
237*77c1e3ccSAndroid Build Coastguard Worker for (int rr = 0; rr < blk_h; ++rr) {
238*77c1e3ccSAndroid Build Coastguard Worker for (int cc = 0; cc < blk_w; ++cc) {
239*77c1e3ccSAndroid Build Coastguard Worker printf("%d ",
240*77c1e3ccSAndroid Build Coastguard Worker src16 ? src16[rr * src_stride + cc] : src[rr * src_stride + cc]);
241*77c1e3ccSAndroid Build Coastguard Worker }
242*77c1e3ccSAndroid Build Coastguard Worker printf("\n");
243*77c1e3ccSAndroid Build Coastguard Worker }
244*77c1e3ccSAndroid Build Coastguard Worker assert(0);
245*77c1e3ccSAndroid Build Coastguard Worker }
246*77c1e3ccSAndroid Build Coastguard Worker }
mismatch_check_block_tx(const uint8_t * src,int src_stride,int frame_offset,int plane,int pixel_c,int pixel_r,int blk_w,int blk_h,int highbd)247*77c1e3ccSAndroid Build Coastguard Worker void mismatch_check_block_tx(const uint8_t *src, int src_stride,
248*77c1e3ccSAndroid Build Coastguard Worker int frame_offset, int plane, int pixel_c,
249*77c1e3ccSAndroid Build Coastguard Worker int pixel_r, int blk_w, int blk_h, int highbd) {
250*77c1e3ccSAndroid Build Coastguard Worker if (pixel_c + blk_w >= frame_stride || pixel_r + blk_h >= frame_height) {
251*77c1e3ccSAndroid Build Coastguard Worker printf("frame_buf undersized\n");
252*77c1e3ccSAndroid Build Coastguard Worker assert(0);
253*77c1e3ccSAndroid Build Coastguard Worker }
254*77c1e3ccSAndroid Build Coastguard Worker
255*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *src16 = highbd ? CONVERT_TO_SHORTPTR(src) : NULL;
256*77c1e3ccSAndroid Build Coastguard Worker int mismatch = 0;
257*77c1e3ccSAndroid Build Coastguard Worker for (int r = 0; r < blk_h; ++r) {
258*77c1e3ccSAndroid Build Coastguard Worker for (int c = 0; c < blk_w; ++c) {
259*77c1e3ccSAndroid Build Coastguard Worker if (frame_tx[frame_buf_idx_r][plane]
260*77c1e3ccSAndroid Build Coastguard Worker [(r + pixel_r) * frame_stride + c + pixel_c] !=
261*77c1e3ccSAndroid Build Coastguard Worker (uint16_t)(src16 ? src16[r * src_stride + c]
262*77c1e3ccSAndroid Build Coastguard Worker : src[r * src_stride + c])) {
263*77c1e3ccSAndroid Build Coastguard Worker mismatch = 1;
264*77c1e3ccSAndroid Build Coastguard Worker }
265*77c1e3ccSAndroid Build Coastguard Worker }
266*77c1e3ccSAndroid Build Coastguard Worker }
267*77c1e3ccSAndroid Build Coastguard Worker if (mismatch) {
268*77c1e3ccSAndroid Build Coastguard Worker printf(
269*77c1e3ccSAndroid Build Coastguard Worker "\ncheck_block_tx failed frame_idx %d frame_offset %d plane %d pixel_c "
270*77c1e3ccSAndroid Build Coastguard Worker "%d pixel_r "
271*77c1e3ccSAndroid Build Coastguard Worker "%d blk_w %d blk_h %d\n",
272*77c1e3ccSAndroid Build Coastguard Worker frame_idx_r, frame_offset, plane, pixel_c, pixel_r, blk_w, blk_h);
273*77c1e3ccSAndroid Build Coastguard Worker printf("enc\n");
274*77c1e3ccSAndroid Build Coastguard Worker for (int rr = 0; rr < blk_h; ++rr) {
275*77c1e3ccSAndroid Build Coastguard Worker for (int cc = 0; cc < blk_w; ++cc) {
276*77c1e3ccSAndroid Build Coastguard Worker printf("%d ", frame_tx[frame_buf_idx_r][plane]
277*77c1e3ccSAndroid Build Coastguard Worker [(rr + pixel_r) * frame_stride + cc + pixel_c]);
278*77c1e3ccSAndroid Build Coastguard Worker }
279*77c1e3ccSAndroid Build Coastguard Worker printf("\n");
280*77c1e3ccSAndroid Build Coastguard Worker }
281*77c1e3ccSAndroid Build Coastguard Worker
282*77c1e3ccSAndroid Build Coastguard Worker printf("dec\n");
283*77c1e3ccSAndroid Build Coastguard Worker for (int rr = 0; rr < blk_h; ++rr) {
284*77c1e3ccSAndroid Build Coastguard Worker for (int cc = 0; cc < blk_w; ++cc) {
285*77c1e3ccSAndroid Build Coastguard Worker printf("%d ",
286*77c1e3ccSAndroid Build Coastguard Worker src16 ? src16[rr * src_stride + cc] : src[rr * src_stride + cc]);
287*77c1e3ccSAndroid Build Coastguard Worker }
288*77c1e3ccSAndroid Build Coastguard Worker printf("\n");
289*77c1e3ccSAndroid Build Coastguard Worker }
290*77c1e3ccSAndroid Build Coastguard Worker assert(0);
291*77c1e3ccSAndroid Build Coastguard Worker }
292*77c1e3ccSAndroid Build Coastguard Worker }
293*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_MISMATCH_DEBUG
294