~ubuntu-branches/debian/sid/mplayer/sid

« back to all changes in this revision

Viewing changes to libavcodec/libamr.c

  • Committer: Bazaar Package Importer
  • Author(s): A Mennucc1
  • Date: 2009-03-23 10:05:45 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090323100545-x8h79obawnnte7kk
Tags: 1.0~rc2+svn20090303-5
debian/control : move docbook-xml,docbook-xsl,xsltproc from 
Build-Depends-Indep to Build-Depends, since they are needed to run
configure

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
#include "avcodec.h"
67
67
 
68
 
#ifdef CONFIG_LIBAMR_NB_FIXED
 
68
#if CONFIG_LIBAMR_NB_FIXED
69
69
 
70
70
#define MMS_IO
71
71
 
81
81
#include <amrnb/interf_enc.h>
82
82
#endif
83
83
 
84
 
static const char *nb_bitrate_unsupported =
 
84
static const char nb_bitrate_unsupported[] =
85
85
    "bitrate not supported: use one of 4.75k, 5.15k, 5.9k, 6.7k, 7.4k, 7.95k, 10.2k or 12.2k\n";
86
 
static const char *wb_bitrate_unsupported =
 
86
static const char wb_bitrate_unsupported[] =
87
87
    "bitrate not supported: use one of 6.6k, 8.85k, 12.65k, 14.25k, 15.85k, 18.25k, 19.85k, 23.05k, or 23.85k\n";
88
88
 
89
89
/* Common code for fixed and float version*/
112
112
    {
113
113
        if(rates[i].rate==bitrate)
114
114
        {
115
 
            return(rates[i].mode);
 
115
            return rates[i].mode;
116
116
        }
117
117
    }
118
118
    /* no bitrate matching, return an error */
134
134
    }
135
135
 
136
136
    avctx->frame_size = 160 * is_amr_wb;
 
137
    avctx->sample_fmt = SAMPLE_FMT_S16;
137
138
}
138
139
 
139
 
#ifdef CONFIG_LIBAMR_NB_FIXED
 
140
#if CONFIG_LIBAMR_NB_FIXED
140
141
/* fixed point version*/
141
142
/* frame size in serial bitstream file (frame type + serial stream + flags) */
142
143
#define SERIAL_FRAMESIZE (1+MAX_SERIAL_SIZE+5)
155
156
    enum TXFrameType tx_frametype;
156
157
} AMRContext;
157
158
 
158
 
static int amr_nb_decode_init(AVCodecContext * avctx)
 
159
static av_cold int amr_nb_decode_init(AVCodecContext * avctx)
159
160
{
160
161
    AMRContext *s = avctx->priv_data;
161
162
 
183
184
    return 0;
184
185
}
185
186
 
186
 
static int amr_nb_encode_init(AVCodecContext * avctx)
 
187
static av_cold int amr_nb_encode_init(AVCodecContext * avctx)
187
188
{
188
189
    AMRContext *s = avctx->priv_data;
189
190
 
224
225
    return 0;
225
226
}
226
227
 
227
 
static int amr_nb_encode_close(AVCodecContext * avctx)
 
228
static av_cold int amr_nb_encode_close(AVCodecContext * avctx)
228
229
{
229
230
    AMRContext *s = avctx->priv_data;
230
231
 
234
235
    return 0;
235
236
}
236
237
 
237
 
static int amr_nb_decode_close(AVCodecContext * avctx)
 
238
static av_cold int amr_nb_decode_close(AVCodecContext * avctx)
238
239
{
239
240
    AMRContext *s = avctx->priv_data;
240
241
 
244
245
 
245
246
static int amr_nb_decode_frame(AVCodecContext * avctx,
246
247
            void *data, int *data_size,
247
 
            uint8_t * buf, int buf_size)
 
248
            const uint8_t * buf, int buf_size)
248
249
{
249
250
    AMRContext *s = avctx->priv_data;
250
 
    uint8_t*amrData=buf;
 
251
    const uint8_t*amrData=buf;
251
252
    int offset=0;
252
253
    UWord8 toc, q, ft;
253
254
    Word16 serial[SERIAL_FRAMESIZE];   /* coded bits */
352
353
}
353
354
 
354
355
 
355
 
#elif defined(CONFIG_LIBAMR_NB) /* Float point version*/
 
356
#elif CONFIG_LIBAMR_NB /* Float point version*/
356
357
 
357
358
typedef struct AMRContext {
358
359
    int frameCount;
361
362
    int enc_bitrate;
362
363
} AMRContext;
363
364
 
364
 
static int amr_nb_decode_init(AVCodecContext * avctx)
 
365
static av_cold int amr_nb_decode_init(AVCodecContext * avctx)
365
366
{
366
367
    AMRContext *s = avctx->priv_data;
367
368
 
384
385
    return 0;
385
386
}
386
387
 
387
 
static int amr_nb_encode_init(AVCodecContext * avctx)
 
388
static av_cold int amr_nb_encode_init(AVCodecContext * avctx)
388
389
{
389
390
    AMRContext *s = avctx->priv_data;
390
391
 
421
422
    return 0;
422
423
}
423
424
 
424
 
static int amr_nb_decode_close(AVCodecContext * avctx)
 
425
static av_cold int amr_nb_decode_close(AVCodecContext * avctx)
425
426
{
426
427
    AMRContext *s = avctx->priv_data;
427
428
 
429
430
    return 0;
430
431
}
431
432
 
432
 
static int amr_nb_encode_close(AVCodecContext * avctx)
 
433
static av_cold int amr_nb_encode_close(AVCodecContext * avctx)
433
434
{
434
435
    AMRContext *s = avctx->priv_data;
435
436
 
440
441
 
441
442
static int amr_nb_decode_frame(AVCodecContext * avctx,
442
443
            void *data, int *data_size,
443
 
            uint8_t * buf, int buf_size)
 
444
            const uint8_t * buf, int buf_size)
444
445
{
445
446
    AMRContext *s = avctx->priv_data;
446
 
    uint8_t*amrData=buf;
447
 
    static short block_size[16]={ 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
 
447
    const uint8_t*amrData=buf;
 
448
    static const uint8_t block_size[16]={ 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
448
449
    enum Mode dec_mode;
449
450
    int packet_size;
450
451
 
491
492
 
492
493
#endif
493
494
 
494
 
#if defined(CONFIG_LIBAMR_NB) || defined(CONFIG_LIBAMR_NB_FIXED)
 
495
#if CONFIG_LIBAMR_NB || CONFIG_LIBAMR_NB_FIXED
495
496
 
496
497
AVCodec libamr_nb_decoder =
497
498
{
503
504
    NULL,
504
505
    amr_nb_decode_close,
505
506
    amr_nb_decode_frame,
 
507
    .long_name = NULL_IF_CONFIG_SMALL("libamr-nb Adaptive Multi-Rate (AMR) Narrow-Band"),
506
508
};
507
509
 
508
510
AVCodec libamr_nb_encoder =
515
517
    amr_nb_encode_frame,
516
518
    amr_nb_encode_close,
517
519
    NULL,
 
520
    .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
 
521
    .long_name = NULL_IF_CONFIG_SMALL("libamr-nb Adaptive Multi-Rate (AMR) Narrow-Band"),
518
522
};
519
523
 
520
524
#endif
521
525
 
522
526
/* -----------AMR wideband ------------*/
523
 
#ifdef CONFIG_LIBAMR_WB
 
527
#if CONFIG_LIBAMR_WB
524
528
 
525
529
#ifdef _TYPEDEF_H
526
 
//To avoid duplicate typedefs from typdef in amr-nb
 
530
//To avoid duplicate typedefs from typedef in amr-nb
527
531
#define typedef_h
528
532
#endif
529
533
 
557
561
    {
558
562
        if(rates[i].rate==bitrate)
559
563
        {
560
 
            return(rates[i].mode);
 
564
            return rates[i].mode;
561
565
        }
562
566
    }
563
567
    /* no bitrate matching, return an error */
650
654
 
651
655
static int amr_wb_decode_frame(AVCodecContext * avctx,
652
656
            void *data, int *data_size,
653
 
            uint8_t * buf, int buf_size)
 
657
            const uint8_t * buf, int buf_size)
654
658
{
655
659
    AMRWBContext *s = avctx->priv_data;
656
 
    uint8_t*amrData=buf;
 
660
    const uint8_t*amrData=buf;
657
661
    int mode;
658
662
    int packet_size;
 
663
    static const uint8_t block_size[16] = {18, 23, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
659
664
 
660
665
    if(buf_size==0) {
661
666
        /* nothing to do */
694
699
    NULL,
695
700
    amr_wb_decode_close,
696
701
    amr_wb_decode_frame,
 
702
    .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"),
697
703
};
698
704
 
699
705
AVCodec libamr_wb_encoder =
706
712
    amr_wb_encode_frame,
707
713
    amr_wb_encode_close,
708
714
    NULL,
 
715
    .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
 
716
    .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"),
709
717
};
710
718
 
711
719
#endif //CONFIG_LIBAMR_WB