diff options
author | Jerome Jiang <jianj@google.com> | 2020-06-02 22:28:57 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-06-02 22:28:57 +0000 |
commit | c1765573149e2c0fe2acabc224c0f9085b9e7f2b (patch) | |
tree | ad1f27c6c6b0f8af76e58f82a33985f8f610e3f4 /vpx/src/vpx_image.c | |
parent | 34034789d758440415306a637e6aea57f34e1a4c (diff) | |
parent | 64485398d86a4b81ce19c35f791cbf0478bde0ee (diff) | |
download | libvpx-c1765573149e2c0fe2acabc224c0f9085b9e7f2b.tar libvpx-c1765573149e2c0fe2acabc224c0f9085b9e7f2b.tar.gz libvpx-c1765573149e2c0fe2acabc224c0f9085b9e7f2b.tar.bz2 libvpx-c1765573149e2c0fe2acabc224c0f9085b9e7f2b.zip |
Merge "Add NV12 support"
Diffstat (limited to 'vpx/src/vpx_image.c')
-rw-r--r-- | vpx/src/vpx_image.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/vpx/src/vpx_image.c b/vpx/src/vpx_image.c index a7c6ec0ce..ff496b5d3 100644 --- a/vpx/src/vpx_image.c +++ b/vpx/src/vpx_image.c @@ -39,7 +39,8 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt, /* Get sample size for this format */ switch (fmt) { case VPX_IMG_FMT_I420: - case VPX_IMG_FMT_YV12: bps = 12; break; + case VPX_IMG_FMT_YV12: + case VPX_IMG_FMT_NV12: bps = 12; break; case VPX_IMG_FMT_I422: case VPX_IMG_FMT_I440: bps = 16; break; case VPX_IMG_FMT_I444: bps = 24; break; @@ -51,6 +52,8 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt, } /* Get chroma shift values for this format */ + // For VPX_IMG_FMT_NV12, xcs needs to be 0 such that UV data is all read at + // one time. switch (fmt) { case VPX_IMG_FMT_I420: case VPX_IMG_FMT_YV12: @@ -62,6 +65,7 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, vpx_img_fmt_t fmt, switch (fmt) { case VPX_IMG_FMT_I420: + case VPX_IMG_FMT_NV12: case VPX_IMG_FMT_I440: case VPX_IMG_FMT_YV12: case VPX_IMG_FMT_I42016: @@ -173,7 +177,12 @@ int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y, data + x * bytes_per_sample + y * img->stride[VPX_PLANE_Y]; data += img->h * img->stride[VPX_PLANE_Y]; - if (!(img->fmt & VPX_IMG_FMT_UV_FLIP)) { + if (img->fmt == VPX_IMG_FMT_NV12) { + img->planes[VPX_PLANE_U] = + data + (x >> img->x_chroma_shift) + + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U]; + img->planes[VPX_PLANE_V] = img->planes[VPX_PLANE_U] + 1; + } else if (!(img->fmt & VPX_IMG_FMT_UV_FLIP)) { img->planes[VPX_PLANE_U] = data + (x >> img->x_chroma_shift) * bytes_per_sample + (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U]; |