summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Martin <christopher.martin@utoronto.ca>2010-02-21 09:43:00 -0500
committerChristopher Martin <christopher.martin@utoronto.ca>2010-02-21 09:43:00 -0500
commit4e697948c4646cf4a5a2fd06490db034b1ae076c (patch)
treed9cbbfa374dd225d83a135ade6ab120e1e9e222f
parentbc733336301ce98879f894600143ddcebcb9fe55 (diff)
downloadxine-lib-4e697948c4646cf4a5a2fd06490db034b1ae076c.tar.gz
xine-lib-4e697948c4646cf4a5a2fd06490db034b1ae076c.tar.bz2
WMAPro support
Rename "wmav3" to "wmapro" in xine-lib's internals to line up xine-lib's nomenclature with what everyone else calls it and knows it as. [Tweaked by ds to avoid API change.] Tell xine-lib that when it finds wmapro, look to ffmpeg. ffmpeg's wmapro decoder is unique in that it puts out samples that are floats, not 16-bit ints. These need to be converted. This requires external ffmpeg.
-rw-r--r--configure.ac4
-rw-r--r--src/combined/ffmpeg/ff_audio_decoder.c43
-rw-r--r--src/combined/ffmpeg/ffmpeg_decoder.c1
-rw-r--r--src/combined/ffmpeg/xine_audio.list1
-rw-r--r--src/libw32dll/w32codec.c6
-rw-r--r--src/xine-engine/buffer.h3
-rw-r--r--src/xine-engine/buffer_types.c4
7 files changed, 42 insertions, 20 deletions
diff --git a/configure.ac b/configure.ac
index 75de5e405..d41b0442c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -411,7 +411,7 @@ for ucname in $ffmpeg_uncommon_codecs; do
done
dnl popular ffmpeg codecs
-ffmpeg_popular_codecs="CINEPAK FLASHSV H261 H263 H263I H264 INDEO2 INDEO3 MJPEG MJPEGB MPEG1VIDEO MPEG2VIDEO MPEG4 MPEGVIDEO MSMPEG4V1 MSMPEG4V2 MSMPEG4V3 MSRLE MSVIDEO1 QTRLE RV10 RV20 SVQ1 SVQ3 VC1 VP3 VP5 VP6 VP6F WMV1 WMV2 WMV3 COOK DTS FLAC MP2 MP3 QDM2 RA_144 RA_288 WAVPACK WMAV1 WMAV2 ADPCM_SWF"
+ffmpeg_popular_codecs="CINEPAK FLASHSV H261 H263 H263I H264 INDEO2 INDEO3 MJPEG MJPEGB MPEG1VIDEO MPEG2VIDEO MPEG4 MPEGVIDEO MSMPEG4V1 MSMPEG4V2 MSMPEG4V3 MSRLE MSVIDEO1 QTRLE RV10 RV20 SVQ1 SVQ3 VC1 VP3 VP5 VP6 VP6F WMV1 WMV2 WMV3 COOK DTS FLAC MP2 MP3 QDM2 RA_144 RA_288 WAVPACK WMAV1 WMAV2 WMAPRO ADPCM_SWF"
for ucname in $ffmpeg_popular_codecs; do
config_name="CONFIG_${ucname}_DECODER"
@@ -3007,7 +3007,7 @@ if test "x$with_external_ffmpeg" = "xyes"; then
else
echo " - ffmpeg (internal library):"
fi
-echo " - Windows Media Audio v1/v2"
+echo " - Windows Media Audio v1/v2/Pro"
echo " - DV - logarithmic PCM"
echo " - 14k4 - 28k8"
echo " - MS ADPCM - IMA ADPCM"
diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c
index bd3ada69d..26e1ac168 100644
--- a/src/combined/ffmpeg/ff_audio_decoder.c
+++ b/src/combined/ffmpeg/ff_audio_decoder.c
@@ -94,6 +94,7 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
int out;
audio_buffer_t *audio_buffer;
int bytes_to_send;
+ unsigned int codec_type = buf->type & 0xFFFF0000;
if ( (buf->decoder_flags & BUF_FLAG_HEADER) &&
!(buf->decoder_flags & BUF_FLAG_SPECIAL) ) {
@@ -105,10 +106,8 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
size_t i;
- unsigned int codec_type;
xine_waveformatex *audio_header;
- codec_type = buf->type & 0xFFFF0000;
this->codec = NULL;
for(i = 0; i < sizeof(ff_audio_lookup)/sizeof(ff_codec_t); i++)
@@ -228,7 +227,7 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
}
}
- /* Current ffmpeg audio decoders always use 16 bits/sample
+ /* Current ffmpeg audio decoders usually use 16 bits/sample
* buf->decoder_info[2] can't be used as it doesn't refer to the output
* bits/sample for some codecs (e.g. MS ADPCM) */
this->audio_bits = 16;
@@ -346,14 +345,36 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
return;
}
- if ((decode_buffer_size - out) > audio_buffer->mem_size)
- bytes_to_send = audio_buffer->mem_size;
- else
- bytes_to_send = decode_buffer_size - out;
-
/* fill up this buffer */
- xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[out],
- bytes_to_send);
+ if (codec_type == BUF_AUDIO_WMAPRO) {
+ /* the above codecs output float samples, not 16-bit integers */
+ int bytes_per_sample = sizeof(float);
+ if (((decode_buffer_size - out) * 2 / bytes_per_sample) > audio_buffer->mem_size)
+ bytes_to_send = audio_buffer->mem_size * bytes_per_sample / 2;
+ else
+ bytes_to_send = decode_buffer_size - out;
+
+ int16_t *int_buffer = calloc(1, bytes_to_send * 2 / bytes_per_sample);
+ int i;
+ for (i = 0; i < (bytes_to_send / bytes_per_sample); i++) {
+ float *float_sample = (float *)&this->decode_buffer[i * bytes_per_sample + out];
+ int_buffer[i] = (int16_t)lrintf(*float_sample * 32768.);
+ }
+
+ out += bytes_to_send;
+ bytes_to_send = bytes_to_send * 2 / bytes_per_sample;
+ xine_fast_memcpy(audio_buffer->mem, int_buffer, bytes_to_send);
+ free(int_buffer);
+ } else {
+ if ((decode_buffer_size - out) > audio_buffer->mem_size)
+ bytes_to_send = audio_buffer->mem_size;
+ else
+ bytes_to_send = decode_buffer_size - out;
+
+ xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[out], bytes_to_send);
+ out += bytes_to_send;
+ }
+
/* byte count / 2 (bytes / sample) / channels */
audio_buffer->num_frames = bytes_to_send / 2 / this->audio_channels;
@@ -361,8 +382,6 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
buf->pts = 0; /* only first buffer gets the real pts */
this->stream->audio_out->put_buffer (this->stream->audio_out,
audio_buffer, this->stream);
-
- out += bytes_to_send;
}
this->size -= bytes_consumed;
diff --git a/src/combined/ffmpeg/ffmpeg_decoder.c b/src/combined/ffmpeg/ffmpeg_decoder.c
index 6d0bfa432..adf0dad78 100644
--- a/src/combined/ffmpeg/ffmpeg_decoder.c
+++ b/src/combined/ffmpeg/ffmpeg_decoder.c
@@ -228,6 +228,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(WAVPACK, wavpack);
REGISTER_DECODER(WMAV1, wmav1);
REGISTER_DECODER(WMAV2, wmav2);
+ REGISTER_DECODER(WMAPRO, wmapro);
REGISTER_DECODER(WS_SND1, ws_snd1);
/* pcm codecs */
diff --git a/src/combined/ffmpeg/xine_audio.list b/src/combined/ffmpeg/xine_audio.list
index 4b6932474..9ec727bf1 100644
--- a/src/combined/ffmpeg/xine_audio.list
+++ b/src/combined/ffmpeg/xine_audio.list
@@ -6,6 +6,7 @@ config=MP3ADU=
WMAV1 WMAV1 MS Windows Media Audio 1
WMAV2 WMAV2 MS Windows Media Audio 2
+WMAPRO WMAPRO MS Windows Media Audio Professional
14_4 RA_144 Real 14.4
28_8 RA_288 Real 28.8
MPEG MP3 MP3
diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c
index 32cd7db29..715b10ff4 100644
--- a/src/libw32dll/w32codec.c
+++ b/src/libw32dll/w32codec.c
@@ -1086,11 +1086,11 @@ static char* get_auds_codec_name(w32a_decoder_t *this, int buf_type) {
_x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC,
"Windows Media Audio v2 (win32)");
return "divxa32.acm";
- case BUF_AUDIO_WMAV3:
+ case BUF_AUDIO_WMAPRO:
this->driver_type = DRIVER_DMO;
this->guid=&wma3_clsid;
_x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC,
- "Windows Media Audio v3 (win32)");
+ "Windows Media Audio Professional (win32)");
return "wma9dmod.dll";
case BUF_AUDIO_WMALL:
this->driver_type = DRIVER_DMO;
@@ -1693,7 +1693,7 @@ static const decoder_info_t dec_info_video = {
};
static uint32_t audio_types[] = {
- BUF_AUDIO_WMAV1, BUF_AUDIO_WMAV2, BUF_AUDIO_WMAV3, BUF_AUDIO_MSADPCM,
+ BUF_AUDIO_WMAV1, BUF_AUDIO_WMAV2, BUF_AUDIO_WMAPRO, BUF_AUDIO_MSADPCM,
BUF_AUDIO_MSIMAADPCM, BUF_AUDIO_MSGSM, BUF_AUDIO_IMC, BUF_AUDIO_LH,
BUF_AUDIO_VOXWARE, BUF_AUDIO_ACELPNET, BUF_AUDIO_VIVOG723, BUF_AUDIO_WMAV,
BUF_AUDIO_WMALL,
diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h
index 42302b30f..3b25c732e 100644
--- a/src/xine-engine/buffer.h
+++ b/src/xine-engine/buffer.h
@@ -232,7 +232,8 @@ extern "C" {
#define BUF_AUDIO_14_4 0x03230000
#define BUF_AUDIO_28_8 0x03240000
#define BUF_AUDIO_SIPRO 0x03250000
-#define BUF_AUDIO_WMAV3 0x03260000
+#define BUF_AUDIO_WMAPRO 0x03260000
+#define BUF_AUDIO_WMAV3 BUF_AUDIO_WMAPRO
#define BUF_AUDIO_INTERPLAY 0x03270000
#define BUF_AUDIO_XA_ADPCM 0x03280000
#define BUF_AUDIO_WESTWOOD 0x03290000
diff --git a/src/xine-engine/buffer_types.c b/src/xine-engine/buffer_types.c
index 51e688f7e..33a09b907 100644
--- a/src/xine-engine/buffer_types.c
+++ b/src/xine-engine/buffer_types.c
@@ -859,8 +859,8 @@ static const audio_db_t audio_db[] = {
{
0x162, 0
},
- BUF_AUDIO_WMAV3,
- "Windows Media Audio v3"
+ BUF_AUDIO_WMAPRO,
+ "Windows Media Audio Professional"
},
{
{