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 13 matching lines...) Expand all Loading... |
24 vpx_codec_flags_t flags, | 24 vpx_codec_flags_t flags, |
25 int ver) { | 25 int ver) { |
26 vpx_codec_err_t res; | 26 vpx_codec_err_t res; |
27 | 27 |
28 if (ver != VPX_DECODER_ABI_VERSION) | 28 if (ver != VPX_DECODER_ABI_VERSION) |
29 res = VPX_CODEC_ABI_MISMATCH; | 29 res = VPX_CODEC_ABI_MISMATCH; |
30 else if (!ctx || !iface) | 30 else if (!ctx || !iface) |
31 res = VPX_CODEC_INVALID_PARAM; | 31 res = VPX_CODEC_INVALID_PARAM; |
32 else if (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION) | 32 else if (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION) |
33 res = VPX_CODEC_ABI_MISMATCH; | 33 res = VPX_CODEC_ABI_MISMATCH; |
34 else if ((flags & VPX_CODEC_USE_XMA) && !(iface->caps & VPX_CODEC_CAP_XMA)) | |
35 res = VPX_CODEC_INCAPABLE; | |
36 else if ((flags & VPX_CODEC_USE_POSTPROC) && !(iface->caps & VPX_CODEC_CAP_POS
TPROC)) | 34 else if ((flags & VPX_CODEC_USE_POSTPROC) && !(iface->caps & VPX_CODEC_CAP_POS
TPROC)) |
37 res = VPX_CODEC_INCAPABLE; | 35 res = VPX_CODEC_INCAPABLE; |
38 else if ((flags & VPX_CODEC_USE_ERROR_CONCEALMENT) && | 36 else if ((flags & VPX_CODEC_USE_ERROR_CONCEALMENT) && |
39 !(iface->caps & VPX_CODEC_CAP_ERROR_CONCEALMENT)) | 37 !(iface->caps & VPX_CODEC_CAP_ERROR_CONCEALMENT)) |
40 res = VPX_CODEC_INCAPABLE; | 38 res = VPX_CODEC_INCAPABLE; |
41 else if ((flags & VPX_CODEC_USE_INPUT_FRAGMENTS) && | 39 else if ((flags & VPX_CODEC_USE_INPUT_FRAGMENTS) && |
42 !(iface->caps & VPX_CODEC_CAP_INPUT_FRAGMENTS)) | 40 !(iface->caps & VPX_CODEC_CAP_INPUT_FRAGMENTS)) |
43 res = VPX_CODEC_INCAPABLE; | 41 res = VPX_CODEC_INCAPABLE; |
44 else if (!(iface->caps & VPX_CODEC_CAP_DECODER)) | 42 else if (!(iface->caps & VPX_CODEC_CAP_DECODER)) |
45 res = VPX_CODEC_INCAPABLE; | 43 res = VPX_CODEC_INCAPABLE; |
46 else { | 44 else { |
47 memset(ctx, 0, sizeof(*ctx)); | 45 memset(ctx, 0, sizeof(*ctx)); |
48 ctx->iface = iface; | 46 ctx->iface = iface; |
49 ctx->name = iface->name; | 47 ctx->name = iface->name; |
50 ctx->priv = NULL; | 48 ctx->priv = NULL; |
51 ctx->init_flags = flags; | 49 ctx->init_flags = flags; |
52 ctx->config.dec = cfg; | 50 ctx->config.dec = cfg; |
53 res = VPX_CODEC_OK; | |
54 | 51 |
55 if (!(flags & VPX_CODEC_USE_XMA)) { | 52 res = ctx->iface->init(ctx, NULL); |
56 res = ctx->iface->init(ctx, NULL); | 53 if (res) { |
| 54 ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL; |
| 55 vpx_codec_destroy(ctx); |
| 56 } |
57 | 57 |
58 if (res) { | 58 if (ctx->priv) |
59 ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL; | 59 ctx->priv->iface = ctx->iface; |
60 vpx_codec_destroy(ctx); | |
61 } | |
62 | |
63 if (ctx->priv) | |
64 ctx->priv->iface = ctx->iface; | |
65 } | |
66 } | 60 } |
67 | 61 |
68 return SAVE_STATUS(ctx, res); | 62 return SAVE_STATUS(ctx, res); |
69 } | 63 } |
70 | 64 |
71 | 65 |
72 vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface, | 66 vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface, |
73 const uint8_t *data, | 67 const uint8_t *data, |
74 unsigned int data_sz, | 68 unsigned int data_sz, |
75 vpx_codec_stream_info_t *si) { | 69 vpx_codec_stream_info_t *si) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 106 |
113 vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, | 107 vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, |
114 const uint8_t *data, | 108 const uint8_t *data, |
115 unsigned int data_sz, | 109 unsigned int data_sz, |
116 void *user_priv, | 110 void *user_priv, |
117 long deadline) { | 111 long deadline) { |
118 vpx_codec_err_t res; | 112 vpx_codec_err_t res; |
119 | 113 |
120 /* Sanity checks */ | 114 /* Sanity checks */ |
121 /* NULL data ptr allowed if data_sz is 0 too */ | 115 /* NULL data ptr allowed if data_sz is 0 too */ |
122 if (!ctx || (!data && data_sz)) | 116 if (!ctx || (!data && data_sz) || (data && !data_sz)) |
123 res = VPX_CODEC_INVALID_PARAM; | 117 res = VPX_CODEC_INVALID_PARAM; |
124 else if (!ctx->iface || !ctx->priv) | 118 else if (!ctx->iface || !ctx->priv) |
125 res = VPX_CODEC_ERROR; | 119 res = VPX_CODEC_ERROR; |
126 else { | 120 else { |
127 res = ctx->iface->dec.decode(ctx->priv->alg_priv, data, data_sz, | 121 res = ctx->iface->dec.decode(ctx->priv->alg_priv, data, data_sz, |
128 user_priv, deadline); | 122 user_priv, deadline); |
129 } | 123 } |
130 | 124 |
131 return SAVE_STATUS(ctx, res); | 125 return SAVE_STATUS(ctx, res); |
132 } | 126 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 res = VPX_CODEC_ERROR; | 170 res = VPX_CODEC_ERROR; |
177 else { | 171 else { |
178 ctx->priv->dec.put_slice_cb.u.put_slice = cb; | 172 ctx->priv->dec.put_slice_cb.u.put_slice = cb; |
179 ctx->priv->dec.put_slice_cb.user_priv = user_priv; | 173 ctx->priv->dec.put_slice_cb.user_priv = user_priv; |
180 res = VPX_CODEC_OK; | 174 res = VPX_CODEC_OK; |
181 } | 175 } |
182 | 176 |
183 return SAVE_STATUS(ctx, res); | 177 return SAVE_STATUS(ctx, res); |
184 } | 178 } |
185 | 179 |
186 | |
187 vpx_codec_err_t vpx_codec_get_mem_map(vpx_codec_ctx_t *ctx, | |
188 vpx_codec_mmap_t *mmap, | |
189 vpx_codec_iter_t *iter) { | |
190 vpx_codec_err_t res = VPX_CODEC_OK; | |
191 | |
192 if (!ctx || !mmap || !iter || !ctx->iface) | |
193 res = VPX_CODEC_INVALID_PARAM; | |
194 else if (!(ctx->iface->caps & VPX_CODEC_CAP_XMA)) | |
195 res = VPX_CODEC_ERROR; | |
196 else | |
197 res = ctx->iface->get_mmap(ctx, mmap, iter); | |
198 | |
199 return SAVE_STATUS(ctx, res); | |
200 } | |
201 | |
202 | |
203 vpx_codec_err_t vpx_codec_set_mem_map(vpx_codec_ctx_t *ctx, | |
204 vpx_codec_mmap_t *mmap, | |
205 unsigned int num_maps) { | |
206 vpx_codec_err_t res = VPX_CODEC_MEM_ERROR; | |
207 | |
208 if (!ctx || !mmap || !ctx->iface) | |
209 res = VPX_CODEC_INVALID_PARAM; | |
210 else if (!(ctx->iface->caps & VPX_CODEC_CAP_XMA)) | |
211 res = VPX_CODEC_ERROR; | |
212 else { | |
213 unsigned int i; | |
214 | |
215 for (i = 0; i < num_maps; i++, mmap++) { | |
216 if (!mmap->base) | |
217 break; | |
218 | |
219 /* Everything look ok, set the mmap in the decoder */ | |
220 res = ctx->iface->set_mmap(ctx, mmap); | |
221 | |
222 if (res) | |
223 break; | |
224 } | |
225 } | |
226 | |
227 return SAVE_STATUS(ctx, res); | |
228 } | |
229 | |
230 vpx_codec_err_t vpx_codec_set_frame_buffer_functions( | 180 vpx_codec_err_t vpx_codec_set_frame_buffer_functions( |
231 vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get, | 181 vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get, |
232 vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) { | 182 vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) { |
233 vpx_codec_err_t res; | 183 vpx_codec_err_t res; |
234 | 184 |
235 if (!ctx || !cb_get || !cb_release) { | 185 if (!ctx || !cb_get || !cb_release) { |
236 res = VPX_CODEC_INVALID_PARAM; | 186 res = VPX_CODEC_INVALID_PARAM; |
237 } else if (!ctx->iface || !ctx->priv || | 187 } else if (!ctx->iface || !ctx->priv || |
238 !(ctx->iface->caps & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER)) { | 188 !(ctx->iface->caps & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER)) { |
239 res = VPX_CODEC_ERROR; | 189 res = VPX_CODEC_ERROR; |
240 } else { | 190 } else { |
241 res = ctx->iface->dec.set_fb_fn(ctx->priv->alg_priv, cb_get, cb_release, | 191 res = ctx->iface->dec.set_fb_fn(ctx->priv->alg_priv, cb_get, cb_release, |
242 cb_priv); | 192 cb_priv); |
243 } | 193 } |
244 | 194 |
245 return SAVE_STATUS(ctx, res); | 195 return SAVE_STATUS(ctx, res); |
246 } | 196 } |
OLD | NEW |