changeset 7062:fb6038ffd2a9 libavcodec

Get rid of the redundant AVG726Context.
author michael
date Wed, 18 Jun 2008 20:51:12 +0000
parents 3e51aa540377
children cd085c1c5103
files g726.c
diffstat 1 files changed, 10 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/g726.c	Wed Jun 18 19:18:32 2008 +0000
+++ b/g726.c	Wed Jun 18 20:51:12 2008 +0000
@@ -89,6 +89,7 @@
     int se;             /**< estimated signal for the next iteration */
     int sez;            /**< estimated second order prediction */
     int y;              /**< quantizer scaling factor for the next iteration */
+    int code_size;
 } G726Context;
 
 static const int quant_tbl16[] =                  /**< 16kbit/s 2bits per sample */
@@ -299,14 +300,9 @@
 
 /* Interfacing to the libavcodec */
 
-typedef struct AVG726Context {
-    G726Context c;
-    int code_size;
-} AVG726Context;
-
 static av_cold int g726_init(AVCodecContext * avctx)
 {
-    AVG726Context* c = (AVG726Context*)avctx->priv_data;
+    G726Context* c = avctx->priv_data;
     unsigned int index= (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2;
 
     if (avctx->bit_rate % avctx->sample_rate && avctx->codec->encode) {
@@ -321,8 +317,8 @@
         av_log(avctx, AV_LOG_ERROR, "Unsupported number of bits %d\n", index+2);
         return -1;
     }
-    g726_reset(&c->c, index);
-    c->code_size = c->c.tbls->bits;
+    g726_reset(c, index);
+    c->code_size = c->tbls->bits;
 
     avctx->coded_frame = avcodec_alloc_frame();
     if (!avctx->coded_frame)
@@ -342,14 +338,14 @@
 static int g726_encode_frame(AVCodecContext *avctx,
                             uint8_t *dst, int buf_size, void *data)
 {
-    AVG726Context *c = avctx->priv_data;
+    G726Context *c = avctx->priv_data;
     short *samples = data;
     PutBitContext pb;
 
     init_put_bits(&pb, dst, 1024*1024);
 
     for (; buf_size; buf_size--)
-        put_bits(&pb, c->code_size, g726_encode(&c->c, *samples++));
+        put_bits(&pb, c->code_size, g726_encode(c, *samples++));
 
     flush_put_bits(&pb);
 
@@ -361,14 +357,14 @@
                              void *data, int *data_size,
                              const uint8_t *buf, int buf_size)
 {
-    AVG726Context *c = avctx->priv_data;
+    G726Context *c = avctx->priv_data;
     short *samples = data;
     GetBitContext gb;
 
     init_get_bits(&gb, buf, buf_size * 8);
 
     while (get_bits_count(&gb) + c->code_size <= buf_size*8)
-        *samples++ = g726_decode(&c->c, get_bits(&gb, c->code_size));
+        *samples++ = g726_decode(c, get_bits(&gb, c->code_size));
 
     if(buf_size*8 != get_bits_count(&gb))
         av_log(avctx, AV_LOG_ERROR, "Frame invalidly split, missing parser?\n");
@@ -382,7 +378,7 @@
     "g726",
     CODEC_TYPE_AUDIO,
     CODEC_ID_ADPCM_G726,
-    sizeof(AVG726Context),
+    sizeof(G726Context),
     g726_init,
     g726_encode_frame,
     g726_close,
@@ -395,7 +391,7 @@
     "g726",
     CODEC_TYPE_AUDIO,
     CODEC_ID_ADPCM_G726,
-    sizeof(AVG726Context),
+    sizeof(G726Context),
     g726_init,
     NULL,
     g726_close,