On Wed, 7 Sep 2011 16:50:52 -0400, Justin Ruggles <[email protected]> wrote: > Make the iff demuxer send the whole audio chunk to the decoder as a > single packet and move stereo interleaving from the iff demuxer to the > decoder. > > Based on a patch by Stefano Sabatini. > git.videolan.org/ffmpeg.git > commit e280a4da2ae6fd44f0079358ecc5aa08e388a5ed > --- > libavcodec/8svx.c | 105 > ++++++++++++++++++++++++++++++++++++++++++++--------- > libavformat/iff.c | 45 +++-------------------- > 2 files changed, 92 insertions(+), 58 deletions(-) > > diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c > index 78c4999..181ebc2 100644 > --- a/libavcodec/8svx.c > +++ b/libavcodec/8svx.c > @@ -32,8 +32,14 @@ > > /** decoder context */ > typedef struct EightSvxContext { > - uint8_t fib_acc; > + uint8_t fib_acc[2]; > const int8_t *table; > + > + /* buffer used to store the whole first packet. > + data is only sent as one large packet */ > + uint8_t *data[2]; > + int data_size; > + int data_idx; > } EightSvxContext; > > static const int8_t fibonacci[16] = { -34, -21, -13, -8, -5, -3, -2, -1, > @@ -41,21 +47,25 @@ static const int8_t fibonacci[16] = { -34, -21, -13, > -8, -5, -3, -2, -1, > static const int8_t exponential[16] = { -128, -64, -32, -16, -8, -4, -2, -1, > 0, 1, 2, 4, 8, 16, 32, 64 > }; > > +#define MAX_FRAME_SIZE 32768 > + > /** > * Delta decode the compressed values in src, and put the resulting > * decoded samples in dst. > */ > static void delta_decode(uint8_t *dst, const uint8_t *src, int src_size, > - uint8_t *state, const int8_t *table) > + uint8_t *state, const int8_t *table, int channels) > { > uint8_t val = *state; > > while (src_size--) { > int d = *src++; > val = av_clip_uint8(val + table[d & 0xF]); > - *dst++ = val; > + *dst = val; > + dst += channels; > val = av_clip_uint8(val + table[d >> 4]); > - *dst++ = val; > + *dst = val; > + dst += channels; > } > > *state = val; > @@ -65,33 +75,73 @@ static void delta_decode(uint8_t *dst, const uint8_t > *src, int src_size, > static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int > *data_size, > AVPacket *avpkt) > { > - const uint8_t *buf = avpkt->data; > - int buf_size = avpkt->size; > EightSvxContext *esc = avctx->priv_data; > + int buf_size; > uint8_t *out_data = data; > - int consumed = buf_size; > + int out_data_size; > + > + /* for the first packet, copy data to buffer */ > + if (avpkt->data) { > + int chan_size;
int chan_size = avpkt->size / (avctx->channels == 2 ? 2 : 1); saves a few lines below and is more readable IMO (even more readable if something in lavc ensures that channels != 0). otherwise looks fine, but i'm not an expert on such things. -- Anton Khirnov _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
