diff options
Diffstat (limited to 'chromium/third_party/libaom/source/libaom/aom_scale')
5 files changed, 204 insertions, 63 deletions
diff --git a/chromium/third_party/libaom/source/libaom/aom_scale/aom_scale.cmake b/chromium/third_party/libaom/source/libaom/aom_scale/aom_scale.cmake index 197dea6bd20..e83299320fc 100644 --- a/chromium/third_party/libaom/source/libaom/aom_scale/aom_scale.cmake +++ b/chromium/third_party/libaom/source/libaom/aom_scale/aom_scale.cmake @@ -31,8 +31,15 @@ function(setup_aom_scale_targets) if(HAVE_DSPR2) add_intrinsics_object_library("" "dspr2" "aom_scale" - "AOM_SCALE_INTRIN_DSPR2" "aom") + "AOM_SCALE_INTRIN_DSPR2") endif() + target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_scale>) + if(BUILD_SHARED_LIBS) + target_sources(aom_static PRIVATE $<TARGET_OBJECTS:aom_scale>) + endif() + + # Pass the new lib targets up to the parent scope instance of + # $AOM_LIB_TARGETS. set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_scale PARENT_SCOPE) endfunction() diff --git a/chromium/third_party/libaom/source/libaom/aom_scale/aom_scale_rtcd.pl b/chromium/third_party/libaom/source/libaom/aom_scale/aom_scale_rtcd.pl index 27378c7ef49..eef6f16a74c 100644 --- a/chromium/third_party/libaom/source/libaom/aom_scale/aom_scale_rtcd.pl +++ b/chromium/third_party/libaom/source/libaom/aom_scale/aom_scale_rtcd.pl @@ -26,6 +26,8 @@ if (aom_config("CONFIG_SPATIAL_RESAMPLING") eq "yes") { 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/int aom_yv12_realloc_with_new_border/, "struct yv12_buffer_config *ybf, int new_border, int byte_alignment, int num_planes"; + add_proto qw/void aom_yv12_extend_frame_borders/, "struct yv12_buffer_config *ybf, const int num_planes"; add_proto qw/void aom_yv12_copy_frame/, "const struct yv12_buffer_config *src_bc, struct yv12_buffer_config *dst_bc, const int num_planes"; diff --git a/chromium/third_party/libaom/source/libaom/aom_scale/generic/yv12config.c b/chromium/third_party/libaom/source/libaom/aom_scale/generic/yv12config.c index dafe02b1716..1f80d7ba720 100644 --- a/chromium/third_party/libaom/source/libaom/aom_scale/generic/yv12config.c +++ b/chromium/third_party/libaom/source/libaom/aom_scale/generic/yv12config.c @@ -11,6 +11,7 @@ #include <assert.h> +#include "aom/internal/aom_image_internal.h" #include "aom_mem/aom_mem.h" #include "aom_ports/mem.h" #include "aom_scale/yv12config.h" @@ -23,60 +24,35 @@ /**************************************************************************** * ****************************************************************************/ -#define yv12_align_addr(addr, align) \ - (void *)(((size_t)(addr) + ((align)-1)) & (size_t) - (align)) // TODO(jkoleszar): Maybe replace this with struct aom_image - int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf) { if (ybf) { if (ybf->buffer_alloc_sz > 0) { aom_free(ybf->buffer_alloc); } if (ybf->y_buffer_8bit) aom_free(ybf->y_buffer_8bit); - + aom_remove_metadata_from_frame_buffer(ybf); /* buffer_alloc isn't accessed by most functions. Rather y_buffer, u_buffer and v_buffer point to buffer_alloc and are used. Clear out all of this so that a freed pointer isn't inadvertently used */ memset(ybf, 0, sizeof(YV12_BUFFER_CONFIG)); - } else { - return -1; + return 0; } - return 0; + return AOM_CODEC_MEM_ERROR; } -int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, - int ss_x, int ss_y, int use_highbitdepth, - int border, int byte_alignment, - aom_codec_frame_buffer_t *fb, - aom_get_frame_buffer_cb_fn_t cb, void *cb_priv) { -#if CONFIG_SIZE_LIMIT - if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT) return -1; -#endif - - /* Only support allocating buffers that have a border that's a multiple - * of 32. The border restriction is required to get 16-byte alignment of - * the start of the chroma rows without introducing an arbitrary gap - * between planes, which would break the semantics of things like - * aom_img_set_rect(). */ - if (border & 0x1f) return -3; - +static int realloc_frame_buffer_aligned( + YV12_BUFFER_CONFIG *ybf, int width, int height, int ss_x, int ss_y, + int use_highbitdepth, int border, int byte_alignment, + aom_codec_frame_buffer_t *fb, aom_get_frame_buffer_cb_fn_t cb, + void *cb_priv, const int y_stride, const uint64_t yplane_size, + const uint64_t uvplane_size, const int aligned_width, + const int aligned_height, const int uv_width, const int uv_height, + const int uv_stride, const int uv_border_w, const int uv_border_h) { if (ybf) { const int aom_byte_align = (byte_alignment == 0) ? 1 : byte_alignment; - const int aligned_width = (width + 7) & ~7; - const int aligned_height = (height + 7) & ~7; - const int y_stride = ((aligned_width + 2 * border) + 31) & ~31; - const uint64_t yplane_size = - (aligned_height + 2 * border) * (uint64_t)y_stride + byte_alignment; - const int uv_width = aligned_width >> ss_x; - const int uv_height = aligned_height >> ss_y; - const int uv_stride = y_stride >> ss_x; - const int uv_border_w = border >> ss_x; - const int uv_border_h = border >> ss_y; - const uint64_t uvplane_size = - (uv_height + 2 * uv_border_h) * (uint64_t)uv_stride + byte_alignment; - const uint64_t frame_size = (1 + use_highbitdepth) * (yplane_size + 2 * uvplane_size); @@ -90,7 +66,8 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, // The decoder may allocate REF_FRAMES frame buffers in the frame buffer // pool. Bound the total amount of allocated memory as if these REF_FRAMES // frame buffers were allocated in a single allocation. - if (alloc_size > AOM_MAX_ALLOCABLE_MEMORY / REF_FRAMES) return -1; + if (alloc_size > AOM_MAX_ALLOCABLE_MEMORY / REF_FRAMES) + return AOM_CODEC_MEM_ERROR; #endif if (cb != NULL) { @@ -99,14 +76,17 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, assert(fb != NULL); - if (external_frame_size != (size_t)external_frame_size) return -1; + if (external_frame_size != (size_t)external_frame_size) + return AOM_CODEC_MEM_ERROR; // Allocation to hold larger frame, or first allocation. - if (cb(cb_priv, (size_t)external_frame_size, fb) < 0) return -1; + if (cb(cb_priv, (size_t)external_frame_size, fb) < 0) + return AOM_CODEC_MEM_ERROR; - if (fb->data == NULL || fb->size < external_frame_size) return -1; + if (fb->data == NULL || fb->size < external_frame_size) + return AOM_CODEC_MEM_ERROR; - ybf->buffer_alloc = (uint8_t *)yv12_align_addr(fb->data, 32); + ybf->buffer_alloc = (uint8_t *)aom_align_addr(fb->data, 32); #if defined(__has_feature) #if __has_feature(memory_sanitizer) @@ -122,10 +102,10 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, ybf->buffer_alloc = NULL; ybf->buffer_alloc_sz = 0; - if (frame_size != (size_t)frame_size) return -1; + if (frame_size != (size_t)frame_size) return AOM_CODEC_MEM_ERROR; ybf->buffer_alloc = (uint8_t *)aom_memalign(32, (size_t)frame_size); - if (!ybf->buffer_alloc) return -1; + if (!ybf->buffer_alloc) return AOM_CODEC_MEM_ERROR; ybf->buffer_alloc_sz = (size_t)frame_size; @@ -161,22 +141,22 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, ybf->flags = 0; } - ybf->y_buffer = (uint8_t *)yv12_align_addr( + ybf->y_buffer = (uint8_t *)aom_align_addr( buf + (border * y_stride) + border, aom_byte_align); - ybf->u_buffer = (uint8_t *)yv12_align_addr( + ybf->u_buffer = (uint8_t *)aom_align_addr( buf + yplane_size + (uv_border_h * uv_stride) + uv_border_w, aom_byte_align); ybf->v_buffer = - (uint8_t *)yv12_align_addr(buf + yplane_size + uvplane_size + - (uv_border_h * uv_stride) + uv_border_w, - aom_byte_align); + (uint8_t *)aom_align_addr(buf + yplane_size + uvplane_size + + (uv_border_h * uv_stride) + uv_border_w, + aom_byte_align); ybf->use_external_reference_buffers = 0; 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; + if (!ybf->y_buffer_8bit) return AOM_CODEC_MEM_ERROR; } else { if (ybf->y_buffer_8bit) { aom_free(ybf->y_buffer_8bit); @@ -188,7 +168,65 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, ybf->corrupted = 0; /* assume not corrupted by errors */ return 0; } - return -2; + return AOM_CODEC_MEM_ERROR; +} + +static int calc_stride_and_planesize(const int ss_x, const int ss_y, + const int aligned_width, + const int aligned_height, const int border, + const int byte_alignment, int *y_stride, + int *uv_stride, uint64_t *yplane_size, + uint64_t *uvplane_size, + const int uv_height) { + /* Only support allocating buffers that have a border that's a multiple + * of 32. The border restriction is required to get 16-byte alignment of + * the start of the chroma rows without introducing an arbitrary gap + * between planes, which would break the semantics of things like + * aom_img_set_rect(). */ + if (border & 0x1f) return AOM_CODEC_MEM_ERROR; + *y_stride = ((aligned_width + 2 * border) + 31) & ~31; + *yplane_size = + (aligned_height + 2 * border) * (uint64_t)(*y_stride) + byte_alignment; + + *uv_stride = *y_stride >> ss_x; + *uvplane_size = (uv_height + 2 * (border >> ss_y)) * (uint64_t)(*uv_stride) + + byte_alignment; + return 0; +} + +int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, + int ss_x, int ss_y, int use_highbitdepth, + int border, int byte_alignment, + aom_codec_frame_buffer_t *fb, + aom_get_frame_buffer_cb_fn_t cb, void *cb_priv) { +#if CONFIG_SIZE_LIMIT + if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT) + return AOM_CODEC_MEM_ERROR; +#endif + + if (ybf) { + int y_stride = 0; + int uv_stride = 0; + uint64_t yplane_size = 0; + uint64_t uvplane_size = 0; + const int aligned_width = (width + 7) & ~7; + const int aligned_height = (height + 7) & ~7; + const int uv_width = aligned_width >> ss_x; + const int uv_height = aligned_height >> ss_y; + const int uv_border_w = border >> ss_x; + const int uv_border_h = border >> ss_y; + + int error = calc_stride_and_planesize( + ss_x, ss_y, aligned_width, aligned_height, border, byte_alignment, + &y_stride, &uv_stride, &yplane_size, &uvplane_size, uv_height); + if (error) return error; + return realloc_frame_buffer_aligned( + ybf, width, height, ss_x, ss_y, use_highbitdepth, border, + byte_alignment, fb, cb, cb_priv, y_stride, yplane_size, uvplane_size, + aligned_width, aligned_height, uv_width, uv_height, uv_stride, + uv_border_w, uv_border_h); + } + return AOM_CODEC_MEM_ERROR; } int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, @@ -200,5 +238,32 @@ int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, use_highbitdepth, border, byte_alignment, NULL, NULL, NULL); } - return -2; + return AOM_CODEC_MEM_ERROR; +} + +void aom_remove_metadata_from_frame_buffer(YV12_BUFFER_CONFIG *ybf) { + if (ybf && ybf->metadata) { + aom_img_metadata_array_free(ybf->metadata); + ybf->metadata = NULL; + } +} + +int aom_copy_metadata_to_frame_buffer(YV12_BUFFER_CONFIG *ybf, + const aom_metadata_array_t *arr) { + if (!ybf || !arr || !arr->metadata_array) return -1; + aom_remove_metadata_from_frame_buffer(ybf); + ybf->metadata = aom_img_metadata_array_alloc(arr->sz); + if (!ybf->metadata) return -1; + for (size_t i = 0; i < ybf->metadata->sz; i++) { + ybf->metadata->metadata_array[i] = aom_img_metadata_alloc( + arr->metadata_array[i]->type, arr->metadata_array[i]->payload, + arr->metadata_array[i]->sz, arr->metadata_array[i]->insert_flag); + if (ybf->metadata->metadata_array[i] == NULL) { + aom_img_metadata_array_free(ybf->metadata); + ybf->metadata = NULL; + return -1; + } + } + ybf->metadata->sz = arr->sz; + return 0; } diff --git a/chromium/third_party/libaom/source/libaom/aom_scale/generic/yv12extend.c b/chromium/third_party/libaom/source/libaom/aom_scale/generic/yv12extend.c index 127ca231169..834a59dbffa 100644 --- a/chromium/third_party/libaom/source/libaom/aom_scale/generic/yv12extend.c +++ b/chromium/third_party/libaom/source/libaom/aom_scale/generic/yv12extend.c @@ -59,6 +59,7 @@ static void extend_plane(uint8_t *const src, int src_stride, int width, } } +#if CONFIG_AV1_HIGHBITDEPTH static void extend_plane_high(uint8_t *const src8, int src_stride, int width, int height, int extend_top, int extend_left, int extend_bottom, int extend_right) { @@ -99,6 +100,7 @@ static void extend_plane_high(uint8_t *const src8, int src_stride, int width, dst_ptr2 += src_stride; } } +#endif // CONFIG_AV1_HIGHBITDEPTH void aom_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf, const int num_planes) { @@ -108,6 +110,7 @@ void aom_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf, assert(ybf->y_height - ybf->y_crop_height >= 0); assert(ybf->y_width - ybf->y_crop_width >= 0); +#if CONFIG_AV1_HIGHBITDEPTH if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) { for (int plane = 0; plane < num_planes; ++plane) { const int is_uv = plane > 0; @@ -120,6 +123,8 @@ void aom_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf, } return; } +#endif + for (int plane = 0; plane < num_planes; ++plane) { const int is_uv = plane > 0; const int plane_border = ybf->border >> is_uv; @@ -141,6 +146,7 @@ static void extend_frame(YV12_BUFFER_CONFIG *const ybf, int ext_size, assert(ybf->y_height - ybf->y_crop_height >= 0); assert(ybf->y_width - ybf->y_crop_width >= 0); +#if CONFIG_AV1_HIGHBITDEPTH if (ybf->flags & YV12_FLAG_HIGHBITDEPTH) { for (int plane = 0; plane < num_planes; ++plane) { const int is_uv = plane > 0; @@ -154,6 +160,8 @@ static void extend_frame(YV12_BUFFER_CONFIG *const ybf, int ext_size, } return; } +#endif + for (int plane = 0; plane < num_planes; ++plane) { const int is_uv = plane > 0; const int top = ext_size >> (is_uv ? ss_y : 0); @@ -184,7 +192,7 @@ void aom_extend_frame_borders_y_c(YV12_BUFFER_CONFIG *ybf) { assert(ybf->y_width - ybf->y_crop_width < 16); assert(ybf->y_height - ybf->y_crop_height >= 0); assert(ybf->y_width - ybf->y_crop_width >= 0); - +#if CONFIG_AV1_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, @@ -192,17 +200,20 @@ void aom_extend_frame_borders_y_c(YV12_BUFFER_CONFIG *ybf) { ext_size + ybf->y_width - ybf->y_crop_width); 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); } +#if CONFIG_AV1_HIGHBITDEPTH static void memcpy_short_addr(uint8_t *dst8, const uint8_t *src8, int num) { uint16_t *dst = CONVERT_TO_SHORTPTR(dst8); uint16_t *src = CONVERT_TO_SHORTPTR(src8); memcpy(dst, src, num * sizeof(uint16_t)); } +#endif // Copies the source image into the destination image and updates the // destination's UMV borders. @@ -217,6 +228,7 @@ void aom_yv12_copy_frame_c(const YV12_BUFFER_CONFIG *src_bc, assert(src_bc->y_height == dst_bc->y_height); #endif +#if CONFIG_AV1_HIGHBITDEPTH assert((src_bc->flags & YV12_FLAG_HIGHBITDEPTH) == (dst_bc->flags & YV12_FLAG_HIGHBITDEPTH)); @@ -235,6 +247,7 @@ void aom_yv12_copy_frame_c(const YV12_BUFFER_CONFIG *src_bc, aom_yv12_extend_frame_borders_c(dst_bc, num_planes); return; } +#endif for (int plane = 0; plane < num_planes; ++plane) { const uint8_t *plane_src = src_bc->buffers[plane]; uint8_t *plane_dst = dst_bc->buffers[plane]; @@ -255,6 +268,7 @@ void aom_yv12_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc, const uint8_t *src = src_ybc->y_buffer; uint8_t *dst = dst_ybc->y_buffer; +#if CONFIG_AV1_HIGHBITDEPTH if (src_ybc->flags & YV12_FLAG_HIGHBITDEPTH) { const uint16_t *src16 = CONVERT_TO_SHORTPTR(src); uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst); @@ -265,6 +279,7 @@ void aom_yv12_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc, } return; } +#endif for (row = 0; row < src_ybc->y_height; ++row) { memcpy(dst, src, src_ybc->y_width); @@ -278,7 +293,7 @@ void aom_yv12_copy_u_c(const YV12_BUFFER_CONFIG *src_bc, int row; const uint8_t *src = src_bc->u_buffer; uint8_t *dst = dst_bc->u_buffer; - +#if CONFIG_AV1_HIGHBITDEPTH if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) { const uint16_t *src16 = CONVERT_TO_SHORTPTR(src); uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst); @@ -289,7 +304,7 @@ void aom_yv12_copy_u_c(const YV12_BUFFER_CONFIG *src_bc, } return; } - +#endif for (row = 0; row < src_bc->uv_height; ++row) { memcpy(dst, src, src_bc->uv_width); src += src_bc->uv_stride; @@ -302,7 +317,7 @@ void aom_yv12_copy_v_c(const YV12_BUFFER_CONFIG *src_bc, int row; const uint8_t *src = src_bc->v_buffer; uint8_t *dst = dst_bc->v_buffer; - +#if CONFIG_AV1_HIGHBITDEPTH if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) { const uint16_t *src16 = CONVERT_TO_SHORTPTR(src); uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst); @@ -313,7 +328,7 @@ void aom_yv12_copy_v_c(const YV12_BUFFER_CONFIG *src_bc, } return; } - +#endif for (row = 0; row < src_bc->uv_height; ++row) { memcpy(dst, src, src_bc->uv_width); src += src_bc->uv_stride; @@ -328,7 +343,7 @@ void aom_yv12_partial_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc, int hstart1, int row; const uint8_t *src = src_ybc->y_buffer; uint8_t *dst = dst_ybc->y_buffer; - +#if CONFIG_AV1_HIGHBITDEPTH if (src_ybc->flags & YV12_FLAG_HIGHBITDEPTH) { const uint16_t *src16 = CONVERT_TO_SHORTPTR(src + vstart1 * src_ybc->y_stride + hstart1); @@ -342,6 +357,7 @@ void aom_yv12_partial_copy_y_c(const YV12_BUFFER_CONFIG *src_ybc, int hstart1, } return; } +#endif src = (src + vstart1 * src_ybc->y_stride + hstart1); dst = (dst + vstart2 * dst_ybc->y_stride + hstart2); @@ -366,7 +382,7 @@ void aom_yv12_partial_copy_u_c(const YV12_BUFFER_CONFIG *src_bc, int hstart1, int row; const uint8_t *src = src_bc->u_buffer; uint8_t *dst = dst_bc->u_buffer; - +#if CONFIG_AV1_HIGHBITDEPTH if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) { const uint16_t *src16 = CONVERT_TO_SHORTPTR(src + vstart1 * src_bc->uv_stride + hstart1); @@ -379,7 +395,7 @@ void aom_yv12_partial_copy_u_c(const YV12_BUFFER_CONFIG *src_bc, int hstart1, } return; } - +#endif src = (src + vstart1 * src_bc->uv_stride + hstart1); dst = (dst + vstart2 * dst_bc->uv_stride + hstart2); @@ -404,7 +420,7 @@ void aom_yv12_partial_copy_v_c(const YV12_BUFFER_CONFIG *src_bc, int hstart1, int row; const uint8_t *src = src_bc->v_buffer; uint8_t *dst = dst_bc->v_buffer; - +#if CONFIG_AV1_HIGHBITDEPTH if (src_bc->flags & YV12_FLAG_HIGHBITDEPTH) { const uint16_t *src16 = CONVERT_TO_SHORTPTR(src + vstart1 * src_bc->uv_stride + hstart1); @@ -417,7 +433,7 @@ void aom_yv12_partial_copy_v_c(const YV12_BUFFER_CONFIG *src_bc, int hstart1, } return; } - +#endif src = (src + vstart1 * src_bc->uv_stride + hstart1); dst = (dst + vstart2 * dst_bc->uv_stride + hstart2); @@ -434,3 +450,28 @@ void aom_yv12_partial_coloc_copy_v_c(const YV12_BUFFER_CONFIG *src_bc, aom_yv12_partial_copy_v_c(src_bc, hstart, hend, vstart, vend, dst_bc, hstart, vstart); } + +int aom_yv12_realloc_with_new_border_c(YV12_BUFFER_CONFIG *ybf, int new_border, + int byte_alignment, int num_planes) { + if (ybf) { + if (new_border == ybf->border) return 0; + YV12_BUFFER_CONFIG new_buf; + memset(&new_buf, 0, sizeof(new_buf)); + const int error = aom_alloc_frame_buffer( + &new_buf, ybf->y_crop_width, ybf->y_crop_height, ybf->subsampling_x, + ybf->subsampling_y, ybf->flags & YV12_FLAG_HIGHBITDEPTH, new_border, + byte_alignment); + if (error) return error; + // Copy image buffer + aom_yv12_copy_frame(ybf, &new_buf, num_planes); + + // Extend up to new border + aom_extend_frame_borders(&new_buf, num_planes); + + // Now free the old buffer and replace with the new + aom_free_frame_buffer(ybf); + memcpy(ybf, &new_buf, sizeof(new_buf)); + return 0; + } + return -2; +} diff --git a/chromium/third_party/libaom/source/libaom/aom_scale/yv12config.h b/chromium/third_party/libaom/source/libaom/aom_scale/yv12config.h index 6ce77a876c2..3642bb7f379 100644 --- a/chromium/third_party/libaom/source/libaom/aom_scale/yv12config.h +++ b/chromium/third_party/libaom/source/libaom/aom_scale/yv12config.h @@ -21,12 +21,13 @@ extern "C" { #include "aom/aom_codec.h" #include "aom/aom_frame_buffer.h" #include "aom/aom_integer.h" +#include "aom/internal/aom_image_internal.h" #define AOMINNERBORDERINPIXELS 160 #define AOM_INTERP_EXTEND 4 #define AOM_BORDER_IN_PIXELS 288 #define AOM_ENC_NO_SCALE_BORDER 160 -#define AOM_DEC_BORDER_IN_PIXELS 288 +#define AOM_DEC_BORDER_IN_PIXELS 64 typedef struct yv12_buffer_config { union { @@ -104,6 +105,7 @@ typedef struct yv12_buffer_config { int corrupted; int flags; + aom_metadata_array_t *metadata; } YV12_BUFFER_CONFIG; #define YV12_FLAG_HIGHBITDEPTH 8 @@ -124,8 +126,32 @@ int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border, int byte_alignment, aom_codec_frame_buffer_t *fb, aom_get_frame_buffer_cb_fn_t cb, void *cb_priv); + int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf); +/*!\brief Removes metadata from YUV_BUFFER_CONFIG struct. + * + * Frees metadata in frame buffer. + * Frame buffer metadata pointer will be set to NULL. + * + * \param[in] ybf Frame buffer struct pointer + */ +void aom_remove_metadata_from_frame_buffer(YV12_BUFFER_CONFIG *ybf); + +/*!\brief Copy metadata to YUV_BUFFER_CONFIG struct. + * + * Copies metadata in frame buffer. + * Frame buffer will clear any previous metadata and will reallocate the + * metadata array to the new metadata size. Then, it will copy the new metadata + * array into it. + * Returns 0 on success or -1 on failure. + * + * \param[in] ybf Frame buffer struct pointer + * \param[in] arr Metadata array struct pointer + */ +int aom_copy_metadata_to_frame_buffer(YV12_BUFFER_CONFIG *ybf, + const aom_metadata_array_t *arr); + #ifdef __cplusplus } #endif |