Commit cdcf4b03 authored by Sebastien Alaiwan's avatar Sebastien Alaiwan Committed by Frédéric BARBIER

Move aom_img_plane_width/height helpers to aom_image.h

Use them to simplify the body of compare_img in encode_test_driver.cc.

Change-Id: I4fbb4e67917f61f224e3d1b1a6970d10fc3cd777
parent 93a802cf
......@@ -240,6 +240,24 @@ void aom_img_flip(aom_image_t *img);
*/
void aom_img_free(aom_image_t *img);
/*!\brief Get the width of a plane
*
* Get the width of a plane of an image
*
* \param[in] img Image descriptor
* \param[in] plane Plane index
*/
int aom_img_plane_width(const aom_image_t *img, int plane);
/*!\brief Get the height of a plane
*
* Get the height of a plane of an image
*
* \param[in] img Image descriptor
* \param[in] plane Plane index
*/
int aom_img_plane_height(const aom_image_t *img, int plane);
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -12,5 +12,7 @@ text aom_codec_version_str
text aom_img_alloc
text aom_img_flip
text aom_img_free
text aom_img_plane_width
text aom_img_plane_height
text aom_img_set_rect
text aom_img_wrap
......@@ -238,3 +238,17 @@ void aom_img_free(aom_image_t *img) {
if (img->self_allocd) free(img);
}
}
int aom_img_plane_width(const aom_image_t *img, int plane) {
if (plane > 0 && img->x_chroma_shift > 0)
return (img->d_w + 1) >> img->x_chroma_shift;
else
return img->d_w;
}
int aom_img_plane_height(const aom_image_t *img, int plane) {
if (plane > 0 && img->y_chroma_shift > 0)
return (img->d_h + 1) >> img->y_chroma_shift;
else
return img->d_h;
}
......@@ -149,11 +149,6 @@ static bool compare_img(const aom_image_t *img1, const aom_image_t *img2,
int *const mismatch_row, int *const mismatch_col,
int *const mismatch_plane, int *const mismatch_pix1,
int *const mismatch_pix2) {
const unsigned int w_y = img1->d_w;
const unsigned int h_y = img1->d_h;
const unsigned int w_uv = ROUND_POWER_OF_TWO(w_y, img1->x_chroma_shift);
const unsigned int h_uv = ROUND_POWER_OF_TWO(h_y, img1->y_chroma_shift);
if (img1->fmt != img2->fmt || img1->cs != img2->cs ||
img1->d_w != img2->d_w || img1->d_h != img2->d_h) {
if (mismatch_row != NULL) *mismatch_row = -1;
......@@ -161,28 +156,15 @@ static bool compare_img(const aom_image_t *img1, const aom_image_t *img2,
return false;
}
if (!compare_plane(img1->planes[AOM_PLANE_Y], img1->stride[AOM_PLANE_Y],
img2->planes[AOM_PLANE_Y], img2->stride[AOM_PLANE_Y], w_y,
h_y, mismatch_row, mismatch_col, mismatch_pix1,
mismatch_pix2)) {
if (mismatch_plane != NULL) *mismatch_plane = AOM_PLANE_Y;
return false;
}
if (!compare_plane(img1->planes[AOM_PLANE_U], img1->stride[AOM_PLANE_U],
img2->planes[AOM_PLANE_U], img2->stride[AOM_PLANE_U], w_uv,
h_uv, mismatch_row, mismatch_col, mismatch_pix1,
mismatch_pix2)) {
if (mismatch_plane != NULL) *mismatch_plane = AOM_PLANE_U;
return false;
}
if (!compare_plane(img1->planes[AOM_PLANE_V], img1->stride[AOM_PLANE_V],
img2->planes[AOM_PLANE_V], img2->stride[AOM_PLANE_V], w_uv,
h_uv, mismatch_row, mismatch_col, mismatch_pix1,
mismatch_pix2)) {
if (mismatch_plane != NULL) *mismatch_plane = AOM_PLANE_U;
return false;
for (int plane = 0; plane < 3; plane++) {
if (!compare_plane(img1->planes[plane], img1->stride[plane],
img2->planes[plane], img2->stride[plane],
aom_img_plane_width(img1, plane),
aom_img_plane_height(img1, plane), mismatch_row,
mismatch_col, mismatch_pix1, mismatch_pix2)) {
if (mismatch_plane != NULL) *mismatch_plane = plane;
return false;
}
}
return true;
......
......@@ -185,22 +185,6 @@ const AvxInterface *get_aom_decoder_by_fourcc(uint32_t fourcc) {
}
#endif // CONFIG_AV1_DECODER
// TODO(dkovalev): move this function to aom_image.{c, h}, so it will be part
// of aom_image_t support
int aom_img_plane_width(const aom_image_t *img, int plane) {
if (plane > 0 && img->x_chroma_shift > 0)
return (img->d_w + 1) >> img->x_chroma_shift;
else
return img->d_w;
}
int aom_img_plane_height(const aom_image_t *img, int plane) {
if (plane > 0 && img->y_chroma_shift > 0)
return (img->d_h + 1) >> img->y_chroma_shift;
else
return img->d_h;
}
void aom_img_write(const aom_image_t *img, FILE *file) {
int plane;
......
......@@ -146,10 +146,6 @@ const AvxInterface *get_aom_decoder_by_index(int i);
const AvxInterface *get_aom_decoder_by_name(const char *name);
const AvxInterface *get_aom_decoder_by_fourcc(uint32_t fourcc);
// TODO(dkovalev): move this function to aom_image.{c, h}, so it will be part
// of aom_image_t support
int aom_img_plane_width(const aom_image_t *img, int plane);
int aom_img_plane_height(const aom_image_t *img, int plane);
void aom_img_write(const aom_image_t *img, FILE *file);
int aom_img_read(aom_image_t *img, FILE *file);
......
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