1
0
mirror of https://github.com/nu774/fdkaac.git synced 2025-06-05 23:29:14 +02:00

9 Commits

Author SHA1 Message Date
33e12bc4f5 bump version 2013-01-17 17:12:06 +09:00
bfb6aa3cb8 compat_win32: free argv with atexit() 2013-01-17 17:11:19 +09:00
360cf7dc8b take care of COPYRIGHT-SIGN in UTF-8 2013-01-17 17:10:21 +09:00
43ab433178 bump version 2013-01-15 21:20:18 +09:00
47c164c85a fix return type of put_type_entry() to void 2013-01-15 21:19:32 +09:00
d52b8bbf13 add ADTS header size(7) to output byte length 2013-01-15 21:18:31 +09:00
f67cfe227e fix mp4 duration & version calcuration 2013-01-13 00:58:38 +09:00
e476728e77 add support for xid 2013-01-11 22:17:28 +09:00
dac71de305 support for i686-pc-mingw32 (missing _vscprintf) 2013-01-11 17:33:54 +09:00
6 changed files with 55 additions and 19 deletions

View File

@ -32,7 +32,7 @@ AC_CHECK_TYPES([ptrdiff_t])
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
AC_CHECK_FUNCS([gettimeofday nl_langinfo strdup])
AC_CHECK_FUNCS([gettimeofday nl_langinfo strdup _vscprintf])
AC_CHECK_FUNC(getopt_long)
AM_CONDITIONAL([FDK_NO_GETOPT_LONG],[test "$ac_cv_func_getopt_long" != "yes"])
AC_SEARCH_LIBS([aacEncOpen],[fdk-aac],[],[],[])

View File

@ -142,7 +142,7 @@ int aac_encode_frame(HANDLE_AACENCODER encoder,
unsigned channel_mode, obytes;
channel_mode = aacEncoder_GetParam(encoder, AACENC_CHANNELMODE);
obytes = 6144 / 8 * channel_mode;
obytes = 6144 / 8 * channel_mode + 7;
if (!*output || *osize < obytes) {
*osize = obytes;
*output = realloc(*output, obytes);

View File

@ -12,6 +12,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#include <io.h>
#include <fcntl.h>
#include <sys/timeb.h>
@ -74,6 +75,17 @@ FILE *aacenc_fopen(const char *name, const char *mode)
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)
{
int i;
@ -85,6 +97,8 @@ void aacenc_getmainargs(int *argc, char ***argv)
for (i = 0; i < *argc; ++i)
codepage_encode_wchar(CP_UTF8, wargv[i], &(*argv)[i]);
(*argv)[*argc] = 0;
__aacenc_argv__ = *argv;
atexit(aacenc_free_mainargs);
}
char *aacenc_to_utf8(const char *s)
@ -92,6 +106,20 @@ char *aacenc_to_utf8(const char *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, ...)
{
va_list ap;

View File

@ -515,15 +515,6 @@ void m4af_update_size(m4af_writer_t *ctx, int64_t 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
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];
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, &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];
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, &version, 1);
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_write(ctx, "\0\0\0\0" /* reserved */
, 4);
m4af_write64(ctx, track->duration);
m4af_write64(ctx, duration);
} else {
m4af_write32(ctx, track->creation_time);
m4af_write32(ctx, track->modification_time);
m4af_write32(ctx, track_idx + 1);
m4af_write(ctx, "\0\0\0\0" /* reserved */
, 4);
m4af_write32(ctx, track->duration);
m4af_write32(ctx, duration);
}
m4af_write(ctx,
"\0\0\0\0" /* reserved[0] */
@ -956,7 +953,7 @@ int64_t m4af_movie_duration(m4af_writer_t *ctx)
unsigned i;
for (i = 0; i < ctx->num_tracks; ++i) {
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)
movie_duration = duration;
}
@ -967,8 +964,10 @@ static
void m4af_mvhd_box(m4af_writer_t *ctx)
{
int64_t pos = m4af_tell(ctx);
uint8_t version = m4af_head_version(ctx, 0);
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, &version, 1);

View File

@ -357,6 +357,14 @@ int parse_options(int argc, char **argv, aacenc_param_ex_t *params)
}
*val++ = '\0';
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)
fcc = 0xa9;
else if (klen != 4) {
@ -470,7 +478,7 @@ END:
}
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;
@ -567,6 +575,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','n','n'):
case M4AF_FOURCC('t','v','s','h'):
case M4AF_FOURCC('x','i','d',' '):
case M4AF_FOURCC('\xa9','e','n','c'):
case M4AF_FOURCC('\xa9','s','t','3'):
{

View File

@ -1,4 +1,4 @@
#ifndef VERSION_H
#define VERSION_H
const char *fdkaac_version = "0.0.9";
const char *fdkaac_version = "0.1.2";
#endif