From 910c8f628197dbefadb5545ddf1a5943fa29567c Mon Sep 17 00:00:00 2001 From: Tomas Kukosa Date: Tue, 11 Dec 2007 11:54:15 +0000 Subject: From Ales Kocourek example plugin updated svn path=/trunk/; revision=23839 --- plugins/easy_codec/codec-g722.c | 6 +++--- plugins/easy_codec/codec-g7231.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'plugins/easy_codec') diff --git a/plugins/easy_codec/codec-g722.c b/plugins/easy_codec/codec-g722.c index 22a56f91ca..576d15a085 100644 --- a/plugins/easy_codec/codec-g722.c +++ b/plugins/easy_codec/codec-g722.c @@ -68,14 +68,14 @@ int codec_g722_decode(void *context, const void *input, int inputSizeBytes, void return 0; if (!output) - return (inputSizeBytes / L_G722_FRAME_COMPRESSED) * L_G722_FRAME * sizeof(short); + return (inputSizeBytes / L_G722_FRAME_COMPRESSED ) * L_G722_FRAME / 2 * sizeof(short) ; while ((inputSizeBytes >= L_G722_FRAME_COMPRESSED) && - ((*outputSizeBytes - decodedBytes) >= L_G722_FRAME * sizeof(short))) { + ((*outputSizeBytes - decodedBytes) >= L_G722_FRAME / 2 * sizeof(short))) { if (EasyG722_decoder(ctx->handle, (unsigned char*)bitstream, ctx->speach_buffer)) { int write_index = 0; - for(i = 0; i < L_G722_FRAME * sizeof(short); i+=2) { + for(i = 0; i < L_G722_FRAME; i+=2) { ctx->speach_buffer[write_index] = ctx->speach_buffer[i]; write_index++; } diff --git a/plugins/easy_codec/codec-g7231.c b/plugins/easy_codec/codec-g7231.c index b1b2b7e1ac..dcfa8923f1 100644 --- a/plugins/easy_codec/codec-g7231.c +++ b/plugins/easy_codec/codec-g7231.c @@ -37,6 +37,7 @@ struct g7231_context { CODER_HANDLE handle; short speach_buffer[L_G7231_FRAME]; + int l_g7231_frame_compressed; }; void *codec_g7231_init(void) { @@ -60,28 +61,27 @@ int codec_g7231_decode(void *context, const void *input, int inputSizeBytes, voi const unsigned char *bitstream = (const unsigned char*)input; short *speech = (short*)output; int decodedBytes = 0; - static int L_G7231_FRAME_COMPRESSED = 0; if (!ctx) return 0; if ( ctx->handle == -1) { if ( bitstream[0] & 0x03 ) { ctx->handle=EasyG7231_init_decoder(FALSE); - L_G7231_FRAME_COMPRESSED = L_G7231_FRAME_COMPRESSED_53; + ctx->l_g7231_frame_compressed = L_G7231_FRAME_COMPRESSED_53; } else { ctx->handle=EasyG7231_init_decoder(TRUE); - L_G7231_FRAME_COMPRESSED = L_G7231_FRAME_COMPRESSED_63; + ctx->l_g7231_frame_compressed = L_G7231_FRAME_COMPRESSED_63; } } - if ((inputSizeBytes % L_G7231_FRAME_COMPRESSED) != 0) + if ((inputSizeBytes % ctx->l_g7231_frame_compressed) != 0) return 0; if (!output) - return (inputSizeBytes / L_G7231_FRAME_COMPRESSED) * L_G7231_FRAME * sizeof(short); + return (inputSizeBytes / ctx->l_g7231_frame_compressed) * L_G7231_FRAME * sizeof(short); - while ((inputSizeBytes >= L_G7231_FRAME_COMPRESSED) && + while ((inputSizeBytes >= ctx->l_g7231_frame_compressed) && ((*outputSizeBytes - decodedBytes) >= L_G7231_FRAME * sizeof(short))) { if (EasyG7231_decoder(ctx->handle, (unsigned char*)bitstream, ctx->speach_buffer)) { @@ -90,8 +90,8 @@ int codec_g7231_decode(void *context, const void *input, int inputSizeBytes, voi decodedBytes += L_G7231_FRAME * sizeof(short); } - bitstream += L_G7231_FRAME_COMPRESSED; - inputSizeBytes -= L_G7231_FRAME_COMPRESSED; + bitstream += ctx->l_g7231_frame_compressed; + inputSizeBytes -= ctx->l_g7231_frame_compressed; } return decodedBytes; -- cgit v1.2.1