int tdav_codec_gsm_open(tmedia_codec_t* self) { tdav_codec_gsm_t* gsm = (tdav_codec_gsm_t*)self; if(!gsm->encoder && !(gsm->encoder = gsm_create())) { TSK_DEBUG_ERROR("Failed to create GSM encoder"); return -2; } if(!gsm->decoder && !(gsm->decoder = gsm_create())) { TSK_DEBUG_ERROR("Failed to create GSM decoder"); return -3; } return 0; }
static int gsmstart_rw(ft_t ft, int w) { struct gsmpriv *p = (struct gsmpriv *) ft->priv; int ch; ft->info.encoding = ST_ENCODING_GSM; ft->info.size = ST_SIZE_BYTE; if (!ft->info.rate) ft->info.rate = 8000; if (ft->info.channels == -1) ft->info.channels = 1; p->channels = ft->info.channels; if (p->channels > MAXCHANS || p->channels <= 0) { st_fail_errno(ft,ST_EFMT,"gsm: channels(%d) must be in 1-16", ft->info.channels); return(ST_EOF); } for (ch=0; ch<p->channels; ch++) { p->handle[ch] = gsm_create(); if (!p->handle[ch]) { st_fail_errno(ft,errno,"unable to create GSM stream"); return (ST_EOF); } } p->frames = (gsm_byte*) malloc(p->channels*FRAMESIZE); p->samples = (gsm_signal*) malloc(BLOCKSIZE * (p->channels+1) * sizeof(gsm_signal)); p->sampleTop = p->samples + BLOCKSIZE*p->channels; p->samplePtr = (w)? p->samples : p->sampleTop; return (ST_SUCCESS); }
static av_cold int libgsm_decode_init(AVCodecContext *avctx) { LibGSMDecodeContext *s = avctx->priv_data; avctx->channels = 1; avctx->channel_layout = AV_CH_LAYOUT_MONO; if (!avctx->sample_rate) avctx->sample_rate = 8000; avctx->sample_fmt = AV_SAMPLE_FMT_S16; s->state = gsm_create(); switch(avctx->codec_id) { case AV_CODEC_ID_GSM: avctx->frame_size = GSM_FRAME_SIZE; avctx->block_align = GSM_BLOCK_SIZE; break; case AV_CODEC_ID_GSM_MS: { int one = 1; gsm_option(s->state, GSM_OPT_WAV49, &one); avctx->frame_size = 2 * GSM_FRAME_SIZE; avctx->block_align = GSM_MS_BLOCK_SIZE; } } return 0; }
int vmsStartRecord(VmsPlayRecordType *vmsP) { int er; vmsP->playRecordObj = gsm_create(); SetAudioTypeLocal(0,2);//record vmsP->aqRecordPlayPcm = InitAudio(vmsP, CallBackVmsUI, CallBackVmsSoundPCM);//playback if(CreateSoundThread(false,vmsP->aqRecordPlayPcm,false,0)) { DeInitAudio( vmsP->aqRecordPlayPcm,false); vmsP->aqRecordPlayPcm = 0; return 1; } else { er = PlayAudio(vmsP->aqRecordPlayPcm); if(er) { DeInitAudio( vmsP->aqRecordPlayPcm,true); vmsP->aqRecordPlayPcm = 0; } return er; } }
static void enc_init(MSFilter *f){ EncState *s=ms_new(EncState,1); s->state=gsm_create(); s->ts=0; s->bufferizer=ms_bufferizer_new(); f->data=s; }
OsStatus MpdSipxGSM::initDecode() { if (mpGsmState == NULL) mpGsmState = gsm_create(); return OS_SUCCESS; }
static void activateGsm(LADSPA_Handle instance) { Gsm *plugin_data = (Gsm *)instance; biquad *blf = plugin_data->blf; int count = plugin_data->count; LADSPA_Data *dry = plugin_data->dry; gsm_signal *dst = plugin_data->dst; float fs = plugin_data->fs; gsm handle = plugin_data->handle; int resamp = plugin_data->resamp; float rsf = plugin_data->rsf; gsm_signal *src = plugin_data->src; #line 41 "gsm_1215.xml" count = 0; memset(src, 0, sizeof(gsm_signal) * 160); memset(dst, 0, sizeof(gsm_signal) * 163); memset(dry, 0, sizeof(LADSPA_Data) * 160 * resamp); handle = gsm_create(); biquad_init(blf); hs_set_params(blf, 3500.0f, -50.0f, 0.7f, fs); plugin_data->blf = blf; plugin_data->count = count; plugin_data->dry = dry; plugin_data->dst = dst; plugin_data->fs = fs; plugin_data->handle = handle; plugin_data->resamp = resamp; plugin_data->rsf = rsf; plugin_data->src = src; }
static void gst_gsmenc_init (GstGSMEnc * gsmenc) { gint use_wav49; /* create the sink and src pads */ gsmenc->sinkpad = gst_pad_new_from_static_template (&gsmenc_sink_template, "sink"); gst_pad_set_chain_function (gsmenc->sinkpad, gst_gsmenc_chain); gst_pad_set_setcaps_function (gsmenc->sinkpad, gst_gsmenc_setcaps); gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->sinkpad); gsmenc->srcpad = gst_pad_new_from_static_template (&gsmenc_src_template, "src"); gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->srcpad); gsmenc->state = gsm_create (); /* turn off WAV49 handling */ use_wav49 = 0; gsm_option (gsmenc->state, GSM_OPT_WAV49, &use_wav49); gsmenc->adapter = gst_adapter_new (); gsmenc->next_ts = 0; }
static void * create_codec(const struct PluginCodec_Definition * codec) { int opt = (int)codec->userData; struct gsm_state * context = gsm_create(); gsm_option(context, GSM_OPT_WAV49, &opt); return context; }
CODEC_API void *PLG_INIT_V1_2(libgsm)(const char* fmtp, int isDecoder, struct MppCodecFmtpInfoV1_2* pCodecInfo) { struct libgsm_codec_data *mpGsm; if (pCodecInfo == NULL) { return NULL; } pCodecInfo->signalingCodec = FALSE; pCodecInfo->minBitrate = 13200; pCodecInfo->maxBitrate = 13200; pCodecInfo->numSamplesPerFrame = GSM_FRAME_SAMPLES; pCodecInfo->minFrameBytes = GSM_FRAME_BYTES; pCodecInfo->maxFrameBytes = GSM_FRAME_BYTES; pCodecInfo->packetLossConcealment = CODEC_PLC_NONE; pCodecInfo->vadCng = CODEC_CNG_NONE; pCodecInfo->algorithmicDelay = 0; mpGsm = (struct libgsm_codec_data *)malloc(sizeof(struct libgsm_codec_data)); if (!mpGsm) { return NULL; } mpGsm->mBufferLoad = 0; mpGsm->mpGsmState = gsm_create(); return mpGsm; }
static av_cold int libgsm_decode_init(AVCodecContext *avctx) { if (avctx->channels > 1) { av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n", avctx->channels); return -1; } if (!avctx->channels) avctx->channels = 1; if (!avctx->sample_rate) avctx->sample_rate = 8000; avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->priv_data = gsm_create(); switch(avctx->codec_id) { case CODEC_ID_GSM: avctx->frame_size = GSM_FRAME_SIZE; avctx->block_align = GSM_BLOCK_SIZE; break; case CODEC_ID_GSM_MS: { int one = 1; gsm_option(avctx->priv_data, GSM_OPT_WAV49, &one); avctx->frame_size = 2 * GSM_FRAME_SIZE; avctx->block_align = GSM_MS_BLOCK_SIZE; } } return 0; }
static int decode_update(struct audec_state **adsp, const struct aucodec *ac, const char *fmtp) { struct audec_state *st; int err = 0; (void)ac; (void)fmtp; if (!adsp) return EINVAL; if (*adsp) return 0; st = mem_zalloc(sizeof(*st), decode_destructor); if (!st) return ENOMEM; st->dec = gsm_create(); if (!st->dec) { err = EPROTO; goto out; } out: if (err) mem_deref(st); else *adsp = st; return err; }
t_gsm_audio_encoder::t_gsm_audio_encoder(uint16 payload_id, uint16 ptime, t_user *user_config) : t_audio_encoder(payload_id, PTIME_GSM, user_config) { _codec = CODEC_GSM; _max_payload_size = 33; gsm_encoder = gsm_create(); }
static void libgsm_flush(AVCodecContext *avctx) { LibGSMDecodeContext *s = avctx->priv_data; int one = 1; gsm_destroy(s->state); s->state = gsm_create(); if (avctx->codec_id == CODEC_ID_GSM_MS) gsm_option(s->state, GSM_OPT_WAV49, &one); }
static gboolean gst_gsmdec_start (GstAudioDecoder * dec) { GstGSMDec *gsmdec = GST_GSMDEC (dec); GST_DEBUG_OBJECT (dec, "start"); gsmdec->state = gsm_create (); return TRUE; }
/* * Open codec. */ static pj_status_t gsm_codec_open( pjmedia_codec *codec, pjmedia_codec_param *attr ) { struct gsm_data *gsm_data = (struct gsm_data*) codec->codec_data; pj_assert(gsm_data != NULL); pj_assert(gsm_data->encoder == NULL && gsm_data->decoder == NULL); gsm_data->encoder = gsm_create(); if (!gsm_data->encoder) return PJMEDIA_CODEC_EFAILED; gsm_data->decoder = gsm_create(); if (!gsm_data->decoder) return PJMEDIA_CODEC_EFAILED; gsm_data->vad_enabled = (attr->setting.vad != 0); gsm_data->plc_enabled = (attr->setting.plc != 0); return PJ_SUCCESS; }
static av_cold int libgsm_init(AVCodecContext *avctx) { if (avctx->channels > 1) { av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n", avctx->channels); return -1; } if(avctx->codec->decode){ if(!avctx->channels) avctx->channels= 1; if(!avctx->sample_rate) avctx->sample_rate= 8000; avctx->sample_fmt = SAMPLE_FMT_S16; }else{ if (avctx->sample_rate != 8000) { av_log(avctx, AV_LOG_ERROR, "Sample rate 8000Hz required for GSM, got %dHz\n", avctx->sample_rate); if(avctx->strict_std_compliance > FF_COMPLIANCE_INOFFICIAL) return -1; } if (avctx->bit_rate != 13000 /* Official */ && avctx->bit_rate != 13200 /* Very common */ && avctx->bit_rate != 0 /* Unknown; a.o. mov does not set bitrate when decoding */ ) { av_log(avctx, AV_LOG_ERROR, "Bitrate 13000bps required for GSM, got %dbps\n", avctx->bit_rate); if(avctx->strict_std_compliance > FF_COMPLIANCE_INOFFICIAL) return -1; } } avctx->priv_data = gsm_create(); switch(avctx->codec_id) { case CODEC_ID_GSM: avctx->frame_size = GSM_FRAME_SIZE; avctx->block_align = GSM_BLOCK_SIZE; break; case CODEC_ID_GSM_MS: { int one = 1; gsm_option(avctx->priv_data, GSM_OPT_WAV49, &one); avctx->frame_size = 2*GSM_FRAME_SIZE; avctx->block_align = GSM_MS_BLOCK_SIZE; } } avctx->coded_frame= avcodec_alloc_frame(); avctx->coded_frame->key_frame= 1; return 0; }
GSMCodec::GSMCodec():AudioCodec() { int fast = 0; int wav = 0; type=AudioCodec::GSM; numFrameSamples=160; frameLength=33; g = gsm_create(); // gsm_option(g, GSM_OPT_FAST, &fast); gsm_option(g, GSM_OPT_WAV49, &wav); }
int wav_gsm610_writer_init (SF_PRIVATE *psf) { GSM610_PRIVATE *pgsm610 ; int true = 1, samplesperblock, bytespersec ; if (psf->mode != SF_MODE_WRITE) return SFE_BAD_MODE_RW ; if (! (pgsm610 = malloc (sizeof (GSM610_PRIVATE)))) return SFE_MALLOC_FAILED ; psf->fdata = (void*) pgsm610 ; memset (pgsm610, 0, sizeof (GSM610_PRIVATE)) ; if (! (pgsm610->gsm_data = gsm_create ())) return SFE_MALLOC_FAILED ; gsm_option (pgsm610->gsm_data, GSM_OPT_WAV49, &true) ; pgsm610->blockcount = 0 ; pgsm610->samplecount = 0 ; samplesperblock = GSM610_SAMPLES ; bytespersec = psf->sf.samplerate * GSM610_BLOCKSIZE / GSM610_SAMPLES ; if (bytespersec * GSM610_SAMPLES / GSM610_BLOCKSIZE < psf->sf.samplerate) bytespersec ++ ; psf->datalength = (psf->sf.samples / samplesperblock) * samplesperblock ; if (psf->sf.samples % samplesperblock) psf->datalength += samplesperblock ; wav_gsm610_write_header (psf) ; #if defined(USE_LIBSND_ALL) || defined(USE_LIBSND_WRITE) psf->write_short = (func_short) wav_gsm610_write_s ; #endif #if defined(USE_LIBSND_ALL) psf->write_int = (func_int) wav_gsm610_write_i ; psf->write_float = (func_float) wav_gsm610_write_f ; psf->write_double = (func_double) wav_gsm610_write_d ; #endif #if defined(USE_LIBSND_ALL) psf->seek_func = NULL ; /* Not seekable */ #endif psf->close = (func_close) wav_gsm610_close ; psf->write_header = (func_wr_hdr) wav_gsm610_write_header ; return 0 ; } /* wav_gsm610_writer_init */
static av_cold int libgsm_encode_init(AVCodecContext *avctx) { if (avctx->channels > 1) { av_log(avctx, AV_LOG_ERROR, "Mono required for GSM, got %d channels\n", avctx->channels); return -1; } if (avctx->sample_rate != 8000) { av_log(avctx, AV_LOG_ERROR, "Sample rate 8000Hz required for GSM, got %dHz\n", avctx->sample_rate); if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) return -1; } if (avctx->bit_rate != 13000 /* Official */ && avctx->bit_rate != 13200 /* Very common */ && avctx->bit_rate != 0 /* Unknown; a.o. mov does not set bitrate when decoding */ ) { av_log(avctx, AV_LOG_ERROR, "Bitrate 13000bps required for GSM, got %dbps\n", avctx->bit_rate); if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) return -1; } avctx->priv_data = gsm_create(); if (!avctx->priv_data) goto error; switch(avctx->codec_id) { case CODEC_ID_GSM: avctx->frame_size = GSM_FRAME_SIZE; avctx->block_align = GSM_BLOCK_SIZE; break; case CODEC_ID_GSM_MS: { int one = 1; gsm_option(avctx->priv_data, GSM_OPT_WAV49, &one); avctx->frame_size = 2*GSM_FRAME_SIZE; avctx->block_align = GSM_MS_BLOCK_SIZE; } } #if FF_API_OLD_ENCODE_AUDIO avctx->coded_frame= avcodec_alloc_frame(); if (!avctx->coded_frame) goto error; #endif return 0; error: libgsm_encode_close(avctx); return -1; }
static int libgsm_init(AVCodecContext *avctx) { if (avctx->channels > 1 || avctx->sample_rate != 8000) return -1; avctx->frame_size = GSM_FRAME_SIZE; avctx->block_align = GSM_BLOCK_SIZE; avctx->priv_data = gsm_create(); avctx->coded_frame= avcodec_alloc_frame(); avctx->coded_frame->key_frame= 1; return 0; }
static struct ast_translator_pvt *gsm_new(void) { struct gsm_coder_pvt *tmp; tmp = malloc(sizeof(struct gsm_coder_pvt)); if (tmp) { if (!(tmp->gsm = gsm_create())) { free(tmp); tmp = NULL; } tmp->tail = 0; localusecnt++; } return tmp; }
static long gsm_create_if(const char* format_parameters, amci_codec_fmt_info_t* format_description) { gsm* h_codec=0; h_codec = malloc(sizeof(gsm)*2); if(!h_codec){ ERROR("gsm.c: could not create handle array\n"); return 0; } h_codec[0] = gsm_create(); h_codec[1] = gsm_create(); format_description[0].id = AMCI_FMT_FRAME_LENGTH ; format_description[0].value = 20; format_description[1].id = AMCI_FMT_FRAME_SIZE; format_description[1].value = 160; format_description[2].id = AMCI_FMT_ENCODED_FRAME_SIZE; format_description[2].value = 33; format_description[3].id = 0; return (long)h_codec; }
/* Create structure for callback method*/ callbackDataIn_t * cretaeCalbackData(mainData_t *mainData){ LOGI("Enter: cretaeCalbackData\n"); callbackDataIn_t * Data = malloc(sizeof(callbackDataIn_t)); if(Data==NULL){ LOGE("Enter: cretaeCalbackData: Can't create callbackData. No memory\n"); return NULL; } Data->mainData = mainData; Data->read = 0; Data->write = 0; Data->count = 0; Data->gsm = gsm_create(); initDataPacket(&Data->outPacket); LOGI("Exit: cretaeCalbackData: OK\n"); return Data; }
static gboolean gst_gsmenc_start (GstAudioEncoder * enc) { GstGSMEnc *gsmenc = GST_GSMENC (enc); gint use_wav49; GST_DEBUG_OBJECT (enc, "start"); gsmenc->state = gsm_create (); /* turn off WAV49 handling */ use_wav49 = 0; gsm_option (gsmenc->state, GSM_OPT_WAV49, &use_wav49); return TRUE; }
int wav_gsm610_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt) { GSM610_PRIVATE *pgsm610 ; int true = 1 ; psf->sf.seekable = SF_FALSE ; /*-psf->sf.seekable = SF_TRUE ; -*/ #if defined(USE_LIBSND_ALL) psf->seek_func = (func_seek) wav_gsm610_seek ; #endif psf->read_short = (func_short) wav_gsm610_read_s ; #if defined(USE_LIBSND_ALL) psf->read_int = (func_int) wav_gsm610_read_i ; psf->read_float = (func_float) wav_gsm610_read_f ; psf->read_double = (func_double) wav_gsm610_read_d ; #endif #if defined(USE_LIBSND_ALL) || defined(USE_LIBSND_WRITE) if (psf->mode != SF_MODE_READ) return SFE_BAD_MODE_RW ; #endif if (! (pgsm610 = malloc (sizeof (GSM610_PRIVATE)))) return SFE_MALLOC_FAILED ; psf->fdata = (void*) pgsm610 ; memset (pgsm610, 0, sizeof (GSM610_PRIVATE)) ; if (! (pgsm610->gsm_data = gsm_create ())) return SFE_MALLOC_FAILED ; gsm_option (pgsm610->gsm_data, GSM_OPT_WAV49, &true) ; if (psf->datalength % GSM610_BLOCKSIZE) { psf_log_printf (psf, "*** Warning : data chunk seems to be truncated.\n") ; pgsm610->blocks = psf->datalength / GSM610_BLOCKSIZE + 1 ; } else pgsm610->blocks = psf->datalength / GSM610_BLOCKSIZE ; psf->sf.samples = GSM610_SAMPLES * pgsm610->blocks ; wav_gsm610_read_block (psf, pgsm610) ; /* Read first block. */ return 0 ; } /* wav_gsm610_reader_init */
SoftGSM::SoftGSM( const char *name, const OMX_CALLBACKTYPE *callbacks, OMX_PTR appData, OMX_COMPONENTTYPE **component) : SimpleSoftOMXComponent(name, callbacks, appData, component), mSignalledError(false) { CHECK(!strcmp(name, "OMX.google.gsm.decoder")); mGsm = gsm_create(); CHECK(mGsm); int msopt = 1; gsm_option(mGsm, GSM_OPT_WAV49, &msopt); initPorts(); }
wr_encoder_t * wr_gsm_encoder_init(wr_encoder_t * pcodec) { wr_gsm_state * state = malloc(sizeof(wr_gsm_state)); if (!state) return NULL; state->handle = gsm_create(); if (!state->handle){ free(state); return NULL; } pcodec->state = (void*) state; pcodec->payload_type = iniparser_getnonnegativeint(wr_options.codecs_options, "gsm:payload_type", 3); return pcodec; }
int main(int argc, char** argv) { gsm gsmh; gsm_signal src[GSM_SAMPLE_BLOCK], dec[GSM_SAMPLE_BLOCK]; gsm_frame dst; const char* inFN; FILE* inFile; const char* encFN; FILE* encFile; const char* decFN; FILE* decFile; int n; /* For status dots */ if (4 != argc) fail ("Usage: testjms input encode decode"); inFN = argv[1]; inFile = mustOpen(inFN, "rb"); encFN = argv[2]; encFile = mustOpen(encFN, "wb"); decFN = argv[3]; decFile = mustOpen(decFN, "wb"); gsmh = gsm_create(); if (! gsmh) fail ("Can't create gsm\n"); while (fread(FP(src), inFile) == GSM_SAMPLE_BLOCK) { if ((n++) % 100) { (void) printf ("."); n = 0; } gsm_encode(gsmh, src, dst); fwrite(FP(dst), encFile); gsm_decode(gsmh, dst, dec); fwrite(FP(dec), decFile); } fclose (inFile); fclose (encFile); fclose (decFile); (void) puts ("\ndone"); return 0; }
static int init_gsm(bgav_stream_t * s) { int tmp; gsm_priv * priv; /* Allocate stuff */ priv = calloc(1, sizeof(*priv)); priv->gsm_state = gsm_create(); s->decoder_priv = priv; if(s->data.audio.format.num_channels > 1) { bgav_log(s->opt, BGAV_LOG_ERROR, LOG_DOMAIN, "Multichannel GSM not supported"); return 0; } if((s->fourcc == BGAV_WAVID_2_FOURCC(0x31)) || (s->fourcc == BGAV_WAVID_2_FOURCC(0x32))) { priv->ms = 1; tmp = 1; gsm_option(priv->gsm_state, GSM_OPT_WAV49, &tmp); } /* Set format */ s->data.audio.format.interleave_mode = GAVL_INTERLEAVE_NONE; s->data.audio.format.sample_format = GAVL_SAMPLE_S16; s->data.audio.format.samples_per_frame = priv->ms ? 2*GSM_FRAME_SAMPLES : GSM_FRAME_SAMPLES; gavl_set_channel_setup(&s->data.audio.format); priv->frame = gavl_audio_frame_create(&s->data.audio.format); if(priv->ms) gavl_metadata_set(&s->m, GAVL_META_FORMAT, "MSGM"); else gavl_metadata_set(&s->m, GAVL_META_FORMAT, "GSM 6.10"); return 1; }