Lines Matching defs:sbc

49 #include "sbc.h"
912 static void sbc_set_defaults(sbc_t *sbc, unsigned long flags)
914 sbc->frequency = SBC_FREQ_44100;
915 sbc->mode = SBC_MODE_STEREO;
916 sbc->subbands = SBC_SB_8;
917 sbc->blocks = SBC_BLK_16;
918 sbc->bitpool = 32;
920 sbc->endian = SBC_LE;
922 sbc->endian = SBC_BE;
928 int sbc_init(sbc_t *sbc, unsigned long flags)
930 if (!sbc)
933 memset(sbc, 0, sizeof(sbc_t));
935 sbc->priv_alloc_base = malloc(sizeof(struct sbc_priv) + SBC_ALIGN_MASK);
936 if (!sbc->priv_alloc_base)
939 sbc->priv = (void *) (((uintptr_t) sbc->priv_alloc_base +
942 memset(sbc->priv, 0, sizeof(struct sbc_priv));
944 sbc_set_defaults(sbc, flags);
949 ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len)
951 return sbc_decode(sbc, input, input_len, NULL, 0, NULL);
954 ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
961 if (!sbc || !input)
964 priv = sbc->priv;
972 sbc->frequency = priv->frame.frequency;
973 sbc->mode = priv->frame.mode;
974 sbc->subbands = priv->frame.subband_mode;
975 sbc->blocks = priv->frame.block_mode;
976 sbc->allocation = priv->frame.allocation;
977 sbc->bitpool = priv->frame.bitpool;
979 priv->frame.codesize = sbc_get_codesize(sbc);
1004 if (sbc->endian == SBC_BE) {
1020 ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
1030 if (!sbc || !input)
1033 priv = sbc->priv;
1039 priv->frame.frequency = sbc->frequency;
1040 priv->frame.mode = sbc->mode;
1041 priv->frame.channels = sbc->mode == SBC_MODE_MONO ? 1 : 2;
1042 priv->frame.allocation = sbc->allocation;
1043 priv->frame.subband_mode = sbc->subbands;
1044 priv->frame.subbands = sbc->subbands ? 8 : 4;
1045 priv->frame.block_mode = sbc->blocks;
1046 priv->frame.blocks = 4 + (sbc->blocks * 4);
1047 priv->frame.bitpool = sbc->bitpool;
1048 priv->frame.codesize = sbc_get_codesize(sbc);
1049 priv->frame.length = sbc_get_frame_length(sbc);
1065 if (sbc->endian == SBC_BE)
1072 if (sbc->endian == SBC_BE)
1106 void sbc_finish(sbc_t *sbc)
1108 if (!sbc)
1111 free(sbc->priv_alloc_base);
1113 memset(sbc, 0, sizeof(sbc_t));
1116 size_t sbc_get_frame_length(sbc_t *sbc)
1122 priv = sbc->priv;
1126 subbands = sbc->subbands ? 8 : 4;
1127 blocks = 4 + (sbc->blocks * 4);
1128 channels = sbc->mode == SBC_MODE_MONO ? 1 : 2;
1129 joint = sbc->mode == SBC_MODE_JOINT_STEREO ? 1 : 0;
1130 bitpool = sbc->bitpool;
1142 unsigned sbc_get_frame_duration(sbc_t *sbc)
1148 priv = sbc->priv;
1150 subbands = sbc->subbands ? 8 : 4;
1151 blocks = 4 + (sbc->blocks * 4);
1157 switch (sbc->frequency) {
1180 size_t sbc_get_codesize(sbc_t *sbc)
1185 priv = sbc->priv;
1187 subbands = sbc->subbands ? 8 : 4;
1188 blocks = 4 + (sbc->blocks * 4);
1189 channels = sbc->mode == SBC_MODE_MONO ? 1 : 2;
1199 const char *sbc_get_implementation_info(sbc_t *sbc)
1203 if (!sbc)
1206 priv = sbc->priv;
1213 int sbc_reinit(sbc_t *sbc, unsigned long flags)
1217 if (!sbc || !sbc->priv)
1220 priv = sbc->priv;
1223 memset(sbc->priv, 0, sizeof(struct sbc_priv));
1225 sbc_set_defaults(sbc, flags);