diff options
Diffstat (limited to 'thirdparty/libvpx/vpx/src')
-rw-r--r-- | thirdparty/libvpx/vpx/src/vpx_codec.c | 158 | ||||
-rw-r--r-- | thirdparty/libvpx/vpx/src/vpx_decoder.c | 197 | ||||
-rw-r--r-- | thirdparty/libvpx/vpx/src/vpx_image.c | 285 | ||||
-rw-r--r-- | thirdparty/libvpx/vpx/src/vpx_psnr.c | 24 |
4 files changed, 0 insertions, 664 deletions
diff --git a/thirdparty/libvpx/vpx/src/vpx_codec.c b/thirdparty/libvpx/vpx/src/vpx_codec.c deleted file mode 100644 index 5a495ce814..0000000000 --- a/thirdparty/libvpx/vpx/src/vpx_codec.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/*!\file - * \brief Provides the high level interface to wrap decoder algorithms. - * - */ -#include <stdarg.h> -#include <stdlib.h> -#include "vpx/vpx_integer.h" -#include "vpx/internal/vpx_codec_internal.h" -#include "vpx_version.h" - -#define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var) - -int vpx_codec_version(void) { - return VERSION_PACKED; -} - - -const char *vpx_codec_version_str(void) { - return VERSION_STRING_NOSP; -} - - -const char *vpx_codec_version_extra_str(void) { - return VERSION_EXTRA; -} - - -const char *vpx_codec_iface_name(vpx_codec_iface_t *iface) { - return iface ? iface->name : "<invalid interface>"; -} - -const char *vpx_codec_err_to_string(vpx_codec_err_t err) { - switch (err) { - case VPX_CODEC_OK: - return "Success"; - case VPX_CODEC_ERROR: - return "Unspecified internal error"; - case VPX_CODEC_MEM_ERROR: - return "Memory allocation error"; - case VPX_CODEC_ABI_MISMATCH: - return "ABI version mismatch"; - case VPX_CODEC_INCAPABLE: - return "Codec does not implement requested capability"; - case VPX_CODEC_UNSUP_BITSTREAM: - return "Bitstream not supported by this decoder"; - case VPX_CODEC_UNSUP_FEATURE: - return "Bitstream required feature not supported by this decoder"; - case VPX_CODEC_CORRUPT_FRAME: - return "Corrupt frame detected"; - case VPX_CODEC_INVALID_PARAM: - return "Invalid parameter"; - case VPX_CODEC_LIST_END: - return "End of iterated list"; - } - - return "Unrecognized error code"; -} - -const char *vpx_codec_error(vpx_codec_ctx_t *ctx) { - return (ctx) ? vpx_codec_err_to_string(ctx->err) - : vpx_codec_err_to_string(VPX_CODEC_INVALID_PARAM); -} - -const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx) { - if (ctx && ctx->err) - return ctx->priv ? ctx->priv->err_detail : ctx->err_detail; - - return NULL; -} - - -vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx) { - vpx_codec_err_t res; - - if (!ctx) - res = VPX_CODEC_INVALID_PARAM; - else if (!ctx->iface || !ctx->priv) - res = VPX_CODEC_ERROR; - else { - ctx->iface->destroy((vpx_codec_alg_priv_t *)ctx->priv); - - ctx->iface = NULL; - ctx->name = NULL; - ctx->priv = NULL; - res = VPX_CODEC_OK; - } - - return SAVE_STATUS(ctx, res); -} - - -vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface) { - return (iface) ? iface->caps : 0; -} - - -vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, - int ctrl_id, - ...) { - vpx_codec_err_t res; - - if (!ctx || !ctrl_id) - res = VPX_CODEC_INVALID_PARAM; - else if (!ctx->iface || !ctx->priv || !ctx->iface->ctrl_maps) - res = VPX_CODEC_ERROR; - else { - vpx_codec_ctrl_fn_map_t *entry; - - res = VPX_CODEC_ERROR; - - for (entry = ctx->iface->ctrl_maps; entry && entry->fn; entry++) { - if (!entry->ctrl_id || entry->ctrl_id == ctrl_id) { - va_list ap; - - va_start(ap, ctrl_id); - res = entry->fn((vpx_codec_alg_priv_t *)ctx->priv, ap); - va_end(ap); - break; - } - } - } - - return SAVE_STATUS(ctx, res); -} - -void vpx_internal_error(struct vpx_internal_error_info *info, - vpx_codec_err_t error, - const char *fmt, - ...) { - va_list ap; - - info->error_code = error; - info->has_detail = 0; - - if (fmt) { - size_t sz = sizeof(info->detail); - - info->has_detail = 1; - va_start(ap, fmt); - vsnprintf(info->detail, sz - 1, fmt, ap); - va_end(ap); - info->detail[sz - 1] = '\0'; - } - - if (info->setjmp) - longjmp(info->jmp, info->error_code); -} diff --git a/thirdparty/libvpx/vpx/src/vpx_decoder.c b/thirdparty/libvpx/vpx/src/vpx_decoder.c deleted file mode 100644 index 802d8edd8a..0000000000 --- a/thirdparty/libvpx/vpx/src/vpx_decoder.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/*!\file - * \brief Provides the high level interface to wrap decoder algorithms. - * - */ -#include <string.h> -#include "vpx/internal/vpx_codec_internal.h" - -#define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var) - -static vpx_codec_alg_priv_t *get_alg_priv(vpx_codec_ctx_t *ctx) { - return (vpx_codec_alg_priv_t *)ctx->priv; -} - -vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx, - vpx_codec_iface_t *iface, - const vpx_codec_dec_cfg_t *cfg, - vpx_codec_flags_t flags, - int ver) { - vpx_codec_err_t res; - - if (ver != VPX_DECODER_ABI_VERSION) - res = VPX_CODEC_ABI_MISMATCH; - else if (!ctx || !iface) - res = VPX_CODEC_INVALID_PARAM; - else if (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION) - res = VPX_CODEC_ABI_MISMATCH; - else if ((flags & VPX_CODEC_USE_POSTPROC) && !(iface->caps & VPX_CODEC_CAP_POSTPROC)) - res = VPX_CODEC_INCAPABLE; - else if ((flags & VPX_CODEC_USE_ERROR_CONCEALMENT) && - !(iface->caps & VPX_CODEC_CAP_ERROR_CONCEALMENT)) - res = VPX_CODEC_INCAPABLE; - else if ((flags & VPX_CODEC_USE_INPUT_FRAGMENTS) && - !(iface->caps & VPX_CODEC_CAP_INPUT_FRAGMENTS)) - res = VPX_CODEC_INCAPABLE; - else if (!(iface->caps & VPX_CODEC_CAP_DECODER)) - res = VPX_CODEC_INCAPABLE; - else { - memset(ctx, 0, sizeof(*ctx)); - ctx->iface = iface; - ctx->name = iface->name; - ctx->priv = NULL; - ctx->init_flags = flags; - ctx->config.dec = cfg; - - res = ctx->iface->init(ctx, NULL); - if (res) { - ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL; - vpx_codec_destroy(ctx); - } - } - - return SAVE_STATUS(ctx, res); -} - - -vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface, - const uint8_t *data, - unsigned int data_sz, - vpx_codec_stream_info_t *si) { - vpx_codec_err_t res; - - if (!iface || !data || !data_sz || !si - || si->sz < sizeof(vpx_codec_stream_info_t)) - res = VPX_CODEC_INVALID_PARAM; - else { - /* Set default/unknown values */ - si->w = 0; - si->h = 0; - - res = iface->dec.peek_si(data, data_sz, si); - } - - return res; -} - - -vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx, - vpx_codec_stream_info_t *si) { - vpx_codec_err_t res; - - if (!ctx || !si || si->sz < sizeof(vpx_codec_stream_info_t)) - res = VPX_CODEC_INVALID_PARAM; - else if (!ctx->iface || !ctx->priv) - res = VPX_CODEC_ERROR; - else { - /* Set default/unknown values */ - si->w = 0; - si->h = 0; - - res = ctx->iface->dec.get_si(get_alg_priv(ctx), si); - } - - return SAVE_STATUS(ctx, res); -} - - -vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, - const uint8_t *data, - unsigned int data_sz, - void *user_priv, - long deadline) { - vpx_codec_err_t res; - - /* Sanity checks */ - /* NULL data ptr allowed if data_sz is 0 too */ - if (!ctx || (!data && data_sz) || (data && !data_sz)) - res = VPX_CODEC_INVALID_PARAM; - else if (!ctx->iface || !ctx->priv) - res = VPX_CODEC_ERROR; - else { - res = ctx->iface->dec.decode(get_alg_priv(ctx), data, data_sz, user_priv, - deadline); - } - - return SAVE_STATUS(ctx, res); -} - -vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, - vpx_codec_iter_t *iter) { - vpx_image_t *img; - - if (!ctx || !iter || !ctx->iface || !ctx->priv) - img = NULL; - else - img = ctx->iface->dec.get_frame(get_alg_priv(ctx), iter); - - return img; -} - - -vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx, - vpx_codec_put_frame_cb_fn_t cb, - void *user_priv) { - vpx_codec_err_t res; - - if (!ctx || !cb) - res = VPX_CODEC_INVALID_PARAM; - else if (!ctx->iface || !ctx->priv - || !(ctx->iface->caps & VPX_CODEC_CAP_PUT_FRAME)) - res = VPX_CODEC_ERROR; - else { - ctx->priv->dec.put_frame_cb.u.put_frame = cb; - ctx->priv->dec.put_frame_cb.user_priv = user_priv; - res = VPX_CODEC_OK; - } - - return SAVE_STATUS(ctx, res); -} - - -vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx, - vpx_codec_put_slice_cb_fn_t cb, - void *user_priv) { - vpx_codec_err_t res; - - if (!ctx || !cb) - res = VPX_CODEC_INVALID_PARAM; - else if (!ctx->iface || !ctx->priv - || !(ctx->iface->caps & VPX_CODEC_CAP_PUT_SLICE)) - res = VPX_CODEC_ERROR; - else { - ctx->priv->dec.put_slice_cb.u.put_slice = cb; - ctx->priv->dec.put_slice_cb.user_priv = user_priv; - res = VPX_CODEC_OK; - } - - return SAVE_STATUS(ctx, res); -} - -vpx_codec_err_t vpx_codec_set_frame_buffer_functions( - vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get, - vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) { - vpx_codec_err_t res; - - if (!ctx || !cb_get || !cb_release) { - res = VPX_CODEC_INVALID_PARAM; - } else if (!ctx->iface || !ctx->priv || - !(ctx->iface->caps & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER)) { - res = VPX_CODEC_ERROR; - } else { - res = ctx->iface->dec.set_fb_fn(get_alg_priv(ctx), cb_get, cb_release, - cb_priv); - } - - return SAVE_STATUS(ctx, res); -} diff --git a/thirdparty/libvpx/vpx/src/vpx_image.c b/thirdparty/libvpx/vpx/src/vpx_image.c deleted file mode 100644 index 9aae12c794..0000000000 --- a/thirdparty/libvpx/vpx/src/vpx_image.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <stdlib.h> -#include <string.h> - -#include "vpx/vpx_image.h" -#include "vpx/vpx_integer.h" -#include "vpx_mem/vpx_mem.h" - -static vpx_image_t *img_alloc_helper(vpx_image_t *img, - vpx_img_fmt_t fmt, - unsigned int d_w, - unsigned int d_h, - unsigned int buf_align, - unsigned int stride_align, - unsigned char *img_data) { - unsigned int h, w, s, xcs, ycs, bps; - unsigned int stride_in_bytes; - int align; - - /* Treat align==0 like align==1 */ - if (!buf_align) - buf_align = 1; - - /* Validate alignment (must be power of 2) */ - if (buf_align & (buf_align - 1)) - goto fail; - - /* Treat align==0 like align==1 */ - if (!stride_align) - stride_align = 1; - - /* Validate alignment (must be power of 2) */ - if (stride_align & (stride_align - 1)) - goto fail; - - /* Get sample size for this format */ - switch (fmt) { - case VPX_IMG_FMT_RGB32: - case VPX_IMG_FMT_RGB32_LE: - case VPX_IMG_FMT_ARGB: - case VPX_IMG_FMT_ARGB_LE: - bps = 32; - break; - case VPX_IMG_FMT_RGB24: - case VPX_IMG_FMT_BGR24: - bps = 24; - break; - case VPX_IMG_FMT_RGB565: - case VPX_IMG_FMT_RGB565_LE: - case VPX_IMG_FMT_RGB555: - case VPX_IMG_FMT_RGB555_LE: - case VPX_IMG_FMT_UYVY: - case VPX_IMG_FMT_YUY2: - case VPX_IMG_FMT_YVYU: - bps = 16; - break; - case VPX_IMG_FMT_I420: - case VPX_IMG_FMT_YV12: - case VPX_IMG_FMT_VPXI420: - case VPX_IMG_FMT_VPXYV12: - bps = 12; - break; - case VPX_IMG_FMT_I422: - case VPX_IMG_FMT_I440: - bps = 16; - break; - case VPX_IMG_FMT_I444: - bps = 24; - break; - case VPX_IMG_FMT_I42016: - bps = 24; - break; - case VPX_IMG_FMT_I42216: - case VPX_IMG_FMT_I44016: - bps = 32; - break; - case VPX_IMG_FMT_I44416: - bps = 48; - break; - default: - bps = 16; - break; - } - - /* Get chroma shift values for this format */ - switch (fmt) { - case VPX_IMG_FMT_I420: - case VPX_IMG_FMT_YV12: - case VPX_IMG_FMT_VPXI420: - case VPX_IMG_FMT_VPXYV12: - case VPX_IMG_FMT_I422: - case VPX_IMG_FMT_I42016: - case VPX_IMG_FMT_I42216: - xcs = 1; - break; - default: - xcs = 0; - break; - } - - switch (fmt) { - case VPX_IMG_FMT_I420: - case VPX_IMG_FMT_I440: - case VPX_IMG_FMT_YV12: - case VPX_IMG_FMT_VPXI420: - case VPX_IMG_FMT_VPXYV12: - case VPX_IMG_FMT_I42016: - case VPX_IMG_FMT_I44016: - ycs = 1; - break; - default: - ycs = 0; - break; - } - - /* Calculate storage sizes given the chroma subsampling */ - align = (1 << xcs) - 1; - w = (d_w + align) & ~align; - align = (1 << ycs) - 1; - h = (d_h + align) & ~align; - s = (fmt & VPX_IMG_FMT_PLANAR) ? w : bps * w / 8; - s = (s + stride_align - 1) & ~(stride_align - 1); - stride_in_bytes = (fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? s * 2 : s; - - /* Allocate the new image */ - if (!img) { - img = (vpx_image_t *)calloc(1, sizeof(vpx_image_t)); - - if (!img) - goto fail; - - img->self_allocd = 1; - } else { - memset(img, 0, sizeof(vpx_image_t)); - } - - img->img_data = img_data; - - if (!img_data) { - const uint64_t alloc_size = (fmt & VPX_IMG_FMT_PLANAR) ? - (uint64_t)h * s * bps / 8 : (uint64_t)h * s; - - if (alloc_size != (size_t)alloc_size) - goto fail; - - img->img_data = (uint8_t *)vpx_memalign(buf_align, (size_t)alloc_size); - img->img_data_owner = 1; - } - - if (!img->img_data) - goto fail; - - img->fmt = fmt; - img->bit_depth = (fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? 16 : 8; - img->w = w; - img->h = h; - img->x_chroma_shift = xcs; - img->y_chroma_shift = ycs; - img->bps = bps; - - /* Calculate strides */ - img->stride[VPX_PLANE_Y] = img->stride[VPX_PLANE_ALPHA] = stride_in_bytes; - img->stride[VPX_PLANE_U] = img->stride[VPX_PLANE_V] = stride_in_bytes >> xcs; - - /* Default viewport to entire image */ - if (!vpx_img_set_rect(img, 0, 0, d_w, d_h)) - return img; - -fail: - vpx_img_free(img); - return NULL; -} - -vpx_image_t *vpx_img_alloc(vpx_image_t *img, - vpx_img_fmt_t fmt, - unsigned int d_w, - unsigned int d_h, - unsigned int align) { - return img_alloc_helper(img, fmt, d_w, d_h, align, align, NULL); -} - -vpx_image_t *vpx_img_wrap(vpx_image_t *img, - vpx_img_fmt_t fmt, - unsigned int d_w, - unsigned int d_h, - unsigned int stride_align, - unsigned char *img_data) { - /* By setting buf_align = 1, we don't change buffer alignment in this - * function. */ - return img_alloc_helper(img, fmt, d_w, d_h, 1, stride_align, img_data); -} - -int vpx_img_set_rect(vpx_image_t *img, - unsigned int x, - unsigned int y, - unsigned int w, - unsigned int h) { - unsigned char *data; - - if (x + w <= img->w && y + h <= img->h) { - img->d_w = w; - img->d_h = h; - - /* Calculate plane pointers */ - if (!(img->fmt & VPX_IMG_FMT_PLANAR)) { - img->planes[VPX_PLANE_PACKED] = - img->img_data + x * img->bps / 8 + y * img->stride[VPX_PLANE_PACKED]; - } else { - const int bytes_per_sample = - (img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) ? 2 : 1; - data = img->img_data; - - if (img->fmt & VPX_IMG_FMT_HAS_ALPHA) { - img->planes[VPX_PLANE_ALPHA] = - data + x * bytes_per_sample + y * img->stride[VPX_PLANE_ALPHA]; - data += img->h * img->stride[VPX_PLANE_ALPHA]; - } - - img->planes[VPX_PLANE_Y] = data + x * bytes_per_sample + - y * img->stride[VPX_PLANE_Y]; - data += img->h * img->stride[VPX_PLANE_Y]; - - if (!(img->fmt & VPX_IMG_FMT_UV_FLIP)) { - img->planes[VPX_PLANE_U] = - data + (x >> img->x_chroma_shift) * bytes_per_sample + - (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U]; - data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_U]; - img->planes[VPX_PLANE_V] = - data + (x >> img->x_chroma_shift) * bytes_per_sample + - (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V]; - } else { - img->planes[VPX_PLANE_V] = - data + (x >> img->x_chroma_shift) * bytes_per_sample + - (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_V]; - data += (img->h >> img->y_chroma_shift) * img->stride[VPX_PLANE_V]; - img->planes[VPX_PLANE_U] = - data + (x >> img->x_chroma_shift) * bytes_per_sample + - (y >> img->y_chroma_shift) * img->stride[VPX_PLANE_U]; - } - } - return 0; - } - return -1; -} - -void vpx_img_flip(vpx_image_t *img) { - /* Note: In the calculation pointer adjustment calculation, we want the - * rhs to be promoted to a signed type. Section 6.3.1.8 of the ISO C99 - * standard indicates that if the adjustment parameter is unsigned, the - * stride parameter will be promoted to unsigned, causing errors when - * the lhs is a larger type than the rhs. - */ - img->planes[VPX_PLANE_Y] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_Y]; - img->stride[VPX_PLANE_Y] = -img->stride[VPX_PLANE_Y]; - - img->planes[VPX_PLANE_U] += (signed)((img->d_h >> img->y_chroma_shift) - 1) - * img->stride[VPX_PLANE_U]; - img->stride[VPX_PLANE_U] = -img->stride[VPX_PLANE_U]; - - img->planes[VPX_PLANE_V] += (signed)((img->d_h >> img->y_chroma_shift) - 1) - * img->stride[VPX_PLANE_V]; - img->stride[VPX_PLANE_V] = -img->stride[VPX_PLANE_V]; - - img->planes[VPX_PLANE_ALPHA] += (signed)(img->d_h - 1) * img->stride[VPX_PLANE_ALPHA]; - img->stride[VPX_PLANE_ALPHA] = -img->stride[VPX_PLANE_ALPHA]; -} - -void vpx_img_free(vpx_image_t *img) { - if (img) { - if (img->img_data && img->img_data_owner) - vpx_free(img->img_data); - - if (img->self_allocd) - free(img); - } -} diff --git a/thirdparty/libvpx/vpx/src/vpx_psnr.c b/thirdparty/libvpx/vpx/src/vpx_psnr.c deleted file mode 100644 index 05843acb61..0000000000 --- a/thirdparty/libvpx/vpx/src/vpx_psnr.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2014 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <math.h> - -#include "vpx/internal/vpx_psnr.h" - -#define MAX_PSNR 100.0 - -double vpx_sse_to_psnr(double samples, double peak, double sse) { - if (sse > 0.0) { - const double psnr = 10.0 * log10(samples * peak * peak / sse); - return psnr > MAX_PSNR ? MAX_PSNR : psnr; - } else { - return MAX_PSNR; - } -} |