aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/libamr.c
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2009-05-15 17:34:26 +0000
committerDiego Biurrun <diego@biurrun.de>2009-05-15 17:34:26 +0000
commitc005a3ba5933b1164a174fd63b671303a64a841d (patch)
treec6d038948eeac65763a82e23574eefe1b85e8daf /libavcodec/libamr.c
parent4d7d5ede5d78260507973ef45e1042e249cac911 (diff)
downloadffmpeg-c005a3ba5933b1164a174fd63b671303a64a841d.tar.gz
cosmetics: Move functions around so that encoding and decoding functions are
grouped together. This will save some #ifdefs. Originally committed as revision 18845 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/libamr.c')
-rw-r--r--libavcodec/libamr.c132
1 files changed, 66 insertions, 66 deletions
diff --git a/libavcodec/libamr.c b/libavcodec/libamr.c
index 11144713c5..ee077216cf 100644
--- a/libavcodec/libamr.c
+++ b/libavcodec/libamr.c
@@ -148,6 +148,58 @@ static av_cold int amr_nb_decode_init(AVCodecContext * avctx)
return 0;
}
+static av_cold int amr_nb_decode_close(AVCodecContext * avctx)
+{
+ AMRContext *s = avctx->priv_data;
+
+ Decoder_Interface_exit(s->decState);
+ return 0;
+}
+
+static int amr_nb_decode_frame(AVCodecContext * avctx,
+ void *data, int *data_size,
+ AVPacket *avpkt)
+{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
+ AMRContext *s = avctx->priv_data;
+ const uint8_t*amrData=buf;
+ static const uint8_t block_size[16]={ 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
+ enum Mode dec_mode;
+ int packet_size;
+
+ /* av_log(NULL,AV_LOG_DEBUG,"amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n",buf,buf_size,s->frameCount); */
+
+ dec_mode = (buf[0] >> 3) & 0x000F;
+ packet_size = block_size[dec_mode]+1;
+
+ if(packet_size > buf_size) {
+ av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", buf_size, packet_size);
+ return -1;
+ }
+
+ s->frameCount++;
+ /* av_log(NULL,AV_LOG_DEBUG,"packet_size=%d amrData= 0x%X %X %X %X\n",packet_size,amrData[0],amrData[1],amrData[2],amrData[3]); */
+ /* call decoder */
+ Decoder_Interface_Decode(s->decState, amrData, data, 0);
+ *data_size=160*2;
+
+ return packet_size;
+}
+
+AVCodec libamr_nb_decoder =
+{
+ "libamr_nb",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_AMR_NB,
+ sizeof(AMRContext),
+ amr_nb_decode_init,
+ NULL,
+ amr_nb_decode_close,
+ amr_nb_decode_frame,
+ .long_name = NULL_IF_CONFIG_SMALL("libamr-nb Adaptive Multi-Rate (AMR) Narrow-Band"),
+};
+
static av_cold int amr_nb_encode_init(AVCodecContext * avctx)
{
AMRContext *s = avctx->priv_data;
@@ -185,14 +237,6 @@ static av_cold int amr_nb_encode_init(AVCodecContext * avctx)
return 0;
}
-static av_cold int amr_nb_decode_close(AVCodecContext * avctx)
-{
- AMRContext *s = avctx->priv_data;
-
- Decoder_Interface_exit(s->decState);
- return 0;
-}
-
static av_cold int amr_nb_encode_close(AVCodecContext * avctx)
{
AMRContext *s = avctx->priv_data;
@@ -202,37 +246,6 @@ static av_cold int amr_nb_encode_close(AVCodecContext * avctx)
return 0;
}
-static int amr_nb_decode_frame(AVCodecContext * avctx,
- void *data, int *data_size,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- AMRContext *s = avctx->priv_data;
- const uint8_t*amrData=buf;
- static const uint8_t block_size[16]={ 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
- enum Mode dec_mode;
- int packet_size;
-
- /* av_log(NULL,AV_LOG_DEBUG,"amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n",buf,buf_size,s->frameCount); */
-
- dec_mode = (buf[0] >> 3) & 0x000F;
- packet_size = block_size[dec_mode]+1;
-
- if(packet_size > buf_size) {
- av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", buf_size, packet_size);
- return -1;
- }
-
- s->frameCount++;
- /* av_log(NULL,AV_LOG_DEBUG,"packet_size=%d amrData= 0x%X %X %X %X\n",packet_size,amrData[0],amrData[1],amrData[2],amrData[3]); */
- /* call decoder */
- Decoder_Interface_Decode(s->decState, amrData, data, 0);
- *data_size=160*2;
-
- return packet_size;
-}
-
static int amr_nb_encode_frame(AVCodecContext *avctx,
unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
{
@@ -255,19 +268,6 @@ static int amr_nb_encode_frame(AVCodecContext *avctx,
return written;
}
-AVCodec libamr_nb_decoder =
-{
- "libamr_nb",
- CODEC_TYPE_AUDIO,
- CODEC_ID_AMR_NB,
- sizeof(AMRContext),
- amr_nb_decode_init,
- NULL,
- amr_nb_decode_close,
- amr_nb_decode_frame,
- .long_name = NULL_IF_CONFIG_SMALL("libamr-nb Adaptive Multi-Rate (AMR) Narrow-Band"),
-};
-
AVCodec libamr_nb_encoder =
{
"libamr_nb",
@@ -395,6 +395,20 @@ static int amr_wb_encode_frame(AVCodecContext *avctx,
return size;
}
+AVCodec libamr_wb_encoder =
+{
+ "libamr_wb",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_AMR_WB,
+ sizeof(AMRWBContext),
+ amr_wb_encode_init,
+ amr_wb_encode_frame,
+ amr_wb_encode_close,
+ NULL,
+ .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"),
+};
+
static av_cold int amr_wb_decode_init(AVCodecContext * avctx)
{
AMRWBContext *s = avctx->priv_data;
@@ -465,18 +479,4 @@ AVCodec libamr_wb_decoder =
.long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"),
};
-AVCodec libamr_wb_encoder =
-{
- "libamr_wb",
- CODEC_TYPE_AUDIO,
- CODEC_ID_AMR_WB,
- sizeof(AMRWBContext),
- amr_wb_encode_init,
- amr_wb_encode_frame,
- amr_wb_encode_close,
- NULL,
- .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
- .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"),
-};
-
#endif //CONFIG_LIBAMR_WB