summaryrefslogtreecommitdiff
path: root/vpxdec.c
diff options
context:
space:
mode:
authorDeb Mukherjee <debargha@google.com>2014-09-25 15:46:50 -0700
committerDeb Mukherjee <debargha@google.com>2014-09-29 11:27:45 -0700
commit9ed23de13f0ddfebea2a7ff6caa370126dd84979 (patch)
tree2ac02213e8561d9ca919f3cb715e220ca4d3bf57 /vpxdec.c
parent8b4dd536a53623f27a5dde7a4e4bd4cae485ba1c (diff)
downloadlibvpx-9ed23de13f0ddfebea2a7ff6caa370126dd84979.tar.gz
libvpx-9ed23de13f0ddfebea2a7ff6caa370126dd84979.tar.bz2
libvpx-9ed23de13f0ddfebea2a7ff6caa370126dd84979.zip
Miscellaneous decoder changes for high bitdepth
Also includes yv12 config changes. Change-Id: Iacf40d8bf486815b54c32a127ce3cd4516b7e44f
Diffstat (limited to 'vpxdec.c')
-rw-r--r--vpxdec.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/vpxdec.c b/vpxdec.c
index cf23c295e..f5c945c05 100644
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -551,8 +551,8 @@ static void high_img_upshift(vpx_image_t *dst, vpx_image_t *src,
int h = src->d_h;
int x, y;
if (plane) {
- w >>= src->x_chroma_shift;
- h >>= src->y_chroma_shift;
+ 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] +
@@ -590,8 +590,8 @@ static void low_img_upshift(vpx_image_t *dst, vpx_image_t *src,
int h = src->d_h;
int x, y;
if (plane) {
- w >>= src->x_chroma_shift;
- h >>= src->y_chroma_shift;
+ 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];
@@ -636,8 +636,8 @@ static void high_img_downshift(vpx_image_t *dst, vpx_image_t *src,
int h = src->d_h;
int x, y;
if (plane) {
- w >>= src->x_chroma_shift;
- h >>= src->y_chroma_shift;
+ 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] +
@@ -674,8 +674,8 @@ static void low_img_downshift(vpx_image_t *dst, vpx_image_t *src,
int h = src->d_h;
int x, y;
if (plane) {
- w >>= src->x_chroma_shift;
- h >>= src->y_chroma_shift;
+ 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] +
@@ -696,6 +696,14 @@ static void img_downshift(vpx_image_t *dst, vpx_image_t *src,
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) {
+ return img->d_w != shifted->d_w ||
+ img->d_h != shifted->d_h ||
+ required_fmt != shifted->fmt;
+}
#endif
int main_loop(int argc, const char **argv_) {
@@ -1130,16 +1138,17 @@ int main_loop(int argc, const char **argv_) {
}
// Shift up or down if necessary
if (output_bit_depth != img->bit_depth) {
+ const vpx_img_fmt_t shifted_fmt = output_bit_depth == 8 ?
+ img->fmt ^ (img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) :
+ img->fmt | VPX_IMG_FMT_HIGHBITDEPTH;
+ if (img_shifted &&
+ img_shifted_realloc_required(img, img_shifted, shifted_fmt)) {
+ vpx_img_free(img_shifted);
+ img_shifted = NULL;
+ }
if (!img_shifted) {
- if (output_bit_depth == 8) {
- img_shifted = vpx_img_alloc(
- NULL, img->fmt - VPX_IMG_FMT_HIGHBITDEPTH,
- img->d_w, img->d_h, 16);
- } else {
- img_shifted = vpx_img_alloc(
- NULL, img->fmt | VPX_IMG_FMT_HIGHBITDEPTH,
- img->d_w, img->d_h, 16);
- }
+ img_shifted = vpx_img_alloc(NULL, shifted_fmt,
+ img->d_w, img->d_h, 16);
img_shifted->bit_depth = output_bit_depth;
}
if (output_bit_depth > img->bit_depth) {