Changeset 2298:159cae76ee09 in roaraudio
- Timestamp:
- 08/05/09 04:54:49 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroardsp/transcode_speex.c
r2296 r2298 31 31 32 32 int roar_xcoder_speex_init (struct roar_xcoder * state) { 33 return -1; 33 struct roar_xcoder_speex * self = malloc(sizeof(struct roar_xcoder_speex)); 34 struct roar_audio_info * info = &(state->info.pcm); 35 int tmp; 36 37 if ( self == NULL ) 38 return -1; 39 40 // curruntly only 16 bit mode is supported 41 if ( info->bits != 16 ) { 42 free(self); 43 return -1; 44 } 45 46 // curruntly only mono mode is supported 47 if ( info->channels != 1 ) { 48 free(self); 49 return -1; 50 } 51 52 memset(self, 0, sizeof(struct roar_xcoder_speex)); 53 54 state->inst = self; 55 56 self->mode = ROAR_SPEEX_MODE_UWB; 57 58 if (state->encode) { 59 switch (self->mode) { 60 case ROAR_SPEEX_MODE_NB: self->xcoder = speex_encoder_init(&speex_nb_mode); break; 61 case ROAR_SPEEX_MODE_WB: self->xcoder = speex_encoder_init(&speex_wb_mode); break; 62 case ROAR_SPEEX_MODE_UWB: self->xcoder = speex_encoder_init(&speex_uwb_mode); break; 63 } 64 tmp = 8; 65 speex_encoder_ctl(self->xcoder, SPEEX_SET_QUALITY, &tmp); 66 speex_encoder_ctl(self->xcoder, SPEEX_GET_FRAME_SIZE, &(self->frame_size)); 67 } else { 68 self->xcoder = NULL; 69 } 70 71 speex_bits_init(&(self->bits)); 72 73 return 0; 34 74 } 35 75 36 76 int roar_xcoder_speex_uninit (struct roar_xcoder * state) { 37 return -1; 77 struct roar_xcoder_speex * self = state->inst; 78 79 if ( self->xcoder != NULL ) { 80 if (state->encode) { 81 speex_encoder_destroy(self->xcoder); 82 } else { 83 speex_decoder_destroy(self->xcoder); 84 } 85 } 86 87 speex_bits_destroy(&(self->bits)); 88 89 free(self); 90 91 return 0; 38 92 } 39 93 40 94 int roar_xcoder_speex_packet_size(struct roar_xcoder * state, int samples) { 41 return -1; 95 struct roar_xcoder_speex * self = state->inst; 96 if (!state->encode) { 97 return -1; 98 } 99 100 return _16BIT * self->frame_size; 42 101 } 43 102
Note: See TracChangeset
for help on using the changeset viewer.