2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
13 * \brief Provides the high level interface to wrap decoder algorithms.
18 #include "vpx/vpx_decoder.h"
19 #include "vpx/internal/vpx_codec_internal.h"
21 #define SAVE_STATUS(ctx,var) (ctx?(ctx->err = var):var)
23 const char *vpx_dec_iface_name(vpx_dec_iface_t
*iface
)
25 return vpx_codec_iface_name((vpx_codec_iface_t
*)iface
);
28 const char *vpx_dec_err_to_string(vpx_dec_err_t err
)
30 return vpx_codec_err_to_string(err
);
33 const char *vpx_dec_error(vpx_dec_ctx_t
*ctx
)
35 return vpx_codec_error((vpx_codec_ctx_t
*)ctx
);
38 const char *vpx_dec_error_detail(vpx_dec_ctx_t
*ctx
)
40 return vpx_codec_error_detail((vpx_codec_ctx_t
*)ctx
);
44 vpx_dec_err_t
vpx_dec_init_ver(vpx_dec_ctx_t
*ctx
,
45 vpx_dec_iface_t
*iface
,
48 return vpx_codec_dec_init_ver((vpx_codec_ctx_t
*)ctx
,
49 (vpx_codec_iface_t
*)iface
,
56 vpx_dec_err_t
vpx_dec_destroy(vpx_dec_ctx_t
*ctx
)
58 return vpx_codec_destroy((vpx_codec_ctx_t
*)ctx
);
62 vpx_dec_caps_t
vpx_dec_get_caps(vpx_dec_iface_t
*iface
)
64 return vpx_codec_get_caps((vpx_codec_iface_t
*)iface
);
68 vpx_dec_err_t
vpx_dec_peek_stream_info(vpx_dec_iface_t
*iface
,
71 vpx_dec_stream_info_t
*si
)
73 return vpx_codec_peek_stream_info((vpx_codec_iface_t
*)iface
, data
, data_sz
,
74 (vpx_codec_stream_info_t
*)si
);
78 vpx_dec_err_t
vpx_dec_get_stream_info(vpx_dec_ctx_t
*ctx
,
79 vpx_dec_stream_info_t
*si
)
81 return vpx_codec_get_stream_info((vpx_codec_ctx_t
*)ctx
,
82 (vpx_codec_stream_info_t
*)si
);
86 vpx_dec_err_t
vpx_dec_control(vpx_dec_ctx_t
*ctx
,
90 return vpx_codec_control_((vpx_codec_ctx_t
*)ctx
, ctrl_id
, data
);
94 vpx_dec_err_t
vpx_dec_decode(vpx_dec_ctx_t
*ctx
,
101 return vpx_codec_decode((vpx_codec_ctx_t
*)ctx
, data
, data_sz
, user_priv
,
105 vpx_image_t
*vpx_dec_get_frame(vpx_dec_ctx_t
*ctx
,
106 vpx_dec_iter_t
*iter
)
108 return vpx_codec_get_frame((vpx_codec_ctx_t
*)ctx
, iter
);
112 vpx_dec_err_t
vpx_dec_register_put_frame_cb(vpx_dec_ctx_t
*ctx
,
113 vpx_dec_put_frame_cb_fn_t cb
,
116 return vpx_codec_register_put_frame_cb((vpx_codec_ctx_t
*)ctx
, cb
,
121 vpx_dec_err_t
vpx_dec_register_put_slice_cb(vpx_dec_ctx_t
*ctx
,
122 vpx_dec_put_slice_cb_fn_t cb
,
125 return vpx_codec_register_put_slice_cb((vpx_codec_ctx_t
*)ctx
, cb
,
130 vpx_dec_err_t
vpx_dec_xma_init_ver(vpx_dec_ctx_t
*ctx
,
131 vpx_dec_iface_t
*iface
,
134 return vpx_codec_dec_init_ver((vpx_codec_ctx_t
*)ctx
,
135 (vpx_codec_iface_t
*)iface
,
141 vpx_dec_err_t
vpx_dec_get_mem_map(vpx_dec_ctx_t
*ctx_
,
142 vpx_dec_mmap_t
*mmap
,
143 const vpx_dec_stream_info_t
*si
,
144 vpx_dec_iter_t
*iter
)
146 vpx_codec_ctx_t
*ctx
= (vpx_codec_ctx_t
*)ctx_
;
147 vpx_dec_err_t res
= VPX_DEC_OK
;
149 if (!ctx
|| !mmap
|| !si
|| !iter
|| !ctx
->iface
)
150 res
= VPX_DEC_INVALID_PARAM
;
151 else if (!(ctx
->iface
->caps
& VPX_DEC_CAP_XMA
))
155 if (!ctx
->config
.dec
)
157 ctx
->config
.dec
= malloc(sizeof(vpx_codec_dec_cfg_t
));
158 ctx
->config
.dec
->w
= si
->w
;
159 ctx
->config
.dec
->h
= si
->h
;
162 res
= ctx
->iface
->get_mmap(ctx
, mmap
, iter
);
165 return SAVE_STATUS(ctx
, res
);
169 vpx_dec_err_t
vpx_dec_set_mem_map(vpx_dec_ctx_t
*ctx_
,
170 vpx_dec_mmap_t
*mmap
,
171 unsigned int num_maps
)
173 vpx_codec_ctx_t
*ctx
= (vpx_codec_ctx_t
*)ctx_
;
174 vpx_dec_err_t res
= VPX_DEC_MEM_ERROR
;
176 if (!ctx
|| !mmap
|| !ctx
->iface
)
177 res
= VPX_DEC_INVALID_PARAM
;
178 else if (!(ctx
->iface
->caps
& VPX_DEC_CAP_XMA
))
182 void *save
= (ctx
->priv
) ? NULL
: ctx
->config
.dec
;
185 for (i
= 0; i
< num_maps
; i
++, mmap
++)
190 /* Everything look ok, set the mmap in the decoder */
191 res
= ctx
->iface
->set_mmap(ctx
, mmap
);
197 if (save
) free(save
);
200 return SAVE_STATUS(ctx
, res
);