[FFmpeg-soc] [soc]: r4150 - in wmapro: wma3.h wma3dec.c
faust3
subversion at mplayerhq.hu
Tue Mar 3 20:59:52 CET 2009
Author: faust3
Date: Tue Mar 3 20:59:51 2009
New Revision: 4150
Log:
use a fixed size buffer for cross packet frames
Modified:
wmapro/wma3.h
wmapro/wma3dec.c
Modified: wmapro/wma3.h
==============================================================================
--- wmapro/wma3.h Mon Mar 2 23:19:00 2009 (r4149)
+++ wmapro/wma3.h Tue Mar 3 20:59:51 2009 (r4150)
@@ -35,6 +35,7 @@
#define MAX_CHANNELS 8 //< max number of handled channels
#define MAX_SUBFRAMES 32 //< max number of subframes per channel
#define MAX_BANDS 29 //< max number of scale factor bands
+#define MAX_FRAMESIZE 16384 //< maximum compressed frame size
/* size of block defines taken from wma.h */
#define BLOCK_MIN_BITS 7 //< log2 of min block size
@@ -88,6 +89,8 @@ typedef struct WMA3DecodeContext {
/** generic decoder variables */
AVCodecContext* avctx; //< codec context for av_log
DSPContext dsp; //< accelerated dsp functions
+ uint8_t frame_data[MAX_FRAMESIZE +
+ FF_INPUT_BUFFER_PADDING_SIZE];//< compressed frame data
MDCTContext mdct_ctx[BLOCK_NB_SIZES]; //< MDCT context per block size
DECLARE_ALIGNED_16(float, tmp[BLOCK_MAX_SIZE]); //< imdct output buffer
float* windows[BLOCK_NB_SIZES]; //< window per block size
@@ -122,7 +125,6 @@ typedef struct WMA3DecodeContext {
/** packet decode state */
uint8_t packet_sequence_number; //< current packet number
int prev_packet_bit_size; //< saved number of bits
- uint8_t* prev_packet_data; //< prev frame data
uint8_t bit5; //< padding bit? (CBR files)
uint8_t bit6; //< unknown
uint8_t packet_loss; //< set in case of bitstream error
Modified: wmapro/wma3dec.c
==============================================================================
--- wmapro/wma3dec.c Mon Mar 2 23:19:00 2009 (r4149)
+++ wmapro/wma3dec.c Tue Mar 3 20:59:51 2009 (r4150)
@@ -105,7 +105,6 @@ static av_cold int wma3_decode_end(AVCod
WMA3DecodeContext *s = avctx->priv_data;
int i;
- av_free(s->prev_packet_data);
av_free(s->num_sfb);
av_free(s->sfb_offsets);
av_free(s->subwoofer_cutoffs);
@@ -1494,32 +1493,31 @@ static void save_bits(WMA3DecodeContext
int pos = (s->prev_packet_bit_size - bit_offset) / 8;
s->prev_packet_bit_size += len;
- if(len <= 0)
+ if(len <= 0 || buflen > MAX_FRAMESIZE){
+ av_log(s->avctx, AV_LOG_ERROR, "input buffer to small\n");
+ s->packet_loss = 1;
return;
-
- /** increase length if needed */
- s->prev_packet_data = av_realloc(s->prev_packet_data,buflen +
- FF_INPUT_BUFFER_PADDING_SIZE);
+ }
/** byte align prev_frame buffer */
if(bit_offset){
int missing = 8 - bit_offset;
if(len < missing)
missing = len;
- s->prev_packet_data[pos++] |=
+ s->frame_data[pos++] |=
get_bits(gb, missing) << (8 - bit_offset - missing);
len -= missing;
}
/** copy full bytes */
while(len > 7){
- s->prev_packet_data[pos++] = get_bits(gb,8);
+ s->frame_data[pos++] = get_bits(gb,8);
len -= 8;
}
/** copy remaining bits */
if(len > 0)
- s->prev_packet_data[pos++] = get_bits(gb,len) << (8 - len);
+ s->frame_data[pos++] = get_bits(gb,len) << (8 - len);
}
/**
@@ -1584,7 +1582,7 @@ static int wma3_decode_packet(AVCodecCon
/** decode the cross packet frame if it is valid */
if(!s->packet_loss){
GetBitContext gb_prev;
- init_get_bits(&gb_prev, s->prev_packet_data,
+ init_get_bits(&gb_prev, s->frame_data,
s->prev_packet_bit_size);
wma_decode_frame(s,&gb_prev);
}
More information about the FFmpeg-soc
mailing list