Commit 87bb0d8e authored by Michael Smith's avatar Michael Smith

Patch from jordy@acm.org (Jordan Mendelson) for little-endian AIFF files,

as (apparently) produced by MacOS X from CDs.

Some code reformatting in encode.c

svn path=/trunk/vorbis-tools/; revision=4088
parent ff48be3c
......@@ -258,9 +258,18 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
fprintf(stderr, _("Warning: AIFF-C header truncated.\n"));
return 0;
}
else if(memcmp(buffer+18, "NONE", 4))
if(!memcmp(buffer+18, "NONE", 4))
{
aiff->bigendian = 1;
}
else if(!memcmp(buffer+18, "sowt", 4))
{
fprintf(stderr, _("Warning: Can't handle compressed AIFF-C\n"));
aiff->bigendian = 0;
}
else
{
fprintf(stderr, _("Warning: Can't handle compressed AIFF-C (%c%c%c%c)\n"), *(buffer+18), *(buffer+19), *(buffer+20), *(buffer+21));
return 0; /* Compressed. Can't handle */
}
}
......@@ -301,7 +310,6 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
aiff->channels = format.channels;
aiff->samplesize = format.samplesize;
aiff->totalsamples = format.totalframes;
aiff->bigendian = 1;
opt->readdata = (void *)aiff;
......@@ -468,8 +476,9 @@ long wav_read(void *in, float **buffer, int samples)
long realsamples;
if(f->totalsamples && f->samplesread +
bytes_read/(sampbyte*f->channels) > f->totalsamples)
bytes_read/(sampbyte*f->channels) > f->totalsamples) {
bytes_read = sampbyte*f->channels*(f->totalsamples - f->samplesread);
}
realsamples = bytes_read/(sampbyte*f->channels);
f->samplesread += realsamples;
......
......@@ -155,46 +155,46 @@ int oe_encode(oe_enc_opt *opt)
vorbis_info_init(&vi);
if(opt->quality_set > 0){
if(vorbis_encode_setup_vbr(&vi, opt->channels, opt->rate, opt->quality)){
fprintf(stderr, _("Mode initialisation failed: invalid parameters for quality\n"));
vorbis_info_clear(&vi);
return 1;
}
if(vorbis_encode_setup_vbr(&vi, opt->channels, opt->rate, opt->quality)){
fprintf(stderr, _("Mode initialisation failed: invalid parameters for quality\n"));
vorbis_info_clear(&vi);
return 1;
}
/* do we have optional hard quality restrictions? */
if(opt->max_bitrate > 0 || opt->min_bitrate > 0){
struct ovectl_ratemanage_arg ai;
vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_GET, &ai);
/* do we have optional hard quality restrictions? */
if(opt->max_bitrate > 0 || opt->min_bitrate > 0){
struct ovectl_ratemanage_arg ai;
vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_GET, &ai);
ai.bitrate_hard_min=opt->min_bitrate;
ai.bitrate_hard_max=opt->max_bitrate;
ai.management_active=1;
ai.bitrate_hard_min=opt->min_bitrate;
ai.bitrate_hard_max=opt->max_bitrate;
ai.management_active=1;
vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_SET, &ai);
vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_SET, &ai);
}
}
}else {
if(vorbis_encode_setup_managed(&vi, opt->channels, opt->rate,
if(vorbis_encode_setup_managed(&vi, opt->channels, opt->rate,
opt->max_bitrate>0?opt->max_bitrate*1000:-1,
opt->bitrate*1000,
opt->min_bitrate>0?opt->min_bitrate*1000:-1)){
fprintf(stderr, _("Mode initialisation failed: invalid parameters for bitrate\n"));
vorbis_info_clear(&vi);
return 1;
}
fprintf(stderr, _("Mode initialisation failed: invalid parameters for bitrate\n"));
vorbis_info_clear(&vi);
return 1;
}
}
if(opt->managed && opt->bitrate < 0)
{
{
vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_AVG, NULL);
}
}
else if(!opt->managed)
{
{
/* Turn off management entirely (if it was turned on). */
vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_SET, NULL);
}
}
set_advanced_encoder_options(opt->advopt, opt->advopt_count, &vi);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment