~ubuntu-branches/debian/jessie/libsndfile/jessie

« back to all changes in this revision

Viewing changes to src/gsm610.c

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2009-02-17 19:21:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090217192103-7rhu1n8p79jnbzy3
Tags: 1.0.18-2
Add missing build-dependencies on pkg-config and libvorbis-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
 
2
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
3
3
**
4
4
** This program is free software; you can redistribute it and/or modify
5
5
** it under the terms of the GNU Lesser General Public License as published by
21
21
#include <stdio.h>
22
22
#include <stdlib.h>
23
23
#include <string.h>
 
24
#include <math.h>
24
25
 
25
26
#include "sndfile.h"
26
27
#include "sfendian.h"
27
 
#include "float_cast.h"
28
28
#include "common.h"
29
29
#include "wav_w64.h"
30
30
#include "GSM610/gsm.h"
105
105
        if ((pgsm610->gsm_data = gsm_create ()) == NULL)
106
106
                return SFE_MALLOC_FAILED ;
107
107
 
108
 
        switch (psf->sf.format & SF_FORMAT_TYPEMASK)
 
108
        switch (SF_CONTAINER (psf->sf.format))
109
109
        {       case SF_FORMAT_WAV :
110
110
                case SF_FORMAT_WAVEX :
111
111
                case SF_FORMAT_W64 :
152
152
 
153
153
                psf->sf.frames = pgsm610->samplesperblock * pgsm610->blocks ;
154
154
 
 
155
                psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
 
156
 
155
157
                pgsm610->decode_block (psf, pgsm610) ;  /* Read first block. */
156
158
 
157
159
                psf->read_short         = gsm610_read_s ;
200
202
                psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, WAV_W64_GSM610_BLOCKSIZE) ;
201
203
 
202
204
        if (gsm_decode (pgsm610->gsm_data, pgsm610->block, pgsm610->samples) < 0)
203
 
        {       psf_log_printf (psf, "Error from gsm_decode() on frame : %d\n", pgsm610->blockcount) ;
 
205
        {       psf_log_printf (psf, "Error from WAV gsm_decode() on frame : %d\n", pgsm610->blockcount) ;
204
206
                return 0 ;
205
207
                } ;
206
208
 
207
209
        if (gsm_decode (pgsm610->gsm_data, pgsm610->block + (WAV_W64_GSM610_BLOCKSIZE + 1) / 2, pgsm610->samples + WAV_W64_GSM610_SAMPLES / 2) < 0)
208
 
        {       psf_log_printf (psf, "Error from gsm_decode() on frame : %d.5\n", pgsm610->blockcount) ;
 
210
        {       psf_log_printf (psf, "Error from WAV gsm_decode() on frame : %d.5\n", pgsm610->blockcount) ;
209
211
                return 0 ;
210
212
                } ;
211
213
 
228
230
                psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, GSM610_BLOCKSIZE) ;
229
231
 
230
232
        if (gsm_decode (pgsm610->gsm_data, pgsm610->block, pgsm610->samples) < 0)
231
 
        {       psf_log_printf (psf, "Error from gsm_decode() on frame : %d\n", pgsm610->blockcount) ;
 
233
        {       psf_log_printf (psf, "Error from standard gsm_decode() on frame : %d\n", pgsm610->blockcount) ;
232
234
                return 0 ;
233
235
                } ;
234
236
 
367
369
} /* gsm610_read_d */
368
370
 
369
371
static sf_count_t
370
 
gsm610_seek     (SF_PRIVATE *psf, int mode, sf_count_t offset)
 
372
gsm610_seek     (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset)
371
373
{       GSM610_PRIVATE *pgsm610 ;
372
374
        int                     newblock, newsample ;
373
375
 
374
 
        mode = mode ;
375
 
 
376
376
        if (psf->codec_data == NULL)
377
377
                return 0 ;
378
378
        pgsm610 = (GSM610_PRIVATE*) psf->codec_data ;
389
389
                pgsm610->blockcount = 0 ;
390
390
 
391
391
                gsm_init (pgsm610->gsm_data) ;
392
 
                if ((psf->sf.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV ||
393
 
                                (psf->sf.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_W64)
 
392
                if ((SF_CONTAINER (psf->sf.format)) == SF_FORMAT_WAV ||
 
393
                                (SF_CONTAINER (psf->sf.format)) == SF_FORMAT_W64)
394
394
                        gsm_option (pgsm610->gsm_data, GSM_OPT_WAV49, &true_flag) ;
395
395
 
396
396
                pgsm610->decode_block (psf, pgsm610) ;
619
619
        return 0 ;
620
620
} /* gsm610_close */
621
621
 
622
 
/*
623
 
** Do not edit or modify anything in this comment block.
624
 
** The arch-tag line is a file identity tag for the GNU Arch 
625
 
** revision control system.
626
 
**
627
 
** arch-tag: 8575187d-af4f-4acf-b9dd-6ff705628345
628
 
*/