• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2 * Copyright (C) 2018 Cadence Design Systems, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to use this Software with Cadence processor cores only and
7 * not with any other processors and platforms, subject to
8 * the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included
11 * in all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 
21 ******************************************************************************/
22 
23 /*******************************************************************************
24  * xa-vorbis-decoder.c
25  *
26  * VORBIS decoder plugin - thin wrapper around VORBISDEC library
27  *
28  ******************************************************************************/
29 
30 #define MODULE_TAG                      VORBISDEC
31 
32 /*******************************************************************************
33  * Includes
34  ******************************************************************************/
35 
36 #include "xf-plugin.h"
37 #include "audio/xa-audio-decoder-api.h"
38 #include "xa_vorbis_dec_api.h"
39 
40 /*******************************************************************************
41  * Override GET-CONFIG-PARAM function
42  ******************************************************************************/
43 
xa_vorbis_get_config_param(xa_codec_handle_t handle,WORD32 i_idx,pVOID pv_value)44 static inline XA_ERRORCODE xa_vorbis_get_config_param(xa_codec_handle_t handle, WORD32 i_idx, pVOID pv_value)
45 {
46     /* ...translate "standard" parameter index into internal value */
47     switch (i_idx)
48     {
49     case XA_CODEC_CONFIG_PARAM_CHANNELS:
50         /* ...return number of output channels */
51         i_idx = XA_VORBISDEC_CONFIG_PARAM_NUM_CHANNELS;
52         break;
53 
54     case XA_CODEC_CONFIG_PARAM_SAMPLE_RATE:
55         /* ...return output sampling frequency */
56         i_idx = XA_VORBISDEC_CONFIG_PARAM_SAMP_FREQ;
57         break;
58 
59     case XA_CODEC_CONFIG_PARAM_PCM_WIDTH:
60         /* ...return sample bit-width */
61         i_idx = XA_VORBISDEC_CONFIG_PARAM_PCM_WDSZ;
62         break;
63     }
64 
65     /* ...pass to library */
66     return xa_vorbis_dec(handle, XA_API_CMD_GET_CONFIG_PARAM, i_idx, pv_value);
67 }
68 
69 /*******************************************************************************
70  * API entry point
71  ******************************************************************************/
72 
xa_vorbis_decoder(xa_codec_handle_t p_xa_module_obj,WORD32 i_cmd,WORD32 i_idx,pVOID pv_value)73 XA_ERRORCODE xa_vorbis_decoder(xa_codec_handle_t p_xa_module_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value)
74 {
75     /* ...process common audio-decoder commands */
76     if (i_cmd == XA_API_CMD_GET_CONFIG_PARAM)
77     {
78         return xa_vorbis_get_config_param(p_xa_module_obj, i_idx, pv_value);
79     }
80     else
81     {
82         return xa_vorbis_dec(p_xa_module_obj, i_cmd, i_idx, pv_value);
83     }
84 }
85