From a30774c50d2b1b626b05a99dcd29aa766f0b223b Mon Sep 17 00:00:00 2001 From: Deb Mukherjee Date: Wed, 1 Oct 2014 12:17:37 -0700 Subject: [PATCH] Adds support of 440 content. Adds enums and corresponding vpx level code. Change-Id: Ia402d47490a4466988d7edc6b7e3e5163f20a381 --- vp9/vp9_iface_common.h | 9 +++++++-- vpx/src/vpx_image.c | 4 ++++ vpx/vpx_image.h | 6 ++++-- vpxdec.c | 10 +++++++++- vpxenc.c | 17 ++++++++++++++++- vpxenc.h | 1 + 6 files changed, 41 insertions(+), 6 deletions(-) diff --git a/vp9/vp9_iface_common.h b/vp9/vp9_iface_common.h index db31a421d..a2bfe62a7 100644 --- a/vp9/vp9_iface_common.h +++ b/vp9/vp9_iface_common.h @@ -28,8 +28,13 @@ static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12, bps = 16; } } else { - img->fmt = VPX_IMG_FMT_I420; - bps = 12; + if (!ss_x) { + img->fmt = VPX_IMG_FMT_I440; + bps = 16; + } else { + img->fmt = VPX_IMG_FMT_I420; + bps = 12; + } } img->bit_depth = 8; img->w = yv12->y_stride; diff --git a/vpx/src/vpx_image.c b/vpx/src/vpx_image.c index 0908e9ee9..9aae12c79 100644 --- a/vpx/src/vpx_image.c +++ b/vpx/src/vpx_image.c @@ -70,6 +70,7 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, bps = 12; break; case VPX_IMG_FMT_I422: + case VPX_IMG_FMT_I440: bps = 16; break; case VPX_IMG_FMT_I444: @@ -79,6 +80,7 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, bps = 24; break; case VPX_IMG_FMT_I42216: + case VPX_IMG_FMT_I44016: bps = 32; break; case VPX_IMG_FMT_I44416: @@ -107,10 +109,12 @@ static vpx_image_t *img_alloc_helper(vpx_image_t *img, switch (fmt) { case VPX_IMG_FMT_I420: + case VPX_IMG_FMT_I440: case VPX_IMG_FMT_YV12: case VPX_IMG_FMT_VPXI420: case VPX_IMG_FMT_VPXYV12: case VPX_IMG_FMT_I42016: + case VPX_IMG_FMT_I44016: ycs = 1; break; default: diff --git a/vpx/vpx_image.h b/vpx/vpx_image.h index ef6d1dd30..337e4c4be 100644 --- a/vpx/vpx_image.h +++ b/vpx/vpx_image.h @@ -58,10 +58,12 @@ extern "C" { VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4, VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5, VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6, - VPX_IMG_FMT_444A = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_HAS_ALPHA | 7, + VPX_IMG_FMT_I440 = VPX_IMG_FMT_PLANAR | 7, + VPX_IMG_FMT_444A = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_HAS_ALPHA | 6, VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH, VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH, - VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH + VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH, + VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH } vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */ /**\brief Image Descriptor */ diff --git a/vpxdec.c b/vpxdec.c index f5c945c05..45dd04125 100644 --- a/vpxdec.c +++ b/vpxdec.c @@ -541,6 +541,7 @@ static void high_img_upshift(vpx_image_t *dst, vpx_image_t *src, 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"); @@ -580,6 +581,7 @@ static void low_img_upshift(vpx_image_t *dst, vpx_image_t *src, 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"); @@ -626,6 +628,7 @@ static void high_img_downshift(vpx_image_t *dst, vpx_image_t *src, 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"); @@ -664,6 +667,7 @@ static void low_img_downshift(vpx_image_t *dst, vpx_image_t *src, 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"); @@ -941,7 +945,7 @@ int main_loop(int argc, const char **argv_) { if (use_y4m && !noblit) { if (!single_file) { fprintf(stderr, "YUV4MPEG2 not supported with output patterns," - " try --i420 or --yv12.\n"); + " try --i420 or --yv12 or --rawvideo.\n"); return EXIT_FAILURE; } @@ -1164,6 +1168,10 @@ int main_loop(int argc, const char **argv_) { if (use_y4m) { char buf[Y4M_BUFFER_SIZE] = {0}; size_t len = 0; + if (img->fmt == VPX_IMG_FMT_I440 || img->fmt == VPX_IMG_FMT_I44016) { + fprintf(stderr, "Cannot produce y4m output for 440 sampling.\n"); + goto fail; + } if (frame_out == 1) { // Y4M file header len = y4m_write_file_header(buf, sizeof(buf), diff --git a/vpxenc.c b/vpxenc.c index a074400f3..53a291152 100644 --- a/vpxenc.c +++ b/vpxenc.c @@ -140,6 +140,8 @@ static const arg_def_t use_i422 = ARG_DEF(NULL, "i422", 0, "Input file is I422"); static const arg_def_t use_i444 = ARG_DEF(NULL, "i444", 0, "Input file is I444"); +static const arg_def_t use_i440 = ARG_DEF(NULL, "i440", 0, + "Input file is I440"); static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1, "Codec to use"); static const arg_def_t passes = ARG_DEF("p", "passes", 1, @@ -244,7 +246,7 @@ static const arg_def_t lag_in_frames = ARG_DEF(NULL, "lag-in-frames", 1, "Max number of frames to lag"); static const arg_def_t *global_args[] = { - &use_yv12, &use_i420, &use_i422, &use_i444, + &use_yv12, &use_i420, &use_i422, &use_i444, &use_i440, &usage, &threads, &profile, &width, &height, #if CONFIG_WEBM_IO @@ -829,6 +831,8 @@ static void parse_global_config(struct VpxEncoderConfig *global, char **argv) { global->color_type = I422; else if (arg_match(&arg, &use_i444, argi)) global->color_type = I444; + else if (arg_match(&arg, &use_i440, argi)) + global->color_type = I440; else if (arg_match(&arg, &quietarg, argi)) global->quiet = 1; else if (arg_match(&arg, &verbosearg, argi)) @@ -1288,7 +1292,12 @@ static const char* image_format_to_string(vpx_img_fmt_t f) { case VPX_IMG_FMT_I420: return "I420"; case VPX_IMG_FMT_I422: return "I422"; case VPX_IMG_FMT_I444: return "I444"; + case VPX_IMG_FMT_I440: return "I440"; case VPX_IMG_FMT_YV12: return "YV12"; + case VPX_IMG_FMT_I42016: return "I42016"; + case VPX_IMG_FMT_I42216: return "I42216"; + case VPX_IMG_FMT_I44416: return "I44416"; + case VPX_IMG_FMT_I44016: return "I44016"; default: return "Other"; } } @@ -1734,6 +1743,7 @@ static void high_img_upshift(vpx_image_t *dst, vpx_image_t *src, 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"); @@ -1774,6 +1784,7 @@ static void low_img_upshift(vpx_image_t *dst, vpx_image_t *src, 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"); @@ -1819,6 +1830,7 @@ static void img_cast_16_to_8(vpx_image_t *dst, vpx_image_t *src) { 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"); @@ -1993,6 +2005,9 @@ int main(int argc, const char **argv_) { case I444: input.fmt = VPX_IMG_FMT_I444; break; + case I440: + input.fmt = VPX_IMG_FMT_I440; + break; case YV12: input.fmt = VPX_IMG_FMT_YV12; break; diff --git a/vpxenc.h b/vpxenc.h index 3d6728e01..d867e9d95 100644 --- a/vpxenc.h +++ b/vpxenc.h @@ -26,6 +26,7 @@ typedef enum { I420, // 4:2:0 8+ bit-depth I422, // 4:2:2 8+ bit-depth I444, // 4:4:4 8+ bit-depth + I440, // 4:4:0 8+ bit-depth YV12, // 4:2:0 with uv flipped, only 8-bit depth } ColorInputType;