Commit b638074c authored by Arild Fuldseth (arilfuld)'s avatar Arild Fuldseth (arilfuld) Committed by Thomas Davies
Browse files

FRAME_SIZE: Never exceed maximum frame dimensions.

Encoder:
Use oxcf->width/heigth instead of cm->width/height in sequence header.
aom_internal_error() if cm->width/height is larger than max values.

Decoder:
aom_internal_error() if cm->width/height is larger than max values.

Change-Id: I8d8b415efe82d961dbe34377f4da79379cb111a8
parent 3866a142
...@@ -1478,6 +1478,11 @@ static void setup_frame_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) { ...@@ -1478,6 +1478,11 @@ static void setup_frame_size(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
int num_bits_width = cm->seq_params.num_bits_width; int num_bits_width = cm->seq_params.num_bits_width;
int num_bits_height = cm->seq_params.num_bits_height; int num_bits_height = cm->seq_params.num_bits_height;
av1_read_frame_size(rb, num_bits_width, num_bits_height, &width, &height); av1_read_frame_size(rb, num_bits_width, num_bits_height, &width, &height);
if (width > cm->seq_params.max_frame_width ||
height > cm->seq_params.max_frame_height) {
aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
"Frame dimensions are larger than the maximum values");
}
} else { } else {
width = cm->seq_params.max_frame_width; width = cm->seq_params.max_frame_width;
height = cm->seq_params.max_frame_height; height = cm->seq_params.max_frame_height;
......
...@@ -3503,15 +3503,15 @@ static void write_bitdepth_colorspace_sampling( ...@@ -3503,15 +3503,15 @@ static void write_bitdepth_colorspace_sampling(
} }
#if CONFIG_REFERENCE_BUFFER || CONFIG_OBU #if CONFIG_REFERENCE_BUFFER || CONFIG_OBU
void write_sequence_header(AV1_COMMON *const cm, void write_sequence_header(AV1_COMP *cpi, struct aom_write_bit_buffer *wb) {
struct aom_write_bit_buffer *wb) { AV1_COMMON *const cm = &cpi->common;
SequenceHeader *seq_params = &cm->seq_params; SequenceHeader *seq_params = &cm->seq_params;
#if CONFIG_FRAME_SIZE #if CONFIG_FRAME_SIZE
int num_bits_width = 16; int num_bits_width = 16;
int num_bits_height = 16; int num_bits_height = 16;
int max_frame_width = cm->width; int max_frame_width = cpi->oxcf.width;
int max_frame_height = cm->height; int max_frame_height = cpi->oxcf.height;
seq_params->num_bits_width = num_bits_width; seq_params->num_bits_width = num_bits_width;
seq_params->num_bits_height = num_bits_height; seq_params->num_bits_height = num_bits_height;
...@@ -3727,7 +3727,7 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi, ...@@ -3727,7 +3727,7 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
if (frame_is_intra_only(cm)) { if (frame_is_intra_only(cm)) {
#if CONFIG_REFERENCE_BUFFER #if CONFIG_REFERENCE_BUFFER
write_sequence_header(cm, wb); write_sequence_header(cpi, wb);
#endif // CONFIG_REFERENCE_BUFFER #endif // CONFIG_REFERENCE_BUFFER
} }
#if CONFIG_REFERENCE_BUFFER #if CONFIG_REFERENCE_BUFFER
...@@ -3739,6 +3739,11 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi, ...@@ -3739,6 +3739,11 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
#endif // CONFIG_REFERENCE_BUFFER #endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_FRAME_SIZE #if CONFIG_FRAME_SIZE
if (cm->width > cm->seq_params.max_frame_width ||
cm->height > cm->seq_params.max_frame_height) {
aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
"Frame dimensions are larger than the maximum values");
}
int frame_size_override_flag = int frame_size_override_flag =
(cm->width != cm->seq_params.max_frame_width || (cm->width != cm->seq_params.max_frame_width ||
cm->height != cm->seq_params.max_frame_height); cm->height != cm->seq_params.max_frame_height);
...@@ -4043,6 +4048,11 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi, ...@@ -4043,6 +4048,11 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
#endif // CONFIG_REFERENCE_BUFFER #endif // CONFIG_REFERENCE_BUFFER
#if CONFIG_FRAME_SIZE #if CONFIG_FRAME_SIZE
if (cm->width > cm->seq_params.max_frame_width ||
cm->height > cm->seq_params.max_frame_height) {
aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
"Frame dimensions are larger than the maximum values");
}
int frame_size_override_flag = int frame_size_override_flag =
(cm->width != cm->seq_params.max_frame_width || (cm->width != cm->seq_params.max_frame_width ||
cm->height != cm->seq_params.max_frame_height); cm->height != cm->seq_params.max_frame_height);
...@@ -4628,7 +4638,7 @@ static uint32_t write_sequence_header_obu(AV1_COMP *cpi, uint8_t *const dst) { ...@@ -4628,7 +4638,7 @@ static uint32_t write_sequence_header_obu(AV1_COMP *cpi, uint8_t *const dst) {
aom_wb_write_literal(&wb, 0, 4); aom_wb_write_literal(&wb, 0, 4);
write_sequence_header(cm, &wb); write_sequence_header(cpi, &wb);
// color_config // color_config
write_bitdepth_colorspace_sampling(cm, &wb); write_bitdepth_colorspace_sampling(cm, &wb);
......
...@@ -21,8 +21,7 @@ extern "C" { ...@@ -21,8 +21,7 @@ extern "C" {
struct aom_write_bit_buffer; struct aom_write_bit_buffer;
#if CONFIG_REFERENCE_BUFFER #if CONFIG_REFERENCE_BUFFER
void write_sequence_header(AV1_COMMON *const cm, void write_sequence_header(AV1_COMP *cpi, struct aom_write_bit_buffer *wb);
struct aom_write_bit_buffer *wb);
#endif #endif
#if CONFIG_OBU #if CONFIG_OBU
......
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