[FFmpeg-soc] [soc]: r313 - in qcelp: doc/NOTES qcelp.h qcelp_glue.diff qcelpdec.c
reynaldo
subversion at mplayerhq.hu
Thu Jul 5 22:18:38 CEST 2007
Author: reynaldo
Date: Thu Jul 5 22:18:38 2007
New Revision: 313
Log:
Should address most of your comments
Modified:
qcelp/doc/NOTES
qcelp/qcelp.h
qcelp/qcelp_glue.diff
qcelp/qcelpdec.c
Modified: qcelp/doc/NOTES
==============================================================================
--- qcelp/doc/NOTES (original)
+++ qcelp/doc/NOTES Thu Jul 5 22:18:38 2007
@@ -1,5 +1,5 @@
-This notes are abstracts from the standard that might
-be usesfull in understanding whats going on.
+These notes are abstracts from the standard that might
+be useful in understanding what's going on.
How stuff works
@@ -13,7 +13,7 @@ The number of bits used to encode the LP
function of the selected rate (1, 1/2, 1/4, 1/8).
-Parameters codes transmited for each rate packet (Page 25)
+Parameter codes transmitted for each rate packet (Page 25)
------------------------------------------------
LSPi | Line Spectral Pair frequency i.
Modified: qcelp/qcelp.h
==============================================================================
--- qcelp/qcelp.h (original)
+++ qcelp/qcelp.h Thu Jul 5 22:18:38 2007
@@ -1,5 +1,5 @@
/*
- * QCELP Decoder
+ * QCELP decoder
* Copyright (c) 2007 Reynaldo H. Verdejo Pinochet
*
* This file is part of FFmpeg.
@@ -21,7 +21,7 @@
/**
* @file qcelp.h
- * QCELP decoder.
+ * QCELP decoder
*/
typedef enum
@@ -30,20 +30,20 @@ typedef enum
RATE_HALF = 1,
RATE_QUARTER= 2,
RATE_OCTAVE = 3,
- I_F_Q, /* insuficient frame quality */
+ I_F_Q, /*!< insufficient frame quality */
BLANK,
RATE_UNKNOWN
-} qcelp_packet_type;
+} qcelp_packet_rate;
-static uint16_t qcelp_bits_per_type[]={266,124,54,20};
+static const uint16_t qcelp_bits_per_rate[]={266,124,54,20};
typedef struct {
- uint8_t index; /* index into the reference frame */
- uint8_t bitpos; /* bit position in the value's byte */
+ uint8_t index; /*!< index into the reference frame */
+ uint8_t bitpos; /*!< bit position in the value's byte */
} QCELPBitmap;
-/*
+/**
* WARNING
*
* YOU WONT SEE ANY mention of a REFERENCE nor an UNIVERSAL frame
@@ -51,18 +51,37 @@ typedef struct {
* reordering needed to unify the decoding process _inside_ this
* code, nothing more.
*
- */
-
-/*
+ *
+ * UNIVERSAL FRAME
+ * ---------------
+ *
+ * Format of QCELPFrame.data
+ *
+ * QCELP_X0_POS
+ * |
+ * CBSIGNs 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ * CBGAINs 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ * CINDEXs 32 33 34 35 36 37 38 39 40 41 43 43 44 45 46 47
+ * PLAGs 48 49 50 51
+ * PFRACs 52 53 54 55
+ * PGAINs 56 57 58 59
+ * LSPVs 60 61 62 63 64
+ * RSVD 65
+ * LSP 66 67 68 69 70 71 72 73 74 75
+ * CBSEED 76
+ *
+ *
* REFERENCE FRAME
+ * ---------------
*
- * This are the reference frame slices. Each touple will be mapped to a
- * QCELPBitmap showing the location of each bit in the input * with
- * respect to a transmision code in the 'universal frame'.
+ *
+ * What follows are the reference frame slices. Each tuple will be mapped
+ * to a QCELPBitmap showing the location of each bit in the input with respect
+ * to a transmission code in the 'universal frame'.
*
* FIXME
- * it would be really nice if someone reviewed this numbers :)
- *------------------------------------------------------------------*/
+ * it would be really nice if someone reviewed these numbers :)
+ *---------------------------------------------------------------------------*/
#define QCELP_RATE_FULL_BITMAP \
{15,0},{47,0},{47,1},{47,2},{47,3},{47,4},{47,5},{47,6},\
@@ -133,10 +152,9 @@ typedef struct {
{65,3},{65,2},{65,1},{65,0}
-/*
+/**
* Position of the bitmapping data for each pkt type in
* the big REFERENCE FRAME array
- *
*/
#define QCELP_FULLPKT_REFERENCE_POS 0
@@ -144,48 +162,13 @@ typedef struct {
#define QCELP_4THRPKT_REFERENCE_POS 390
#define QCELP_8THRPKT_REFERENCE_POS 444
-/*
- * Reference frame, finally :-)
- *
- */
-
-static QCELPBitmap QCELP_REFERENCE_FRAME[]={QCELP_RATE_FULL_BITMAP,
- QCELP_RATE_HALF_BITMAP,
- QCELP_RATE_4THR_BITMAP,
- QCELP_RATE_8THR_BITMAP};
-
-/*
- * UNIVERSAL FRAME
- *
- *
- * Oce frame is parsed all data gets stored in QCELPFrame.data acording
- * to this structure:
- *
- * QCELP_X0_POS
- * |
- * CBSIGNs 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- * CBGAINs 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
- * CINDEXs 32 33 34 35 36 37 38 39 40 41 43 43 44 45 46 47
- * PLAGs 48 49 50 51
- * PFRACs 52 53 54 55
- * PGAINs 56 57 58 59
- * LSPVs 60 61 62 63 64
- * RSVD 65
- * LSP 66 67 68 69 70 71 72 73 74 75
- * CBSEED 76
- *
- *-------------------------------------------------------------------------*/
-
-typedef struct
-{
- qcelp_packet_type type;
- uint8_t data[76]; /* holds all data from a frame (_once_ parsed) */
- uint8_t bits;
-} QCELPFrame;
+static const QCELPBitmap QCELP_REFERENCE_FRAME[]={QCELP_RATE_FULL_BITMAP,
+ QCELP_RATE_HALF_BITMAP,
+ QCELP_RATE_4THR_BITMAP,
+ QCELP_RATE_8THR_BITMAP};
-/*
- * Position of the transmision codes inside the universal frame.
- *
+/**
+ * Position of the transmission codes inside the universal frame.
*/
#define QCELP_CBSIGN0_POS 0
@@ -195,13 +178,16 @@ typedef struct
#define QCELP_PFRAC0_POS 52
#define QCELP_PGAIN0_POS 56
#define QCELP_LSPV0_POS 60
-#define QCELP_RSRVD_POS 65 /* on all but rate 1/2 packets */
-#define QCELP_LSP0_POS 66 /* only in rate 1/8 packets */
-#define QCELP_CBSEED_POS 76 /* only in rate 1/8 packets */
+#define QCELP_RSRVD_POS 65 /*!< on all but rate 1/2 packets */
+#define QCELP_LSP0_POS 66 /*!< only in rate 1/8 packets */
+#define QCELP_CBSEED_POS 76 /*!< only in rate 1/8 packets */
-/* rest its currently unused */
+/* rest is currently unused */
-static float qcelp_fullrate_ccodebook[]=
+static const int qcelp_cumulative_gainloss[]={0,1,2,6};
+static const float qcelp_cumulative_pitchsaturation[]={0.9,0.6,0.3,0.0};
+
+static const float qcelp_fullrate_ccodebook[]=
{
0.10,-0.65,-0.59, 0.12, 1.10, 0.34,-1.34, 1.57,
1.04,-0.84,-0.34,-1.15, 0.23,-1.01, 0.03, 0.45,
@@ -221,7 +207,7 @@ static float qcelp_fullrate_ccodebook[]=
-1.84,-1.97, 0.52,-0.03, 0.78,-1.89, 0.08,-0.65
};
-static float qcelp_halfrate_ccodebook[]=
+static const float qcelp_halfrate_ccodebook[]=
{
0.0, -2.0, 0.0, -1.5, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
Modified: qcelp/qcelp_glue.diff
==============================================================================
--- qcelp/qcelp_glue.diff (original)
+++ qcelp/qcelp_glue.diff Thu Jul 5 22:18:38 2007
@@ -2,38 +2,38 @@ Index: libavcodec/Makefile
===================================================================
--- libavcodec/Makefile (revision 9314)
+++ libavcodec/Makefile (working copy)
-@@ -147,6 +147,7 @@
- OBJS-$(CONFIG_SHORTEN_DECODER) += shorten.o golomb.o
- OBJS-$(CONFIG_SMACKAUD_DECODER) += smacker.o
- OBJS-$(CONFIG_SMACKER_DECODER) += smacker.o
+@@ -128,6 +128,7 @@
+ OBJS-$(CONFIG_PNG_ENCODER) += png.o
+ OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o pnm.o
+ OBJS-$(CONFIG_PTX_DECODER) += ptx.o
+OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o
- OBJS-$(CONFIG_SMC_DECODER) += smc.o
- OBJS-$(CONFIG_SNOW_DECODER) += snow.o
- OBJS-$(CONFIG_SNOW_ENCODER) += snow.o
+ OBJS-$(CONFIG_QDM2_DECODER) += qdm2.o mdct.o fft.o mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o
+ OBJS-$(CONFIG_QDRAW_DECODER) += qdrw.o
+ OBJS-$(CONFIG_QPEG_DECODER) += qpeg.o
Index: libavcodec/allcodecs.c
===================================================================
--- libavcodec/allcodecs.c (revision 9314)
+++ libavcodec/allcodecs.c (working copy)
-@@ -196,6 +196,7 @@
- REGISTER_DECODER(RA_288, ra_288);
- REGISTER_DECODER(SHORTEN, shorten);
- REGISTER_DECODER(SMACKAUD, smackaud);
+@@ -191,6 +191,7 @@
+ REGISTER_DECODER(MP3ADU, mp3adu);
+ REGISTER_DECODER(MP3ON4, mp3on4);
+ REGISTER_DECODER(MPC7, mpc7);
+ REGISTER_DECODER(QCELP, qcelp);
- REGISTER_ENCDEC (SONIC, sonic);
- REGISTER_ENCODER(SONIC_LS, sonic_ls);
- REGISTER_DECODER(TRUESPEECH, truespeech);
+ REGISTER_DECODER(QDM2, qdm2);
+ REGISTER_DECODER(RA_144, ra_144);
+ REGISTER_DECODER(RA_288, ra_288);
Index: libavcodec/allcodecs.h
===================================================================
--- libavcodec/allcodecs.h (revision 9314)
+++ libavcodec/allcodecs.h (working copy)
-@@ -161,6 +161,7 @@
- extern AVCodec shorten_decoder;
- extern AVCodec smackaud_decoder;
- extern AVCodec smacker_decoder;
+@@ -144,6 +144,7 @@
+ extern AVCodec nuv_decoder;
+ extern AVCodec png_decoder;
+ extern AVCodec ptx_decoder;
+extern AVCodec qcelp_decoder;
- extern AVCodec smc_decoder;
- extern AVCodec snow_decoder;
- extern AVCodec sol_dpcm_decoder;
+ extern AVCodec qdm2_decoder;
+ extern AVCodec qdraw_decoder;
+ extern AVCodec qpeg_decoder;
Index: libavformat/mov.c
===================================================================
--- libavformat/mov.c (revision 9314)
Modified: qcelp/qcelpdec.c
==============================================================================
--- qcelp/qcelpdec.c (original)
+++ qcelp/qcelpdec.c Thu Jul 5 22:18:38 2007
@@ -1,5 +1,5 @@
/*
- * QCELP Decoder
+ * QCELP decoder
* Copyright (c) 2007 Reynaldo H. Verdejo Pinochet
*
* This file is part of FFmpeg.
@@ -21,16 +21,12 @@
/**
* @file qcelpdec.c
- * QCELP decoder.
+ * QCELP decoder
*/
-/* First we include some default includes */
#include <math.h>
#include <stddef.h>
-#include <stdio.h>
-/* The following includes have the bitstream reader, various dsp functions and the various defaults */
-#define ALT_BITSTREAM_READER
#include "avcodec.h"
#include "bitstream.h"
#include "dsputil.h"
@@ -39,6 +35,13 @@
#define DEBUG 1
+typedef struct
+{
+ qcelp_packet_rate rate;
+ uint8_t data[76]; /* data from a _parsed_ frame */
+ uint8_t bits;
+} QCELPFrame;
+
typedef struct {
GetBitContext gb;
QCELPFrame *frame;
@@ -68,65 +71,58 @@ static int qcelp_decode_init(AVCodecCont
return 0;
}
-static int qcelp_parse_pkt_full(uint8_t *buf, QCELPFrame *frame)
-{
- return 0;
-}
static int qcelp_decode_frame(AVCodecContext *avctx, void *data,
int *data_size, uint8_t *buf, int buf_size)
{
- QCELPContext *q = avctx->priv_data;
- int16_t *outbuffer = data;
- int8_t samples;
- int8_t bitcount;
- int16_t first16 = 0; /* needed for rate 1/8 particularities */
-
- QCELPBitmap *order;
-
- order = NULL;
+ QCELPContext *q = avctx->priv_data;
+ QCELPBitmap *order = NULL;
+ int16_t *outbuffer = data;
+ int8_t samples;
+ int n;
+ uint16_t first16 = 0; /* needed for rate 1/8 peculiarities */
+ int is_ifq = 0;
init_get_bits(&q->gb, buf, buf_size*8);
/*
- * FIXME this comment should actually make some sence ..
- *
- * Here we try to identify each frame's rate by its byte size,
- * then, after setting a few utility vars we point 'order'
- * to start at the location of the rate's reference _slice_
- * inside the big REFERECE_FRAME array. We then proceed with
- * the bit reordering that will leave a full raw frame's data
- * ordered in our 'universal frame'
+ * figure out frame's rate by its size, set up a few utility vars
+ * and point 'order' to the rate's reference _slice_ inside the
+ * big REFERENCE_FRAME array.
*/
switch(buf_size)
{
case 34:
- q->frame->type = RATE_FULL;
- q->frame->bits = qcelp_bits_per_type[RATE_FULL];
- order = QCELP_REFERENCE_FRAME + QCELP_FULLPKT_REFERENCE_POS;
+ q->frame->rate = RATE_FULL;
+ q->frame->bits = qcelp_bits_per_rate[RATE_FULL];
+ order =
+ (QCELPBitmap*)(QCELP_REFERENCE_FRAME + QCELP_FULLPKT_REFERENCE_POS);
break;
case 16:
- q->frame->type = RATE_HALF;
- q->frame->bits = qcelp_bits_per_type[RATE_HALF];
- order = QCELP_REFERENCE_FRAME + QCELP_HALFPKT_REFERENCE_POS;
+ q->frame->rate = RATE_HALF;
+ q->frame->bits = qcelp_bits_per_rate[RATE_HALF];
+ order =
+ (QCELPBitmap*)(QCELP_REFERENCE_FRAME + QCELP_HALFPKT_REFERENCE_POS);
break;
case 7:
- q->frame->type = RATE_QUARTER;
- q->frame->bits = qcelp_bits_per_type[RATE_QUARTER];
- order = QCELP_REFERENCE_FRAME + QCELP_4THRPKT_REFERENCE_POS;
+ q->frame->rate = RATE_QUARTER;
+ q->frame->bits = qcelp_bits_per_rate[RATE_QUARTER];
+ order =
+ (QCELPBitmap*)(QCELP_REFERENCE_FRAME + QCELP_4THRPKT_REFERENCE_POS);
break;
case 3:
- q->frame->type = RATE_OCTAVE;
- q->frame->bits = qcelp_bits_per_type[RATE_OCTAVE];
- order = QCELP_REFERENCE_FRAME + QCELP_8THRPKT_REFERENCE_POS;
+ q->frame->rate = RATE_OCTAVE;
+ q->frame->bits = qcelp_bits_per_rate[RATE_OCTAVE];
+ order =
+ (QCELPBitmap*)(QCELP_REFERENCE_FRAME + QCELP_8THRPKT_REFERENCE_POS);
break;
case 0: /* FIXME */
- q->frame->type = BLANK;
+ q->frame->rate = BLANK;
q->frame->bits = 0;
break;
default:
- q->frame->type = RATE_UNKNOWN;
+ q->frame->rate = RATE_UNKNOWN;
q->frame->bits = 0;
/*
printf("UNKNOWN PACKET RATE\n");
@@ -138,100 +134,56 @@ static int qcelp_decode_frame(AVCodecCon
* reordering loop
*/
- bitcount=0;
- while(bitcount < q->frame->bits)
+ for(n=0; n < q->frame->bits; n++)
{
- /*
- * order[bitcount]->index holds the placement of this
- * input stream bit in the universal frame.
- *
- * order[bitcount]->pos holds the bit pos inside this value
- * byte.
- *
- */
-
- q->frame->data[ order[bitcount].index ] |=
- get_bits1(&q->gb)>>(order[bitcount].bitpos);
-
- /*
- * viral sample! :D
- *
- * just needed for rate 1/8 packets
- *
- */
+ q->frame->data[ order[n].index ] |=
+ get_bits1(&q->gb)<<order[n].bitpos;
- if(bitcount<16)
+ if(n<16)
{
- first16 |= q->frame->data[ order[bitcount].index ]>>bitcount
+ first16 |= q->frame->data[ order[n].index ]>>n;
}
- bitcount++;
}
/* DONE REORDERING */
- /*
- * check for erasures/blanks on rates 1, 1/4 and 1/8
- *
- */
+ /* check for erasures/blanks on rates 1, 1/4 and 1/8 */
- if(q->frame->type != RATE_HALF)
- {
- if(!q->frame->data[QCELP_RSRVD_POS])
- {
- /*
- * flag aproach: set flag for ifq/blank/incorrect
- * decoding
- */
- }
- }
+ if(q->frame->rate != RATE_HALF && !q->frame->data[QCELP_RSRVD_POS])
+ is_ifq=1;
- /* particularities for rate 1/8 */
- if(q->frame->type == RATE_OCTAVE)
- {
- if(first16==0xFFFF)
- {
- /*
- * flag aproach: set flag for ifq/blank/incorrect
- * decoding
- */
- }
- }
+ if(q->frame->rate == RATE_OCTAVE && first16==0xFFFF)
+ is_ifq=1;
- /*
- * check for badly received packets
- * for rate 1, 1/2 and 1/4
- */
+ /* check for badly received packets */
- if(q->frame->type != RATE_OCTAVE)
+ if(q->frame->rate != RATE_OCTAVE)
{
- /*
- * flag aproach: set flag for ifq/blank/incorrect
- * decoding
- */
+ /* check for outbound LSP freqs and codebook gain params */
+ if(q->frame->rate != RATE_QUARTER)
+ {
+ /* magic here */
+ }
}
-
-
/*
* decode loop
*
*/
-
-
return 1;
}
AVCodec qcelp_decoder =
{
- .name = "qcelp",
- .type = CODEC_TYPE_AUDIO,
- .id = CODEC_ID_QCELP,
- .priv_data_size = sizeof(QCELPContext),
- .init = qcelp_decode_init,
- .close = qcelp_decode_close,
+ .name = "qcelp",
+ .type = CODEC_TYPE_AUDIO,
+ .id = CODEC_ID_QCELP,
+ .init = qcelp_decode_init,
+ .close = qcelp_decode_close,
.decode = qcelp_decode_frame,
+ .priv_data_size = sizeof(QCELPContext),
};
More information about the FFmpeg-soc
mailing list