diff options
Diffstat (limited to 'third_party/aom/aom_scale')
-rw-r--r-- | third_party/aom/aom_scale/aom_scale.cmake | 2 | ||||
-rw-r--r-- | third_party/aom/aom_scale/aom_scale_rtcd.pl | 24 | ||||
-rw-r--r-- | third_party/aom/aom_scale/generic/aom_scale.c | 76 | ||||
-rw-r--r-- | third_party/aom/aom_scale/generic/yv12config.c | 13 | ||||
-rw-r--r-- | third_party/aom/aom_scale/generic/yv12extend.c | 167 | ||||
-rw-r--r-- | third_party/aom/aom_scale/yv12config.h | 70 |
6 files changed, 156 insertions, 196 deletions
diff --git a/third_party/aom/aom_scale/aom_scale.cmake b/third_party/aom/aom_scale/aom_scale.cmake index b52fd83dc..1c00b590e 100644 --- a/third_party/aom/aom_scale/aom_scale.cmake +++ b/third_party/aom/aom_scale/aom_scale.cmake @@ -30,7 +30,7 @@ function (setup_aom_scale_targets) if (HAVE_DSPR2) add_intrinsics_object_library("" "dspr2" "aom_scale" - "AOM_SCALE_INTRIN_DSPR2" "aom_scale") + "AOM_SCALE_INTRIN_DSPR2" "aom") endif () set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_scale PARENT_SCOPE) diff --git a/third_party/aom/aom_scale/aom_scale_rtcd.pl b/third_party/aom/aom_scale/aom_scale_rtcd.pl index 9d9a1a29a..c44966f96 100644 --- a/third_party/aom/aom_scale/aom_scale_rtcd.pl +++ b/third_party/aom/aom_scale/aom_scale_rtcd.pl @@ -7,13 +7,13 @@ forward_decls qw/aom_scale_forward_decls/; # Scaler functions if (aom_config("CONFIG_SPATIAL_RESAMPLING") eq "yes") { - add_proto qw/void aom_horizontal_line_5_4_scale/, "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"; - add_proto qw/void aom_vertical_band_5_4_scale/, "unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width"; - add_proto qw/void aom_horizontal_line_5_3_scale/, "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"; - add_proto qw/void aom_vertical_band_5_3_scale/, "unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width"; - add_proto qw/void aom_horizontal_line_2_1_scale/, "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"; - add_proto qw/void aom_vertical_band_2_1_scale/, "unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width"; - add_proto qw/void aom_vertical_band_2_1_scale_i/, "unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width"; + add_proto qw/void aom_horizontal_line_5_4_scale/, "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"; + add_proto qw/void aom_vertical_band_5_4_scale/, "unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width"; + add_proto qw/void aom_horizontal_line_5_3_scale/, "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"; + add_proto qw/void aom_vertical_band_5_3_scale/, "unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width"; + add_proto qw/void aom_horizontal_line_2_1_scale/, "const unsigned char *source, unsigned int source_width, unsigned char *dest, unsigned int dest_width"; + add_proto qw/void aom_vertical_band_2_1_scale/, "unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width"; + add_proto qw/void aom_vertical_band_2_1_scale_i/, "unsigned char *source, int src_pitch, unsigned char *dest, int dest_pitch, unsigned int dest_width"; } add_proto qw/void aom_yv12_extend_frame_borders/, "struct yv12_buffer_config *ybf"; @@ -27,12 +27,12 @@ add_proto qw/void aom_yv12_copy_u/, "const struct yv12_buffer_config *src_bc, st add_proto qw/void aom_yv12_copy_v/, "const struct yv12_buffer_config *src_bc, struct yv12_buffer_config *dst_bc"; if (aom_config("CONFIG_AV1") eq "yes") { - add_proto qw/void aom_extend_frame_borders/, "struct yv12_buffer_config *ybf"; - specialize qw/aom_extend_frame_borders dspr2/; + add_proto qw/void aom_extend_frame_borders/, "struct yv12_buffer_config *ybf"; + specialize qw/aom_extend_frame_borders dspr2/; - add_proto qw/void aom_extend_frame_inner_borders/, "struct yv12_buffer_config *ybf"; - specialize qw/aom_extend_frame_inner_borders dspr2/; + add_proto qw/void aom_extend_frame_inner_borders/, "struct yv12_buffer_config *ybf"; + specialize qw/aom_extend_frame_inner_borders dspr2/; - add_proto qw/void aom_extend_frame_borders_y/, "struct yv12_buffer_config *ybf"; + add_proto qw/void aom_extend_frame_borders_y/, "struct yv12_buffer_config *ybf"; } 1; diff --git a/third_party/aom/aom_scale/generic/aom_scale.c b/third_party/aom/aom_scale/generic/aom_scale.c index 14f3ae0da..d124832b7 100644 --- a/third_party/aom/aom_scale/generic/aom_scale.c +++ b/third_party/aom/aom_scale/generic/aom_scale.c @@ -476,54 +476,30 @@ void aom_scale_frame(YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, unsigned int hscale, unsigned int hratio, unsigned int vscale, unsigned int vratio, unsigned int interlaced) { - int i; - int dw = (hscale - 1 + src->y_width * hratio) / hscale; - int dh = (vscale - 1 + src->y_height * vratio) / vscale; - - /* call our internal scaling routines!! */ - Scale2D((unsigned char *)src->y_buffer, src->y_stride, src->y_width, - src->y_height, (unsigned char *)dst->y_buffer, dst->y_stride, dw, dh, - temp_area, temp_height, hscale, hratio, vscale, vratio, interlaced); - - if (dw < (int)dst->y_width) - for (i = 0; i < dh; ++i) - memset(dst->y_buffer + i * dst->y_stride + dw - 1, - dst->y_buffer[i * dst->y_stride + dw - 2], dst->y_width - dw + 1); - - if (dh < (int)dst->y_height) - for (i = dh - 1; i < (int)dst->y_height; ++i) - memcpy(dst->y_buffer + i * dst->y_stride, - dst->y_buffer + (dh - 2) * dst->y_stride, dst->y_width + 1); - - Scale2D((unsigned char *)src->u_buffer, src->uv_stride, src->uv_width, - src->uv_height, (unsigned char *)dst->u_buffer, dst->uv_stride, - dw / 2, dh / 2, temp_area, temp_height, hscale, hratio, vscale, - vratio, interlaced); - - if (dw / 2 < (int)dst->uv_width) - for (i = 0; i < dst->uv_height; ++i) - memset(dst->u_buffer + i * dst->uv_stride + dw / 2 - 1, - dst->u_buffer[i * dst->uv_stride + dw / 2 - 2], - dst->uv_width - dw / 2 + 1); - - if (dh / 2 < (int)dst->uv_height) - for (i = dh / 2 - 1; i < (int)dst->y_height / 2; ++i) - memcpy(dst->u_buffer + i * dst->uv_stride, - dst->u_buffer + (dh / 2 - 2) * dst->uv_stride, dst->uv_width); - - Scale2D((unsigned char *)src->v_buffer, src->uv_stride, src->uv_width, - src->uv_height, (unsigned char *)dst->v_buffer, dst->uv_stride, - dw / 2, dh / 2, temp_area, temp_height, hscale, hratio, vscale, - vratio, interlaced); - - if (dw / 2 < (int)dst->uv_width) - for (i = 0; i < dst->uv_height; ++i) - memset(dst->v_buffer + i * dst->uv_stride + dw / 2 - 1, - dst->v_buffer[i * dst->uv_stride + dw / 2 - 2], - dst->uv_width - dw / 2 + 1); - - if (dh / 2 < (int)dst->uv_height) - for (i = dh / 2 - 1; i < (int)dst->y_height / 2; ++i) - memcpy(dst->v_buffer + i * dst->uv_stride, - dst->v_buffer + (dh / 2 - 2) * dst->uv_stride, dst->uv_width); + const int dw = (hscale - 1 + src->y_width * hratio) / hscale; + const int dh = (vscale - 1 + src->y_height * vratio) / vscale; + + for (int plane = 0; plane < 3; ++plane) { + const int is_uv = plane > 0; + const int plane_dw = dw >> is_uv; + const int plane_dh = dh >> is_uv; + + Scale2D((unsigned char *)src->buffers[plane], src->strides[is_uv], + src->widths[is_uv], src->heights[is_uv], + (unsigned char *)dst->buffers[plane], dst->strides[is_uv], plane_dw, + plane_dh, temp_area, temp_height, hscale, hratio, vscale, vratio, + interlaced); + + if (plane_dw < dst->widths[is_uv]) + for (int i = 0; i < plane_dh; ++i) + memset(dst->buffers[plane] + i * dst->strides[is_uv] + plane_dw - 1, + dst->buffers[plane][i * dst->strides[is_uv] + plane_dw - 2], + dst->widths[is_uv] - plane_dw + 1); + + if (plane_dh < dst->heights[is_uv]) + for (int i = plane_dh - 1; i < dst->heights[is_uv]; ++i) + memcpy(dst->buffers[plane] + i * dst->strides[is_uv], + dst->buffers[plane] + (plane_dh - 2) * dst->strides[is_uv], + dst->widths[is_uv] + 1); + } } diff --git a/third_party/aom/aom_scale/generic/yv12config.c b/third_party/aom/aom_scale/generic/yv12config.c index ee15ae103..fce719273 100644 --- a/third_party/aom/aom_scale/generic/yv12config.c +++ b/third_party/aom/aom_scale/generic/yv12config.c @@ -11,9 +11,9 @@ #include <assert.h> -#include "aom_scale/yv12config.h" #include "aom_mem/aom_mem.h" #include "aom_ports/mem.h" +#include "aom_scale/yv12config.h" /**************************************************************************** * Exports @@ -35,7 +35,7 @@ int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf) { } #if CONFIG_HIGHBITDEPTH && CONFIG_GLOBAL_MOTION - if (ybf->y_buffer_8bit) free(ybf->y_buffer_8bit); + if (ybf->y_buffer_8bit) aom_free(ybf->y_buffer_8bit); #endif /* buffer_alloc isn't accessed by most functions. Rather y_buffer, @@ -168,9 +168,12 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, aom_byte_align); #if CONFIG_HIGHBITDEPTH && CONFIG_GLOBAL_MOTION - if (ybf->y_buffer_8bit) { - free(ybf->y_buffer_8bit); - ybf->y_buffer_8bit = NULL; + if (use_highbitdepth) { + if (ybf->y_buffer_8bit) aom_free(ybf->y_buffer_8bit); + ybf->y_buffer_8bit = (uint8_t *)aom_memalign(32, (size_t)yplane_size); + if (!ybf->y_buffer_8bit) return -1; + } else { + assert(!ybf->y_buffer_8bit); } #endif diff --git a/third_party/aom/aom_scale/generic/yv12extend.c b/third_party/aom/aom_scale/generic/yv12extend.c index 05e463362..8266743cf 100644 --- a/third_party/aom/aom_scale/generic/yv12extend.c +++ b/third_party/aom/aom_scale/generic/yv12extend.c @@ -101,8 +101,6 @@ static void extend_plane_high(uint8_t *const src8, int src_stride, int width, #endif void aom_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) { - const int uv_border = ybf->border / 2; - assert(ybf->border % 2 == 0); assert(ybf->y_height - ybf->y_crop_height < 16); assert(ybf->y_width - ybf->y_crop_width < 16); @@ -111,49 +109,33 @@ void aom_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) { #if CONFIG_HIGHBITDEPTH if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) { - extend_plane_high(ybf->y_buffer, ybf->y_stride, ybf->y_crop_width, - ybf->y_crop_height, ybf->border, ybf->border, - ybf->border + ybf->y_height - ybf->y_crop_height, - ybf->border + ybf->y_width - ybf->y_crop_width); - - extend_plane_high(ybf->u_buffer, ybf->uv_stride, ybf->uv_crop_width, - ybf->uv_crop_height, uv_border, uv_border, - uv_border + ybf->uv_height - ybf->uv_crop_height, - uv_border + ybf->uv_width - ybf->uv_crop_width); - - extend_plane_high(ybf->v_buffer, ybf->uv_stride, ybf->uv_crop_width, - ybf->uv_crop_height, uv_border, uv_border, - uv_border + ybf->uv_height - ybf->uv_crop_height, - uv_border + ybf->uv_width - ybf->uv_crop_width); + for (int plane = 0; plane < 3; ++plane) { + const int is_uv = plane > 0; + const int plane_border = ybf->border >> is_uv; + extend_plane_high( + ybf->buffers[plane], ybf->strides[is_uv], ybf->crop_widths[is_uv], + ybf->crop_heights[is_uv], plane_border, plane_border, + plane_border + ybf->heights[is_uv] - ybf->crop_heights[is_uv], + plane_border + ybf->widths[is_uv] - ybf->crop_widths[is_uv]); + } return; } #endif - extend_plane(ybf->y_buffer, ybf->y_stride, ybf->y_crop_width, - ybf->y_crop_height, ybf->border, ybf->border, - ybf->border + ybf->y_height - ybf->y_crop_height, - ybf->border + ybf->y_width - ybf->y_crop_width); - - extend_plane(ybf->u_buffer, ybf->uv_stride, ybf->uv_crop_width, - ybf->uv_crop_height, uv_border, uv_border, - uv_border + ybf->uv_height - ybf->uv_crop_height, - uv_border + ybf->uv_width - ybf->uv_crop_width); - - extend_plane(ybf->v_buffer, ybf->uv_stride, ybf->uv_crop_width, - ybf->uv_crop_height, uv_border, uv_border, - uv_border + ybf->uv_height - ybf->uv_crop_height, - uv_border + ybf->uv_width - ybf->uv_crop_width); + for (int plane = 0; plane < 3; ++plane) { + const int is_uv = plane > 0; + const int plane_border = ybf->border >> is_uv; + extend_plane(ybf->buffers[plane], ybf->strides[is_uv], + ybf->crop_widths[is_uv], ybf->crop_heights[is_uv], + plane_border, plane_border, + plane_border + ybf->heights[is_uv] - ybf->crop_heights[is_uv], + plane_border + ybf->widths[is_uv] - ybf->crop_widths[is_uv]); + } } #if CONFIG_AV1 static void extend_frame(YV12_BUFFER_CONFIG *const ybf, int ext_size) { - const int c_w = ybf->uv_crop_width; - const int c_h = ybf->uv_crop_height; const int ss_x = ybf->uv_width < ybf->y_width; const int ss_y = ybf->uv_height < ybf->y_height; - const int c_et = ext_size >> ss_y; - const int c_el = ext_size >> ss_x; - const int c_eb = c_et + ybf->uv_height - ybf->uv_crop_height; - const int c_er = c_el + ybf->uv_width - ybf->uv_crop_width; assert(ybf->y_height - ybf->y_crop_height < 16); assert(ybf->y_width - ybf->y_crop_width < 16); @@ -162,25 +144,29 @@ static void extend_frame(YV12_BUFFER_CONFIG *const ybf, int ext_size) { #if CONFIG_HIGHBITDEPTH if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) { - extend_plane_high(ybf->y_buffer, ybf->y_stride, ybf->y_crop_width, - ybf->y_crop_height, ext_size, ext_size, - ext_size + ybf->y_height - ybf->y_crop_height, - ext_size + ybf->y_width - ybf->y_crop_width); - extend_plane_high(ybf->u_buffer, ybf->uv_stride, c_w, c_h, c_et, c_el, c_eb, - c_er); - extend_plane_high(ybf->v_buffer, ybf->uv_stride, c_w, c_h, c_et, c_el, c_eb, - c_er); + for (int plane = 0; plane < 3; ++plane) { + const int is_uv = plane > 0; + const int top = ext_size >> (is_uv ? ss_y : 0); + const int left = ext_size >> (is_uv ? ss_x : 0); + const int bottom = top + ybf->heights[is_uv] - ybf->crop_heights[is_uv]; + const int right = left + ybf->widths[is_uv] - ybf->crop_widths[is_uv]; + extend_plane_high(ybf->buffers[plane], ybf->strides[is_uv], + ybf->crop_widths[is_uv], ybf->crop_heights[is_uv], top, + left, bottom, right); + } return; } #endif - extend_plane(ybf->y_buffer, ybf->y_stride, ybf->y_crop_width, - ybf->y_crop_height, ext_size, ext_size, - ext_size + ybf->y_height - ybf->y_crop_height, - ext_size + ybf->y_width - ybf->y_crop_width); - - extend_plane(ybf->u_buffer, ybf->uv_stride, c_w, c_h, c_et, c_el, c_eb, c_er); - - extend_plane(ybf->v_buffer, ybf->uv_stride, c_w, c_h, c_et, c_el, c_eb, c_er); + for (int plane = 0; plane < 3; ++plane) { + const int is_uv = plane > 0; + const int top = ext_size >> (is_uv ? ss_y : 0); + const int left = ext_size >> (is_uv ? ss_x : 0); + const int bottom = top + ybf->heights[is_uv] - ybf->crop_heights[is_uv]; + const int right = left + ybf->widths[is_uv] - ybf->crop_widths[is_uv]; + extend_plane(ybf->buffers[plane], ybf->strides[is_uv], + ybf->crop_widths[is_uv], ybf->crop_heights[is_uv], top, left, + bottom, right); + } } void aom_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) { @@ -230,10 +216,6 @@ static void memcpy_short_addr(uint8_t *dst8, const uint8_t *src8, int num) { // Note: The frames are assumed to be identical in size. void aom_yv12_copy_frame_c(const YV12_BUFFER_CONFIG *src_bc, YV12_BUFFER_CONFIG *dst_bc) { - int row; - const uint8_t *src = src_bc->y_buffer; - uint8_t *dst = dst_bc->y_buffer; - #if 0 /* These assertions are valid in the codec, but the libaom-tester uses * this code slightly differently. @@ -243,63 +225,36 @@ void aom_yv12_copy_frame_c(const YV12_BUFFER_CONFIG *src_bc, #endif #if CONFIG_HIGHBITDEPTH - if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) { - assert(dst_bc->flags & YV12_FLAG_HIGHBITDEPTH); - for (row = 0; row < src_bc->y_height; ++row) { - memcpy_short_addr(dst, src, src_bc->y_width); - src += src_bc->y_stride; - dst += dst_bc->y_stride; - } - - src = src_bc->u_buffer; - dst = dst_bc->u_buffer; - - for (row = 0; row < src_bc->uv_height; ++row) { - memcpy_short_addr(dst, src, src_bc->uv_width); - src += src_bc->uv_stride; - dst += dst_bc->uv_stride; - } - - src = src_bc->v_buffer; - dst = dst_bc->v_buffer; + assert((src_bc->flags & YV12_FLAG_HIGHBITDEPTH) == + (dst_bc->flags & YV12_FLAG_HIGHBITDEPTH)); - for (row = 0; row < src_bc->uv_height; ++row) { - memcpy_short_addr(dst, src, src_bc->uv_width); - src += src_bc->uv_stride; - dst += dst_bc->uv_stride; + if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) { + for (int plane = 0; plane < 3; ++plane) { + const uint8_t *plane_src = src_bc->buffers[plane]; + uint8_t *plane_dst = dst_bc->buffers[plane]; + const int is_uv = plane > 0; + + for (int row = 0; row < src_bc->heights[is_uv]; ++row) { + memcpy_short_addr(plane_dst, plane_src, src_bc->widths[is_uv]); + plane_src += src_bc->strides[is_uv]; + plane_dst += dst_bc->strides[is_uv]; + } } - aom_yv12_extend_frame_borders_c(dst_bc); return; - } else { - assert(!(dst_bc->flags & YV12_FLAG_HIGHBITDEPTH)); } #endif - - for (row = 0; row < src_bc->y_height; ++row) { - memcpy(dst, src, src_bc->y_width); - src += src_bc->y_stride; - dst += dst_bc->y_stride; - } - - src = src_bc->u_buffer; - dst = dst_bc->u_buffer; - - for (row = 0; row < src_bc->uv_height; ++row) { - memcpy(dst, src, src_bc->uv_width); - src += src_bc->uv_stride; - dst += dst_bc->uv_stride; - } - - src = src_bc->v_buffer; - dst = dst_bc->v_buffer; - - for (row = 0; row < src_bc->uv_height; ++row) { - memcpy(dst, src, src_bc->uv_width); - src += src_bc->uv_stride; - dst += dst_bc->uv_stride; + for (int plane = 0; plane < 3; ++plane) { + const uint8_t *plane_src = src_bc->buffers[plane]; + uint8_t *plane_dst = dst_bc->buffers[plane]; + const int is_uv = plane > 0; + + for (int row = 0; row < src_bc->heights[is_uv]; ++row) { + memcpy(plane_dst, plane_src, src_bc->widths[is_uv]); + plane_src += src_bc->strides[is_uv]; + plane_dst += dst_bc->strides[is_uv]; + } } - aom_yv12_extend_frame_borders_c(dst_bc); } diff --git a/third_party/aom/aom_scale/yv12config.h b/third_party/aom/aom_scale/yv12config.h index 76bfe9d7b..0c47f650d 100644 --- a/third_party/aom/aom_scale/yv12config.h +++ b/third_party/aom/aom_scale/yv12config.h @@ -34,31 +34,59 @@ extern "C" { #define AOM_BORDER_IN_PIXELS 160 typedef struct yv12_buffer_config { - int y_width; - int y_height; - int y_crop_width; - int y_crop_height; - int y_stride; - - int uv_width; - int uv_height; - int uv_crop_width; - int uv_crop_height; - int uv_stride; - - int alpha_width; - int alpha_height; - int alpha_stride; - - uint8_t *y_buffer; - uint8_t *u_buffer; - uint8_t *v_buffer; - uint8_t *alpha_buffer; + union { + struct { + int y_width; + int uv_width; + int alpha_width; + }; + int widths[3]; + }; + union { + struct { + int y_height; + int uv_height; + int alpha_height; + }; + int heights[3]; + }; + union { + struct { + int y_crop_width; + int uv_crop_width; + }; + int crop_widths[2]; + }; + union { + struct { + int y_crop_height; + int uv_crop_height; + }; + int crop_heights[2]; + }; + union { + struct { + int y_stride; + int uv_stride; + int alpha_stride; + }; + int strides[3]; + }; + union { + struct { + uint8_t *y_buffer; + uint8_t *u_buffer; + uint8_t *v_buffer; + uint8_t *alpha_buffer; + }; + uint8_t *buffers[4]; + }; #if CONFIG_HIGHBITDEPTH && CONFIG_GLOBAL_MOTION // If the frame is stored in a 16-bit buffer, this stores an 8-bit version // for use in global motion detection. It is allocated on-demand. uint8_t *y_buffer_8bit; + int buf_8bit_valid; #endif uint8_t *buffer_alloc; @@ -69,10 +97,8 @@ typedef struct yv12_buffer_config { int subsampling_y; unsigned int bit_depth; aom_color_space_t color_space; -#if CONFIG_COLORSPACE_HEADERS aom_transfer_function_t transfer_function; aom_chroma_sample_position_t chroma_sample_position; -#endif aom_color_range_t color_range; int render_width; int render_height; |