mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 00:21:43 +00:00
- Fixed: OggMod passes the raw sample data to OggEnc for stereo samples, so
the resultant Vorbis stream is not actually stereo but mono with the right channel after the left. The two need to be interleaved just like uncompressed samples are. - Removed the pattern length limit in the XM reader. SVN r1326 (trunk)
This commit is contained in:
parent
835ed26370
commit
97de7897de
2 changed files with 51 additions and 19 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
December 19, 2008
|
||||||
|
- Fixed: OggMod passes the raw sample data to OggEnc for stereo samples, so
|
||||||
|
the resultant Vorbis stream is not actually stereo but mono with the right
|
||||||
|
channel after the left. The two need to be interleaved just like
|
||||||
|
uncompressed samples are.
|
||||||
|
- Removed the pattern length limit in the XM reader.
|
||||||
|
|
||||||
December 18, 2008
|
December 18, 2008
|
||||||
- Decal changes as per Xaser's suggestions: Smaller decal for PhoenixFX2,
|
- Decal changes as per Xaser's suggestions: Smaller decal for PhoenixFX2,
|
||||||
CrossbowFX2 and MaceFX4 were missing decals, and HornRodFX2 gets a whole
|
CrossbowFX2 and MaceFX4 were missing decals, and HornRodFX2 gets a whole
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define MAX_COLUMN_MEMORY (1024*5)
|
|
||||||
|
|
||||||
extern short *DUMBCALLBACK dumb_decode_vorbis(int outlen, const void *oggstream, int sizebytes);
|
extern short *DUMBCALLBACK dumb_decode_vorbis(int outlen, const void *oggstream, int sizebytes);
|
||||||
|
|
||||||
/** TODO:
|
/** TODO:
|
||||||
|
@ -178,7 +176,7 @@ static void it_xm_convert_volume(int volume, IT_ENTRY *entry)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int it_xm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels, unsigned char *buffer, int version)
|
static int it_xm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels, unsigned char **bufferptr, int *buffersize, int version)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
int pos;
|
int pos;
|
||||||
|
@ -186,6 +184,7 @@ static int it_xm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels,
|
||||||
int row;
|
int row;
|
||||||
int effect, effectvalue;
|
int effect, effectvalue;
|
||||||
IT_ENTRY *entry;
|
IT_ENTRY *entry;
|
||||||
|
unsigned char *buffer;
|
||||||
|
|
||||||
/* pattern header size */
|
/* pattern header size */
|
||||||
if (dumbfile_igetl(f) != ( version == 0x0102 ? 0x08 : 0x09 ) ) {
|
if (dumbfile_igetl(f) != ( version == 0x0102 ? 0x08 : 0x09 ) ) {
|
||||||
|
@ -212,8 +211,16 @@ static int it_xm_read_pattern(IT_PATTERN *pattern, DUMBFILE *f, int n_channels,
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (size > MAX_COLUMN_MEMORY * n_channels) {
|
if (size > *buffersize) {
|
||||||
TRACE("XM error: pattern data size > %d bytes\n", MAX_COLUMN_MEMORY * n_channels);
|
if (*bufferptr != NULL) {
|
||||||
|
free(*bufferptr);
|
||||||
|
}
|
||||||
|
*bufferptr = malloc(size);
|
||||||
|
*buffersize = size;
|
||||||
|
}
|
||||||
|
buffer = *bufferptr;
|
||||||
|
if (buffer == NULL) {
|
||||||
|
TRACE("XM error: out of memory reading pattern\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,6 +620,7 @@ static int it_xm_read_sample_data(IT_SAMPLE *sample, unsigned char roguebytes, D
|
||||||
int32 i;
|
int32 i;
|
||||||
int n_channels;
|
int n_channels;
|
||||||
int32 datasizebytes;
|
int32 datasizebytes;
|
||||||
|
void *ibuffer;
|
||||||
|
|
||||||
if (!(sample->flags & IT_SAMPLE_EXISTS))
|
if (!(sample->flags & IT_SAMPLE_EXISTS))
|
||||||
return dumbfile_skip(f, roguebytes);
|
return dumbfile_skip(f, roguebytes);
|
||||||
|
@ -648,6 +656,7 @@ static int it_xm_read_sample_data(IT_SAMPLE *sample, unsigned char roguebytes, D
|
||||||
|
|
||||||
if (!(sample->flags & IT_SAMPLE_16BIT))
|
if (!(sample->flags & IT_SAMPLE_16BIT))
|
||||||
{
|
{
|
||||||
|
/* Because it'll be 16-bit when we're done with it. */
|
||||||
outlen <<= 1;
|
outlen <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,7 +672,30 @@ static int it_xm_read_sample_data(IT_SAMPLE *sample, unsigned char roguebytes, D
|
||||||
sample->loop_start <<= 1;
|
sample->loop_start <<= 1;
|
||||||
sample->loop_end <<= 1;
|
sample->loop_end <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
it_xm_fixup_sample_points(sample);
|
it_xm_fixup_sample_points(sample);
|
||||||
|
/* Stereo samples are still passed to OggEnc as mono sounds, just like
|
||||||
|
* uncompressed samples, so we need to interleave them now. */
|
||||||
|
ibuffer = malloc(sample->length << 2);
|
||||||
|
if (ibuffer == NULL)
|
||||||
|
{
|
||||||
|
/* No memory => ignore stereo bits at the end */
|
||||||
|
sample->flags &= ~IT_SAMPLE_STEREO;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < sample->length; ++i)
|
||||||
|
{
|
||||||
|
((short *)ibuffer)[i*2] = ((short *)sample->data)[i];
|
||||||
|
((short *)ibuffer)[i*2+1] = ((short *)sample->data)[i + sample->length];
|
||||||
|
}
|
||||||
|
for (i = 0; i < sample->length; ++i)
|
||||||
|
{
|
||||||
|
((short *)ibuffer)[i*2+1] -= ((short *)ibuffer)[sample->length*2 - 1];
|
||||||
|
}
|
||||||
|
free(sample->data);
|
||||||
|
sample->data = ibuffer;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Decode failed, so assume it's normal sample data that just so
|
/* Decode failed, so assume it's normal sample data that just so
|
||||||
|
@ -680,8 +712,8 @@ static int it_xm_read_sample_data(IT_SAMPLE *sample, unsigned char roguebytes, D
|
||||||
/* Stereo samples are a ModPlug extension, so to keep compatibility with
|
/* Stereo samples are a ModPlug extension, so to keep compatibility with
|
||||||
* players that don't know about it (and FastTracker 2 itself), the two
|
* players that don't know about it (and FastTracker 2 itself), the two
|
||||||
* channels are not stored interleaved but rather, one after the other. */
|
* channels are not stored interleaved but rather, one after the other. */
|
||||||
void *ibuffer = malloc(sample->length << ((sample->flags & IT_SAMPLE_16BIT) ? 2 : 1));
|
|
||||||
int old_r = 0;
|
int old_r = 0;
|
||||||
|
ibuffer = malloc(sample->length << ((sample->flags & IT_SAMPLE_16BIT) ? 2 : 1));
|
||||||
if (ibuffer == NULL)
|
if (ibuffer == NULL)
|
||||||
{
|
{
|
||||||
/* No memory => ignore stereo bits at the end */
|
/* No memory => ignore stereo bits at the end */
|
||||||
|
@ -859,13 +891,10 @@ static DUMB_IT_SIGDATA *it_xm_load_sigdata(DUMBFILE *f, int * version)
|
||||||
sigdata->pattern[i].entry = NULL;
|
sigdata->pattern[i].entry = NULL;
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned char *buffer = malloc(MAX_COLUMN_MEMORY * n_channels); /* 256 rows * 5 bytes */
|
unsigned char *buffer = NULL;
|
||||||
if (!buffer) {
|
int buffersize = 0;
|
||||||
_dumb_it_unload_sigdata(sigdata);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
for (i = 0; i < sigdata->n_patterns; i++) {
|
for (i = 0; i < sigdata->n_patterns; i++) {
|
||||||
if (it_xm_read_pattern(&sigdata->pattern[i], f, n_channels, buffer, * version) != 0) {
|
if (it_xm_read_pattern(&sigdata->pattern[i], f, n_channels, &buffer, &buffersize, * version) != 0) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
_dumb_it_unload_sigdata(sigdata);
|
_dumb_it_unload_sigdata(sigdata);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1054,14 +1083,10 @@ static DUMB_IT_SIGDATA *it_xm_load_sigdata(DUMBFILE *f, int * version)
|
||||||
sigdata->pattern[i].entry = NULL;
|
sigdata->pattern[i].entry = NULL;
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned char *buffer = malloc(MAX_COLUMN_MEMORY * n_channels); /* 256 rows * 5 bytes */
|
unsigned char *buffer = NULL;
|
||||||
if (!buffer) {
|
int buffersize = 0;
|
||||||
free(roguebytes);
|
|
||||||
_dumb_it_unload_sigdata(sigdata);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
for (i = 0; i < sigdata->n_patterns; i++) {
|
for (i = 0; i < sigdata->n_patterns; i++) {
|
||||||
if (it_xm_read_pattern(&sigdata->pattern[i], f, n_channels, buffer, * version) != 0) {
|
if (it_xm_read_pattern(&sigdata->pattern[i], f, n_channels, &buffer, &buffersize, * version) != 0) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
free(roguebytes);
|
free(roguebytes);
|
||||||
_dumb_it_unload_sigdata(sigdata);
|
_dumb_it_unload_sigdata(sigdata);
|
||||||
|
|
Loading…
Reference in a new issue