Merge "Reimplementation of setup_frame_size." into experimental
This commit is contained in:
commit
4d9dbb2ae8
@ -212,25 +212,20 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
|
||||
struct loop_filter_info lfi;
|
||||
const FRAME_TYPE frame_type = cm->frame_type;
|
||||
int mb_row, mb_col;
|
||||
uint8_t *y_ptr, *u_ptr, *v_ptr;
|
||||
|
||||
/* Point at base of Mb MODE_INFO list */
|
||||
// Set up the buffer pointers
|
||||
uint8_t *y_ptr = post->y_buffer;
|
||||
uint8_t *u_ptr = y_only ? 0 : post->u_buffer;
|
||||
uint8_t *v_ptr = y_only ? 0 : post->v_buffer;
|
||||
|
||||
// Point at base of Mb MODE_INFO list
|
||||
const MODE_INFO *mode_info_context = cm->mi;
|
||||
const int mis = cm->mode_info_stride;
|
||||
|
||||
/* Initialize the loop filter for this frame. */
|
||||
// Initialize the loop filter for this frame.
|
||||
vp9_loop_filter_frame_init(cm, xd, frame_filter_level);
|
||||
/* Set up the buffer pointers */
|
||||
y_ptr = post->y_buffer;
|
||||
if (y_only) {
|
||||
u_ptr = 0;
|
||||
v_ptr = 0;
|
||||
} else {
|
||||
u_ptr = post->u_buffer;
|
||||
v_ptr = post->v_buffer;
|
||||
}
|
||||
|
||||
/* vp9_filter each macro block */
|
||||
// vp9_filter each macro block
|
||||
for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
|
||||
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
|
||||
const MB_PREDICTION_MODE mode = mode_info_context->mbmi.mode;
|
||||
@ -382,14 +377,14 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
|
||||
u_ptr += 8;
|
||||
v_ptr += 8;
|
||||
}
|
||||
mode_info_context++; /* step to next MB */
|
||||
mode_info_context++; // step to next MB
|
||||
}
|
||||
y_ptr += post->y_stride * 16 - post->y_width;
|
||||
if (!y_only) {
|
||||
u_ptr += post->uv_stride * 8 - post->uv_width;
|
||||
v_ptr += post->uv_stride * 8 - post->uv_width;
|
||||
}
|
||||
mode_info_context++; /* Skip border mb */
|
||||
mode_info_context++; // Skip border mb
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1413,63 +1413,66 @@ static void setup_loopfilter(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_reader *r) {
|
||||
}
|
||||
}
|
||||
|
||||
static const uint8_t *read_frame_size(VP9_COMMON *const pc, const uint8_t *data,
|
||||
const uint8_t *data_end,
|
||||
int *width, int *height) {
|
||||
if (data + 4 < data_end) {
|
||||
*width = read_le16(data);
|
||||
*height = read_le16(data + 2);
|
||||
data += 4;
|
||||
} else {
|
||||
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
||||
"Failed to read frame size");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static const uint8_t *setup_frame_size(VP9D_COMP *pbi, int scaling_active,
|
||||
const uint8_t *data,
|
||||
const uint8_t *data_end) {
|
||||
VP9_COMMON *const pc = &pbi->common;
|
||||
const int width = pc->width;
|
||||
const int height = pc->height;
|
||||
|
||||
// If error concealment is enabled we should only parse the new size
|
||||
// if we have enough data. Otherwise we will end up with the wrong size.
|
||||
if (scaling_active && data + 4 < data_end) {
|
||||
pc->display_width = read_le16(data + 0);
|
||||
pc->display_height = read_le16(data + 2);
|
||||
data += 4;
|
||||
}
|
||||
VP9_COMMON *const pc = &pbi->common;
|
||||
int display_width = pc->display_width;
|
||||
int display_height = pc->display_height;
|
||||
int width = pc->width;
|
||||
int height = pc->height;
|
||||
|
||||
if (data + 4 < data_end) {
|
||||
pc->width = read_le16(data + 0);
|
||||
pc->height = read_le16(data + 2);
|
||||
data += 4;
|
||||
}
|
||||
if (scaling_active)
|
||||
data = read_frame_size(pc, data, data_end, &display_width, &display_height);
|
||||
|
||||
if (!scaling_active) {
|
||||
pc->display_width = pc->width;
|
||||
pc->display_height = pc->height;
|
||||
}
|
||||
data = read_frame_size(pc, data, data_end, &width, &height);
|
||||
|
||||
if (width != pc->width || height != pc->height) {
|
||||
if (pc->width <= 0) {
|
||||
pc->width = width;
|
||||
if (pc->width != width || pc->height != height) {
|
||||
if (width <= 0)
|
||||
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
||||
"Invalid frame width");
|
||||
}
|
||||
|
||||
if (pc->height <= 0) {
|
||||
pc->height = height;
|
||||
if (height <= 0)
|
||||
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
||||
"Invalid frame height");
|
||||
}
|
||||
|
||||
if (!pbi->initial_width || !pbi->initial_height) {
|
||||
if (vp9_alloc_frame_buffers(pc, pc->width, pc->height))
|
||||
if (vp9_alloc_frame_buffers(pc, width, height))
|
||||
vpx_internal_error(&pc->error, VPX_CODEC_MEM_ERROR,
|
||||
"Failed to allocate frame buffers");
|
||||
pbi->initial_width = pc->width;
|
||||
pbi->initial_height = pc->height;
|
||||
}
|
||||
|
||||
if (pc->width > pbi->initial_width) {
|
||||
pbi->initial_width = width;
|
||||
pbi->initial_height = height;
|
||||
} else {
|
||||
if (width > pbi->initial_width)
|
||||
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
||||
"Frame width too large");
|
||||
}
|
||||
|
||||
if (pc->height > pbi->initial_height) {
|
||||
if (height > pbi->initial_height)
|
||||
vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
|
||||
"Frame height too large");
|
||||
}
|
||||
|
||||
pc->width = width;
|
||||
pc->height = height;
|
||||
pc->display_width = scaling_active ? display_width : width;
|
||||
pc->display_height = scaling_active ? display_height : height;
|
||||
|
||||
update_frame_size(pbi);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user