Add faad2 for aac decoding
This commit is contained in:
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
|
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
**
|
||||
** This program 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.
|
||||
**
|
||||
** This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
**
|
||||
** Any non-GPL usage of this software or parts of this software is strictly
|
||||
** forbidden.
|
||||
**
|
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2
|
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
|
||||
**
|
||||
** Commercial non-GPL licensing of this software is possible.
|
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
|
||||
**
|
||||
** $Id: audio.c,v 1.30 2015/01/22 09:40:52 knik Exp $
|
||||
**/
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <neaacdec.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "unicode_support.h"
|
||||
#include "audio.h"
|
||||
|
||||
static size_t write_wav_header(audio_file *aufile);
|
||||
static size_t write_wav_extensible_header(audio_file *aufile, long channelMask);
|
||||
static size_t write_audio_16bit(audio_file *aufile, void *sample_buffer,
|
||||
unsigned int samples);
|
||||
static size_t write_audio_24bit(audio_file *aufile, void *sample_buffer,
|
||||
unsigned int samples);
|
||||
static size_t write_audio_32bit(audio_file *aufile, void *sample_buffer,
|
||||
unsigned int samples);
|
||||
static size_t write_audio_float(audio_file *aufile, void *sample_buffer,
|
||||
unsigned int samples);
|
||||
|
||||
audio_file *open_audio_file(char *infile, int samplerate, int channels,
|
||||
int outputFormat, int fileType, long channelMask)
|
||||
{
|
||||
audio_file *aufile = malloc(sizeof(audio_file));
|
||||
|
||||
aufile->outputFormat = outputFormat;
|
||||
|
||||
aufile->samplerate = samplerate;
|
||||
aufile->channels = channels;
|
||||
aufile->total_samples = 0;
|
||||
aufile->fileType = fileType;
|
||||
aufile->channelMask = channelMask;
|
||||
|
||||
switch (outputFormat)
|
||||
{
|
||||
case FAAD_FMT_16BIT:
|
||||
aufile->bits_per_sample = 16;
|
||||
break;
|
||||
case FAAD_FMT_24BIT:
|
||||
aufile->bits_per_sample = 24;
|
||||
break;
|
||||
case FAAD_FMT_32BIT:
|
||||
case FAAD_FMT_FLOAT:
|
||||
aufile->bits_per_sample = 32;
|
||||
break;
|
||||
default:
|
||||
if (aufile) free(aufile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(infile[0] == '-')
|
||||
{
|
||||
#ifdef _WIN32
|
||||
_setmode(_fileno(stdout), O_BINARY);
|
||||
#endif
|
||||
aufile->sndfile = stdout;
|
||||
aufile->toStdio = 1;
|
||||
} else {
|
||||
aufile->toStdio = 0;
|
||||
aufile->sndfile = faad_fopen(infile, "wb");
|
||||
}
|
||||
|
||||
if (aufile->sndfile == NULL)
|
||||
{
|
||||
if (aufile) free(aufile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (aufile->fileType == OUTPUT_WAV)
|
||||
{
|
||||
if (aufile->channelMask)
|
||||
write_wav_extensible_header(aufile, aufile->channelMask);
|
||||
else
|
||||
write_wav_header(aufile);
|
||||
}
|
||||
|
||||
return aufile;
|
||||
}
|
||||
|
||||
size_t write_audio_file(audio_file *aufile, void *sample_buffer, int samples)
|
||||
{
|
||||
char *buf = (char *)sample_buffer;
|
||||
switch (aufile->outputFormat)
|
||||
{
|
||||
case FAAD_FMT_16BIT:
|
||||
return write_audio_16bit(aufile, buf, samples);
|
||||
case FAAD_FMT_24BIT:
|
||||
return write_audio_24bit(aufile, buf, samples);
|
||||
case FAAD_FMT_32BIT:
|
||||
return write_audio_32bit(aufile, buf, samples);
|
||||
case FAAD_FMT_FLOAT:
|
||||
return write_audio_float(aufile, buf, samples);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
// return 0;
|
||||
}
|
||||
|
||||
void close_audio_file(audio_file *aufile)
|
||||
{
|
||||
if ((aufile->fileType == OUTPUT_WAV) && (aufile->toStdio == 0))
|
||||
{
|
||||
fseek(aufile->sndfile, 0, SEEK_SET);
|
||||
|
||||
if (aufile->channelMask)
|
||||
write_wav_extensible_header(aufile, aufile->channelMask);
|
||||
else
|
||||
write_wav_header(aufile);
|
||||
}
|
||||
|
||||
if (aufile->toStdio == 0)
|
||||
fclose(aufile->sndfile);
|
||||
|
||||
if (aufile) free(aufile);
|
||||
}
|
||||
|
||||
static size_t write_wav_header(audio_file *aufile)
|
||||
{
|
||||
unsigned char header[44];
|
||||
unsigned char* p = header;
|
||||
unsigned int bytes = (aufile->bits_per_sample + 7) / 8;
|
||||
float data_size = (float)bytes * aufile->total_samples;
|
||||
unsigned long word32;
|
||||
|
||||
*p++ = 'R'; *p++ = 'I'; *p++ = 'F'; *p++ = 'F';
|
||||
|
||||
word32 = (data_size + (44 - 8) < (float)MAXWAVESIZE) ?
|
||||
(unsigned long)data_size + (44 - 8) : (unsigned long)MAXWAVESIZE;
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
*p++ = (unsigned char)(word32 >> 16);
|
||||
*p++ = (unsigned char)(word32 >> 24);
|
||||
|
||||
*p++ = 'W'; *p++ = 'A'; *p++ = 'V'; *p++ = 'E';
|
||||
|
||||
*p++ = 'f'; *p++ = 'm'; *p++ = 't'; *p++ = ' ';
|
||||
|
||||
*p++ = 0x10; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
|
||||
|
||||
if (aufile->outputFormat == FAAD_FMT_FLOAT)
|
||||
{
|
||||
*p++ = 0x03; *p++ = 0x00;
|
||||
} else {
|
||||
*p++ = 0x01; *p++ = 0x00;
|
||||
}
|
||||
|
||||
*p++ = (unsigned char)(aufile->channels >> 0);
|
||||
*p++ = (unsigned char)(aufile->channels >> 8);
|
||||
|
||||
word32 = (unsigned long)(aufile->samplerate + 0.5);
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
*p++ = (unsigned char)(word32 >> 16);
|
||||
*p++ = (unsigned char)(word32 >> 24);
|
||||
|
||||
word32 = aufile->samplerate * bytes * aufile->channels;
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
*p++ = (unsigned char)(word32 >> 16);
|
||||
*p++ = (unsigned char)(word32 >> 24);
|
||||
|
||||
word32 = bytes * aufile->channels;
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
|
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 0);
|
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 8);
|
||||
|
||||
*p++ = 'd'; *p++ = 'a'; *p++ = 't'; *p++ = 'a';
|
||||
|
||||
word32 = data_size < MAXWAVESIZE ?
|
||||
(unsigned long)data_size : (unsigned long)MAXWAVESIZE;
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
*p++ = (unsigned char)(word32 >> 16);
|
||||
*p++ = (unsigned char)(word32 >> 24);
|
||||
|
||||
return fwrite(header, sizeof(header), 1, aufile->sndfile);
|
||||
}
|
||||
|
||||
static size_t write_wav_extensible_header(audio_file *aufile, long channelMask)
|
||||
{
|
||||
unsigned char header[68];
|
||||
unsigned char* p = header;
|
||||
unsigned int bytes = (aufile->bits_per_sample + 7) / 8;
|
||||
float data_size = (float)bytes * aufile->total_samples;
|
||||
unsigned long word32;
|
||||
|
||||
*p++ = 'R'; *p++ = 'I'; *p++ = 'F'; *p++ = 'F';
|
||||
|
||||
word32 = (data_size + (68 - 8) < (float)MAXWAVESIZE) ?
|
||||
(unsigned long)data_size + (68 - 8) : (unsigned long)MAXWAVESIZE;
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
*p++ = (unsigned char)(word32 >> 16);
|
||||
*p++ = (unsigned char)(word32 >> 24);
|
||||
|
||||
*p++ = 'W'; *p++ = 'A'; *p++ = 'V'; *p++ = 'E';
|
||||
|
||||
*p++ = 'f'; *p++ = 'm'; *p++ = 't'; *p++ = ' ';
|
||||
|
||||
*p++ = /*0x10*/0x28; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
|
||||
|
||||
/* WAVE_FORMAT_EXTENSIBLE */
|
||||
*p++ = 0xFE; *p++ = 0xFF;
|
||||
|
||||
*p++ = (unsigned char)(aufile->channels >> 0);
|
||||
*p++ = (unsigned char)(aufile->channels >> 8);
|
||||
|
||||
word32 = (unsigned long)(aufile->samplerate + 0.5);
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
*p++ = (unsigned char)(word32 >> 16);
|
||||
*p++ = (unsigned char)(word32 >> 24);
|
||||
|
||||
word32 = aufile->samplerate * bytes * aufile->channels;
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
*p++ = (unsigned char)(word32 >> 16);
|
||||
*p++ = (unsigned char)(word32 >> 24);
|
||||
|
||||
word32 = bytes * aufile->channels;
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
|
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 0);
|
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 8);
|
||||
|
||||
/* cbSize */
|
||||
*p++ = (unsigned char)(22);
|
||||
*p++ = (unsigned char)(0);
|
||||
|
||||
/* WAVEFORMATEXTENSIBLE */
|
||||
|
||||
/* wValidBitsPerSample */
|
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 0);
|
||||
*p++ = (unsigned char)(aufile->bits_per_sample >> 8);
|
||||
|
||||
/* dwChannelMask */
|
||||
word32 = channelMask;
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
*p++ = (unsigned char)(word32 >> 16);
|
||||
*p++ = (unsigned char)(word32 >> 24);
|
||||
|
||||
/* SubFormat */
|
||||
if (aufile->outputFormat == FAAD_FMT_FLOAT)
|
||||
{
|
||||
/* KSDATAFORMAT_SUBTYPE_IEEE_FLOAT: 00000003-0000-0010-8000-00aa00389b71 */
|
||||
*p++ = 0x03;
|
||||
*p++ = 0x00;
|
||||
*p++ = 0x00;
|
||||
*p++ = 0x00;
|
||||
*p++ = 0x00; *p++ = 0x00; *p++ = 0x10; *p++ = 0x00; *p++ = 0x80; *p++ = 0x00;
|
||||
*p++ = 0x00; *p++ = 0xaa; *p++ = 0x00; *p++ = 0x38; *p++ = 0x9b; *p++ = 0x71;
|
||||
} else {
|
||||
/* KSDATAFORMAT_SUBTYPE_PCM: 00000001-0000-0010-8000-00aa00389b71 */
|
||||
*p++ = 0x01;
|
||||
*p++ = 0x00;
|
||||
*p++ = 0x00;
|
||||
*p++ = 0x00;
|
||||
*p++ = 0x00; *p++ = 0x00; *p++ = 0x10; *p++ = 0x00; *p++ = 0x80; *p++ = 0x00;
|
||||
*p++ = 0x00; *p++ = 0xaa; *p++ = 0x00; *p++ = 0x38; *p++ = 0x9b; *p++ = 0x71;
|
||||
}
|
||||
|
||||
/* end WAVEFORMATEXTENSIBLE */
|
||||
|
||||
*p++ = 'd'; *p++ = 'a'; *p++ = 't'; *p++ = 'a';
|
||||
|
||||
word32 = data_size < MAXWAVESIZE ?
|
||||
(unsigned long)data_size : (unsigned long)MAXWAVESIZE;
|
||||
*p++ = (unsigned char)(word32 >> 0);
|
||||
*p++ = (unsigned char)(word32 >> 8);
|
||||
*p++ = (unsigned char)(word32 >> 16);
|
||||
*p++ = (unsigned char)(word32 >> 24);
|
||||
|
||||
return fwrite(header, sizeof(header), 1, aufile->sndfile);
|
||||
}
|
||||
|
||||
static size_t write_audio_16bit(audio_file *aufile, void *sample_buffer,
|
||||
unsigned int samples)
|
||||
{
|
||||
size_t ret;
|
||||
unsigned int i;
|
||||
short *sample_buffer16 = (short*)sample_buffer;
|
||||
char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
|
||||
|
||||
aufile->total_samples += samples;
|
||||
|
||||
if (aufile->channels == 6 && aufile->channelMask)
|
||||
{
|
||||
for (i = 0; i < samples; i += aufile->channels)
|
||||
{
|
||||
short r1, r2, r3, r4, r5, r6;
|
||||
r1 = sample_buffer16[i];
|
||||
r2 = sample_buffer16[i+1];
|
||||
r3 = sample_buffer16[i+2];
|
||||
r4 = sample_buffer16[i+3];
|
||||
r5 = sample_buffer16[i+4];
|
||||
r6 = sample_buffer16[i+5];
|
||||
sample_buffer16[i] = r2;
|
||||
sample_buffer16[i+1] = r3;
|
||||
sample_buffer16[i+2] = r1;
|
||||
sample_buffer16[i+3] = r6;
|
||||
sample_buffer16[i+4] = r4;
|
||||
sample_buffer16[i+5] = r5;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < samples; i++)
|
||||
{
|
||||
data[i*2] = (char)(sample_buffer16[i] & 0xFF);
|
||||
data[i*2+1] = (char)((sample_buffer16[i] >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
|
||||
|
||||
if (data) free(data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static size_t write_audio_24bit(audio_file *aufile, void *sample_buffer,
|
||||
unsigned int samples)
|
||||
{
|
||||
size_t ret;
|
||||
unsigned int i;
|
||||
int32_t *sample_buffer24 = (int32_t*)sample_buffer;
|
||||
char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
|
||||
|
||||
aufile->total_samples += samples;
|
||||
|
||||
if (aufile->channels == 6 && aufile->channelMask)
|
||||
{
|
||||
for (i = 0; i < samples; i += aufile->channels)
|
||||
{
|
||||
long r1, r2, r3, r4, r5, r6;
|
||||
r1 = sample_buffer24[i];
|
||||
r2 = sample_buffer24[i+1];
|
||||
r3 = sample_buffer24[i+2];
|
||||
r4 = sample_buffer24[i+3];
|
||||
r5 = sample_buffer24[i+4];
|
||||
r6 = sample_buffer24[i+5];
|
||||
sample_buffer24[i] = r2;
|
||||
sample_buffer24[i+1] = r3;
|
||||
sample_buffer24[i+2] = r1;
|
||||
sample_buffer24[i+3] = r6;
|
||||
sample_buffer24[i+4] = r4;
|
||||
sample_buffer24[i+5] = r5;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < samples; i++)
|
||||
{
|
||||
data[i*3] = (char)(sample_buffer24[i] & 0xFF);
|
||||
data[i*3+1] = (char)((sample_buffer24[i] >> 8) & 0xFF);
|
||||
data[i*3+2] = (char)((sample_buffer24[i] >> 16) & 0xFF);
|
||||
}
|
||||
|
||||
ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
|
||||
|
||||
if (data) free(data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static size_t write_audio_32bit(audio_file *aufile, void *sample_buffer,
|
||||
unsigned int samples)
|
||||
{
|
||||
size_t ret;
|
||||
unsigned int i;
|
||||
int32_t *sample_buffer32 = (int32_t*)sample_buffer;
|
||||
char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
|
||||
|
||||
aufile->total_samples += samples;
|
||||
|
||||
if (aufile->channels == 6 && aufile->channelMask)
|
||||
{
|
||||
for (i = 0; i < samples; i += aufile->channels)
|
||||
{
|
||||
long r1, r2, r3, r4, r5, r6;
|
||||
r1 = sample_buffer32[i];
|
||||
r2 = sample_buffer32[i+1];
|
||||
r3 = sample_buffer32[i+2];
|
||||
r4 = sample_buffer32[i+3];
|
||||
r5 = sample_buffer32[i+4];
|
||||
r6 = sample_buffer32[i+5];
|
||||
sample_buffer32[i] = r2;
|
||||
sample_buffer32[i+1] = r3;
|
||||
sample_buffer32[i+2] = r1;
|
||||
sample_buffer32[i+3] = r6;
|
||||
sample_buffer32[i+4] = r4;
|
||||
sample_buffer32[i+5] = r5;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < samples; i++)
|
||||
{
|
||||
data[i*4] = (char)(sample_buffer32[i] & 0xFF);
|
||||
data[i*4+1] = (char)((sample_buffer32[i] >> 8) & 0xFF);
|
||||
data[i*4+2] = (char)((sample_buffer32[i] >> 16) & 0xFF);
|
||||
data[i*4+3] = (char)((sample_buffer32[i] >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
|
||||
|
||||
if (data) free(data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static size_t write_audio_float(audio_file *aufile, void *sample_buffer,
|
||||
unsigned int samples)
|
||||
{
|
||||
size_t ret;
|
||||
unsigned int i;
|
||||
float *sample_buffer_f = (float*)sample_buffer;
|
||||
unsigned char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8);
|
||||
|
||||
aufile->total_samples += samples;
|
||||
|
||||
if (aufile->channels == 6 && aufile->channelMask)
|
||||
{
|
||||
for (i = 0; i < samples; i += aufile->channels)
|
||||
{
|
||||
float r1, r2, r3, r4, r5, r6;
|
||||
r1 = sample_buffer_f[i];
|
||||
r2 = sample_buffer_f[i+1];
|
||||
r3 = sample_buffer_f[i+2];
|
||||
r4 = sample_buffer_f[i+3];
|
||||
r5 = sample_buffer_f[i+4];
|
||||
r6 = sample_buffer_f[i+5];
|
||||
sample_buffer_f[i] = r2;
|
||||
sample_buffer_f[i+1] = r3;
|
||||
sample_buffer_f[i+2] = r1;
|
||||
sample_buffer_f[i+3] = r6;
|
||||
sample_buffer_f[i+4] = r4;
|
||||
sample_buffer_f[i+5] = r5;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < samples; i++)
|
||||
{
|
||||
int exponent, mantissa, negative = 0 ;
|
||||
float in = sample_buffer_f[i];
|
||||
|
||||
data[i*4] = 0; data[i*4+1] = 0; data[i*4+2] = 0; data[i*4+3] = 0;
|
||||
if (in == 0.0)
|
||||
continue;
|
||||
|
||||
if (in < 0.0)
|
||||
{
|
||||
in *= -1.0;
|
||||
negative = 1;
|
||||
}
|
||||
in = (float)frexp(in, &exponent);
|
||||
exponent += 126;
|
||||
in *= (float)0x1000000;
|
||||
mantissa = (((int)in) & 0x7FFFFF);
|
||||
|
||||
if (negative)
|
||||
data[i*4+3] |= 0x80;
|
||||
|
||||
if (exponent & 0x01)
|
||||
data[i*4+2] |= 0x80;
|
||||
|
||||
data[i*4] = mantissa & 0xFF;
|
||||
data[i*4+1] = (mantissa >> 8) & 0xFF;
|
||||
data[i*4+2] |= (mantissa >> 16) & 0x7F;
|
||||
data[i*4+3] |= (exponent >> 1) & 0x7F;
|
||||
}
|
||||
|
||||
ret = fwrite(data, samples, aufile->bits_per_sample/8, aufile->sndfile);
|
||||
|
||||
if (data) free(data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
|
||||
** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
|
||||
**
|
||||
** This program 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.
|
||||
**
|
||||
** This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
**
|
||||
** Any non-GPL usage of this software or parts of this software is strictly
|
||||
** forbidden.
|
||||
**
|
||||
** The "appropriate copyright message" mentioned in section 2c of the GPLv2
|
||||
** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
|
||||
**
|
||||
** Commercial non-GPL licensing of this software is possible.
|
||||
** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
|
||||
**
|
||||
** $Id: audio.h,v 1.19 2007/11/01 12:33:29 menno Exp $
|
||||
**/
|
||||
|
||||
#ifndef AUDIO_H_INCLUDED
|
||||
#define AUDIO_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAXWAVESIZE 4294967040LU
|
||||
|
||||
#define OUTPUT_WAV 1
|
||||
#define OUTPUT_RAW 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int toStdio;
|
||||
int outputFormat;
|
||||
FILE *sndfile;
|
||||
unsigned int fileType;
|
||||
unsigned long samplerate;
|
||||
unsigned int bits_per_sample;
|
||||
unsigned int channels;
|
||||
unsigned long total_samples;
|
||||
long channelMask;
|
||||
} audio_file;
|
||||
|
||||
audio_file *open_audio_file(char *infile, int samplerate, int channels,
|
||||
int outputFormat, int fileType, long channelMask);
|
||||
size_t write_audio_file(audio_file *aufile, void *sample_buffer, int samples);
|
||||
void close_audio_file(audio_file *aufile);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,85 @@
|
||||
.TH FAAD "1" "October 2006" "faad 2.5" ""
|
||||
.SH NAME
|
||||
faad \(em Process an Advanced Audio Codec stream
|
||||
|
||||
.SH "SYNOPSIS"
|
||||
.B faad
|
||||
[options] [\-w | \-o <output_filename> | \-a <output_filename>] input_filename
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
This utility provides a command line interface to libfaad2. This program reads in MPEG\(hy4 AAC files, processes, and outputs them in either Microsoft WAV, MPEG\(hy4 AAC ADTS, or standard PCM formats.
|
||||
|
||||
.SH "OPTIONS"
|
||||
.TP
|
||||
.BI \-a " <filename>" ", \-\^\-adtsout" " <filename>"
|
||||
Sets the processing to output to the specified file in MPEG\(hy4 AAC ADTS format
|
||||
.TP
|
||||
.BI \-b " <number>" ", \-\^\-bits" " <number>"
|
||||
Set the output (individual) sample format. The number takes one of the following values:
|
||||
.RS
|
||||
.RS
|
||||
1: 16\(hybit PCM data (default).
|
||||
.br
|
||||
2: 24\(hybit PCM data.
|
||||
.br
|
||||
3: 32\(hybit PCM data.
|
||||
.br
|
||||
4: 32\(hybit floating\(hypoint data.
|
||||
.br
|
||||
5: 64\(hybit floating\(hypoint data.
|
||||
.RE
|
||||
.RE
|
||||
.TP
|
||||
.B \-d ", \-\^\-downmix"
|
||||
Set the processing to downsample from 5.1 (surround sound and bass) channels to 2 channels (stereo).
|
||||
.TP
|
||||
.BI \-f " <number>" ", \-\^\-format" " <number>"
|
||||
Set the output file format. The number takes one of the following values:
|
||||
.RS
|
||||
.RS
|
||||
1: Microsoft WAV format (default).
|
||||
.br
|
||||
2: Raw PCM data.
|
||||
.RE
|
||||
.RE
|
||||
.TP
|
||||
.BI \-g
|
||||
Set the processing to not perform gapless decoding.
|
||||
.TP
|
||||
.B \-h ", \-\^\-help"
|
||||
Shows a usage summary.
|
||||
.TP
|
||||
.B \-i ", \-\^\-info"
|
||||
Shows information about the about the input file.
|
||||
.TP
|
||||
.BI \-l " <number>" ", \-\^\-objecttype" " <number>"
|
||||
Sets the MPEG\hy(4 profile and object type for the processing to use. The number takes one of the following values:
|
||||
.RS
|
||||
.RS
|
||||
1: Main object type.
|
||||
.br
|
||||
2: Low Complexity (LC) object type (default).
|
||||
.br
|
||||
4: Long Term Prediction (LTP) object type.
|
||||
.br
|
||||
23: Low Delay (LD) object type.
|
||||
.RE
|
||||
.RE
|
||||
.TP
|
||||
.BI \-o " <filename>" ", \-\^\-outfile" " <number>"
|
||||
Sets the filename for processing output.
|
||||
.TP
|
||||
.B \-q ", \-\^\-quiet"
|
||||
Quiet \- Suppresses status messages during processing.
|
||||
.TP
|
||||
.B \-t ", \-\^\-oldformat"
|
||||
Sets the processing to use the old MPEG\(hy4 AAC ADTS format when outputting in said format.
|
||||
.TP
|
||||
.B \-w ", \-\^\-stdio"
|
||||
Sets the processing output to be sent to the standard out.
|
||||
|
||||
.SH "AUTHOR"
|
||||
Matthew W. S. Bell <matthew (at) bells23.org.uk>
|
||||
|
||||
.SH "SEE ALSO"
|
||||
\fBfaac\fP(1)
|
||||
@@ -0,0 +1,725 @@
|
||||
/* Getopt for GNU.
|
||||
NOTE: getopt is now part of the C library, so if you don't know what
|
||||
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
|
||||
before changing it!
|
||||
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program 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, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef __STDC__
|
||||
# ifndef const
|
||||
# define const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */
|
||||
#ifndef _NO_PROTO
|
||||
#define _NO_PROTO
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#if defined (_LIBC) || !defined (__GNU_LIBRARY__) || !__MacOSX__
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* Don't include stdlib.h for non-GNU C libraries because some of them
|
||||
contain conflicting prototypes for getopt. */
|
||||
#include <stdlib.h>
|
||||
#endif /* GNU C library. */
|
||||
|
||||
/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
|
||||
long-named option. Because this is not POSIX.2 compliant, it is
|
||||
being phased out. */
|
||||
/* #define GETOPT_COMPAT */
|
||||
|
||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
||||
but it behaves differently for the user, since it allows the user
|
||||
to intersperse the options with the other arguments.
|
||||
|
||||
As `getopt' works, it permutes the elements of ARGV so that,
|
||||
when it is done, all the options precede everything else. Thus
|
||||
all application programs are extended to handle flexible argument order.
|
||||
|
||||
Setting the environment variable POSIXLY_CORRECT disables permutation.
|
||||
Then the behavior is completely standard.
|
||||
|
||||
GNU application programs can use a third alternative mode in which
|
||||
they can distinguish the relative order of options and other arguments. */
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
char *optarg = 0;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns EOF, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
/* XXX 1003.2 says this must be 1 before any call. */
|
||||
int optind = 0;
|
||||
|
||||
/* The next char to be scanned in the option-element
|
||||
in which the last option character we returned was found.
|
||||
This allows us to pick up the scan where we left off.
|
||||
|
||||
If this is zero, or a null string, it means resume the scan
|
||||
by advancing to the next ARGV-element. */
|
||||
|
||||
static char *nextchar;
|
||||
|
||||
/* Callers store zero here to inhibit the error message
|
||||
for unrecognized options. */
|
||||
|
||||
int opterr = 1;
|
||||
|
||||
/* Set to an option character which was unrecognized.
|
||||
This must be initialized on some systems to avoid linking in the
|
||||
system's own getopt implementation. */
|
||||
|
||||
#define BAD_OPTION '\0'
|
||||
int optopt = BAD_OPTION;
|
||||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything,
|
||||
the default is REQUIRE_ORDER if the environment variable
|
||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
||||
|
||||
REQUIRE_ORDER means don't recognize them as options;
|
||||
stop option processing when the first non-option is seen.
|
||||
This is what Unix does.
|
||||
This mode of operation is selected by either setting the environment
|
||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
||||
of the list of option characters.
|
||||
|
||||
PERMUTE is the default. We permute the contents of ARGV as we scan,
|
||||
so that eventually all the non-options are at the end. This allows options
|
||||
to be given in any order, even with programs that were not written to
|
||||
expect this.
|
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were written
|
||||
to expect options and other ARGV-elements in any order and that care about
|
||||
the ordering of the two. We describe each non-option ARGV-element
|
||||
as if it were the argument of an option with character code 1.
|
||||
Using `-' as the first character of the list of option characters
|
||||
selects this mode of operation.
|
||||
|
||||
The special argument `--' forces an end of option-scanning regardless
|
||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
|
||||
|
||||
static enum
|
||||
{
|
||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
||||
} ordering;
|
||||
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* We want to avoid inclusion of string.h with non-GNU libraries
|
||||
because there are many ways it can cause trouble.
|
||||
On some systems, it contains special magic macros that don't work
|
||||
in GCC. */
|
||||
#include <string.h>
|
||||
#define my_index strchr
|
||||
#define my_strlen strlen
|
||||
#else
|
||||
|
||||
/* Avoid depending on library functions or files
|
||||
whose names are inconsistent. */
|
||||
|
||||
#if __STDC__ || defined(PROTO)
|
||||
extern char *getenv(const char *name);
|
||||
extern int strcmp (const char *s1, const char *s2);
|
||||
|
||||
static int my_strlen(const char *s);
|
||||
static char *my_index (const char *str, int chr);
|
||||
#else
|
||||
extern char *getenv (const char *name);
|
||||
#endif
|
||||
|
||||
static int my_strlen(const char *str) {
|
||||
int n = 0;
|
||||
while (*str++)
|
||||
n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
static char *my_index(const char *str, int chr) {
|
||||
while (*str)
|
||||
{
|
||||
if (*str == chr)
|
||||
return (char *) str;
|
||||
str++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* GNU C library. */
|
||||
|
||||
/* Handle permutation of arguments. */
|
||||
|
||||
/* Describe the part of ARGV that contains non-options that have
|
||||
been skipped. `first_nonopt' is the index in ARGV of the first of them;
|
||||
`last_nonopt' is the index after the last of them. */
|
||||
|
||||
static int first_nonopt;
|
||||
static int last_nonopt;
|
||||
|
||||
/* Exchange two adjacent subsequences of ARGV.
|
||||
One subsequence is elements [first_nonopt,last_nonopt)
|
||||
which contains all the non-options that have been skipped so far.
|
||||
The other is elements [last_nonopt,optind), which contains all
|
||||
the options processed since those non-options were skipped.
|
||||
|
||||
`first_nonopt' and `last_nonopt' are relocated so that they describe
|
||||
the new indices of the non-options in ARGV after they are moved.
|
||||
|
||||
To perform the swap, we first reverse the order of all elements. So
|
||||
all options now come before all non options, but they are in the
|
||||
wrong order. So we put back the options and non options in original
|
||||
order by reversing them again. For example:
|
||||
original input: a b c -x -y
|
||||
reverse all: -y -x c b a
|
||||
reverse options: -x -y c b a
|
||||
reverse non options: -x -y a b c
|
||||
*/
|
||||
|
||||
#if __STDC__ || defined(PROTO)
|
||||
static void exchange (char **argv);
|
||||
#endif
|
||||
|
||||
static void exchange (char **argv) {
|
||||
char *temp, **first, **last;
|
||||
|
||||
/* Reverse all the elements [first_nonopt, optind) */
|
||||
first = &argv[first_nonopt];
|
||||
last = &argv[optind-1];
|
||||
while (first < last) {
|
||||
temp = *first; *first = *last; *last = temp; first++; last--;
|
||||
}
|
||||
/* Put back the options in order */
|
||||
first = &argv[first_nonopt];
|
||||
first_nonopt += (optind - last_nonopt);
|
||||
last = &argv[first_nonopt - 1];
|
||||
while (first < last) {
|
||||
temp = *first; *first = *last; *last = temp; first++; last--;
|
||||
}
|
||||
|
||||
/* Put back the non options in order */
|
||||
first = &argv[first_nonopt];
|
||||
last_nonopt = optind;
|
||||
last = &argv[last_nonopt-1];
|
||||
while (first < last) {
|
||||
temp = *first; *first = *last; *last = temp; first++; last--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
||||
given in OPTSTRING.
|
||||
|
||||
If an element of ARGV starts with '-', and is not exactly "-" or "--",
|
||||
then it is an option element. The characters of this element
|
||||
(aside from the initial '-') are option characters. If `getopt'
|
||||
is called repeatedly, it returns successively each of the option characters
|
||||
from each of the option elements.
|
||||
|
||||
If `getopt' finds another option character, it returns that character,
|
||||
updating `optind' and `nextchar' so that the next call to `getopt' can
|
||||
resume the scan with the following option character or ARGV-element.
|
||||
|
||||
If there are no more option characters, `getopt' returns `EOF'.
|
||||
Then `optind' is the index in ARGV of the first ARGV-element
|
||||
that is not an option. (The ARGV-elements have been permuted
|
||||
so that those that are not options now come last.)
|
||||
|
||||
OPTSTRING is a string containing the legitimate option characters.
|
||||
If an option character is seen that is not listed in OPTSTRING,
|
||||
return BAD_OPTION after printing an error message. If you set `opterr' to
|
||||
zero, the error message is suppressed but we still return BAD_OPTION.
|
||||
|
||||
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
|
||||
so the following text in the same ARGV-element, or the text of the following
|
||||
ARGV-element, is returned in `optarg'. Two colons mean an option that
|
||||
wants an optional arg; if there is text in the current ARGV-element,
|
||||
it is returned in `optarg', otherwise `optarg' is set to zero.
|
||||
|
||||
If OPTSTRING starts with `-' or `+', it requests different methods of
|
||||
handling the non-option ARGV-elements.
|
||||
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
|
||||
|
||||
Long-named options begin with `--' instead of `-'.
|
||||
Their names may be abbreviated as long as the abbreviation is unique
|
||||
or is an exact match for some defined option. If they have an
|
||||
argument, it follows the option name in the same ARGV-element, separated
|
||||
from the option name by a `=', or else the in next ARGV-element.
|
||||
When `getopt' finds a long-named option, it returns 0 if that option's
|
||||
`flag' field is nonzero, the value of the option's `val' field
|
||||
if the `flag' field is zero.
|
||||
|
||||
The elements of ARGV aren't really const, because we permute them.
|
||||
But we pretend they're const in the prototype to be compatible
|
||||
with other systems.
|
||||
|
||||
LONGOPTS is a vector of `struct option' terminated by an
|
||||
element containing a name which is zero.
|
||||
|
||||
LONGIND returns the index in LONGOPT of the long-named option found.
|
||||
It is only valid when a long-named option has been found by the most
|
||||
recent call.
|
||||
|
||||
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
|
||||
long-named options. */
|
||||
|
||||
int _getopt_internal(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only) {
|
||||
int option_index;
|
||||
|
||||
optarg = 0;
|
||||
|
||||
/* Initialize the internal data when the first call is made.
|
||||
Start processing options with ARGV-element 1 (since ARGV-element 0
|
||||
is the program name); the sequence of previously skipped
|
||||
non-option ARGV-elements is empty. */
|
||||
|
||||
if (optind == 0)
|
||||
{
|
||||
first_nonopt = last_nonopt = optind = 1;
|
||||
|
||||
nextchar = NULL;
|
||||
|
||||
/* Determine how to handle the ordering of options and nonoptions. */
|
||||
|
||||
if (optstring[0] == '-')
|
||||
{
|
||||
ordering = RETURN_IN_ORDER;
|
||||
++optstring;
|
||||
}
|
||||
else if (optstring[0] == '+')
|
||||
{
|
||||
ordering = REQUIRE_ORDER;
|
||||
++optstring;
|
||||
}
|
||||
else if (getenv ("POSIXLY_CORRECT") != NULL)
|
||||
ordering = REQUIRE_ORDER;
|
||||
else
|
||||
ordering = PERMUTE;
|
||||
}
|
||||
|
||||
if (nextchar == NULL || *nextchar == '\0')
|
||||
{
|
||||
if (ordering == PERMUTE)
|
||||
{
|
||||
/* If we have just processed some options following some non-options,
|
||||
exchange them so that the options come first. */
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||
exchange ((char **) argv);
|
||||
else if (last_nonopt != optind)
|
||||
first_nonopt = optind;
|
||||
|
||||
/* Now skip any additional non-options
|
||||
and extend the range of non-options previously skipped. */
|
||||
|
||||
while (optind < argc
|
||||
&& (argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||
#ifdef GETOPT_COMPAT
|
||||
&& (longopts == NULL
|
||||
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
|
||||
#endif /* GETOPT_COMPAT */
|
||||
)
|
||||
optind++;
|
||||
last_nonopt = optind;
|
||||
}
|
||||
|
||||
/* Special ARGV-element `--' means premature end of options.
|
||||
Skip it like a null option,
|
||||
then exchange with previous non-options as if it were an option,
|
||||
then skip everything else like a non-option. */
|
||||
|
||||
if (optind != argc && !strcmp (argv[optind], "--"))
|
||||
{
|
||||
optind++;
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||
exchange ((char **) argv);
|
||||
else if (first_nonopt == last_nonopt)
|
||||
first_nonopt = optind;
|
||||
last_nonopt = argc;
|
||||
|
||||
optind = argc;
|
||||
}
|
||||
|
||||
/* If we have done all the ARGV-elements, stop the scan
|
||||
and back over any non-options that we skipped and permuted. */
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
/* Set the next-arg-index to point at the non-options
|
||||
that we previously skipped, so the caller will digest them. */
|
||||
if (first_nonopt != last_nonopt)
|
||||
optind = first_nonopt;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* If we have come to a non-option and did not permute it,
|
||||
either stop the scan or describe it to the caller and pass it by. */
|
||||
|
||||
if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||
#ifdef GETOPT_COMPAT
|
||||
&& (longopts == NULL
|
||||
|| argv[optind][0] != '+' || argv[optind][1] == '\0')
|
||||
#endif /* GETOPT_COMPAT */
|
||||
)
|
||||
{
|
||||
if (ordering == REQUIRE_ORDER)
|
||||
return EOF;
|
||||
optarg = argv[optind++];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* We have found another option-ARGV-element.
|
||||
Start decoding its characters. */
|
||||
|
||||
nextchar = (argv[optind] + 1
|
||||
+ (longopts != NULL && argv[optind][1] == '-'));
|
||||
}
|
||||
|
||||
if (longopts != NULL
|
||||
&& ((argv[optind][0] == '-'
|
||||
&& (argv[optind][1] == '-' || long_only))
|
||||
#ifdef GETOPT_COMPAT
|
||||
|| argv[optind][0] == '+'
|
||||
#endif /* GETOPT_COMPAT */
|
||||
))
|
||||
{
|
||||
const struct option *p;
|
||||
char *s = nextchar;
|
||||
int exact = 0;
|
||||
int ambig = 0;
|
||||
const struct option *pfound = NULL;
|
||||
int indfound = 0;
|
||||
|
||||
while (*s && *s != '=')
|
||||
s++;
|
||||
|
||||
/* Test all options for either exact match or abbreviated matches. */
|
||||
for (p = longopts, option_index = 0; p->name;
|
||||
p++, option_index++)
|
||||
if (!strncmp (p->name, nextchar, s - nextchar))
|
||||
{
|
||||
if (s - nextchar == my_strlen (p->name))
|
||||
{
|
||||
/* Exact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
exact = 1;
|
||||
break;
|
||||
}
|
||||
else if (pfound == NULL)
|
||||
{
|
||||
/* First nonexact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
}
|
||||
else
|
||||
/* Second nonexact match found. */
|
||||
ambig = 1;
|
||||
}
|
||||
|
||||
if (ambig && !exact)
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, "%s: option `%s' is ambiguous\n",
|
||||
argv[0], argv[optind]);
|
||||
nextchar += my_strlen (nextchar);
|
||||
optind++;
|
||||
return BAD_OPTION;
|
||||
}
|
||||
|
||||
if (pfound != NULL)
|
||||
{
|
||||
option_index = indfound;
|
||||
optind++;
|
||||
if (*s)
|
||||
{
|
||||
/* Don't test has_arg with >, because some C compilers don't
|
||||
allow it to be used on enums. */
|
||||
if (pfound->has_arg)
|
||||
optarg = s + 1;
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
"%s: option `--%s' doesn't allow an argument\n",
|
||||
argv[0], pfound->name);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr,
|
||||
"%s: option `%c%s' doesn't allow an argument\n",
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
}
|
||||
nextchar += my_strlen (nextchar);
|
||||
return BAD_OPTION;
|
||||
}
|
||||
}
|
||||
else if (pfound->has_arg == 1)
|
||||
{
|
||||
if (optind < argc)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, "%s: option `%s' requires an argument\n",
|
||||
argv[0], argv[optind - 1]);
|
||||
nextchar += my_strlen (nextchar);
|
||||
return optstring[0] == ':' ? ':' : BAD_OPTION;
|
||||
}
|
||||
}
|
||||
nextchar += my_strlen (nextchar);
|
||||
if (longind != NULL)
|
||||
*longind = option_index;
|
||||
if (pfound->flag)
|
||||
{
|
||||
*(pfound->flag) = pfound->val;
|
||||
return 0;
|
||||
}
|
||||
return pfound->val;
|
||||
}
|
||||
/* Can't find it as a long option. If this is not getopt_long_only,
|
||||
or the option starts with '--' or is not a valid short
|
||||
option, then it's an error.
|
||||
Otherwise interpret it as a short option. */
|
||||
if (!long_only || argv[optind][1] == '-'
|
||||
#ifdef GETOPT_COMPAT
|
||||
|| argv[optind][0] == '+'
|
||||
#endif /* GETOPT_COMPAT */
|
||||
|| my_index (optstring, *nextchar) == NULL)
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (argv[optind][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr, "%s: unrecognized option `--%s'\n",
|
||||
argv[0], nextchar);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
|
||||
argv[0], argv[optind][0], nextchar);
|
||||
}
|
||||
nextchar = (char *) "";
|
||||
optind++;
|
||||
return BAD_OPTION;
|
||||
}
|
||||
}
|
||||
|
||||
/* Look at and handle the next option-character. */
|
||||
|
||||
{
|
||||
char c = *nextchar++;
|
||||
char *temp = my_index (optstring, c);
|
||||
|
||||
/* Increment `optind' when we start to process its last character. */
|
||||
if (*nextchar == '\0')
|
||||
++optind;
|
||||
|
||||
if (temp == NULL || c == ':')
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
#if 0
|
||||
if (c < 040 || c >= 0177)
|
||||
fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
|
||||
argv[0], c);
|
||||
else
|
||||
fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
|
||||
#else
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c);
|
||||
#endif
|
||||
}
|
||||
optopt = c;
|
||||
return BAD_OPTION;
|
||||
}
|
||||
if (temp[1] == ':')
|
||||
{
|
||||
if (temp[2] == ':')
|
||||
{
|
||||
/* This is an option that accepts an argument optionally. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
optarg = 0;
|
||||
nextchar = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an option that requires an argument. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
/* If we end this ARGV-element by taking the rest as an arg,
|
||||
we must advance to the next element now. */
|
||||
optind++;
|
||||
}
|
||||
else if (optind == argc)
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
#if 0
|
||||
fprintf (stderr, "%s: option `-%c' requires an argument\n",
|
||||
argv[0], c);
|
||||
#else
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
fprintf (stderr, "%s: option requires an argument -- %c\n",
|
||||
argv[0], c);
|
||||
#endif
|
||||
}
|
||||
optopt = c;
|
||||
if (optstring[0] == ':')
|
||||
c = ':';
|
||||
else
|
||||
c = BAD_OPTION;
|
||||
}
|
||||
else
|
||||
/* We already incremented `optind' once;
|
||||
increment it again when taking next ARGV-elt as argument. */
|
||||
optarg = argv[optind++];
|
||||
nextchar = NULL;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
int getopt (int argc, char *const *argv, const char *optstring) {
|
||||
return _getopt_internal (argc, argv, optstring,
|
||||
(const struct option *) 0,
|
||||
(int *) 0,
|
||||
0);
|
||||
}
|
||||
|
||||
int getopt_long(int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index) {
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
||||
}
|
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
/* Compile with -DTEST to make an executable for use in testing
|
||||
the above definition of `getopt'. */
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
|
||||
c = getopt (argc, argv, "abc:d:0123456789");
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case BAD_OPTION:
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
@@ -0,0 +1,130 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
|
||||
This program 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, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
#define _GETOPT_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MacOSX__
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns EOF, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
#endif
|
||||
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
#if __STDC__
|
||||
const char *name;
|
||||
#else
|
||||
char *name;
|
||||
#endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
//#if __STDC__ || defined(PROTO)
|
||||
#if defined(__GNU_LIBRARY__)
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
||||
#endif /* not __GNU_LIBRARY__ */
|
||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
extern int getopt_long_only (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int _getopt_internal (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind,
|
||||
int long_only);
|
||||
//#else /* not __STDC__ */
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
||||
//extern int getopt_long ();
|
||||
//extern int getopt_long_only ();
|
||||
|
||||
//extern int _getopt_internal ();
|
||||
//#endif /* not __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GETOPT_H */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
MP4 input module
|
||||
|
||||
Copyright (C) 2017 Krzysztof Nikiel
|
||||
|
||||
This program 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t len;
|
||||
uint32_t offset;
|
||||
} frame_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t firstchunk;
|
||||
uint32_t samplesperchunk;
|
||||
} slice_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ctime, mtime;
|
||||
uint32_t samplerate;
|
||||
// total sound samples
|
||||
uint32_t samples;
|
||||
uint32_t channels;
|
||||
// sample depth
|
||||
uint32_t bits;
|
||||
// buffer config
|
||||
uint32_t buffersize;
|
||||
uint32_t bitratemax;
|
||||
uint32_t bitrateavg;
|
||||
// frame size / offsets
|
||||
struct
|
||||
{
|
||||
frame_info_t *info;
|
||||
slice_info_t *map;
|
||||
uint32_t nsamples;
|
||||
uint32_t nsclices;
|
||||
uint32_t current;
|
||||
uint32_t maxsize;
|
||||
} frame;
|
||||
// AudioSpecificConfig data:
|
||||
struct
|
||||
{
|
||||
uint8_t buf[10];
|
||||
uint32_t size;
|
||||
} asc;
|
||||
struct {
|
||||
uint32_t size;
|
||||
uint8_t *data;
|
||||
} bitbuf;
|
||||
struct {
|
||||
int header;
|
||||
int tags;
|
||||
} verbose;
|
||||
} mp4config_t;
|
||||
|
||||
extern mp4config_t mp4config;
|
||||
|
||||
int mp4read_open(char *name);
|
||||
int mp4read_seek(uint32_t framenum);
|
||||
int mp4read_frame(void);
|
||||
int mp4read_close(void);
|
||||
@@ -0,0 +1,172 @@
|
||||
/* Copyright (c) 2004-2012 LoRd_MuldeR <mulder2@gmx.de>
|
||||
File: unicode_support.c
|
||||
|
||||
This file was originally part of a patch included with LameXP,
|
||||
released under the same license as the original audio tools.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
|
||||
|
||||
#include "unicode_support.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
#include <io.h>
|
||||
|
||||
static UINT g_old_output_cp = ((UINT)-1);
|
||||
|
||||
static char *utf16_to_utf8(const wchar_t *input)
|
||||
{
|
||||
char *Buffer;
|
||||
int BuffSize = 0, Result = 0;
|
||||
|
||||
BuffSize = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL);
|
||||
Buffer = (char*) malloc(sizeof(char) * BuffSize);
|
||||
if(Buffer)
|
||||
{
|
||||
Result = WideCharToMultiByte(CP_UTF8, 0, input, -1, Buffer, BuffSize, NULL, NULL);
|
||||
}
|
||||
|
||||
return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
|
||||
}
|
||||
|
||||
static wchar_t *utf8_to_utf16(const char *input)
|
||||
{
|
||||
wchar_t *Buffer;
|
||||
int BuffSize = 0, Result = 0;
|
||||
|
||||
BuffSize = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0);
|
||||
Buffer = (wchar_t*) malloc(sizeof(wchar_t) * BuffSize);
|
||||
if(Buffer)
|
||||
{
|
||||
Result = MultiByteToWideChar(CP_UTF8, 0, input, -1, Buffer, BuffSize);
|
||||
}
|
||||
|
||||
return ((Result > 0) && (Result <= BuffSize)) ? Buffer : NULL;
|
||||
}
|
||||
|
||||
void init_commandline_arguments_utf8(int *argc, char ***argv)
|
||||
{
|
||||
int i, nArgs;
|
||||
LPWSTR *szArglist;
|
||||
|
||||
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
|
||||
|
||||
if(NULL == szArglist)
|
||||
{
|
||||
fprintf(stderr, "\nFATAL: CommandLineToArgvW failed\n\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
*argv = (char**) malloc(sizeof(char*) * nArgs);
|
||||
*argc = nArgs;
|
||||
|
||||
if(NULL == *argv)
|
||||
{
|
||||
fprintf(stderr, "\nFATAL: Malloc failed\n\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for(i = 0; i < nArgs; i++)
|
||||
{
|
||||
(*argv)[i] = utf16_to_utf8(szArglist[i]);
|
||||
if(NULL == (*argv)[i])
|
||||
{
|
||||
fprintf(stderr, "\nFATAL: utf16_to_utf8 failed\n\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
LocalFree(szArglist);
|
||||
}
|
||||
|
||||
void free_commandline_arguments_utf8(int *argc, char ***argv)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if(*argv != NULL)
|
||||
{
|
||||
for(i = 0; i < *argc; i++)
|
||||
{
|
||||
if((*argv)[i] != NULL)
|
||||
{
|
||||
free((*argv)[i]);
|
||||
(*argv)[i] = NULL;
|
||||
}
|
||||
}
|
||||
free(*argv);
|
||||
*argv = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
FILE *faad_fopen(const char *filename, const char *mode)
|
||||
{
|
||||
FILE *ret = NULL;
|
||||
wchar_t *filename_utf16 = utf8_to_utf16(filename);
|
||||
wchar_t *mode_utf16 = utf8_to_utf16(mode);
|
||||
|
||||
if(filename_utf16 && mode_utf16)
|
||||
{
|
||||
ret = _wfopen(filename_utf16, mode_utf16);
|
||||
}
|
||||
|
||||
if(filename_utf16) free(filename_utf16);
|
||||
if(mode_utf16) free(mode_utf16);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void init_console_utf8(FILE *const stream)
|
||||
{
|
||||
if (_isatty(_fileno(stream)))
|
||||
{
|
||||
g_old_output_cp = GetConsoleOutputCP();
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
}
|
||||
}
|
||||
|
||||
void uninit_console_utf8(void)
|
||||
{
|
||||
if(g_old_output_cp != ((UINT)-1))
|
||||
{
|
||||
SetConsoleOutputCP(g_old_output_cp);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
FILE *faad_fopen(const char *filename, const char *mode)
|
||||
{
|
||||
return fopen(filename, mode);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
/* Copyright (c) 2004-2012 LoRd_MuldeR <mulder2@gmx.de>
|
||||
File: unicode_support.h
|
||||
|
||||
This file was originally part of a patch included with LameXP,
|
||||
released under the same license as the original audio tools.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef UNICODE_SUPPORT_H_INCLUDED
|
||||
#define UNICODE_SUPPORT_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
|
||||
void init_commandline_arguments_utf8(int *argc, char ***argv);
|
||||
void free_commandline_arguments_utf8(int *argc, char ***argv);
|
||||
void init_console_utf8(FILE *const stream);
|
||||
void uninit_console_utf8(void);
|
||||
#endif
|
||||
|
||||
FILE *faad_fopen(const char *filename, const char *mode);
|
||||
|
||||
#endif //UNICODE_SUPPORT_H_INCLUDED
|
||||
Reference in New Issue
Block a user