static void aom_img_copy_tile(const aom_image_t *src, const aom_image_t *dst, int dst_row_offset, int dst_col_offset) { const int shift = (src->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 1 : 0; int plane; for (plane = 0; plane < 3; ++plane) { const unsigned char *src_buf = src->planes[plane]; const int src_stride = src->stride[plane]; unsigned char *dst_buf = dst->planes[plane]; const int dst_stride = dst->stride[plane]; const int roffset = (plane > 0) ? dst_row_offset >> dst->y_chroma_shift : dst_row_offset; const int coffset = (plane > 0) ? dst_col_offset >> dst->x_chroma_shift : dst_col_offset; // col offset needs to be adjusted for HBD. dst_buf += roffset * dst_stride + (coffset << shift); const int w = (aom_img_plane_width(src, plane) << shift); const int h = aom_img_plane_height(src, plane); int y; for (y = 0; y < h; ++y) { memcpy(dst_buf, src_buf, w); src_buf += src_stride; dst_buf += dst_stride; } } }
static int aom_img_size_bytes(aom_image_t *img) { int image_size_bytes = 0; int plane; for (plane = 0; plane < 3; ++plane) { const int w = aom_img_plane_width(img, plane) * ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1); const int h = aom_img_plane_height(img, plane); image_size_bytes += w * h; } return image_size_bytes; }
static void update_image_md5(const aom_image_t *img, const int planes[3], MD5Context *md5) { int i, y; for (i = 0; i < 3; ++i) { const int plane = planes[i]; const unsigned char *buf = img->planes[plane]; const int stride = img->stride[plane]; const int w = aom_img_plane_width(img, plane) * ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1); const int h = aom_img_plane_height(img, plane); for (y = 0; y < h; ++y) { MD5Update(md5, buf, w); buf += stride; } } }
static void write_image_file(const aom_image_t *img, const int planes[3], FILE *file) { int i, y; #if CONFIG_AOM_HIGHBITDEPTH const int bytes_per_sample = ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1); #else const int bytes_per_sample = 1; #endif for (i = 0; i < 3; ++i) { const int plane = planes[i]; const unsigned char *buf = img->planes[plane]; const int stride = img->stride[plane]; const int w = aom_img_plane_width(img, plane); const int h = aom_img_plane_height(img, plane); for (y = 0; y < h; ++y) { fwrite(buf, bytes_per_sample, w, file); buf += stride; } } }
EMSCRIPTEN_KEEPALIVE int get_plane_width(int plane) { return aom_img_plane_width(img, plane); }