[FFmpeg-soc] [soc]: r4087 - in amr: amrnbfloatdata.h amrnbfloatdec.c
kmalaussene
subversion at mplayerhq.hu
Thu Feb 19 04:17:13 CET 2009
Author: kmalaussene
Date: Thu Feb 19 04:17:10 2009
New Revision: 4087
Log:
Simplify decode_bitstream.
Modified:
amr/amrnbfloatdata.h
amr/amrnbfloatdec.c
Modified: amr/amrnbfloatdata.h
==============================================================================
--- amr/amrnbfloatdata.h Thu Feb 19 03:30:52 2009 (r4086)
+++ amr/amrnbfloatdata.h Thu Feb 19 04:17:10 2009 (r4087)
@@ -493,6 +493,22 @@ static const AMROrder order_MODE_DTX[35]
{ 4, 2}, { 4, 1}, { 4, 0}
};
+/**
+ * position of the bitmapping data for each packet type in
+ * the AMRNBFrame
+ */
+static const AMROrder * const amr_unpacking_bitmaps_per_mode[9] = {
+ order_MODE_475,
+ order_MODE_515,
+ order_MODE_59,
+ order_MODE_67,
+ order_MODE_74,
+ order_MODE_795,
+ order_MODE_102,
+ order_MODE_122,
+ order_MODE_DTX,
+};
+
// number of bits for each mode
static const uint8_t mode_bits[N_MODES] = {
FF_ARRAY_ELEMS(order_MODE_475),
Modified: amr/amrnbfloatdec.c
==============================================================================
--- amr/amrnbfloatdec.c Thu Feb 19 03:30:52 2009 (r4086)
+++ amr/amrnbfloatdec.c Thu Feb 19 04:17:10 2009 (r4087)
@@ -181,8 +181,6 @@ enum Mode decode_bitstream(AMRContext *p
enum Mode *speech_mode)
{
enum Mode mode;
- int i;
- const AMROrder *order;
// initialize get_bits
init_get_bits(&p->gb, buf, buf_size*8);
@@ -193,66 +191,28 @@ enum Mode decode_bitstream(AMRContext *p
p->bad_frame_indicator = !get_bits1(&p->gb);
skip_bits(&p->gb, 2);
- switch(mode) {
- case MODE_DTX:
- order = order_MODE_DTX;
- p->cur_frame_type = RX_SID_FIRST; // get SID type bit
- break;
- case NO_DATA:
- p->cur_frame_type = RX_NO_DATA;
- break;
- case MODE_475:
- order = order_MODE_475;
- p->cur_frame_type = RX_SPEECH_GOOD;
- break;
- case MODE_515:
- order = order_MODE_515;
- p->cur_frame_type = RX_SPEECH_GOOD;
- break;
- case MODE_59:
- order = order_MODE_59;
- p->cur_frame_type = RX_SPEECH_GOOD;
- break;
- case MODE_67:
- order = order_MODE_67;
- p->cur_frame_type = RX_SPEECH_GOOD;
- break;
- case MODE_74:
- order = order_MODE_74;
- p->cur_frame_type = RX_SPEECH_GOOD;
- break;
- case MODE_795:
- order = order_MODE_795;
- p->cur_frame_type = RX_SPEECH_GOOD;
- break;
- case MODE_102:
- order = order_MODE_102;
- p->cur_frame_type = RX_SPEECH_GOOD;
- break;
- case MODE_122:
- order = order_MODE_122;
- p->cur_frame_type = RX_SPEECH_GOOD;
- break;
- default:
- p->cur_frame_type = RX_SPEECH_BAD;
- break;
- }
-
- // reorder the bitstream to match the bit allocation in the specification
- if((p->cur_frame_type != RX_NO_DATA) && (p->cur_frame_type != RX_SPEECH_BAD)) {
+ if(MODE_475 <= mode && mode <= MODE_DTX) {
uint16_t *data = (uint16_t *)&p->frame;
+ const AMROrder *order = amr_unpacking_bitmaps_per_mode[mode];
+ int i;
memset(&p->frame, 0, sizeof(AMRNBFrame));
for(i=0; i<mode_bits[mode]; i++) {
data[order[i].array_element] += get_bits1(&p->gb) * (1<< order[i].bit_mask);
}
- }
if(mode == MODE_DTX) {
+ p->cur_frame_type = RX_SID_FIRST; // get SID type bit
skip_bits(&p->gb, 4); // skip to the next byte
if(get_bits1(&p->gb)) // use the update if there is one
p->cur_frame_type = RX_SID_UPDATE;
*speech_mode = get_bits(&p->gb, 3); // speech mode indicator
+ }else
+ p->cur_frame_type = RX_SPEECH_GOOD;
+ }else if(mode == NO_DATA) {
+ p->cur_frame_type = RX_NO_DATA;
+ }else {
+ p->cur_frame_type = RX_SPEECH_BAD;
}
return mode;
More information about the FFmpeg-soc
mailing list