Skip to content

Commit cb67119

Browse files
committed
fix a bug of tiny_ssim to handle odd frame sizes
Change-Id: Id8ef0eb211517a8f8ec764ec398d16efb9320540
1 parent e196a6a commit cb67119

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/tiny_ssim.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int open_input_file(const char *file_name, input_file_t *input, int w,
121121
input->w = w;
122122
input->h = h;
123123
// handle odd frame sizes
124-
input->frame_size = w * h + ((w + 1) / 2 * (h + 1) / 2) * 2;
124+
input->frame_size = w * h + ((w + 1) / 2) * ((h + 1) / 2) * 2;
125125
if (bit_depth > 8) {
126126
input->frame_size *= 2;
127127
}
@@ -156,12 +156,12 @@ static size_t read_input_file(input_file_t *in, unsigned char **y,
156156
r1 = fread(in->buf, in->frame_size, 1, in->file);
157157
*y = in->buf;
158158
*u = in->buf + in->w * in->h;
159-
*v = *u + (1 + in->w) / 2 * (1 + in->h) / 2;
159+
*v = *u + ((1 + in->w) / 2) * ((1 + in->h) / 2);
160160
} else {
161161
r1 = fread(in->buf, in->frame_size, 1, in->file);
162162
*y = in->buf;
163163
*u = in->buf + (in->w * in->h) * 2;
164-
*v = *u + 2 * ((1 + in->w) / 2 * (1 + in->h) / 2);
164+
*v = *u + 2 * ((1 + in->w) / 2) * ((1 + in->h) / 2);
165165
}
166166
break;
167167
}

0 commit comments

Comments
 (0)