Commit 6b223fcb authored by Yaowu Xu's avatar Yaowu Xu

Enable decoder to pass through color space info

This commit added a field to vpx_image_t for indicating color space,
the field is also added to YUV_BUFFER_CONFIG. This allows the color
space information pass through the decoder from input stream to the
output buffer.

The commit also updated compare_img() function with added verification
of matching color space to ensure the color space information to be
correctly passed from encode to decoder in compressed vp9 streams.

Change-Id: I412776ec83defd8a09d76759aeb057b8fa690371
parent 6f6fbf91
......@@ -114,6 +114,7 @@ void EncoderTest::SetMode(TestMode mode) {
static bool compare_img(const vpx_image_t *img1,
const vpx_image_t *img2) {
bool match = (img1->fmt == img2->fmt) &&
(img1->cs == img2->cs) &&
(img1->d_w == img2->d_w) &&
(img1->d_h == img2->d_h);
......
......@@ -727,6 +727,8 @@ static void setup_frame_size(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) {
}
cm->frame_bufs[cm->new_fb_idx].buf.subsampling_x = cm->subsampling_x;
cm->frame_bufs[cm->new_fb_idx].buf.subsampling_y = cm->subsampling_y;
cm->frame_bufs[cm->new_fb_idx].buf.color_space =
(vpx_color_space_t)cm->color_space;
cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
}
......
......@@ -34,6 +34,7 @@ static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12,
bps = 12;
}
}
img->cs = yv12->color_space;
img->bit_depth = 8;
img->w = yv12->y_stride;
img->h = ALIGN_POWER_OF_TWO(yv12->y_height + 2 * VP9_ENC_BORDER_IN_PIXELS, 3);
......@@ -92,6 +93,7 @@ static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
yv12->y_stride = img->stride[VPX_PLANE_Y];
yv12->uv_stride = img->stride[VPX_PLANE_U];
yv12->color_space = img->cs;
#if CONFIG_VP9_HIGHBITDEPTH
if (img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) {
......
......@@ -28,7 +28,7 @@ extern "C" {
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define VPX_IMAGE_ABI_VERSION (2) /**<\hideinitializer*/
#define VPX_IMAGE_ABI_VERSION (3) /**<\hideinitializer*/
#define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
......@@ -66,9 +66,22 @@ extern "C" {
VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH
} vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
/*!\brief List of supported color spaces */
typedef enum vpx_color_space {
VPX_CS_UNKNOWN = 0, // Unknown
VPX_CS_BT_601 = 1, // BT.601
VPX_CS_BT_709 = 2, // BT.709
VPX_CS_SMPTE_170 = 3, // SMPTE.170
VPX_CS_SMPTE_240 = 4, // SMPTE.240
VPX_CS_BT_2020 = 5, // BT.2020
VPX_CS_RESERVED = 6, // Reserved
VPX_CS_SRGB = 7 // sRGB
} vpx_color_space_t; /**< alias for enum vpx_color_space */
/**\brief Image Descriptor */
typedef struct vpx_image {
vpx_img_fmt_t fmt; /**< Image Format */
vpx_color_space_t cs; /**< Color Space */
/* Image storage dimensions */
unsigned int w; /**< Stored image width */
......
......@@ -55,6 +55,7 @@ typedef struct yv12_buffer_config {
int subsampling_x;
int subsampling_y;
unsigned int bit_depth;
vpx_color_space_t color_space;
int corrupted;
int flags;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment