Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2013 - 2016 Sony Corporation
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef _LDACLIB_H
     18 #define _LDACLIB_H
     19 #ifdef __cplusplus
     20 extern "C" {
     21 #endif /* __cplusplus */
     22 
     23 /***************************************************************************************************
     24     Macro Definitions
     25 ***************************************************************************************************/
     26 #define LDAC_HOST_ENDIAN_LITTLE
     27 
     28 #define LDAC_PRCNCH        2
     29 #define LDAC_FRMHDRBYTES   3
     30 #define LDAC_CONFIGBYTES   4
     31 
     32 typedef int LDAC_RESULT;
     33 #define LDAC_S_OK          ((LDAC_RESULT)0x00000000L)
     34 #define LDAC_S_FALSE       ((LDAC_RESULT)0x00000001L)
     35 #define LDAC_E_UNEXPECTED  ((LDAC_RESULT)0x8000FFFFL)
     36 #define LDAC_E_OUTOFMEMORY ((LDAC_RESULT)0x8007000EL)
     37 #define LDAC_E_INVALIDARG  ((LDAC_RESULT)0x80070057L)
     38 #define LDAC_E_FAIL        ((LDAC_RESULT)0x80004005L)
     39 #define LDAC_E_NOTIMPL     ((LDAC_RESULT)0x80004001L)
     40 
     41 #define LDAC_SUCCEEDED(result) ((LDAC_RESULT)(result)>=0)
     42 #define LDAC_FAILED(result)    ((LDAC_RESULT)(result)<0)
     43 
     44 #define DECLSPEC
     45 
     46 typedef struct _handle_ldac_struct *HANDLE_LDAC;
     47 
     48 typedef enum {
     49     LDAC_SMPL_FMT_NONE,
     50     LDAC_SMPL_FMT_S08,
     51     LDAC_SMPL_FMT_S16,
     52     LDAC_SMPL_FMT_S24,
     53     LDAC_SMPL_FMT_S32,
     54     LDAC_SMPL_FMT_F32,
     55     LDAC_SMPL_FMT_NUM,
     56     LDAC_SMPL_FMT_MAX = 0x7fffffff
     57 } LDAC_SMPL_FMT_T;
     58 
     59 /***************************************************************************************************
     60     Function Declarations
     61 ***************************************************************************************************/
     62 /* Common API Functions */
     63 DECLSPEC int ldaclib_get_version(void);
     64 DECLSPEC int ldaclib_get_major_version(void);
     65 DECLSPEC int ldaclib_get_minor_version(void);
     66 DECLSPEC int ldaclib_get_branch_version(void);
     67 
     68 DECLSPEC LDAC_RESULT ldaclib_get_sampling_rate_index(int, int *);
     69 DECLSPEC LDAC_RESULT ldaclib_get_sampling_rate(int, int *);
     70 DECLSPEC LDAC_RESULT ldaclib_get_frame_samples(int, int *);
     71 DECLSPEC LDAC_RESULT ldaclib_get_nlnn(int, int *);
     72 DECLSPEC LDAC_RESULT ldaclib_get_channel(int, int *);
     73 DECLSPEC LDAC_RESULT ldaclib_get_channel_config_index(int, int *);
     74 DECLSPEC LDAC_RESULT ldaclib_check_nlnn_shift(int, int);
     75 
     76 DECLSPEC HANDLE_LDAC ldaclib_get_handle(void);
     77 DECLSPEC LDAC_RESULT ldaclib_free_handle(HANDLE_LDAC);
     78 
     79 DECLSPEC LDAC_RESULT ldaclib_set_config_info(HANDLE_LDAC, int, int, int, int);
     80 DECLSPEC LDAC_RESULT ldaclib_get_config_info(HANDLE_LDAC, int *, int *, int *, int *);
     81 DECLSPEC LDAC_RESULT ldaclib_set_frame_header(HANDLE_LDAC, unsigned char *, int, int, int, int);
     82 
     83 /* Encoder API Functions */
     84 DECLSPEC LDAC_RESULT ldaclib_get_encode_setting(int, int, int *, int *, int *, int *, int *, int *, int *);
     85 DECLSPEC LDAC_RESULT ldaclib_set_encode_frame_length(HANDLE_LDAC, int);
     86 DECLSPEC LDAC_RESULT ldaclib_get_encode_frame_length(HANDLE_LDAC, int *);
     87 DECLSPEC LDAC_RESULT ldaclib_set_encode_info(HANDLE_LDAC, int, int, int, int, int, int, int);
     88 DECLSPEC LDAC_RESULT ldaclib_init_encode(HANDLE_LDAC);
     89 DECLSPEC LDAC_RESULT ldaclib_free_encode(HANDLE_LDAC);
     90 DECLSPEC LDAC_RESULT ldaclib_encode(HANDLE_LDAC, char *[], LDAC_SMPL_FMT_T, unsigned char *, int *);
     91 DECLSPEC LDAC_RESULT ldaclib_flush_encode(HANDLE_LDAC, LDAC_SMPL_FMT_T, unsigned char *, int *);
     92 
     93 
     94 /* Error Code Dispatch */
     95 DECLSPEC LDAC_RESULT ldaclib_get_error_code(HANDLE_LDAC, int *);
     96 DECLSPEC LDAC_RESULT ldaclib_get_internal_error_code(HANDLE_LDAC, int *);
     97 DECLSPEC LDAC_RESULT ldaclib_clear_error_code(HANDLE_LDAC);
     98 DECLSPEC LDAC_RESULT ldaclib_clear_internal_error_code(HANDLE_LDAC);
     99 
    100 /***************************************************************************************************
    101     Error Code Definitions
    102 ***************************************************************************************************/
    103 #define LDAC_ERR_NONE                       0
    104 
    105 /* Non Fatal Error */
    106 #define LDAC_ERR_NON_FATAL                  1
    107 
    108 /* Non Fatal Error (Block Level) */
    109 #define LDAC_ERR_BIT_ALLOCATION             5
    110 
    111 /* Non Fatal Error (Handle Level) */
    112 #define LDAC_ERR_NOT_IMPLEMENTED          128
    113 #define LDAC_ERR_NON_FATAL_ENCODE         132
    114 
    115 /* Fatal Error */
    116 #define LDAC_ERR_FATAL                    256
    117 
    118 /* Fatal Error (Block Level) */
    119 #define LDAC_ERR_SYNTAX_BAND              260
    120 #define LDAC_ERR_SYNTAX_GRAD_A            261
    121 #define LDAC_ERR_SYNTAX_GRAD_B            262
    122 #define LDAC_ERR_SYNTAX_GRAD_C            263
    123 #define LDAC_ERR_SYNTAX_GRAD_D            264
    124 #define LDAC_ERR_SYNTAX_GRAD_E            265
    125 #define LDAC_ERR_SYNTAX_IDSF              266
    126 #define LDAC_ERR_SYNTAX_SPEC              267
    127 
    128 #define LDAC_ERR_BIT_PACKING              280
    129 
    130 #define LDAC_ERR_ALLOC_MEMORY             300
    131 
    132 /* Fatal Error (Handle Level) */
    133 #define LDAC_ERR_FATAL_HANDLE             512
    134 
    135 #define LDAC_ERR_ILL_SYNCWORD             516
    136 #define LDAC_ERR_ILL_SMPL_FORMAT          517
    137 
    138 #define LDAC_ERR_ASSERT_SAMPLING_RATE     530
    139 #define LDAC_ERR_ASSERT_SUP_SAMPLING_RATE 531
    140 #define LDAC_ERR_CHECK_SAMPLING_RATE      532
    141 #define LDAC_ERR_ASSERT_CHANNEL_CONFIG    533
    142 #define LDAC_ERR_CHECK_CHANNEL_CONFIG     534
    143 #define LDAC_ERR_ASSERT_FRAME_LENGTH      535
    144 #define LDAC_ERR_ASSERT_SUP_FRAME_LENGTH  536
    145 #define LDAC_ERR_ASSERT_FRAME_STATUS      537
    146 #define LDAC_ERR_ASSERT_NSHIFT            538
    147 
    148 #define LDAC_ERR_ENC_INIT_ALLOC           550
    149 #define LDAC_ERR_ENC_ILL_GRADMODE         551
    150 #define LDAC_ERR_ENC_ILL_GRADPAR_A        552
    151 #define LDAC_ERR_ENC_ILL_GRADPAR_B        553
    152 #define LDAC_ERR_ENC_ILL_GRADPAR_C        554
    153 #define LDAC_ERR_ENC_ILL_GRADPAR_D        555
    154 #define LDAC_ERR_ENC_ILL_NBANDS           556
    155 #define LDAC_ERR_PACK_BLOCK_FAILED        557
    156 
    157 #define LDAC_ERR_DEC_INIT_ALLOC           570
    158 #define LDAC_ERR_INPUT_BUFFER_SIZE        571
    159 #define LDAC_ERR_UNPACK_BLOCK_FAILED      572
    160 #define LDAC_ERR_UNPACK_BLOCK_ALIGN       573
    161 #define LDAC_ERR_UNPACK_FRAME_ALIGN       574
    162 #define LDAC_ERR_FRAME_LENGTH_OVER        575
    163 #define LDAC_ERR_FRAME_ALIGN_OVER         576
    164 
    165 #define LDAC_ERR_FRAME_LIMIT              998
    166 #define LDAC_ERR_TIME_EXPIRED             999
    167 
    168 #define LDAC_ERROR(err)       ((LDAC_ERR_NON_FATAL) <= (err) ? 1 : 0)
    169 #define LDAC_FATAL_ERROR(err) ((LDAC_ERR_FATAL) <= (err) ? 1 : 0)
    170 
    171 #ifdef __cplusplus
    172 }
    173 #endif /* __cplusplus */
    174 #endif /* _LDACLIB_H */
    175 
    176