Mercurial > audlegacy-plugins
changeset 2873:31d6c44ffef2
most of encoder backends require GINT16_NE;
this is a temporary solution, it works for Icecast,
but breaks FileWriter's WAV output on Big Endian systems;
also, 8-bit data may be handled wrong;
needs to be re-written with libSAD usage
author | Andrew O. Shadoura <bugzilla@tut.by> |
---|---|
date | Wed, 16 Jul 2008 23:09:38 +0300 |
parents | f1b6f1b2cdb3 |
children | 11ef2164d90b |
files | src/filewriter/filewriter.c src/filewriter/filewriter.h src/filewriter/flac.c src/filewriter/mp3.c src/filewriter/vorbis.c src/filewriter/wav.c src/icecast/icecast.c |
diffstat | 7 files changed, 35 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/src/filewriter/filewriter.c Mon Jul 14 03:35:13 2008 +0300 +++ b/src/filewriter/filewriter.c Wed Jul 16 23:09:38 2008 +0300 @@ -276,21 +276,21 @@ gint8 *ptr2 = buffer; for (i = 0; i < length; i++) - *(ptr1++) = *(ptr2++) ^ 128; + *(ptr1++) = *(ptr2++) + 128; } if (input.format == FMT_S16_BE) { gint16 *ptr = buffer; for (i = 0; i < length >> 1; i++, ptr++) - *ptr = GUINT16_SWAP_LE_BE(*ptr); + *ptr = GINT16_FROM_BE(*ptr); } - if (input.format == FMT_S16_NE) + if (input.format == FMT_S16_LE) { gint16 *ptr = buffer; for (i = 0; i < length >> 1; i++, ptr++) - *ptr = GINT16_TO_LE(*ptr); + *ptr = GINT16_FROM_LE(*ptr); } if (input.format == FMT_U16_BE) { @@ -298,7 +298,7 @@ guint16 *ptr2 = buffer; for (i = 0; i < length >> 1; i++, ptr2++) - *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_BE(*ptr2) ^ 32768); + *(ptr1++) = GUINT16_FROM_BE(*ptr2) - 32768; } if (input.format == FMT_U16_LE) { @@ -306,7 +306,7 @@ guint16 *ptr2 = buffer; for (i = 0; i < length >> 1; i++, ptr2++) - *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_LE(*ptr2) ^ 32768); + *(ptr1++) = GUINT16_FROM_LE(*ptr2) - 32768; } if (input.format == FMT_U16_NE) { @@ -314,18 +314,20 @@ guint16 *ptr2 = buffer; for (i = 0; i < length >> 1; i++, ptr2++) - *(ptr1++) = GINT16_TO_LE((*ptr2) ^ 32768); + *(ptr1++) = (*ptr2) - 32768; } } static void file_write(void *ptr, gint length) { - if (input.format == FMT_S8 || input.format == FMT_S16_BE || - input.format == FMT_U16_LE || input.format == FMT_U16_BE || - input.format == FMT_U16_NE) + if (input.format == FMT_S8 || input.format == FMT_U16_NE || + input.format == FMT_U16_LE || input.format == FMT_U16_BE) convert_buffer(ptr, length); #ifdef WORDS_BIGENDIAN - if (input.format == FMT_S16_NE) + if (input.format == FMT_S16_LE) + convert_buffer(ptr, length); +#else + if (input.format == FMT_S16_BE) convert_buffer(ptr, length); #endif
--- a/src/filewriter/filewriter.h Mon Jul 14 03:35:13 2008 +0300 +++ b/src/filewriter/filewriter.h Wed Jul 16 23:09:38 2008 +0300 @@ -65,6 +65,7 @@ gint (*free)(void); gint (*playing)(void); gint (*get_written_time)(void); + AFormat format_required; }; #endif
--- a/src/filewriter/flac.c Mon Jul 14 03:35:13 2008 +0300 +++ b/src/filewriter/flac.c Wed Jul 16 23:09:38 2008 +0300 @@ -44,7 +44,8 @@ flac_close, flac_free, flac_playing, - flac_get_written_time + flac_get_written_time, + FMT_S16_NE }; static FLAC__StreamEncoder *flac_encoder;
--- a/src/filewriter/mp3.c Mon Jul 14 03:35:13 2008 +0300 +++ b/src/filewriter/mp3.c Wed Jul 16 23:09:38 2008 +0300 @@ -50,7 +50,8 @@ mp3_close, mp3_free, mp3_playing, - mp3_get_written_time + mp3_get_written_time, + FMT_S16_NE }; static GtkWidget *configure_win = NULL;
--- a/src/filewriter/vorbis.c Mon Jul 14 03:35:13 2008 +0300 +++ b/src/filewriter/vorbis.c Wed Jul 16 23:09:38 2008 +0300 @@ -47,7 +47,8 @@ vorbis_close, vorbis_free, vorbis_playing, - vorbis_get_written_time + vorbis_get_written_time, + FMT_S16_NE }; static float v_base_quality = 0.5;
--- a/src/filewriter/wav.c Mon Jul 14 03:35:13 2008 +0300 +++ b/src/filewriter/wav.c Wed Jul 16 23:09:38 2008 +0300 @@ -40,7 +40,8 @@ wav_close, wav_free, wav_playing, - wav_get_written_time + wav_get_written_time, + FMT_S16_LE };
--- a/src/icecast/icecast.c Mon Jul 14 03:35:13 2008 +0300 +++ b/src/icecast/icecast.c Wed Jul 16 23:09:38 2008 +0300 @@ -341,21 +341,21 @@ gint8 *ptr2 = buffer; for (i = 0; i < length; i++) - *(ptr1++) = *(ptr2++) ^ 128; + *(ptr1++) = *(ptr2++) + 128; } if (input.format == FMT_S16_BE) { gint16 *ptr = buffer; for (i = 0; i < length >> 1; i++, ptr++) - *ptr = GUINT16_SWAP_LE_BE(*ptr); + *ptr = GINT16_FROM_BE(*ptr); } - if (input.format == FMT_S16_NE) + if (input.format == FMT_S16_LE) { gint16 *ptr = buffer; for (i = 0; i < length >> 1; i++, ptr++) - *ptr = GINT16_TO_LE(*ptr); + *ptr = GINT16_FROM_LE(*ptr); } if (input.format == FMT_U16_BE) { @@ -363,7 +363,7 @@ guint16 *ptr2 = buffer; for (i = 0; i < length >> 1; i++, ptr2++) - *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_BE(*ptr2) ^ 32768); + *(ptr1++) = GUINT16_FROM_BE(*ptr2) - 32768; } if (input.format == FMT_U16_LE) { @@ -371,7 +371,7 @@ guint16 *ptr2 = buffer; for (i = 0; i < length >> 1; i++, ptr2++) - *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_LE(*ptr2) ^ 32768); + *(ptr1++) = GUINT16_FROM_LE(*ptr2) - 32768; } if (input.format == FMT_U16_NE) { @@ -379,18 +379,20 @@ guint16 *ptr2 = buffer; for (i = 0; i < length >> 1; i++, ptr2++) - *(ptr1++) = GINT16_TO_LE((*ptr2) ^ 32768); + *(ptr1++) = (*ptr2) - 32768; } } static void ice_write(void *ptr, gint length) { - if (input.format == FMT_S8 || input.format == FMT_S16_BE || - input.format == FMT_U16_LE || input.format == FMT_U16_BE || - input.format == FMT_U16_NE) + if (input.format == FMT_S8 || input.format == FMT_U16_NE || + input.format == FMT_U16_LE || input.format == FMT_U16_BE) convert_buffer(ptr, length); #ifdef WORDS_BIGENDIAN - if (input.format == FMT_S16_NE) + if (input.format == FMT_S16_LE) + convert_buffer(ptr, length); +#else + if (input.format == FMT_S16_BE) convert_buffer(ptr, length); #endif