summaryrefslogtreecommitdiff
path: root/src/demuxers
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2008-04-07 17:54:25 +0100
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2008-04-07 17:54:25 +0100
commit3cd18fa8a66318366936c50d54e65a8703a66ebd (patch)
treecc184b7bafd7dee79a1247192190101f83f57876 /src/demuxers
parent3e12aeb9041aaddefad0782921033abbabd9e518 (diff)
downloadxine-lib-3cd18fa8a66318366936c50d54e65a8703a66ebd.tar.gz
xine-lib-3cd18fa8a66318366936c50d54e65a8703a66ebd.tar.bz2
Move the sipro codec swap data & code into a common header.
Diffstat (limited to 'src/demuxers')
-rw-r--r--src/demuxers/Makefile.am2
-rw-r--r--src/demuxers/demux_real.c35
-rw-r--r--src/demuxers/demux_realaudio.c31
-rw-r--r--src/demuxers/real_common.h56
4 files changed, 64 insertions, 60 deletions
diff --git a/src/demuxers/Makefile.am b/src/demuxers/Makefile.am
index ffbfa0a8d..2c4b38e4a 100644
--- a/src/demuxers/Makefile.am
+++ b/src/demuxers/Makefile.am
@@ -141,4 +141,4 @@ xineplug_dmx_flv_la_SOURCES = demux_flv.c
xineplug_dmx_flv_la_LIBADD = $(XINE_LIB) $(LTLIBINTL)
xineinclude_HEADERS = demux.h
-noinst_HEADERS = asfheader.h qtpalette.h group_games.h group_audio.h id3.h ebml.h matroska.h iff.h flacutils.h
+noinst_HEADERS = asfheader.h qtpalette.h group_games.h group_audio.h id3.h ebml.h matroska.h iff.h flacutils.h real_common.h
diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c
index f0724a992..cb67c36fa 100644
--- a/src/demuxers/demux_real.c
+++ b/src/demuxers/demux_real.c
@@ -55,6 +55,8 @@
#include "demux.h"
#include "bswap.h"
+#include "real_common.h"
+
#define FOURCC_TAG BE_FOURCC
#define RMF_TAG FOURCC_TAG('.', 'R', 'M', 'F')
#define PROP_TAG FOURCC_TAG('P', 'R', 'O', 'P')
@@ -174,13 +176,6 @@ typedef struct {
demux_class_t demux_class;
} demux_real_class_t;
-static const unsigned char sipr_swaps[38][2] = {
- {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},
- {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46},
- {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56},
- {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83},
- {77,80}};
-
static void real_parse_index(demux_real_t *this) {
off_t next_index_chunk = this->index_start;
@@ -1453,30 +1448,8 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
this->status = DEMUX_FINISHED;
return this->status;
}
- if (spc == sph - 1) {
- int n;
- int bs = sph * w * 2 / 96; /* nibbles per subpacket */
- /* Perform reordering */
- for(n=0; n < 38; n++) {
- int j;
- int i = bs * sipr_swaps[n][0];
- int o = bs * sipr_swaps[n][1];
- /* swap nibbles of block 'i' with 'o' TODO: optimize */
- for(j = 0;j < bs; j++) {
- int x = (i & 1) ? (buffer[i >> 1] >> 4) : (buffer[i >> 1] & 0x0F);
- int y = (o & 1) ? (buffer[o >> 1] >> 4) : (buffer[o >> 1] & 0x0F);
- if(o & 1)
- buffer[o >> 1] = (buffer[o >> 1] & 0x0F) | (x << 4);
- else
- buffer[o >> 1] = (buffer[o >> 1] & 0xF0) | x;
- if(i & 1)
- buffer[i >> 1] = (buffer[i >> 1] & 0x0F) | (y << 4);
- else
- buffer[i >> 1] = (buffer[i >> 1] & 0xF0) | y;
- ++i; ++o;
- }
- }
- }
+ if (spc == sph - 1)
+ demux_real_sipro_swap (buffer, sph * w * 2 / 96);
break;
}
if(++this->audio_stream->sub_packet_cnt == sph) {
diff --git a/src/demuxers/demux_realaudio.c b/src/demuxers/demux_realaudio.c
index 2075f1b6f..5bdf13d89 100644
--- a/src/demuxers/demux_realaudio.c
+++ b/src/demuxers/demux_realaudio.c
@@ -41,6 +41,8 @@
#include "bswap.h"
#include "group_audio.h"
+#include "real_common.h"
+
#define RA_FILE_HEADER_PREV_SIZE 22
typedef struct {
@@ -74,13 +76,6 @@ typedef struct {
demux_class_t demux_class;
} demux_ra_class_t;
-static const unsigned char sipr_swaps[38][2]={
- {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},
- {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46},
- {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56},
- {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83},
- {77,80}};
-
/* Map flavour to bytes per second */
static int sipr_fl2bps[4] = {813, 1062, 625, 2000}; // 6.5, 8.5, 5, 16 kbit per second
@@ -255,7 +250,6 @@ static int demux_ra_send_chunk(demux_plugin_t *this_gen) {
if (this->audio_type == BUF_AUDIO_SIPRO) {
int n;
int len = this->h * this->w;
- int bs = len * 2 / 96; /* nibbles per subpacket */
if(this->input->read(this->input, this->frame_buffer, len) < len) {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
"demux_realaudio: failed to read audio chunk\n");
@@ -263,26 +257,7 @@ static int demux_ra_send_chunk(demux_plugin_t *this_gen) {
this->status = DEMUX_FINISHED;
return this->status;
}
- /* Perform reordering */
- for(n = 0; n < 38; n++) {
- int j;
- int i = bs * sipr_swaps[n][0];
- int o = bs * sipr_swaps[n][1];
- /* swap nibbles of block 'i' with 'o' TODO: optimize */
- for(j = 0; j < bs; j++) {
- int x = (i & 1) ? (this->frame_buffer[i >> 1] >> 4) : (this->frame_buffer[i >> 1] & 0x0F);
- int y = (o & 1) ? (this->frame_buffer[o >> 1] >> 4) : (this->frame_buffer[o >> 1] & 0x0F);
- if(o & 1)
- this->frame_buffer[o >> 1] = (this->frame_buffer[o >> 1] & 0x0F) | (x << 4);
- else
- this->frame_buffer[o >> 1] = (this->frame_buffer[o >> 1] & 0xF0) | x;
- if(i & 1)
- this->frame_buffer[i >> 1] = (this->frame_buffer[i >> 1] & 0x0F) | (y << 4);
- else
- this->frame_buffer[i >> 1] = (this->frame_buffer[i >> 1] & 0xF0) | y;
- ++i; ++o;
- }
- }
+ demux_real_sipro_swap (this->frame_buffer, len * 2 / 96);
} else {
int x, y;
int pos;
diff --git a/src/demuxers/real_common.h b/src/demuxers/real_common.h
new file mode 100644
index 000000000..4945a65ff
--- /dev/null
+++ b/src/demuxers/real_common.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2008 the xine project
+ *
+ * This file is part of xine, a free video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+static inline void demux_real_sipro_swap (char buffer[], int bs)
+{
+ /* bs = nybbles per subpacket */
+ static const unsigned char sipr_swaps[38][2] = {
+ {0, 63}, {1, 22}, {2, 44}, {3, 90}, {5, 81}, {7, 31}, {8, 86}, {9, 58},
+ {10, 36}, {12, 68}, {13, 39}, {14, 73}, {15, 53}, {16, 69}, {17, 57},
+ {19, 88}, {20, 34}, {21, 71}, {24, 46}, {25, 94}, {26, 54}, {28, 75},
+ {29, 50}, {32, 70}, {33, 92}, {35, 74}, {38, 85}, {40, 56}, {42, 87},
+ {43, 65}, {45, 59}, {48, 79}, {49, 93}, {51, 89}, {55, 95}, {61, 76},
+ {67, 83}, {77, 80}
+ };
+ int n;
+
+ for (n = 0; n < 38; ++n)
+ {
+ int j;
+ int i = bs * sipr_swaps[n][0];
+ int o = bs * sipr_swaps[n][1];
+ /* swap nibbles of block 'i' with 'o' TODO: optimize */
+ for (j = 0; j < bs; ++j)
+ {
+ int x = (i & 1) ? (buffer[i >> 1] >> 4) : (buffer[i >> 1] & 0x0F);
+ int y = (o & 1) ? (buffer[o >> 1] >> 4) : (buffer[o >> 1] & 0x0F);
+ if (o & 1)
+ buffer[o >> 1] = (buffer[o >> 1] & 0x0F) | (x << 4);
+ else
+ buffer[o >> 1] = (buffer[o >> 1] & 0xF0) | x;
+ if (i & 1)
+ buffer[i >> 1] = (buffer[i >> 1] & 0x0F) | (y << 4);
+ else
+ buffer[i >> 1] = (buffer[i >> 1] & 0xF0) | y;
+ ++i;
+ ++o;
+ }
+ }
+}