/* * 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 encoder algorithms. *
*/ #include <assert.h> #include <limits.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include"vp8/common/blockd.h" #include"vpx_config.h" #include"vpx/internal/vpx_codec_internal.h"
if (ver != VPX_ENCODER_ABI_VERSION)
res = VPX_CODEC_ABI_MISMATCH; elseif (!ctx || !iface || !cfg)
res = VPX_CODEC_INVALID_PARAM; elseif (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION)
res = VPX_CODEC_ABI_MISMATCH; elseif (!(iface->caps & VPX_CODEC_CAP_ENCODER))
res = VPX_CODEC_INCAPABLE; elseif ((flags & VPX_CODEC_USE_PSNR) && !(iface->caps & VPX_CODEC_CAP_PSNR))
res = VPX_CODEC_INCAPABLE; elseif ((flags & VPX_CODEC_USE_OUTPUT_PARTITION) &&
!(iface->caps & VPX_CODEC_CAP_OUTPUT_PARTITION))
res = VPX_CODEC_INCAPABLE; else {
ctx->iface = iface;
ctx->name = iface->name;
ctx->priv = NULL;
ctx->init_flags = flags;
ctx->config.enc = cfg;
res = ctx->iface->init(ctx, NULL);
if (res) { // IMPORTANT: ctx->priv->err_detail must be null or point to a string // that remains valid after ctx->priv is destroyed, such as a C string // literal. This makes it safe to call vpx_codec_error_detail() after // vpx_codec_enc_init_ver() failed.
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_enc_init_multi_ver(
vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg, int num_enc, vpx_codec_flags_t flags, vpx_rational_t *dsf, int ver) {
vpx_codec_err_t res = VPX_CODEC_OK;
if (ver != VPX_ENCODER_ABI_VERSION)
res = VPX_CODEC_ABI_MISMATCH; elseif (!ctx || !iface || !cfg || (num_enc > 16 || num_enc < 1))
res = VPX_CODEC_INVALID_PARAM; elseif (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION)
res = VPX_CODEC_ABI_MISMATCH; elseif (!(iface->caps & VPX_CODEC_CAP_ENCODER))
res = VPX_CODEC_INCAPABLE; elseif ((flags & VPX_CODEC_USE_PSNR) && !(iface->caps & VPX_CODEC_CAP_PSNR))
res = VPX_CODEC_INCAPABLE; elseif ((flags & VPX_CODEC_USE_OUTPUT_PARTITION) &&
!(iface->caps & VPX_CODEC_CAP_OUTPUT_PARTITION))
res = VPX_CODEC_INCAPABLE; else { int i; #if CONFIG_MULTI_RES_ENCODING int mem_loc_owned = 0; #endif void *mem_loc = NULL;
if (iface->enc.mr_get_mem_loc == NULL) return VPX_CODEC_INCAPABLE;
if (!(res = iface->enc.mr_get_mem_loc(cfg, &mem_loc))) { for (i = 0; i < num_enc; i++) {
vpx_codec_priv_enc_mr_cfg_t mr_cfg;
if (!ctx || (img && !duration))
res = VPX_CODEC_INVALID_PARAM; elseif (!ctx->iface || !ctx->priv)
res = VPX_CODEC_ERROR; elseif (!(ctx->iface->caps & VPX_CODEC_CAP_ENCODER))
res = VPX_CODEC_INCAPABLE; #if ULONG_MAX > UINT32_MAX elseif (duration > UINT32_MAX || deadline > UINT32_MAX)
res = VPX_CODEC_INVALID_PARAM; #endif else { unsignedint num_enc = ctx->priv->enc.total_encoders;
/* Execute in a normalized floating point environment, if the platform * requires it.
*/
FLOATING_POINT_INIT();
if (num_enc == 1)
res = ctx->iface->enc.encode(get_alg_priv(ctx), img, pts, duration, flags,
deadline); else { /* Multi-resolution encoding: * Encode multi-levels in reverse order. For example, * if mr_total_resolutions = 3, first encode level 2, * then encode level 1, and finally encode level 0.
*/ int i;
ctx += num_enc - 1; if (img) img += num_enc - 1;
for (i = num_enc - 1; i >= 0; i--) { if ((res = ctx->iface->enc.encode(get_alg_priv(ctx), img, pts, duration,
flags, deadline))) break;
if (pkt && pkt->kind == VPX_CODEC_CX_FRAME_PKT) { // If the application has specified a destination area for the // compressed data, and the codec has not placed the data there, // and it fits, copy it.
vpx_codec_priv_t *const priv = ctx->priv; char *const dst_buf = (char *)priv->enc.cx_data_dst_buf.buf;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.