Commit 25c57d2b authored by Rupert Swarbrick's avatar Rupert Swarbrick

Simplify prototype of av1_loop_restoration_filter_frame

This is always called with all components and no destination buffer.

Change-Id: I76d1a16a87e05b8ecec387288139e846e9894384
parent ffbff57d
...@@ -1357,49 +1357,30 @@ static void filter_frame_on_unit(const RestorationTileLimits *limits, ...@@ -1357,49 +1357,30 @@ static void filter_frame_on_unit(const RestorationTileLimits *limits,
} }
void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame, void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame,
AV1_COMMON *cm, RestorationInfo *rsi, AV1_COMMON *cm, RestorationInfo *rsi) {
int components_pattern,
YV12_BUFFER_CONFIG *dst) {
YV12_BUFFER_CONFIG dst_;
typedef void (*copy_fun)(const YV12_BUFFER_CONFIG *src, typedef void (*copy_fun)(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst); YV12_BUFFER_CONFIG *dst);
static const copy_fun copy_funs[3] = { aom_yv12_copy_y, aom_yv12_copy_u, static const copy_fun copy_funs[3] = { aom_yv12_copy_y, aom_yv12_copy_u,
aom_yv12_copy_v }; aom_yv12_copy_v };
for (int plane = 0; plane < 3; ++plane) { if (rsi[0].frame_restoration_type == RESTORE_NONE &&
if ((components_pattern == 1 << plane) && rsi[1].frame_restoration_type == RESTORE_NONE &&
(rsi[plane].frame_restoration_type == RESTORE_NONE)) { rsi[2].frame_restoration_type == RESTORE_NONE) {
if (dst) copy_funs[plane](frame, dst); return;
return;
}
}
if (components_pattern ==
((1 << AOM_PLANE_Y) | (1 << AOM_PLANE_U) | (1 << AOM_PLANE_V))) {
// All components
if (rsi[0].frame_restoration_type == RESTORE_NONE &&
rsi[1].frame_restoration_type == RESTORE_NONE &&
rsi[2].frame_restoration_type == RESTORE_NONE) {
if (dst) aom_yv12_copy_frame(frame, dst);
return;
}
} }
if (!dst) { YV12_BUFFER_CONFIG dst;
dst = &dst_; memset(&dst, 0, sizeof(dst));
memset(dst, 0, sizeof(YV12_BUFFER_CONFIG)); const int frame_width = frame->crop_widths[0];
const int frame_width = frame->crop_widths[0]; const int frame_height = ALIGN_POWER_OF_TWO(frame->crop_heights[0], 3);
const int frame_height = ALIGN_POWER_OF_TWO(frame->crop_heights[0], 3); if (aom_realloc_frame_buffer(
if (aom_realloc_frame_buffer(dst, frame_width, frame_height, &dst, frame_width, frame_height, cm->subsampling_x, cm->subsampling_y,
cm->subsampling_x, cm->subsampling_y,
#if CONFIG_HIGHBITDEPTH #if CONFIG_HIGHBITDEPTH
cm->use_highbitdepth, cm->use_highbitdepth,
#endif #endif
AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL) < 0)
NULL, NULL) < 0) aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR, "Failed to allocate restoration dst buffer");
"Failed to allocate restoration dst buffer");
}
#if CONFIG_STRIPED_LOOP_RESTORATION #if CONFIG_STRIPED_LOOP_RESTORATION
RestorationLineBuffers rlbs; RestorationLineBuffers rlbs;
...@@ -1413,11 +1394,10 @@ void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame, ...@@ -1413,11 +1394,10 @@ void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame,
#endif #endif
for (int plane = 0; plane < 3; ++plane) { for (int plane = 0; plane < 3; ++plane) {
if (!((components_pattern >> plane) & 1)) continue;
const RestorationInfo *prsi = &rsi[plane]; const RestorationInfo *prsi = &rsi[plane];
RestorationType rtype = prsi->frame_restoration_type; RestorationType rtype = prsi->frame_restoration_type;
if (rtype == RESTORE_NONE) { if (rtype == RESTORE_NONE) {
copy_funs[plane](frame, dst); copy_funs[plane](frame, &dst);
continue; continue;
} }
...@@ -1442,23 +1422,19 @@ void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame, ...@@ -1442,23 +1422,19 @@ void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame,
ctxt.highbd = highbd; ctxt.highbd = highbd;
ctxt.bit_depth = bit_depth; ctxt.bit_depth = bit_depth;
ctxt.data8 = frame->buffers[plane]; ctxt.data8 = frame->buffers[plane];
ctxt.dst8 = dst->buffers[plane]; ctxt.dst8 = dst.buffers[plane];
ctxt.data_stride = frame->strides[is_uv]; ctxt.data_stride = frame->strides[is_uv];
ctxt.dst_stride = dst->strides[is_uv]; ctxt.dst_stride = dst.strides[is_uv];
ctxt.tmpbuf = cm->rst_tmpbuf; ctxt.tmpbuf = cm->rst_tmpbuf;
av1_foreach_rest_unit_in_frame(cm, plane, filter_frame_on_tile, av1_foreach_rest_unit_in_frame(cm, plane, filter_frame_on_tile,
filter_frame_on_unit, &ctxt); filter_frame_on_unit, &ctxt);
} }
if (dst == &dst_) { for (int plane = 0; plane < 3; ++plane) {
for (int plane = 0; plane < 3; ++plane) { copy_funs[plane](&dst, frame);
if ((components_pattern >> plane) & 1) {
copy_funs[plane](dst, frame);
}
}
aom_free_frame_buffer(dst);
} }
aom_free_frame_buffer(&dst);
} }
static void foreach_rest_unit_in_tile(const AV1PixelRect *tile_rect, static void foreach_rest_unit_in_tile(const AV1PixelRect *tile_rect,
......
...@@ -322,9 +322,7 @@ void av1_loop_restoration_filter_unit( ...@@ -322,9 +322,7 @@ void av1_loop_restoration_filter_unit(
void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame, void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame,
struct AV1Common *cm, struct AV1Common *cm,
RestorationInfo *rsi, RestorationInfo *rsi);
int components_pattern,
YV12_BUFFER_CONFIG *dst);
void av1_loop_restoration_precal(); void av1_loop_restoration_precal();
typedef void (*rest_unit_visitor_t)(const RestorationTileLimits *limits, typedef void (*rest_unit_visitor_t)(const RestorationTileLimits *limits,
......
...@@ -3692,7 +3692,7 @@ void av1_decode_tg_tiles_and_wrapup(AV1Decoder *pbi, const uint8_t *data, ...@@ -3692,7 +3692,7 @@ void av1_decode_tg_tiles_and_wrapup(AV1Decoder *pbi, const uint8_t *data,
av1_loop_restoration_save_boundary_lines(&pbi->cur_buf->buf, cm, 1); av1_loop_restoration_save_boundary_lines(&pbi->cur_buf->buf, cm, 1);
#endif #endif
av1_loop_restoration_filter_frame((YV12_BUFFER_CONFIG *)xd->cur_buf, cm, av1_loop_restoration_filter_frame((YV12_BUFFER_CONFIG *)xd->cur_buf, cm,
cm->rst_info, 7, NULL); cm->rst_info);
} }
#endif // CONFIG_LOOP_RESTORATION #endif // CONFIG_LOOP_RESTORATION
......
...@@ -4766,8 +4766,7 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) { ...@@ -4766,8 +4766,7 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
if (cm->rst_info[0].frame_restoration_type != RESTORE_NONE || if (cm->rst_info[0].frame_restoration_type != RESTORE_NONE ||
cm->rst_info[1].frame_restoration_type != RESTORE_NONE || cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
cm->rst_info[2].frame_restoration_type != RESTORE_NONE) { cm->rst_info[2].frame_restoration_type != RESTORE_NONE) {
av1_loop_restoration_filter_frame(cm->frame_to_show, cm, cm->rst_info, 7, av1_loop_restoration_filter_frame(cm->frame_to_show, cm, cm->rst_info);
NULL);
} }
} }
#endif // CONFIG_LOOP_RESTORATION #endif // CONFIG_LOOP_RESTORATION
......
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