diff options
Diffstat (limited to 'vpxdec.c')
-rw-r--r-- | vpxdec.c | 180 |
1 files changed, 4 insertions, 176 deletions
@@ -527,180 +527,6 @@ static FILE *open_outfile(const char *name) { } #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH -static void high_img_upshift(vpx_image_t *dst, vpx_image_t *src, - int input_shift) { - const int offset = input_shift > 0 ? (1 << (input_shift - 1)) : 0; - int plane; - if (dst->d_w != src->d_w || dst->d_h != src->d_h || - dst->x_chroma_shift != src->x_chroma_shift || - dst->y_chroma_shift != src->y_chroma_shift || - dst->fmt != src->fmt || input_shift < 0) { - fatal("Unsupported image conversion"); - } - switch (src->fmt) { - case VPX_IMG_FMT_I42016: - case VPX_IMG_FMT_I42216: - case VPX_IMG_FMT_I44416: - case VPX_IMG_FMT_I44016: - break; - default: - fatal("Unsupported image conversion"); - break; - } - for (plane = 0; plane < 3; plane++) { - int w = src->d_w; - int h = src->d_h; - int x, y; - if (plane) { - w = (w + src->x_chroma_shift) >> src->x_chroma_shift; - 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]); - 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; - } - } -} - -static void low_img_upshift(vpx_image_t *dst, vpx_image_t *src, - int input_shift) { - const int offset = input_shift > 0 ? (1 << (input_shift - 1)) : 0; - int plane; - if (dst->d_w != src->d_w || dst->d_h != src->d_h || - dst->x_chroma_shift != src->x_chroma_shift || - dst->y_chroma_shift != src->y_chroma_shift || - dst->fmt != src->fmt + VPX_IMG_FMT_HIGHBITDEPTH || - input_shift < 0) { - fatal("Unsupported image conversion"); - } - switch (src->fmt) { - case VPX_IMG_FMT_I420: - case VPX_IMG_FMT_I422: - case VPX_IMG_FMT_I444: - case VPX_IMG_FMT_I440: - break; - default: - fatal("Unsupported image conversion"); - break; - } - for (plane = 0; plane < 3; plane++) { - int w = src->d_w; - int h = src->d_h; - int x, y; - if (plane) { - w = (w + src->x_chroma_shift) >> src->x_chroma_shift; - 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]; - 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; - } - } - } -} - -static void img_upshift(vpx_image_t *dst, vpx_image_t *src, - int input_shift) { - if (src->fmt & VPX_IMG_FMT_HIGHBITDEPTH) { - high_img_upshift(dst, src, input_shift); - } else { - low_img_upshift(dst, src, input_shift); - } -} - -static void high_img_downshift(vpx_image_t *dst, vpx_image_t *src, - int down_shift) { - int plane; - if (dst->d_w != src->d_w || dst->d_h != src->d_h || - dst->x_chroma_shift != src->x_chroma_shift || - dst->y_chroma_shift != src->y_chroma_shift || - dst->fmt != src->fmt || down_shift < 0) { - fatal("Unsupported image conversion"); - } - switch (src->fmt) { - case VPX_IMG_FMT_I42016: - case VPX_IMG_FMT_I42216: - case VPX_IMG_FMT_I44416: - case VPX_IMG_FMT_I44016: - break; - default: - fatal("Unsupported image conversion"); - break; - } - for (plane = 0; plane < 3; plane++) { - int w = src->d_w; - int h = src->d_h; - int x, y; - if (plane) { - w = (w + src->x_chroma_shift) >> src->x_chroma_shift; - 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]); - 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; - } - } -} - -static void low_img_downshift(vpx_image_t *dst, vpx_image_t *src, - int down_shift) { - int plane; - if (dst->d_w != src->d_w || dst->d_h != src->d_h || - dst->x_chroma_shift != src->x_chroma_shift || - dst->y_chroma_shift != src->y_chroma_shift || - src->fmt != dst->fmt + VPX_IMG_FMT_HIGHBITDEPTH || - down_shift < 0) { - fatal("Unsupported image conversion"); - } - switch (dst->fmt) { - case VPX_IMG_FMT_I420: - case VPX_IMG_FMT_I422: - case VPX_IMG_FMT_I444: - case VPX_IMG_FMT_I440: - break; - default: - fatal("Unsupported image conversion"); - break; - } - for (plane = 0; plane < 3; plane++) { - int w = src->d_w; - int h = src->d_h; - int x, y; - if (plane) { - w = (w + src->x_chroma_shift) >> src->x_chroma_shift; - 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]); - uint8_t *p_dst = dst->planes[plane] + y * dst->stride[plane]; - for (x = 0; x < w; x++) { - *p_dst++ = *p_src++ >> down_shift; - } - } - } -} - -static void img_downshift(vpx_image_t *dst, vpx_image_t *src, - int down_shift) { - if (dst->fmt & VPX_IMG_FMT_HIGHBITDEPTH) { - high_img_downshift(dst, src, down_shift); - } else { - low_img_downshift(dst, src, down_shift); - } -} - static int img_shifted_realloc_required(const vpx_image_t *img, const vpx_image_t *shifted, vpx_img_fmt_t required_fmt) { @@ -1156,9 +982,11 @@ int main_loop(int argc, const char **argv_) { img_shifted->bit_depth = output_bit_depth; } if (output_bit_depth > img->bit_depth) { - img_upshift(img_shifted, img, output_bit_depth - img->bit_depth); + vpx_img_upshift(img_shifted, img, + output_bit_depth - img->bit_depth); } else { - img_downshift(img_shifted, img, img->bit_depth - output_bit_depth); + vpx_img_downshift(img_shifted, img, + img->bit_depth - output_bit_depth); } img = img_shifted; } |