Declare the 'src' parameters as const.
The 'src' parameter of aom_img_downshift() was changed to const in
commit bf9d6d4b3a7e2496aaf226784861882bcba72322. This CL makes the
same change to the 'src' parameters of aom_img_upshift() and
aom_img_truncate_16_to_8() for consistency. It also declares the
p_src local variables as const.
Change-Id: I8b0b4895657891cbcad7b4c6edf2839444e5e196
diff --git a/common/tools_common.c b/common/tools_common.c
index 960a9b9..21cd800 100644
--- a/common/tools_common.c
+++ b/common/tools_common.c
@@ -236,7 +236,7 @@
}
// TODO(debargha): Consolidate the functions below into a separate file.
-static void highbd_img_upshift(aom_image_t *dst, aom_image_t *src,
+static void highbd_img_upshift(aom_image_t *dst, const aom_image_t *src,
int input_shift) {
// Note the offset is 1 less than half.
const int offset = input_shift > 0 ? (1 << (input_shift - 1)) - 1 : 0;
@@ -262,8 +262,8 @@
h = (h + src->y_chroma_shift) >> src->y_chroma_shift;
}
for (y = 0; y < h; y++) {
- uint16_t *p_src =
- (uint16_t *)(src->planes[plane] + y * src->stride[plane]);
+ const uint16_t *p_src =
+ (const uint16_t *)(src->planes[plane] + y * src->stride[plane]);
uint16_t *p_dst =
(uint16_t *)(dst->planes[plane] + y * dst->stride[plane]);
for (x = 0; x < w; x++) *p_dst++ = (*p_src++ << input_shift) + offset;
@@ -271,7 +271,7 @@
}
}
-static void lowbd_img_upshift(aom_image_t *dst, aom_image_t *src,
+static void lowbd_img_upshift(aom_image_t *dst, const aom_image_t *src,
int input_shift) {
// Note the offset is 1 less than half.
const int offset = input_shift > 0 ? (1 << (input_shift - 1)) - 1 : 0;
@@ -297,7 +297,7 @@
h = (h + src->y_chroma_shift) >> src->y_chroma_shift;
}
for (y = 0; y < h; y++) {
- uint8_t *p_src = src->planes[plane] + y * src->stride[plane];
+ const uint8_t *p_src = src->planes[plane] + y * src->stride[plane];
uint16_t *p_dst =
(uint16_t *)(dst->planes[plane] + y * dst->stride[plane]);
for (x = 0; x < w; x++) {
@@ -307,7 +307,8 @@
}
}
-void aom_img_upshift(aom_image_t *dst, aom_image_t *src, int input_shift) {
+void aom_img_upshift(aom_image_t *dst, const aom_image_t *src,
+ int input_shift) {
if (src->fmt & AOM_IMG_FMT_HIGHBITDEPTH) {
highbd_img_upshift(dst, src, input_shift);
} else {
@@ -315,7 +316,7 @@
}
}
-void aom_img_truncate_16_to_8(aom_image_t *dst, aom_image_t *src) {
+void aom_img_truncate_16_to_8(aom_image_t *dst, const aom_image_t *src) {
int plane;
if (dst->fmt + AOM_IMG_FMT_HIGHBITDEPTH != src->fmt || dst->d_w != src->d_w ||
dst->d_h != src->d_h || dst->x_chroma_shift != src->x_chroma_shift ||
@@ -337,8 +338,8 @@
h = (h + src->y_chroma_shift) >> src->y_chroma_shift;
}
for (y = 0; y < h; y++) {
- uint16_t *p_src =
- (uint16_t *)(src->planes[plane] + y * src->stride[plane]);
+ const uint16_t *p_src =
+ (const uint16_t *)(src->planes[plane] + y * src->stride[plane]);
uint8_t *p_dst = dst->planes[plane] + y * dst->stride[plane];
for (x = 0; x < w; x++) {
*p_dst++ = (uint8_t)(*p_src++);
@@ -371,8 +372,8 @@
h = (h + src->y_chroma_shift) >> src->y_chroma_shift;
}
for (y = 0; y < h; y++) {
- uint16_t *p_src =
- (uint16_t *)(src->planes[plane] + y * src->stride[plane]);
+ const uint16_t *p_src =
+ (const uint16_t *)(src->planes[plane] + y * src->stride[plane]);
uint16_t *p_dst =
(uint16_t *)(dst->planes[plane] + y * dst->stride[plane]);
for (x = 0; x < w; x++) *p_dst++ = *p_src++ >> down_shift;
@@ -404,8 +405,8 @@
h = (h + src->y_chroma_shift) >> src->y_chroma_shift;
}
for (y = 0; y < h; y++) {
- uint16_t *p_src =
- (uint16_t *)(src->planes[plane] + y * src->stride[plane]);
+ const uint16_t *p_src =
+ (const uint16_t *)(src->planes[plane] + y * src->stride[plane]);
uint8_t *p_dst = dst->planes[plane] + y * dst->stride[plane];
for (x = 0; x < w; x++) {
*p_dst++ = *p_src++ >> down_shift;
diff --git a/common/tools_common.h b/common/tools_common.h
index 4811de4..5879036 100644
--- a/common/tools_common.h
+++ b/common/tools_common.h
@@ -152,10 +152,10 @@
int aom_img_read(aom_image_t *img, FILE *file);
double sse_to_psnr(double samples, double peak, double mse);
-void aom_img_upshift(aom_image_t *dst, aom_image_t *src, int input_shift);
+void aom_img_upshift(aom_image_t *dst, const aom_image_t *src, int input_shift);
void aom_img_downshift(aom_image_t *dst, const aom_image_t *src,
int down_shift);
-void aom_img_truncate_16_to_8(aom_image_t *dst, aom_image_t *src);
+void aom_img_truncate_16_to_8(aom_image_t *dst, const aom_image_t *src);
#ifdef __cplusplus
} /* extern "C" */