mirror of
https://github.com/nu774/fdkaac.git
synced 2025-06-05 23:29:14 +02:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
5af13f7d79 | |||
5c534696a9 | |||
33e12bc4f5 | |||
bfb6aa3cb8 | |||
360cf7dc8b | |||
43ab433178 | |||
47c164c85a | |||
d52b8bbf13 | |||
f67cfe227e | |||
e476728e77 | |||
dac71de305 |
@ -32,7 +32,7 @@ AC_CHECK_TYPES([ptrdiff_t])
|
|||||||
|
|
||||||
AC_SYS_LARGEFILE
|
AC_SYS_LARGEFILE
|
||||||
AC_FUNC_FSEEKO
|
AC_FUNC_FSEEKO
|
||||||
AC_CHECK_FUNCS([gettimeofday nl_langinfo strdup])
|
AC_CHECK_FUNCS([gettimeofday nl_langinfo strdup _vscprintf])
|
||||||
AC_CHECK_FUNC(getopt_long)
|
AC_CHECK_FUNC(getopt_long)
|
||||||
AM_CONDITIONAL([FDK_NO_GETOPT_LONG],[test "$ac_cv_func_getopt_long" != "yes"])
|
AM_CONDITIONAL([FDK_NO_GETOPT_LONG],[test "$ac_cv_func_getopt_long" != "yes"])
|
||||||
AC_SEARCH_LIBS([aacEncOpen],[fdk-aac],[],[],[])
|
AC_SEARCH_LIBS([aacEncOpen],[fdk-aac],[],[],[])
|
||||||
|
@ -142,7 +142,7 @@ int aac_encode_frame(HANDLE_AACENCODER encoder,
|
|||||||
unsigned channel_mode, obytes;
|
unsigned channel_mode, obytes;
|
||||||
|
|
||||||
channel_mode = aacEncoder_GetParam(encoder, AACENC_CHANNELMODE);
|
channel_mode = aacEncoder_GetParam(encoder, AACENC_CHANNELMODE);
|
||||||
obytes = 6144 / 8 * channel_mode;
|
obytes = 6144 / 8 * channel_mode + 7;
|
||||||
if (!*output || *osize < obytes) {
|
if (!*output || *osize < obytes) {
|
||||||
*osize = obytes;
|
*osize = obytes;
|
||||||
*output = realloc(*output, obytes);
|
*output = realloc(*output, obytes);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
@ -74,6 +75,17 @@ FILE *aacenc_fopen(const char *name, const char *mode)
|
|||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char **__aacenc_argv__;
|
||||||
|
|
||||||
|
static
|
||||||
|
void aacenc_free_mainargs(void)
|
||||||
|
{
|
||||||
|
char **p = __aacenc_argv__;
|
||||||
|
for (; *p; ++p)
|
||||||
|
free(*p);
|
||||||
|
free(__aacenc_argv__);
|
||||||
|
}
|
||||||
|
|
||||||
void aacenc_getmainargs(int *argc, char ***argv)
|
void aacenc_getmainargs(int *argc, char ***argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -85,6 +97,8 @@ void aacenc_getmainargs(int *argc, char ***argv)
|
|||||||
for (i = 0; i < *argc; ++i)
|
for (i = 0; i < *argc; ++i)
|
||||||
codepage_encode_wchar(CP_UTF8, wargv[i], &(*argv)[i]);
|
codepage_encode_wchar(CP_UTF8, wargv[i], &(*argv)[i]);
|
||||||
(*argv)[*argc] = 0;
|
(*argv)[*argc] = 0;
|
||||||
|
__aacenc_argv__ = *argv;
|
||||||
|
atexit(aacenc_free_mainargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *aacenc_to_utf8(const char *s)
|
char *aacenc_to_utf8(const char *s)
|
||||||
@ -92,6 +106,20 @@ char *aacenc_to_utf8(const char *s)
|
|||||||
return _strdup(s);
|
return _strdup(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__MINGW32__) && !defined(HAVE__VSCPRINTF)
|
||||||
|
int _vscprintf(const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
static int (*fp_vscprintf)(const char *, va_list) = 0;
|
||||||
|
if (!fp_vscprintf) {
|
||||||
|
HANDLE h = GetModuleHandleA("msvcrt.dll");
|
||||||
|
FARPROC fp = GetProcAddress(h, "_vscprintf");
|
||||||
|
InterlockedCompareExchangePointer(&fp_vscprintf, fp, 0);
|
||||||
|
}
|
||||||
|
assert(fp_vscprintf);
|
||||||
|
return fp_vscprintf(fmt, ap);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int aacenc_fprintf(FILE *fp, const char *fmt, ...)
|
int aacenc_fprintf(FILE *fp, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
29
src/m4af.c
29
src/m4af.c
@ -515,15 +515,6 @@ void m4af_update_size(m4af_writer_t *ctx, int64_t pos)
|
|||||||
m4af_set_pos(ctx, current_pos);
|
m4af_set_pos(ctx, current_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
int m4af_head_version(m4af_writer_t *ctx, int track_idx)
|
|
||||||
{
|
|
||||||
m4af_track_t *track = &ctx->track[track_idx];
|
|
||||||
return track->duration > UINT32_MAX
|
|
||||||
|| track->creation_time > UINT32_MAX
|
|
||||||
|| track->modification_time > UINT32_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void m4af_descriptor(m4af_writer_t *ctx, uint32_t tag, uint32_t size)
|
void m4af_descriptor(m4af_writer_t *ctx, uint32_t tag, uint32_t size)
|
||||||
{
|
{
|
||||||
@ -835,7 +826,9 @@ void m4af_mdhd_box(m4af_writer_t *ctx, int track_idx)
|
|||||||
{
|
{
|
||||||
m4af_track_t *track = &ctx->track[track_idx];
|
m4af_track_t *track = &ctx->track[track_idx];
|
||||||
int64_t pos = m4af_tell(ctx);
|
int64_t pos = m4af_tell(ctx);
|
||||||
uint8_t version = m4af_head_version(ctx, track_idx);
|
uint8_t version = (track->creation_time > UINT32_MAX ||
|
||||||
|
track->modification_time > UINT32_MAX ||
|
||||||
|
track->duration > UINT32_MAX);
|
||||||
|
|
||||||
m4af_write(ctx, "\0\0\0\0mdhd", 8);
|
m4af_write(ctx, "\0\0\0\0mdhd", 8);
|
||||||
m4af_write(ctx, &version, 1);
|
m4af_write(ctx, &version, 1);
|
||||||
@ -898,7 +891,11 @@ void m4af_tkhd_box(m4af_writer_t *ctx, int track_idx)
|
|||||||
{
|
{
|
||||||
m4af_track_t *track = &ctx->track[track_idx];
|
m4af_track_t *track = &ctx->track[track_idx];
|
||||||
int64_t pos = m4af_tell(ctx);
|
int64_t pos = m4af_tell(ctx);
|
||||||
uint8_t version = m4af_head_version(ctx, track_idx);
|
int64_t duration =
|
||||||
|
(double)track->duration / track->timescale * ctx->timescale + .5;
|
||||||
|
uint8_t version = (track->creation_time > UINT32_MAX ||
|
||||||
|
track->modification_time > UINT32_MAX ||
|
||||||
|
duration > UINT32_MAX);
|
||||||
m4af_write(ctx, "\0\0\0\0tkhd", 8);
|
m4af_write(ctx, "\0\0\0\0tkhd", 8);
|
||||||
m4af_write(ctx, &version, 1);
|
m4af_write(ctx, &version, 1);
|
||||||
m4af_write(ctx, "\0\0\007", 3); /* flags */
|
m4af_write(ctx, "\0\0\007", 3); /* flags */
|
||||||
@ -908,14 +905,14 @@ void m4af_tkhd_box(m4af_writer_t *ctx, int track_idx)
|
|||||||
m4af_write32(ctx, track_idx + 1);
|
m4af_write32(ctx, track_idx + 1);
|
||||||
m4af_write(ctx, "\0\0\0\0" /* reserved */
|
m4af_write(ctx, "\0\0\0\0" /* reserved */
|
||||||
, 4);
|
, 4);
|
||||||
m4af_write64(ctx, track->duration);
|
m4af_write64(ctx, duration);
|
||||||
} else {
|
} else {
|
||||||
m4af_write32(ctx, track->creation_time);
|
m4af_write32(ctx, track->creation_time);
|
||||||
m4af_write32(ctx, track->modification_time);
|
m4af_write32(ctx, track->modification_time);
|
||||||
m4af_write32(ctx, track_idx + 1);
|
m4af_write32(ctx, track_idx + 1);
|
||||||
m4af_write(ctx, "\0\0\0\0" /* reserved */
|
m4af_write(ctx, "\0\0\0\0" /* reserved */
|
||||||
, 4);
|
, 4);
|
||||||
m4af_write32(ctx, track->duration);
|
m4af_write32(ctx, duration);
|
||||||
}
|
}
|
||||||
m4af_write(ctx,
|
m4af_write(ctx,
|
||||||
"\0\0\0\0" /* reserved[0] */
|
"\0\0\0\0" /* reserved[0] */
|
||||||
@ -956,7 +953,7 @@ int64_t m4af_movie_duration(m4af_writer_t *ctx)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < ctx->num_tracks; ++i) {
|
for (i = 0; i < ctx->num_tracks; ++i) {
|
||||||
double x = ctx->track[i].duration;
|
double x = ctx->track[i].duration;
|
||||||
int64_t duration = x * ctx->track[i].timescale / ctx->timescale + .5;
|
int64_t duration = x / ctx->track[i].timescale * ctx->timescale + .5;
|
||||||
if (duration > movie_duration)
|
if (duration > movie_duration)
|
||||||
movie_duration = duration;
|
movie_duration = duration;
|
||||||
}
|
}
|
||||||
@ -967,8 +964,10 @@ static
|
|||||||
void m4af_mvhd_box(m4af_writer_t *ctx)
|
void m4af_mvhd_box(m4af_writer_t *ctx)
|
||||||
{
|
{
|
||||||
int64_t pos = m4af_tell(ctx);
|
int64_t pos = m4af_tell(ctx);
|
||||||
uint8_t version = m4af_head_version(ctx, 0);
|
|
||||||
int64_t movie_duration = m4af_movie_duration(ctx);
|
int64_t movie_duration = m4af_movie_duration(ctx);
|
||||||
|
uint8_t version = (ctx->creation_time > UINT32_MAX ||
|
||||||
|
ctx->modification_time > UINT32_MAX ||
|
||||||
|
movie_duration > UINT32_MAX);
|
||||||
|
|
||||||
m4af_write(ctx, "\0\0\0\0mvhd", 8);
|
m4af_write(ctx, "\0\0\0\0mvhd", 8);
|
||||||
m4af_write(ctx, &version, 1);
|
m4af_write(ctx, &version, 1);
|
||||||
|
16
src/main.c
16
src/main.c
@ -108,7 +108,7 @@ PROGNAME " %s\n"
|
|||||||
" transport layer\n"
|
" transport layer\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -o <filename> Output filename\n"
|
" -o <filename> Output filename\n"
|
||||||
" --ignore-length Ignore length of WAV header\n"
|
" --ignorelength Ignore length of WAV header\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options for raw (headerless) input:\n"
|
"Options for raw (headerless) input:\n"
|
||||||
" -R, --raw Treat input as raw (by default WAV is\n"
|
" -R, --raw Treat input as raw (by default WAV is\n"
|
||||||
@ -212,7 +212,7 @@ int parse_options(int argc, char **argv, aacenc_param_ex_t *params)
|
|||||||
{ "adts-crc-check", no_argument, 0, 'C' },
|
{ "adts-crc-check", no_argument, 0, 'C' },
|
||||||
{ "header-period", required_argument, 0, 'P' },
|
{ "header-period", required_argument, 0, 'P' },
|
||||||
|
|
||||||
{ "ignore-length", no_argument, 0, 'I' },
|
{ "ignorelength", no_argument, 0, 'I' },
|
||||||
|
|
||||||
{ "raw", no_argument, 0, 'R' },
|
{ "raw", no_argument, 0, 'R' },
|
||||||
{ "raw-channels", required_argument, 0, OPT_RAW_CHANNELS },
|
{ "raw-channels", required_argument, 0, OPT_RAW_CHANNELS },
|
||||||
@ -233,6 +233,7 @@ int parse_options(int argc, char **argv, aacenc_param_ex_t *params)
|
|||||||
{ "tempo", required_argument, 0, M4AF_TAG_TEMPO },
|
{ "tempo", required_argument, 0, M4AF_TAG_TEMPO },
|
||||||
{ "tag", required_argument, 0, OPT_SHORT_TAG },
|
{ "tag", required_argument, 0, OPT_SHORT_TAG },
|
||||||
{ "long-tag", required_argument, 0, OPT_LONG_TAG },
|
{ "long-tag", required_argument, 0, OPT_LONG_TAG },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
params->afterburner = 1;
|
params->afterburner = 1;
|
||||||
|
|
||||||
@ -357,6 +358,14 @@ int parse_options(int argc, char **argv, aacenc_param_ex_t *params)
|
|||||||
}
|
}
|
||||||
*val++ = '\0';
|
*val++ = '\0';
|
||||||
if (ch == OPT_SHORT_TAG) {
|
if (ch == OPT_SHORT_TAG) {
|
||||||
|
/*
|
||||||
|
* take care of U+00A9(COPYRIGHT SIGN).
|
||||||
|
* 1) if length of fcc is 3, we prepend '\xa9'.
|
||||||
|
* 2) U+00A9 becomes "\xc2\xa9" in UTF-8. Therefore
|
||||||
|
* we remove first '\xc2'.
|
||||||
|
*/
|
||||||
|
if (optarg[0] == '\xc2')
|
||||||
|
++optarg;
|
||||||
if ((klen = strlen(optarg))== 3)
|
if ((klen = strlen(optarg))== 3)
|
||||||
fcc = 0xa9;
|
fcc = 0xa9;
|
||||||
else if (klen != 4) {
|
else if (klen != 4) {
|
||||||
@ -470,7 +479,7 @@ END:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int put_tag_entry(m4af_writer_t *m4af, const aacenc_tag_entry_t *tag)
|
void put_tag_entry(m4af_writer_t *m4af, const aacenc_tag_entry_t *tag)
|
||||||
{
|
{
|
||||||
unsigned m, n = 0;
|
unsigned m, n = 0;
|
||||||
|
|
||||||
@ -567,6 +576,7 @@ int put_tag_entry(m4af_writer_t *m4af, const aacenc_tag_entry_t *tag)
|
|||||||
case M4AF_FOURCC('t','v','e','n'):
|
case M4AF_FOURCC('t','v','e','n'):
|
||||||
case M4AF_FOURCC('t','v','n','n'):
|
case M4AF_FOURCC('t','v','n','n'):
|
||||||
case M4AF_FOURCC('t','v','s','h'):
|
case M4AF_FOURCC('t','v','s','h'):
|
||||||
|
case M4AF_FOURCC('x','i','d',' '):
|
||||||
case M4AF_FOURCC('\xa9','e','n','c'):
|
case M4AF_FOURCC('\xa9','e','n','c'):
|
||||||
case M4AF_FOURCC('\xa9','s','t','3'):
|
case M4AF_FOURCC('\xa9','s','t','3'):
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user