On Mon, Jul 25, 2016 at 10:13:38PM +0530, Umair Khan wrote:
> On Sun, Jul 24, 2016 at 1:47 AM, Umair Khan <omerj...@gmail.com> wrote:
> >
> > HI,
> >
> > On Fri, Jul 22, 2016 at 9:19 PM, Michael Niedermayer
> > <mich...@niedermayer.cc> wrote:
> > > On Fri, Jul 22, 2016 at 06:22:30PM +0530, Umair Khan wrote:
> > >> On Thu, Jul 21, 2016 at 6:18 PM, Michael Niedermayer
> > >> <mich...@niedermayer.cc> wrote:
> > >> > On Sun, Jul 17, 2016 at 12:06:03AM +0530, Umair Khan wrote:
> > > [...]
> > >> >> +static int decode_string(MLZDict *dict, unsigned char *buff, int 
> > >> >> string_code, int *first_char_code, unsigned long bufsize) {
> > >> >> +    unsigned long count, offset;
> > >> >> +    int current_code, parent_code, tmp_code;
> > >> >> +
> > >> >> +    count            = 0;
> > >> >> +    current_code     = string_code;
> > >> >> +    *first_char_code = CODE_UNSET;
> > >> >> +
> > >> >> +    while (count < bufsize) {
> > >> >> +        switch (current_code) {
> > >> >> +        case CODE_UNSET:
> > >> >> +            return count;
> > >> >> +            break;
> > >> >> +        default:
> > >> >> +            if (current_code < FIRST_CODE) {
> > >> >> +                *first_char_code = current_code;
> > >> >> +                buff[0] = current_code;
> > >> >> +                count++;
> > >> >> +                return count;
> > >> >> +            } else {
> > >> >> +                offset  = dict[current_code].match_len - 1;
> > >> >> +                tmp_code = dict[current_code].char_code;
> > >> >> +                buff[offset] = tmp_code;
> > >> >> +                count++;
> > >> >> +            }
> > >> >> +            current_code = dict[current_code].parent_code;
> > >> >> +            if ((current_code < 0) || (current_code > (DIC_INDEX_MAX 
> > >> >> - 1))) {
> > >> >
> > >> >> +                av_log(NULL, AV_LOG_ERROR, "MLZ dic index error.\n");
> > >> >
> > >> > it would be ideal if all av_log() would have a context instead of NULL
> > >>
> > >> How to go ahead with this? Should I create MLZContext or something? If
> > >> yes, could you please tell how?
> > >
> > > possible or you pass a void *context
> >
> > Updated patch.
> 
> Another revision. Fixes some things I had overlooked.
> 
> - Umair

>  Changelog                     |    3 
>  libavcodec/Makefile           |    2 
>  libavcodec/alsdec.c           |  286 
> +++++++++++++++++++++++++++++++++++++++++-
>  libavcodec/mlz.c              |  173 +++++++++++++++++++++++++
>  libavcodec/mlz.h              |   70 ++++++++++
>  libavutil/softfloat_ieee754.h |  115 ++++++++++++++++
>  6 files changed, 646 insertions(+), 3 deletions(-)
> 66dd916fe5b2e98b30aed21f4cf656b66c51ce1f  
> 0001-avcodec-alsdec-implement-floating-point-decoding.patch
> From 44567b208cf0b697a4403420bc3f7ba0cebabbc1 Mon Sep 17 00:00:00 2001
> From: Umair Khan <omerj...@gmail.com>
> Date: Sun, 24 Jul 2016 00:28:55 +0530
> Subject: [PATCH 1/1] avcodec/alsdec: implement floating point decoding
> 
> It conforms to RM22 version of the reference codec.

gcc generates these warnings:

libavcodec/mlz.c: In function ‘ff_mlz_decompression’:
libavcodec/mlz.c:152:25: warning: passing argument 1 of ‘decode_string’ from 
incompatible pointer type [enabled by default]
libavcodec/mlz.c:61:12: note: expected ‘struct MLZ *’ but argument is of type 
‘struct MLZDict *’
libavcodec/mlz.c:153:25: warning: passing argument 1 of ‘decode_string’ from 
incompatible pointer type [enabled by default]
libavcodec/mlz.c:61:12: note: expected ‘struct MLZ *’ but argument is of type 
‘struct MLZDict *’
libavcodec/mlz.c:157:25: warning: passing argument 1 of ‘decode_string’ from 
incompatible pointer type [enabled by default]


[...]
> +
> +/** Read and decode the floating point sample data
> + */
> +static int read_diff_float_data(ALSDecContext *ctx, unsigned int ra_frame) {
> +    AVCodecContext *avctx   = ctx->avctx;
> +    GetBitContext *gb       = &ctx->gb;
> +    SoftFloat_IEEE754 *acf  = ctx->acf;
> +    int *shift_value        = ctx->shift_value;
> +    int *last_shift_value   = ctx->last_shift_value;
> +    int *last_acf_mantissa  = ctx->last_acf_mantissa;
> +    int **raw_mantissa      = ctx->raw_mantissa;
> +    int *nbits              = ctx->nbits;
> +    unsigned char *larray   = ctx->larray;
> +    int frame_length        = ctx->cur_frame_length;
> +    SoftFloat_IEEE754 scale = av_int2sf_ieee754(0x1u, 23);
> +    unsigned int partA_flag;
> +    unsigned int highest_byte;
> +    unsigned int shift_amp;
> +    uint32_t tmp_32;
> +    int use_acf;
> +    int nchars;
> +    int i;
> +    int c;
> +    long k;
> +    long nbits_aligned;
> +    unsigned long acc;
> +    unsigned long j;
> +    uint32_t sign;
> +    uint32_t e;
> +    uint32_t mantissa;
> +
> +    skip_bits_long(gb, 32); //num_bytes_diff_float
> +    use_acf = get_bits1(gb);
> +
> +    if (ra_frame) {

> +        memset(last_acf_mantissa, 0, sizeof(last_acf_mantissa));
> +        memset(last_shift_value,  0, sizeof(last_shift_value) );

the sizeof look a bit strange, these are not the allocated array sizes



[...]
> @@ -1678,6 +1931,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>  {
>      unsigned int c;
>      unsigned int channel_size;
> +    unsigned int i;
>      int num_buffers, ret;
>      ALSDecContext *ctx = avctx->priv_data;
>      ALSSpecificConfig *sconf = &ctx->sconf;
> @@ -1803,6 +2057,34 @@ static av_cold int decode_init(AVCodecContext *avctx)
>      ctx->raw_buffer       = av_mallocz_array(avctx->channels * channel_size, 
> sizeof(*ctx->raw_buffer));
>      ctx->raw_samples      = av_malloc_array(avctx->channels, 
> sizeof(*ctx->raw_samples));
>  
> +    if (sconf->floating) {
> +        ctx->acf               = av_malloc_array(avctx->channels, 
> sizeof(*ctx->acf));
> +        ctx->shift_value       = av_malloc_array(avctx->channels, 
> sizeof(*ctx->shift_value));
> +        ctx->last_shift_value  = av_malloc_array(avctx->channels, 
> sizeof(*ctx->last_shift_value));
> +        ctx->last_acf_mantissa = av_malloc_array(avctx->channels, 
> sizeof(*ctx->last_acf_mantissa));
> +        ctx->raw_mantissa      = av_malloc_array(avctx->channels, 
> sizeof(*ctx->raw_mantissa));
> +
> +        for (c = 0; c < avctx->channels; ++c) {
> +            ctx->raw_mantissa[c] = av_malloc_array(ctx->cur_frame_length, 
> sizeof(**ctx->raw_mantissa));

using ctx->raw_mantissa without prior malloc failure check

thx#

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.

Attachment: signature.asc
Description: Digital signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to