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 |
11 | 11 |
12 /*!\file | 12 /*!\file |
13 * \brief Provides the high level interface to wrap decoder algorithms. | 13 * \brief Provides the high level interface to wrap decoder algorithms. |
14 * | 14 * |
15 */ | 15 */ |
16 #include <string.h> | 16 #include <string.h> |
17 #include "vpx/internal/vpx_codec_internal.h" | 17 #include "vpx/internal/vpx_codec_internal.h" |
18 | 18 |
19 #define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var) | 19 #define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var) |
20 | 20 |
| 21 static vpx_codec_alg_priv_t *get_alg_priv(vpx_codec_ctx_t *ctx) { |
| 22 return (vpx_codec_alg_priv_t *)ctx->priv; |
| 23 } |
| 24 |
21 vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx, | 25 vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx, |
22 vpx_codec_iface_t *iface, | 26 vpx_codec_iface_t *iface, |
23 vpx_codec_dec_cfg_t *cfg, | 27 const vpx_codec_dec_cfg_t *cfg, |
24 vpx_codec_flags_t flags, | 28 vpx_codec_flags_t flags, |
25 int ver) { | 29 int ver) { |
26 vpx_codec_err_t res; | 30 vpx_codec_err_t res; |
27 | 31 |
28 if (ver != VPX_DECODER_ABI_VERSION) | 32 if (ver != VPX_DECODER_ABI_VERSION) |
29 res = VPX_CODEC_ABI_MISMATCH; | 33 res = VPX_CODEC_ABI_MISMATCH; |
30 else if (!ctx || !iface) | 34 else if (!ctx || !iface) |
31 res = VPX_CODEC_INVALID_PARAM; | 35 res = VPX_CODEC_INVALID_PARAM; |
32 else if (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION) | 36 else if (iface->abi_version != VPX_CODEC_INTERNAL_ABI_VERSION) |
33 res = VPX_CODEC_ABI_MISMATCH; | 37 res = VPX_CODEC_ABI_MISMATCH; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 91 |
88 if (!ctx || !si || si->sz < sizeof(vpx_codec_stream_info_t)) | 92 if (!ctx || !si || si->sz < sizeof(vpx_codec_stream_info_t)) |
89 res = VPX_CODEC_INVALID_PARAM; | 93 res = VPX_CODEC_INVALID_PARAM; |
90 else if (!ctx->iface || !ctx->priv) | 94 else if (!ctx->iface || !ctx->priv) |
91 res = VPX_CODEC_ERROR; | 95 res = VPX_CODEC_ERROR; |
92 else { | 96 else { |
93 /* Set default/unknown values */ | 97 /* Set default/unknown values */ |
94 si->w = 0; | 98 si->w = 0; |
95 si->h = 0; | 99 si->h = 0; |
96 | 100 |
97 res = ctx->iface->dec.get_si(ctx->priv->alg_priv, si); | 101 res = ctx->iface->dec.get_si(get_alg_priv(ctx), si); |
98 } | 102 } |
99 | 103 |
100 return SAVE_STATUS(ctx, res); | 104 return SAVE_STATUS(ctx, res); |
101 } | 105 } |
102 | 106 |
103 | 107 |
104 vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, | 108 vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, |
105 const uint8_t *data, | 109 const uint8_t *data, |
106 unsigned int data_sz, | 110 unsigned int data_sz, |
107 void *user_priv, | 111 void *user_priv, |
108 long deadline) { | 112 long deadline) { |
109 vpx_codec_err_t res; | 113 vpx_codec_err_t res; |
110 | 114 |
111 /* Sanity checks */ | 115 /* Sanity checks */ |
112 /* NULL data ptr allowed if data_sz is 0 too */ | 116 /* NULL data ptr allowed if data_sz is 0 too */ |
113 if (!ctx || (!data && data_sz) || (data && !data_sz)) | 117 if (!ctx || (!data && data_sz) || (data && !data_sz)) |
114 res = VPX_CODEC_INVALID_PARAM; | 118 res = VPX_CODEC_INVALID_PARAM; |
115 else if (!ctx->iface || !ctx->priv) | 119 else if (!ctx->iface || !ctx->priv) |
116 res = VPX_CODEC_ERROR; | 120 res = VPX_CODEC_ERROR; |
117 else { | 121 else { |
118 res = ctx->iface->dec.decode(ctx->priv->alg_priv, data, data_sz, | 122 res = ctx->iface->dec.decode(get_alg_priv(ctx), data, data_sz, user_priv, |
119 user_priv, deadline); | 123 deadline); |
120 } | 124 } |
121 | 125 |
122 return SAVE_STATUS(ctx, res); | 126 return SAVE_STATUS(ctx, res); |
123 } | 127 } |
124 | 128 |
125 vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, | 129 vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, |
126 vpx_codec_iter_t *iter) { | 130 vpx_codec_iter_t *iter) { |
127 vpx_image_t *img; | 131 vpx_image_t *img; |
128 | 132 |
129 if (!ctx || !iter || !ctx->iface || !ctx->priv) | 133 if (!ctx || !iter || !ctx->iface || !ctx->priv) |
130 img = NULL; | 134 img = NULL; |
131 else | 135 else |
132 img = ctx->iface->dec.get_frame(ctx->priv->alg_priv, iter); | 136 img = ctx->iface->dec.get_frame(get_alg_priv(ctx), iter); |
133 | 137 |
134 return img; | 138 return img; |
135 } | 139 } |
136 | 140 |
137 | 141 |
138 vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx
, | 142 vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx
, |
139 vpx_codec_put_frame_cb_fn_t cb, | 143 vpx_codec_put_frame_cb_fn_t cb, |
140 void *user_
priv) { | 144 void *user_
priv) { |
141 vpx_codec_err_t res; | 145 vpx_codec_err_t res; |
142 | 146 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get, | 182 vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get, |
179 vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) { | 183 vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) { |
180 vpx_codec_err_t res; | 184 vpx_codec_err_t res; |
181 | 185 |
182 if (!ctx || !cb_get || !cb_release) { | 186 if (!ctx || !cb_get || !cb_release) { |
183 res = VPX_CODEC_INVALID_PARAM; | 187 res = VPX_CODEC_INVALID_PARAM; |
184 } else if (!ctx->iface || !ctx->priv || | 188 } else if (!ctx->iface || !ctx->priv || |
185 !(ctx->iface->caps & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER)) { | 189 !(ctx->iface->caps & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER)) { |
186 res = VPX_CODEC_ERROR; | 190 res = VPX_CODEC_ERROR; |
187 } else { | 191 } else { |
188 res = ctx->iface->dec.set_fb_fn(ctx->priv->alg_priv, cb_get, cb_release, | 192 res = ctx->iface->dec.set_fb_fn(get_alg_priv(ctx), cb_get, cb_release, |
189 cb_priv); | 193 cb_priv); |
190 } | 194 } |
191 | 195 |
192 return SAVE_STATUS(ctx, res); | 196 return SAVE_STATUS(ctx, res); |
193 } | 197 } |
OLD | NEW |