[FFmpeg-soc] [soc]AMR-WB decoder branch, master, updated.

Marcelo Póvoa marspeoplester at gmail.com
Tue Jul 20 04:40:41 CEST 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "AMR-WB decoder".

The branch, master has been updated
       via  ef5497e0213b4143f745be78fdd2dfc3579dee8c (commit)
       via  b6c07e986a96e8b699c79fa69939ff1bdf3f8def (commit)
      from  4df069267c507ece9555404b369ea6043e116854 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ef5497e0213b4143f745be78fdd2dfc3579dee8c
Author: Marcelo Povoa <marspeoplester at gmail.com>
Date:   Mon Jul 19 23:16:17 2010 -0300

    Fix AVCodec interfacing, now it returns the number
    of bytes consumed and samples produced

diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h
index 21b0a5e..779fa70 100644
--- a/libavcodec/amrwbdata.h
+++ b/libavcodec/amrwbdata.h
@@ -30,7 +30,8 @@
 #define MIN_ENERGY           -14.0             ///< initial innnovation energy (dB)
 #define ENERGY_MEAN           30.0             ///< mean innovation energy (dB) in all modes
 
-#define AMRWB_SUBFRAME_SIZE   64               ///< samples per subframe
+#define AMRWB_SUBFRAME_SIZE   64               ///< samples per subframe at 12.8 kHz
+#define AMRWB_SFR_SIZE_OUT    80               ///< samples per subframe at 16 kHz
 #define AMRWB_SAMPLE_BOUND    32768.0          ///< threshold for synthesis overflow
 #define PITCH_MAX             231              ///< maximum received pitch delay value
 
diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index e9866d8..b1f2cc2 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -75,11 +75,13 @@ typedef struct {
     float                             hpf_mem[4]; ///< previous values in the high-pass filter
 } AMRWBContext;
 
-static int amrwb_decode_init(AVCodecContext *avctx)
+static av_cold int amrwb_decode_init(AVCodecContext *avctx)
 {
     AMRWBContext *ctx = avctx->priv_data;
     int i;
 
+    avctx->sample_fmt = SAMPLE_FMT_FLT;
+
     ctx->excitation = &ctx->excitation_buf[PITCH_MAX + LP_ORDER + 1];
 
     for (i = 0; i < LP_ORDER; i++) {
@@ -1095,7 +1097,10 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     // update state for next frame
     memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0]));
 
-    return 0;
+    /* report how many samples we got */
+    *data_size = 4 * AMRWB_SFR_SIZE_OUT * sizeof(float);
+
+    return ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1;
 }
 
 AVCodec amrwb_decoder =

commit b6c07e986a96e8b699c79fa69939ff1bdf3f8def
Author: Marcelo Povoa <marspeoplester at gmail.com>
Date:   Mon Jul 19 23:12:11 2010 -0300

    Fix frame parsing, the reordering tables seems to
    work at least for the isp indexes

diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h
index d2612f4..21b0a5e 100644
--- a/libavcodec/amrwbdata.h
+++ b/libavcodec/amrwbdata.h
@@ -69,7 +69,7 @@ typedef struct {
 } AMRWBFrame;
 
 /** The index of a frame parameter */
-#define AMR_BIT(field)                  (offsetof(AMRWBFrame, field))
+#define AMR_BIT(field)                  (offsetof(AMRWBFrame, field) >> 1)
 /** The index of a subframe-specific parameter */
 #define AMR_OF(frame_num, variable)     AMR_BIT(subframe[frame_num].variable)
 
diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index 97c806e..e9866d8 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -113,18 +113,23 @@ static enum Mode unpack_bitstream(AMRWBContext *ctx, const uint8_t *buf,
 
     init_get_bits(&gb, buf, buf_size * 8);
 
-    /* AMR-WB header */
+    /* AMR-WB header (1st octet) */
+    skip_bits(&gb, 1);      // padding bit
     ctx->fr_cur_mode  = get_bits(&gb, 4);
     mode              = ctx->fr_cur_mode;
     ctx->fr_quality   = get_bits1(&gb);
+    skip_bits(&gb, 2);
 
-    skip_bits(&gb, 3);
+    // XXX: We are using only the "MIME/storage" format
+    // used by libopencore. This format is simpler and
+    // do not have the auxiliary information of the frame
 
     /* AMR-WB Auxiliary Information */
-    ctx->fr_mode_ind = get_bits(&gb, 4);
-    ctx->fr_mode_req = get_bits(&gb, 4);
-    // XXX: Need to check conformity in mode_ind/mode_req and crc?
-    ctx->fr_crc = get_bits(&gb, 8);
+    /*
+     * ctx->fr_mode_ind = get_bits(&gb, 4);
+     * ctx->fr_mode_req = get_bits(&gb, 4);
+     * ctx->fr_crc = get_bits(&gb, 8);
+     */
 
     data = (uint16_t *) &ctx->frame;
     memset(data, 0, sizeof(AMRWBFrame));
@@ -138,9 +143,10 @@ static enum Mode unpack_bitstream(AMRWBContext *ctx, const uint8_t *buf,
             int field = 0;
             int field_offset = *perm++;
             while (field_size--) {
-               uint16_t bit = *perm++;
+               uint16_t bit_idx = *perm++;
                field <<= 1;
-               field |= buf[bit >> 3] >> (bit & 7) & 1;
+               /* The bit index inside the byte is reversed */
+               field |= BIT_POS(buf[bit_idx >> 3], 7 - (bit_idx & 7));
             }
             data[field_offset] = field;
         }

-----------------------------------------------------------------------

Summary of changes:
 libavcodec/amrwbdata.h |    5 +++--
 libavcodec/amrwbdec.c  |   31 +++++++++++++++++++++----------
 2 files changed, 24 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
AMR-WB decoder


More information about the FFmpeg-soc mailing list