[k3b] [Bug 386105] K3b FFmpeg decode plugin seems to be broken, produces noise

bugzilla_noreply at kde.org bugzilla_noreply at kde.org
Sat Mar 31 06:59:34 UTC 2018


https://bugs.kde.org/show_bug.cgi?id=386105

--- Comment #11 from blaze at vivaldi.net ---
So here's my code which converts float audio to 16bit (for WMA and AAC):

>        for(int sample=0; sample<nb_s; sample++) {
>            for(int ch=0; ch<nb_ch; ch++) {
>                float smpl = *(reinterpret_cast<float*>(
>                    d->frame->extended_data[ch] + sample*4)) * 32767.0;
>                smpl = smpl > 32767.0 ? 32767.0 : smpl;
>                smpl = smpl < -32767.0 ? -32767.0 : smpl;
>                int16_t smpl2 = (((int16_t)(smpl + 32768.5)) - 32768);
>                ::memcpy(d->outputBufferPos + (sample * nb_ch + ch) * 2,
>                         &smpl2,
>                         2);
>            }
>        }

It works nicely: no noise or clipping. Made it just out of curiosity. But it's
better to use libswresample. When it's done right it will cover all possible
cases for the input audio. I'll get to that later. Stay tuned for patches.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the k3b mailing list