Commit b932c6c5 authored by Alex Converse's avatar Alex Converse
Browse files

BITSTREAM CLARIFICATION: Forbid referencing across color spaces.

Check image format of reference frames.

Change-Id: I7d8d7f097ba547839ff9cec3880bd15a4948ee06
Showing with 24 additions and 0 deletions
...@@ -668,6 +668,15 @@ static void setup_frame_size(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { ...@@ -668,6 +668,15 @@ static void setup_frame_size(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) {
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffer"); "Failed to allocate frame buffer");
} }
cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
}
static INLINE int valid_ref_frame_img_fmt(vpx_bit_depth_t ref_bit_depth,
int ref_xss, int ref_yss,
vpx_bit_depth_t this_bit_depth,
int this_xss, int this_yss) {
return ref_bit_depth == this_bit_depth && ref_xss == this_xss &&
ref_yss == this_yss;
} }
static void setup_frame_size_with_refs(VP9_COMMON *cm, static void setup_frame_size_with_refs(VP9_COMMON *cm,
...@@ -707,6 +716,18 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm, ...@@ -707,6 +716,18 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm,
if (!has_valid_ref_frame) if (!has_valid_ref_frame)
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
"Referenced frame has invalid size"); "Referenced frame has invalid size");
for (i = 0; i < REFS_PER_FRAME; ++i) {
RefBuffer *const ref_frame = &cm->frame_refs[i];
if (!valid_ref_frame_img_fmt(
ref_frame->buf->bit_depth,
ref_frame->buf->uv_crop_width < ref_frame->buf->y_crop_width,
ref_frame->buf->uv_crop_height < ref_frame->buf->y_crop_height,
cm->bit_depth,
cm->subsampling_x,
cm->subsampling_y))
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
"Referenced frame has incompatible color space");
}
resize_context_buffers(cm, width, height); resize_context_buffers(cm, width, height);
setup_display_size(cm, rb); setup_display_size(cm, rb);
...@@ -723,6 +744,7 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm, ...@@ -723,6 +744,7 @@ static void setup_frame_size_with_refs(VP9_COMMON *cm,
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate frame buffer"); "Failed to allocate frame buffer");
} }
cm->frame_bufs[cm->new_fb_idx].buf.bit_depth = (unsigned int)cm->bit_depth;
} }
static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
extern "C" { extern "C" {
#endif #endif
#include "vpx/vpx_codec.h"
#include "vpx/vpx_frame_buffer.h" #include "vpx/vpx_frame_buffer.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
...@@ -50,6 +51,7 @@ typedef struct yv12_buffer_config { ...@@ -50,6 +51,7 @@ typedef struct yv12_buffer_config {
int buffer_alloc_sz; int buffer_alloc_sz;
int border; int border;
int frame_size; int frame_size;
unsigned int bit_depth;
int corrupted; int corrupted;
int flags; int flags;
......
Supports Markdown
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