Lines Matching defs:sbc_info

42 struct sbc_info {
157 static void set_info_and_sample_spec_from_sbc_config(struct sbc_info *sbc_info, pa_sample_spec *sample_spec, const a2dp_sbc_t *config) {
160 sbc_info->frequency = SBC_FREQ_16000;
164 sbc_info->frequency = SBC_FREQ_32000;
168 sbc_info->frequency = SBC_FREQ_44100;
172 sbc_info->frequency = SBC_FREQ_48000;
181 sbc_info->mode = SBC_MODE_MONO;
185 sbc_info->mode = SBC_MODE_DUAL_CHANNEL;
189 sbc_info->mode = SBC_MODE_STEREO;
193 sbc_info->mode = SBC_MODE_JOINT_STEREO;
202 sbc_info->allocation = SBC_AM_SNR;
205 sbc_info->allocation = SBC_AM_LOUDNESS;
213 sbc_info->subbands = SBC_SB_4;
214 sbc_info->nr_subbands = 4;
217 sbc_info->subbands = SBC_SB_8;
218 sbc_info->nr_subbands = 8;
226 sbc_info->blocks = SBC_BLK_4;
227 sbc_info->nr_blocks = 4;
230 sbc_info->blocks = SBC_BLK_8;
231 sbc_info->nr_blocks = 8;
234 sbc_info->blocks = SBC_BLK_12;
235 sbc_info->nr_blocks = 12;
238 sbc_info->blocks = SBC_BLK_16;
239 sbc_info->nr_blocks = 16;
245 sbc_info->min_bitpool = config->min_bitpool;
246 sbc_info->max_bitpool = config->max_bitpool;
249 static void set_params(struct sbc_info *sbc_info) {
250 sbc_info->sbc.frequency = sbc_info->frequency;
251 sbc_info->sbc.blocks = sbc_info->blocks;
252 sbc_info->sbc.subbands = sbc_info->subbands;
253 sbc_info->sbc.mode = sbc_info->mode;
254 sbc_info->sbc.allocation = sbc_info->allocation;
255 sbc_info->sbc.bitpool = sbc_info->initial_bitpool;
256 sbc_info->sbc.endian = SBC_LE;
258 sbc_info->codesize = sbc_get_codesize(&sbc_info->sbc);
259 sbc_info->frame_length = sbc_get_frame_length(&sbc_info->sbc);
264 struct sbc_info sbc_info;
269 ret = sbc_init(&sbc_info.sbc, 0);
275 set_info_and_sample_spec_from_sbc_config(&sbc_info, &sample_spec, config);
280 sbc_info.initial_bitpool = midpoint;
281 set_params(&sbc_info);
283 size_t bitrate = sbc_info.frame_length * 8 * sample_spec.rate / (sbc_info.nr_subbands * sbc_info.nr_blocks);
291 sbc_finish(&sbc_info.sbc);
648 struct sbc_info *sbc_info;
655 sbc_info = pa_xnew0(struct sbc_info, 1);
657 ret = sbc_init(&sbc_info->sbc, 0);
659 pa_xfree(sbc_info);
666 set_info_and_sample_spec_from_sbc_config(sbc_info, sample_spec, config);
673 sbc_info->initial_bitpool = for_encoding ? sbc_info->max_bitpool : sbc_info->min_bitpool;
675 set_params(sbc_info);
678 sbc_info->sbc.allocation ? "SNR" : "Loudness", sbc_info->sbc.subbands ? 8 : 4,
679 (sbc_info->sbc.blocks+1)*4, sbc_info->sbc.mode == SBC_MODE_MONO ? "Mono" :
680 sbc_info->sbc.mode == SBC_MODE_DUAL_CHANNEL ? "DualChannel" :
681 sbc_info->sbc.mode == SBC_MODE_STEREO ? "Stereo" : "JointStereo",
682 sbc_info->sbc.bitpool, (unsigned)sbc_info->codesize, (unsigned)sbc_info->frame_length);
684 return sbc_info;
688 struct sbc_info *sbc_info = (struct sbc_info *) codec_info;
690 sbc_finish(&sbc_info->sbc);
691 pa_xfree(sbc_info);
694 static void set_bitpool(struct sbc_info *sbc_info, uint8_t bitpool) {
695 if (bitpool > sbc_info->max_bitpool)
696 bitpool = sbc_info->max_bitpool;
697 else if (bitpool < sbc_info->min_bitpool)
698 bitpool = sbc_info->min_bitpool;
700 sbc_info->sbc.bitpool = bitpool;
702 sbc_info->codesize = sbc_get_codesize(&sbc_info->sbc);
703 sbc_info->frame_length = sbc_get_frame_length(&sbc_info->sbc);
705 pa_log_debug("Bitpool has changed to %u", sbc_info->sbc.bitpool);
709 struct sbc_info *sbc_info = (struct sbc_info *) codec_info;
712 ret = sbc_reinit(&sbc_info->sbc, 0);
719 set_params(sbc_info);
721 sbc_info->seq_num = 0;
726 struct sbc_info *sbc_info = (struct sbc_info *) codec_info;
728 size_t frame_count = (link_mtu - rtp_size) / sbc_info->frame_length;
738 pa_log_warn("SBC packet size %lu is larger than link MTU %lu", sbc_info->frame_length + rtp_size, link_mtu);
742 return frame_count * sbc_info->codesize;
746 struct sbc_info *sbc_info = (struct sbc_info *) codec_info;
750 pa_assert_fp(input_size % sbc_info->codesize == 0);
752 return (input_size / sbc_info->codesize) * sbc_info->frame_length + rtp_size;
756 struct sbc_info *sbc_info = (struct sbc_info *) codec_info;
759 bitpool = PA_MAX(sbc_info->sbc.bitpool - SBC_BITPOOL_DEC_STEP, sbc_info->min_bitpool);
761 if (sbc_info->sbc.bitpool == bitpool)
764 set_bitpool(sbc_info, bitpool);
769 struct sbc_info *sbc_info = (struct sbc_info *) codec_info;
772 bitpool = PA_MIN(sbc_info->sbc.bitpool + SBC_BITPOOL_INC_STEP, sbc_info->max_bitpool);
774 if (sbc_info->sbc.bitpool == bitpool)
777 set_bitpool(sbc_info, bitpool);
782 struct sbc_info *sbc_info = (struct sbc_info *) codec_info;
806 encoded = sbc_encode(&sbc_info->sbc,
822 pa_assert_fp((size_t) encoded == sbc_info->codesize);
825 pa_assert_fp((size_t) written == sbc_info->frame_length);
837 pa_log_debug("Using SBC codec implementation: %s", pa_strnull(sbc_get_implementation_info(&sbc_info->sbc)));
854 header->sequence_number = htons(sbc_info->seq_num++);
864 struct sbc_info *sbc_info = (struct sbc_info *) codec_info;
895 decoded = sbc_decode(&sbc_info->sbc,
906 sbc_info->frame_length = sbc_get_frame_length(&sbc_info->sbc);
909 pa_assert_fp((size_t) decoded == sbc_info->frame_length);
912 pa_assert_fp((size_t) written == sbc_info->codesize);