On Wed, 12 Oct 2011 19:04:12 -0400, Justin Ruggles <justin.rugg...@gmail.com> 
wrote:
> This also allows for removing some of the buf_size checks and using the
> sample count for some of the decoding loops.
> ---
>  libavcodec/adpcm.c |  351 
> ++++++++++++++++++++++++++++++++++------------------
>  1 files changed, 231 insertions(+), 120 deletions(-)
> 
> diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
> index 774193e..ddb08b5 100644
> --- a/libavcodec/adpcm.c
> +++ b/libavcodec/adpcm.c
> @@ -315,6 +315,173 @@ static void xa_decode(short *out, const unsigned char 
> *in,
>      }
>  }
>  
> +/**
> + * Get the number of samples that will be decoded from the packet.
> + * In one case, this is actually the maximum number of samples possible to
> + * decode with the given buf_size.
> + *
> + * @param[out] coded_samples set to the number of samples as coded in the
> + *                           packet, or 0 if the codec does not encode the
> + *                           number of samples in each frame.
> + */
> +static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf,
> +                          int buf_size, int *coded_samples)
> +{
> +    ADPCMDecodeContext *s = avctx->priv_data;
> +    int nb_samples        = 0;
> +    int ch                = avctx->channels;
> +    int has_coded_samples = 0;
> +    int header_size;
> +
> +    *coded_samples = 0;
> +
> +    switch (avctx->codec->id) {
> +    /* constant, only check buf_size */
> +    case CODEC_ID_ADPCM_EA_XAS:
> +        if (buf_size < 76 * avctx->channels)
> +            return 0;
> +        nb_samples = 128;
> +        break;
> +    case CODEC_ID_ADPCM_IMA_QT:
> +        if (buf_size < 34)

Looks ok except for missing channel count here as we discussed on IRC.

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to