[Libav-user] Filtering audio example : filtering_audio.c - Why do we use uint16_t

Matthieu Corbeau matthieu.corbeau at gmail.com
Wed Dec 3 12:58:48 CET 2014

Hi all,

I am reading a lot this example lately and I have a question that I cannot
quite answer myself. Here is the deal (
in print_frame there is a cast to uint16_t:

const uint16_t *p = (uint16_t*)frame->data

however the filtering description is set with s16:

static const char *filter_descr
= "aresample=8000,aformat=sample_fmts=s16:channel_layouts=mono";
Now I tried to change the cast to int16_t instead of uint16_t and I have no
audible change in the filtered stream when played back by ffplay (ffplay -f
s16le -ar 8000 -ac 1 -).

My question is, when casting signed to unsigned, is there any possibility
that the signal gets modified due to the 2-complementation (or are the
samples always positive somehow) ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141203/79dfa6fc/attachment.html>

More information about the Libav-user mailing list