Ticket #6785: patchs32p.diff

File patchs32p.diff, 1.4 KB (added by Carl Eugen Hoyos, 9 years ago)
  • libswresample/rematrix.c

    diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
    index 66a43c1..03152c1 100644
    a b av_cold int swri_rematrix_init(SwrContext *s){  
    445445        s->mix_2_1_f = (mix_2_1_func_type*)sum2_double;
    446446        s->mix_any_f = (mix_any_func_type*)get_mix_any_func_double(s);
    447447    }else if(s->midbuf.fmt == AV_SAMPLE_FMT_S32P){
    448         // Only for dithering currently
    449 //         s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double));
    450         s->native_one    = av_mallocz(sizeof(int));
     448        s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int64_t));
     449        s->native_one    = av_mallocz(sizeof(int64_t));
    451450        if (!s->native_one)
    452451            return AVERROR(ENOMEM);
    453 //         for (i = 0; i < nb_out; i++)
    454 //             for (j = 0; j < nb_in; j++)
    455 //                 ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];
     452        for (i = 0; i < nb_out; i++) {
     453            double rem = 0;
     454
     455            for (j = 0; j < nb_in; j++) {
     456                double target = s->matrix[i][j] * 32768 + rem;
     457                ((int64_t*)s->native_matrix)[i * nb_in + j] = lrintf(target);
     458                rem += target - ((int64_t*)s->native_matrix)[i * nb_in + j];
     459            }
     460        }
    456461        *((int*)s->native_one) = 32768;
    457462        s->mix_1_1_f = (mix_1_1_func_type*)copy_s32;
    458463        s->mix_2_1_f = (mix_2_1_func_type*)sum2_s32;