Fixes ticket #6785.
Showing the changes to libswresample (2 of 2 files). Show all
Unified · Split
| @@ -445,14 +445,23 @@ av_cold int swri_rematrix_init(SwrContext *s){ · 444 unmodified lines | |||
| 445 | s->mix_2_1_f = (mix_2_1_func_type*)sum2_double; | 445 | s->mix_2_1_f = (mix_2_1_func_type*)sum2_double; |
| 446 | s->mix_any_f = (mix_any_func_type*)get_mix_any_func_double(s); | 446 | s->mix_any_f = (mix_any_func_type*)get_mix_any_func_double(s); |
| 447 | }else if(s->midbuf.fmt == AV_SAMPLE_FMT_S32P){ | 447 | }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_one = av_mallocz(sizeof(int)); |
| 451 | if (!s->native_one) | 449 | if (!s->native_one) |
| 452 | return AVERROR(ENOMEM); | 450 | return AVERROR(ENOMEM); |
| 453 | // for (i = 0; i < nb_out; i++) | 451 | s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int)); |
| 454 | // for (j = 0; j < nb_in; j++) | 452 | if (!s->native_matrix) { |
| 455 | // ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j]; | 453 | av_freep(&s->native_one); |
| 454 | return AVERROR(ENOMEM); | ||
| 455 | } | ||
| 456 | for (i = 0; i < nb_out; i++) { | ||
| 457 | double rem = 0; | ||
| 458 | |||
| 459 | for (j = 0; j < nb_in; j++) { | ||
| 460 | double target = s->matrix[i][j] * 32768 + rem; | ||
| 461 | ((int*)s->native_matrix)[i * nb_in + j] = lrintf(target); | ||
| 462 | rem += target - ((int*)s->native_matrix)[i * nb_in + j]; | ||
| 463 | } | ||
| 464 | } | ||
| 456 | *((int*)s->native_one) = 32768; | 465 | *((int*)s->native_one) = 32768; |
| 457 | s->mix_1_1_f = (mix_1_1_func_type*)copy_s32; | 466 | s->mix_1_1_f = (mix_1_1_func_type*)copy_s32; |
| 458 | s->mix_2_1_f = (mix_2_1_func_type*)sum2_s32; | 467 | s->mix_2_1_f = (mix_2_1_func_type*)sum2_s32; |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | |||
| 30 | 30 | ||
| 31 | #define LIBSWRESAMPLE_VERSION_MAJOR 3 | 31 | #define LIBSWRESAMPLE_VERSION_MAJOR 3 |
| 32 | #define LIBSWRESAMPLE_VERSION_MINOR 0 | 32 | #define LIBSWRESAMPLE_VERSION_MINOR 0 |
| 33 | #define LIBSWRESAMPLE_VERSION_MICRO 100 | 33 | #define LIBSWRESAMPLE_VERSION_MICRO 101 |
| 34 | 34 | ||
| 35 | #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ | 35 | #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ |
| 36 | LIBSWRESAMPLE_VERSION_MINOR, \ | 36 | LIBSWRESAMPLE_VERSION_MINOR, \ |