| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 res = entry->fn(ctx->priv->alg_priv, ap); | 128 res = entry->fn(ctx->priv->alg_priv, ap); |
| 129 va_end(ap); | 129 va_end(ap); |
| 130 break; | 130 break; |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 return SAVE_STATUS(ctx, res); | 135 return SAVE_STATUS(ctx, res); |
| 136 } | 136 } |
| 137 | 137 |
| 138 //------------------------------------------------------------------------------ | 138 void vpx_internal_error(struct vpx_internal_error_info *info, |
| 139 // mmap interface | 139 vpx_codec_err_t error, |
| 140 const char *fmt, |
| 141 ...) { |
| 142 va_list ap; |
| 140 | 143 |
| 141 vpx_codec_err_t vpx_mmap_alloc(vpx_codec_mmap_t *mmap) { | 144 info->error_code = error; |
| 142 unsigned int align = mmap->align ? mmap->align - 1 : 0; | 145 info->has_detail = 0; |
| 143 | 146 |
| 144 if (mmap->flags & VPX_CODEC_MEM_ZERO) | 147 if (fmt) { |
| 145 mmap->priv = calloc(1, mmap->sz + align); | 148 size_t sz = sizeof(info->detail); |
| 146 else | |
| 147 mmap->priv = malloc(mmap->sz + align); | |
| 148 | 149 |
| 149 if (mmap->priv == NULL) return VPX_CODEC_MEM_ERROR; | 150 info->has_detail = 1; |
| 150 mmap->base = (void *)((((uintptr_t)mmap->priv) + align) & ~(uintptr_t)align); | 151 va_start(ap, fmt); |
| 151 mmap->dtor = vpx_mmap_dtor; | 152 vsnprintf(info->detail, sz - 1, fmt, ap); |
| 152 return VPX_CODEC_OK; | 153 va_end(ap); |
| 154 info->detail[sz - 1] = '\0'; |
| 155 } |
| 156 |
| 157 if (info->setjmp) |
| 158 longjmp(info->jmp, info->error_code); |
| 153 } | 159 } |
| 154 | |
| 155 void vpx_mmap_dtor(vpx_codec_mmap_t *mmap) { | |
| 156 free(mmap->priv); | |
| 157 } | |
| 158 | |
| 159 vpx_codec_err_t vpx_validate_mmaps(const vpx_codec_stream_info_t *si, | |
| 160 const vpx_codec_mmap_t *mmaps, | |
| 161 const mem_req_t *mem_reqs, int nreqs, | |
| 162 vpx_codec_flags_t init_flags) { | |
| 163 int i; | |
| 164 | |
| 165 for (i = 0; i < nreqs - 1; ++i) { | |
| 166 /* Ensure the segment has been allocated */ | |
| 167 if (mmaps[i].base == NULL) { | |
| 168 return VPX_CODEC_MEM_ERROR; | |
| 169 } | |
| 170 | |
| 171 /* Verify variable size segment is big enough for the current si. */ | |
| 172 if (mem_reqs[i].calc_sz != NULL) { | |
| 173 vpx_codec_dec_cfg_t cfg; | |
| 174 | |
| 175 cfg.w = si->w; | |
| 176 cfg.h = si->h; | |
| 177 | |
| 178 if (mmaps[i].sz < mem_reqs[i].calc_sz(&cfg, init_flags)) { | |
| 179 return VPX_CODEC_MEM_ERROR; | |
| 180 } | |
| 181 } | |
| 182 } | |
| 183 return VPX_CODEC_OK; | |
| 184 } | |
| OLD | NEW |