summaryrefslogtreecommitdiff
path: root/ffmpeg/libavcodec/vima.c
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/vima.c
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/vima.c')
-rw-r--r--ffmpeg/libavcodec/vima.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/ffmpeg/libavcodec/vima.c b/ffmpeg/libavcodec/vima.c
index 705839e..f040e1b 100644
--- a/ffmpeg/libavcodec/vima.c
+++ b/ffmpeg/libavcodec/vima.c
@@ -19,15 +19,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/**
+ * @file
+ * LucasArts VIMA audio decoder
+ * @author Paul B Mahol
+ */
+
#include "libavutil/channel_layout.h"
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
#include "adpcm_data.h"
-typedef struct {
- uint16_t predict_table[5786 * 2];
-} VimaContext;
+static int predict_table_init = 0;
+static uint16_t predict_table[5786 * 2];
static const uint8_t size_table[] =
{
@@ -103,8 +108,12 @@ static const int8_t* const step_index_tables[] =
static av_cold int decode_init(AVCodecContext *avctx)
{
- VimaContext *vima = avctx->priv_data;
- int start_pos;
+ int start_pos;
+
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+
+ if (predict_table_init)
+ return 0;
for (start_pos = 0; start_pos < 64; start_pos++) {
unsigned int dest_pos, table_pos;
@@ -120,11 +129,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
put += table_value;
table_value >>= 1;
}
- vima->predict_table[dest_pos] = put;
+ predict_table[dest_pos] = put;
}
}
-
- avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ predict_table_init = 1;
return 0;
}
@@ -133,7 +141,6 @@ static int decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *pkt)
{
GetBitContext gb;
- VimaContext *vima = avctx->priv_data;
AVFrame *frame = data;
int16_t pcm_data[2];
uint32_t samples;
@@ -200,7 +207,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
predict_index = (lookup << (7 - lookup_size)) | (step_index << 6);
predict_index = av_clip(predict_index, 0, 5785);
- diff = vima->predict_table[predict_index];
+ diff = predict_table[predict_index];
if (lookup)
diff += ff_adpcm_step_table[step_index] >> (lookup_size - 1);
if (highbit)
@@ -223,11 +230,10 @@ static int decode_frame(AVCodecContext *avctx, void *data,
AVCodec ff_vima_decoder = {
.name = "vima",
+ .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_VIMA,
- .priv_data_size = sizeof(VimaContext),
.init = decode_init,
.decode = decode_frame,
.capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"),
};