Mercurial > libavcodec.hg
annotate libopencore-amr.c @ 11300:1f512abdf680 libavcodec
Simplify code to set cbp_*
this seems 1 cpu cycle slower even though we practically just remove code.
Speed loss seems caused by the merge of if(left_type), iam commiting this
anyway as i cant imagine this to be anything but compiler messup.
author | michael |
---|---|
date | Fri, 26 Feb 2010 09:13:40 +0000 |
parents | 7955db355703 |
children | 8a4984c5cacc |
rev | line source |
---|---|
9818
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
1 /* |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
2 * AMR Audio decoder stub |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
3 * Copyright (c) 2003 the ffmpeg project |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
4 * |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
5 * This file is part of FFmpeg. |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
6 * |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
11 * |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
16 * |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
20 */ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
21 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
22 #include "avcodec.h" |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
23 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
24 static void amr_decode_fix_avctx(AVCodecContext *avctx) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
25 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
26 const int is_amr_wb = 1 + (avctx->codec_id == CODEC_ID_AMR_WB); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
27 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
28 if (!avctx->sample_rate) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
29 avctx->sample_rate = 8000 * is_amr_wb; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
30 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
31 if (!avctx->channels) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
32 avctx->channels = 1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
33 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
34 avctx->frame_size = 160 * is_amr_wb; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
35 avctx->sample_fmt = SAMPLE_FMT_S16; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
36 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
37 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
38 #if CONFIG_LIBOPENCORE_AMRNB |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
39 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
40 #include <opencore-amrnb/interf_dec.h> |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
41 #include <opencore-amrnb/interf_enc.h> |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
42 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
43 static const char nb_bitrate_unsupported[] = |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
44 "bitrate not supported: use one of 4.75k, 5.15k, 5.9k, 6.7k, 7.4k, 7.95k, 10.2k or 12.2k\n"; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
45 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
46 /* Common code for fixed and float version*/ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
47 typedef struct AMR_bitrates { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
48 int rate; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
49 enum Mode mode; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
50 } AMR_bitrates; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
51 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
52 /* Match desired bitrate */ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
53 static int getBitrateMode(int bitrate) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
54 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
55 /* make the correspondance between bitrate and mode */ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
56 AMR_bitrates rates[] = { { 4750, MR475}, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
57 { 5150, MR515}, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
58 { 5900, MR59}, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
59 { 6700, MR67}, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
60 { 7400, MR74}, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
61 { 7950, MR795}, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
62 {10200, MR102}, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
63 {12200, MR122}, }; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
64 int i; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
65 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
66 for (i = 0; i < 8; i++) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
67 if (rates[i].rate == bitrate) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
68 return rates[i].mode; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
69 /* no bitrate matching, return an error */ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
70 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
71 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
72 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
73 typedef struct AMRContext { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
74 int frameCount; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
75 void *decState; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
76 int *enstate; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
77 int enc_bitrate; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
78 } AMRContext; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
79 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
80 static av_cold int amr_nb_decode_init(AVCodecContext *avctx) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
81 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
82 AMRContext *s = avctx->priv_data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
83 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
84 s->frameCount = 0; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
85 s->decState = Decoder_Interface_init(); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
86 if (!s->decState) { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
87 av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\r\n"); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
88 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
89 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
90 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
91 amr_decode_fix_avctx(avctx); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
92 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
93 if (avctx->channels > 1) { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
94 av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n"); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
95 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
96 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
97 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
98 return 0; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
99 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
100 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
101 static av_cold int amr_nb_decode_close(AVCodecContext *avctx) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
102 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
103 AMRContext *s = avctx->priv_data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
104 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
105 Decoder_Interface_exit(s->decState); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
106 return 0; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
107 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
108 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
109 static int amr_nb_decode_frame(AVCodecContext *avctx, void *data, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
110 int *data_size, AVPacket *avpkt) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
111 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
112 const uint8_t *buf = avpkt->data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
113 int buf_size = avpkt->size; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
114 AMRContext *s = avctx->priv_data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
115 const uint8_t *amrData = buf; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
116 static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 }; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
117 enum Mode dec_mode; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
118 int packet_size; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
119 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
120 /* av_log(NULL, AV_LOG_DEBUG, "amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n", |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
121 buf, buf_size, s->frameCount); */ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
122 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
123 dec_mode = (buf[0] >> 3) & 0x000F; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
124 packet_size = block_size[dec_mode] + 1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
125 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
126 if (packet_size > buf_size) { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
127 av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
128 buf_size, packet_size); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
129 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
130 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
131 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
132 s->frameCount++; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
133 /* av_log(NULL, AV_LOG_DEBUG, "packet_size=%d amrData= 0x%X %X %X %X\n", |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
134 packet_size, amrData[0], amrData[1], amrData[2], amrData[3]); */ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
135 /* call decoder */ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
136 Decoder_Interface_Decode(s->decState, amrData, data, 0); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
137 *data_size = 160 * 2; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
138 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
139 return packet_size; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
140 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
141 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
142 AVCodec libopencore_amrnb_decoder = { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
143 "libopencore_amrnb", |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
144 CODEC_TYPE_AUDIO, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
145 CODEC_ID_AMR_NB, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
146 sizeof(AMRContext), |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
147 amr_nb_decode_init, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
148 NULL, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
149 amr_nb_decode_close, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
150 amr_nb_decode_frame, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
151 .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"), |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
152 }; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
153 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
154 static av_cold int amr_nb_encode_init(AVCodecContext *avctx) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
155 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
156 AMRContext *s = avctx->priv_data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
157 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
158 s->frameCount = 0; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
159 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
160 if (avctx->sample_rate != 8000) { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
161 av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n"); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
162 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
163 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
164 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
165 if (avctx->channels != 1) { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
166 av_log(avctx, AV_LOG_ERROR, "Only mono supported\n"); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
167 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
168 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
169 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
170 avctx->frame_size = 160; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
171 avctx->coded_frame = avcodec_alloc_frame(); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
172 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
173 s->enstate=Encoder_Interface_init(0); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
174 if (!s->enstate) { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
175 av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n"); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
176 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
177 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
178 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
179 if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
180 av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
181 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
182 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
183 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
184 return 0; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
185 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
186 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
187 static av_cold int amr_nb_encode_close(AVCodecContext *avctx) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
188 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
189 AMRContext *s = avctx->priv_data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
190 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
191 Encoder_Interface_exit(s->enstate); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
192 av_freep(&avctx->coded_frame); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
193 return 0; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
194 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
195 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
196 static int amr_nb_encode_frame(AVCodecContext *avctx, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
197 unsigned char *frame/*out*/, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
198 int buf_size, void *data/*in*/) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
199 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
200 AMRContext *s = avctx->priv_data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
201 int written; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
202 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
203 if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
204 av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
205 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
206 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
207 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
208 written = Encoder_Interface_Encode(s->enstate, s->enc_bitrate, data, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
209 frame, 0); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
210 /* av_log(NULL, AV_LOG_DEBUG, "amr_nb_encode_frame encoded %u bytes, bitrate %u, first byte was %#02x\n", |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
211 written, s->enc_bitrate, frame[0] ); */ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
212 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
213 return written; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
214 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
215 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
216 AVCodec libopencore_amrnb_encoder = { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
217 "libopencore_amrnb", |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
218 CODEC_TYPE_AUDIO, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
219 CODEC_ID_AMR_NB, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
220 sizeof(AMRContext), |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
221 amr_nb_encode_init, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
222 amr_nb_encode_frame, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
223 amr_nb_encode_close, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
224 NULL, |
10145
7955db355703
Make sample_fmts and channel_layouts compound literals const to reduce size of
reimar
parents:
9818
diff
changeset
|
225 .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, |
9818
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
226 .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"), |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
227 }; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
228 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
229 #endif |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
230 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
231 /* -----------AMR wideband ------------*/ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
232 #if CONFIG_LIBOPENCORE_AMRWB |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
233 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
234 #ifdef _TYPEDEF_H |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
235 //To avoid duplicate typedefs from typedef in amr-nb |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
236 #define typedef_h |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
237 #endif |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
238 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
239 #include <opencore-amrwb/dec_if.h> |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
240 #include <opencore-amrwb/if_rom.h> |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
241 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
242 static const char wb_bitrate_unsupported[] = |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
243 "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"; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
244 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
245 /* Common code for fixed and float version*/ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
246 typedef struct AMRWB_bitrates { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
247 int rate; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
248 int mode; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
249 } AMRWB_bitrates; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
250 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
251 typedef struct AMRWBContext { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
252 int frameCount; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
253 void *state; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
254 int mode; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
255 Word16 allow_dtx; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
256 } AMRWBContext; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
257 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
258 static av_cold int amr_wb_decode_init(AVCodecContext *avctx) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
259 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
260 AMRWBContext *s = avctx->priv_data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
261 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
262 s->frameCount = 0; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
263 s->state = D_IF_init(); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
264 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
265 amr_decode_fix_avctx(avctx); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
266 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
267 if (avctx->channels > 1) { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
268 av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n"); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
269 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
270 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
271 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
272 return 0; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
273 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
274 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
275 static int amr_wb_decode_frame(AVCodecContext *avctx, void *data, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
276 int *data_size, AVPacket *avpkt) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
277 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
278 const uint8_t *buf = avpkt->data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
279 int buf_size = avpkt->size; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
280 AMRWBContext *s = avctx->priv_data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
281 const uint8_t *amrData = buf; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
282 int mode; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
283 int packet_size; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
284 static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1}; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
285 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
286 if (!buf_size) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
287 /* nothing to do */ |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
288 return 0; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
289 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
290 mode = (amrData[0] >> 3) & 0x000F; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
291 packet_size = block_size[mode]; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
292 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
293 if (packet_size > buf_size) { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
294 av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
295 buf_size, packet_size + 1); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
296 return -1; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
297 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
298 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
299 s->frameCount++; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
300 D_IF_decode(s->state, amrData, data, _good_frame); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
301 *data_size = 320 * 2; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
302 return packet_size; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
303 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
304 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
305 static int amr_wb_decode_close(AVCodecContext *avctx) |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
306 { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
307 AMRWBContext *s = avctx->priv_data; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
308 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
309 D_IF_exit(s->state); |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
310 return 0; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
311 } |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
312 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
313 AVCodec libopencore_amrwb_decoder = { |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
314 "libopencore_amrwb", |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
315 CODEC_TYPE_AUDIO, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
316 CODEC_ID_AMR_WB, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
317 sizeof(AMRWBContext), |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
318 amr_wb_decode_init, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
319 NULL, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
320 amr_wb_decode_close, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
321 amr_wb_decode_frame, |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
322 .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Wide-Band"), |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
323 }; |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
324 |
038c7940a21e
Add support for external OpenCORE libraries for AMR-NB/WB support.
diego
parents:
diff
changeset
|
325 #endif /* CONFIG_LIBOPENCORE_AMRWB */ |