[FFmpeg-cvslog] r18845 - trunk/libavcodec/libamr.c

diego subversion
Fri May 15 19:34:27 CEST 2009


Author: diego
Date: Fri May 15 19:34:26 2009
New Revision: 18845

Log:
cosmetics: Move functions around so that encoding and decoding functions are
grouped together. This will save some #ifdefs.

Modified:
   trunk/libavcodec/libamr.c

Modified: trunk/libavcodec/libamr.c
==============================================================================
--- trunk/libavcodec/libamr.c	Fri May 15 19:22:41 2009	(r18844)
+++ trunk/libavcodec/libamr.c	Fri May 15 19:34:26 2009	(r18845)
@@ -148,6 +148,58 @@ static av_cold int amr_nb_decode_init(AV
     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(AV
     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(A
     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(AVCodecCo
     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(AVCodecCo
     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



More information about the ffmpeg-cvslog mailing list