summaryrefslogtreecommitdiff
path: root/vpx/src/vpx_image.c
diff options
context:
space:
mode:
authorJerome Jiang <jianj@google.com>2020-05-27 13:57:50 -0700
committerJerome Jiang <jianj@google.com>2020-06-02 14:09:48 -0700
commit64485398d86a4b81ce19c35f791cbf0478bde0ee (patch)
tree67864fa42a4814bac306119442ea66653d423566 /vpx/src/vpx_image.c
parent3bc58f13cc4ae0881ce483a8dcd7789a2d6f325d (diff)
downloadlibvpx-64485398d86a4b81ce19c35f791cbf0478bde0ee.tar
libvpx-64485398d86a4b81ce19c35f791cbf0478bde0ee.tar.gz
libvpx-64485398d86a4b81ce19c35f791cbf0478bde0ee.tar.bz2
libvpx-64485398d86a4b81ce19c35f791cbf0478bde0ee.zip
Add NV12 support
Change-Id: Ia2a8221a156e0882079c5a252f59bc84d8f516b1
Diffstat (limited to 'vpx/src/vpx_image.c')
-rw-r--r--vpx/src/vpx_image.c13
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];