Commit bf769906 authored by Warren Dukes's avatar Warren Dukes

import mp4ff, since its not installed correctly by faad2

git-svn-id: https://svn.musicpd.org/mpd/trunk@265 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent f114fbd4
......@@ -9,8 +9,11 @@ retrieval, and playlist management can all be managed remotely.
To install MPD, see INSTALL.
MPD includes 2 libraries in the source. libid3tag and libmad are released under
MPD includes 3 libraries in the source. libid3tag and libmad are released under
the GPL and copyrighted by Robert Leslie (http://www.underbit.com/products/mad).
mp4ff is released under the GPL and copyrighted by M. Bakker, Ahead Software AG
(http://www.nero.com) and is distributed as a part of the FAAD2 - Freeware
Advance Audio (AAC) Decoder.
MPD is released under the GNU Public License.
You should have received a copy of the GNU General Public License
......
......@@ -17,6 +17,8 @@ AC_SUBST(MAD_SUBDIR)
AC_SUBST(MAD_LIB)
AC_SUBST(ID3_SUBDIR)
AC_SUBST(ID3_LIB)
AC_SUBST(MP4FF_SUBDIR)
AC_SUBST(MP4FF_LIB)
AC_SUBST(MPD_LIBS)
AC_SUBST(MPD_CFLAGS)
......@@ -42,9 +44,9 @@ AC_ARG_WITH(mad,[ --with-mad=PFX Prefix where libmad is installed (optional)]
AC_ARG_WITH(mad-libraries,[ --with-mad-libraries=DIR Directory where libmad library is installed (optional)], mad_libraries="$withval", mad_libraries="")
AC_ARG_WITH(mad-includes,[ --with-mad-includes=DIR Directory where mad header files are installed (optional)], mad_includes="$withval", mad_includes="")
AC_ARG_WITH(faad,[ --with-faad=PFX Prefix where faad lib is installed (optional)], faad_prefix="$withval", faad_prefix="")
AC_ARG_WITH(faad-libraries,[ --with-faad-libraries=DIR Directory where faad library is installed (optional)], faad_libraries="$withval", faad_libraries="")
AC_ARG_WITH(faad-includes,[ --with-faad-includes=DIR Directory where faad header files are installed (optional)], faad_includes="$withval", faad_includes="")
AC_ARG_WITH(faad2,[ --with-faad2=PFX Prefix where faad2 is installed (optional)], faad_prefix="$withval", faad_prefix="")
AC_ARG_WITH(faad2-libraries,[ --with-faad-libraries=DIR Directory where faad2 library is installed (optional)], faad_libraries="$withval", faad_libraries="")
AC_ARG_WITH(faad2-includes,[ --with-faad-includes=DIR Directory where faad2 header files are installed (optional)], faad_includes="$withval", faad_includes="")
AC_C_BIGENDIAN
......@@ -195,6 +197,8 @@ if test x$enable_mp3 = xyes; then
MPD_CFLAGS="$MPD_CFLAGS -DHAVE_MAD"
fi
MP4FF_SUBDIR=""
if test x$enable_aac = xyes; then
if test "x$faad_libraries" != "x" ; then
FAAD_LIBS="-L$faad_libraries"
......@@ -204,7 +208,7 @@ if test x$enable_aac = xyes; then
FAAD_LIBS="-L$libdir"
fi
FAAD_LIBS="$FAAD_LIBS -lfaad"
FAAD_LIBS="$FAAD_LIBS -lfaad -lmp4v2"
if test "x$faad_includes" != "x" ; then
FAAD_CFLAGS="-I$faad_includes"
......@@ -220,7 +224,16 @@ if test x$enable_aac = xyes; then
LIBS="$LIBS $MPD_LIBS $FAAD_LIBS"
AC_CHECK_HEADER(faad.h,,enable_aac=no)
if test x$enable_aac = xyes; then
AC_CHECK_LIB(faad, faacDecDecode,[MPD_LIBS="$MPD_LIBS $FAAD_LIBS";MPD_CFLAGS="$MPD_CFLAGS $FAAD_CFLAGS -DHAVE_FAAD"],enable_aac=no)
AC_CHECK_HEADER(mp4.h,,enable_aac=no)
fi
if test x$enable_aac = xyes; then
AC_CHECK_LIB(mp4v2, MP4Create,,enable_aac=no)
fi
if test x$enable_aac = xyes; then
AC_CHECK_LIB(mp4v2, MP4MetadataDelete,,enable_aac=no)
fi
if test x$enable_aac = xyes; then
AC_CHECK_LIB(faad, faacDecDecode,[MPD_LIBS="$MPD_LIBS $FAAD_LIBS";MPD_CFLAGS="$MPD_CFLAGS $FAAD_CFLAGS -DHAVE_FAAD";MP4FF_SUBDIR="mp4ff";MP4FF_LIB="mp4ff/libmp4ff.la"],enable_aac=no)
fi
CFLAGS=$oldcflags
LIBS=$oldlibs
......@@ -320,4 +333,4 @@ if test x$enable_audiofile = xyes; then
[enable_audiofile=no;AC_MSG_WARN(You need audiofile -- disabling audiofile support)])
fi
AC_OUTPUT(doc/Makefile src/Makefile Makefile )
AC_OUTPUT(src/mp4ff/Makefile doc/Makefile src/Makefile Makefile )
bin_PROGRAMS = mpd
SUBDIRS = $(ID3_SUBDIR) $(MAD_SUBDIR)
SUBDIRS = $(ID3_SUBDIR) $(MAD_SUBDIR) $(MP4FF_SUBDIR)
mpd_headers = buffer2array.h interface.h command.h playlist.h ls.h \
song.h list.h directory.h tables.h utils.h path.h mp3_decode.h \
tag.h player.h listen.h conf.h ogg_decode.h volume.h flac_decode.h \
......@@ -12,4 +12,4 @@ mpd_SOURCES = main.c buffer2array.c interface.c command.c playlist.c ls.c \
audiofile_decode.c charConv.c permission.c pcm_utils.c $(mpd_headers)
mpd_CFLAGS = $(MPD_CFLAGS)
mpd_LDADD = $(MPD_LIBS) $(ID3_LIB) $(MAD_LIB)
mpd_LDADD = $(MPD_LIBS) $(ID3_LIB) $(MAD_LIB) $(MP4FF_LIB)
noinst_LTLIBRARIES = libmp4ff.la
noinst_HEADERS = mp4ff.h
libmp4ff_la_SOURCES = mp4ff.c mp4atom.c mp4meta.c mp4sample.c mp4util.c \
mp4tagupdate.c mp4ff.h mp4ffint.h mp4ff_int_types.h \
drms.h drms.c drmstables.h
/*****************************************************************************
* drms.h : DRMS
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: drms.h,v 1.3 2004/01/11 15:52:18 menno Exp $
*
* Author: Jon Lech Johansen <jon-vl@nanocrew.net>
*
* 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, USA.
*****************************************************************************/
#define DRMS_INIT_UKEY 0
#define DRMS_INIT_IVIV 1
#define DRMS_INIT_NAME 2
#define DRMS_INIT_PRIV 3
extern int drms_get_sys_key( uint32_t *p_sys_key );
extern int drms_get_user_key( uint32_t *p_sys_key,
uint32_t *p_user_key );
extern void *drms_alloc();
extern void drms_free( void *p_drms );
extern int drms_init( void *p_drms, uint32_t i_type,
uint8_t *p_info, uint32_t i_len );
extern void drms_decrypt( void *p_drms, uint32_t *p_buffer,
uint32_t i_len );
# Microsoft Developer Studio Project File - Name="mp4ff" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=mp4ff - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "mp4ff.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "mp4ff.mak" CFG="mp4ff - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "mp4ff - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "mp4ff - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "mp4ff - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
F90=df.exe
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_TAGGING" /YX /FD /c
# ADD BASE RSC /l 0x413 /d "NDEBUG"
# ADD RSC /l 0x413 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=xilink6.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "mp4ff - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
F90=df.exe
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_TAGGING" /YX /FD /GZ /c
# ADD BASE RSC /l 0x413 /d "_DEBUG"
# ADD RSC /l 0x413 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=xilink6.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "mp4ff - Win32 Release"
# Name "mp4ff - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\drms.c
# End Source File
# Begin Source File
SOURCE=.\mp4atom.c
# End Source File
# Begin Source File
SOURCE=.\mp4ff.c
# End Source File
# Begin Source File
SOURCE=.\mp4meta.c
# End Source File
# Begin Source File
SOURCE=.\mp4sample.c
# End Source File
# Begin Source File
SOURCE=.\mp4tagupdate.c
# End Source File
# Begin Source File
SOURCE=.\mp4util.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\drms.h
# End Source File
# Begin Source File
SOURCE=.\drmstables.h
# End Source File
# Begin Source File
SOURCE=.\mp4ff.h
# End Source File
# Begin Source File
SOURCE=.\mp4ff_int_types.h
# End Source File
# Begin Source File
SOURCE=.\mp4ffint.h
# End Source File
# End Group
# End Target
# End Project
/*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
** Copyright (C) 2003-2004 M. Bakker, Ahead Software 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.
**
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** $Id: mp4ff.h,v 1.19 2004/01/11 15:52:18 menno Exp $
**/
#ifndef MP4FF_H
#define MP4FF_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "mp4ff_int_types.h"
/* file callback structure */
typedef struct
{
uint32_t (*read)(void *user_data, void *buffer, uint32_t length);
uint32_t (*write)(void *udata, void *buffer, uint32_t length);
uint32_t (*seek)(void *user_data, uint64_t position);
uint32_t (*truncate)(void *user_data);
void *user_data;
} mp4ff_callback_t;
/* mp4 main file structure */
typedef void* mp4ff_t;
/* API */
mp4ff_t *mp4ff_open_read(mp4ff_callback_t *f);
void mp4ff_close(mp4ff_t *f);
int32_t mp4ff_get_sample_duration(const mp4ff_t *f, const int32_t track, const int32_t sample);
int32_t mp4ff_get_sample_duration_use_offsets(const mp4ff_t *f, const int32_t track, const int32_t sample);
int64_t mp4ff_get_sample_position(const mp4ff_t *f, const int32_t track, const int32_t sample);
int32_t mp4ff_get_sample_offset(const mp4ff_t *f, const int32_t track, const int32_t sample);
int32_t mp4ff_find_sample(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip);
int32_t mp4ff_find_sample_use_offsets(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip);
int32_t mp4ff_read_sample(mp4ff_t *f, const int track, const int sample,
unsigned char **audio_buffer, unsigned int *bytes);
int32_t mp4ff_read_sample_v2(mp4ff_t *f, const int track, const int sample,unsigned char *buffer);//returns 0 on error, number of bytes read on success, use mp4ff_read_sample_getsize() to check buffer size needed
int32_t mp4ff_read_sample_getsize(mp4ff_t *f, const int track, const int sample);//returns 0 on error, buffer size needed for mp4ff_read_sample_v2() on success
int32_t mp4ff_get_decoder_config(const mp4ff_t *f, const int track,
unsigned char** ppBuf, unsigned int* pBufSize);
int32_t mp4ff_get_track_type(const mp4ff_t *f, const int track);
int32_t mp4ff_total_tracks(const mp4ff_t *f);
int32_t mp4ff_num_samples(const mp4ff_t *f, const int track);
int32_t mp4ff_time_scale(const mp4ff_t *f, const int track);
uint32_t mp4ff_get_avg_bitrate(const mp4ff_t *f, const int32_t track);
uint32_t mp4ff_get_max_bitrate(const mp4ff_t *f, const int32_t track);
int64_t mp4ff_get_track_duration(const mp4ff_t *f, const int32_t track); //returns (-1) if unknown
int64_t mp4ff_get_track_duration_use_offsets(const mp4ff_t *f, const int32_t track); //returns (-1) if unknown
uint32_t mp4ff_get_sample_rate(const mp4ff_t *f, const int32_t track);
uint32_t mp4ff_get_channel_count(const mp4ff_t * f,const int32_t track);
uint32_t mp4ff_get_audio_type(const mp4ff_t * f,const int32_t track);
/* metadata */
int mp4ff_meta_get_num_items(const mp4ff_t *f);
int mp4ff_meta_get_by_index(const mp4ff_t *f, unsigned int index,
char **item, char **value);
int mp4ff_meta_get_title(const mp4ff_t *f, char **value);
int mp4ff_meta_get_artist(const mp4ff_t *f, char **value);
int mp4ff_meta_get_writer(const mp4ff_t *f, char **value);
int mp4ff_meta_get_album(const mp4ff_t *f, char **value);
int mp4ff_meta_get_date(const mp4ff_t *f, char **value);
int mp4ff_meta_get_tool(const mp4ff_t *f, char **value);
int mp4ff_meta_get_comment(const mp4ff_t *f, char **value);
int mp4ff_meta_get_genre(const mp4ff_t *f, char **value);
int mp4ff_meta_get_track(const mp4ff_t *f, char **value);
int mp4ff_meta_get_disc(const mp4ff_t *f, char **value);
int mp4ff_meta_get_compilation(const mp4ff_t *f, char **value);
int mp4ff_meta_get_tempo(const mp4ff_t *f, char **value);
int32_t mp4ff_meta_get_coverart(const mp4ff_t *f, char **value);
#ifdef USE_TAGGING
/* metadata tag structure */
typedef struct
{
char *item;
char *value;
} mp4ff_tag_t;
/* metadata list structure */
typedef struct
{
mp4ff_tag_t *tags;
uint32_t count;
} mp4ff_metadata_t;
int32_t mp4ff_meta_update(mp4ff_callback_t *f,const mp4ff_metadata_t * data);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
\ No newline at end of file
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="mp4ff"
ProjectGUID="{F470BB4A-7675-4D6A-B310-41F33AC6F987}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="1"
InlineFunctionExpansion="1"
PreprocessorDefinitions="USE_TAGGING"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/mp4ff.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
Detect64BitPortabilityProblems="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
AdditionalOptions=""
OutputFile=".\Release\mp4ff.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1043"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="0"
PreprocessorDefinitions="USE_TAGGING"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/mp4ff.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
AdditionalOptions=""
OutputFile=".\Debug\mp4ff.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1043"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath=".\drms.c">
</File>
<File
RelativePath="mp4atom.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath="mp4ff.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath="mp4meta.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath="mp4sample.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath=".\mp4tagupdate.c">
</File>
<File
RelativePath="mp4util.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="1"
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=""
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath=".\drms.h">
</File>
<File
RelativePath=".\drmstables.h">
</File>
<File
RelativePath=".\mp4ff.h">
</File>
<File
RelativePath=".\mp4ff_int_types.h">
</File>
<File
RelativePath="mp4ffint.h">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
#ifndef _MP4FF_INT_TYPES_H_
#define _MP4FF_INT_TYPES_H_
#ifdef _WIN32
typedef char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef long int32_t;
typedef unsigned long uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
#endif
/*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
** Copyright (C) 2003-2004 M. Bakker, Ahead Software 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.
**
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** $Id: mp4sample.c,v 1.15 2004/01/11 15:52:19 menno Exp $
**/
#include <stdlib.h>
#include "mp4ffint.h"
static int32_t mp4ff_chunk_of_sample(const mp4ff_t *f, const int32_t track, const int32_t sample,
int32_t *chunk_sample, int32_t *chunk)
{
int32_t total_entries = 0;
int32_t chunk2entry;
int32_t chunk1, chunk2, chunk1samples, range_samples, total = 0;
if (f->track[track] == NULL)
{
return -1;
}
total_entries = f->track[track]->stsc_entry_count;
chunk1 = 1;
chunk1samples = 0;
chunk2entry = 0;
do
{
chunk2 = f->track[track]->stsc_first_chunk[chunk2entry];
*chunk = chunk2 - chunk1;
range_samples = *chunk * chunk1samples;
if (sample < total + range_samples) break;
chunk1samples = f->track[track]->stsc_samples_per_chunk[chunk2entry];
chunk1 = chunk2;
if(chunk2entry < total_entries)
{
chunk2entry++;
total += range_samples;
}
} while (chunk2entry < total_entries);
if (chunk1samples)
*chunk = (sample - total) / chunk1samples + chunk1;
else
*chunk = 1;
*chunk_sample = total + (*chunk - chunk1) * chunk1samples;
return 0;
}
static int32_t mp4ff_chunk_to_offset(const mp4ff_t *f, const int32_t track, const int32_t chunk)
{
const mp4ff_track_t * p_track = f->track[track];
if (p_track->stco_entry_count && (chunk > p_track->stco_entry_count))
{
return p_track->stco_chunk_offset[p_track->stco_entry_count - 1];
} else if (p_track->stco_entry_count) {
return p_track->stco_chunk_offset[chunk - 1];
} else {
return 8;
}
return 0;
}
static int32_t mp4ff_sample_range_size(const mp4ff_t *f, const int32_t track,
const int32_t chunk_sample, const int32_t sample)
{
int32_t i, total;
const mp4ff_track_t * p_track = f->track[track];
if (p_track->stsz_sample_size)
{
return (sample - chunk_sample) * p_track->stsz_sample_size;
}
else
{
if (sample>=p_track->stsz_sample_count) return 0;//error
for(i = chunk_sample, total = 0; i < sample; i++)
{
total += p_track->stsz_table[i];
}
}
return total;
}
static int32_t mp4ff_sample_to_offset(const mp4ff_t *f, const int32_t track, const int32_t sample)
{
int32_t chunk, chunk_sample, chunk_offset1, chunk_offset2;
mp4ff_chunk_of_sample(f, track, sample, &chunk_sample, &chunk);
chunk_offset1 = mp4ff_chunk_to_offset(f, track, chunk);
chunk_offset2 = chunk_offset1 + mp4ff_sample_range_size(f, track, chunk_sample, sample);
return chunk_offset2;
}
int32_t mp4ff_audio_frame_size(const mp4ff_t *f, const int32_t track, const int32_t sample)
{
int32_t bytes;
const mp4ff_track_t * p_track = f->track[track];
if (p_track->stsz_sample_size)
{
bytes = p_track->stsz_sample_size;
} else {
bytes = p_track->stsz_table[sample];
}
return bytes;
}
int32_t mp4ff_set_sample_position(mp4ff_t *f, const int32_t track, const int32_t sample)
{
int32_t offset;
offset = mp4ff_sample_to_offset(f, track, sample);
mp4ff_set_position(f, offset);
return 0;
}
/*
** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
** Copyright (C) 2003-2004 M. Bakker, Ahead Software 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.
**
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
** $Id: mp4util.c,v 1.15 2004/01/11 15:52:19 menno Exp $
**/
#include "mp4ffint.h"
#include <stdlib.h>
int32_t mp4ff_read_data(mp4ff_t *f, int8_t *data, uint32_t size)
{
int32_t result = 1;
result = f->stream->read(f->stream->user_data, data, size);
f->current_position += size;
return result;
}
int32_t mp4ff_truncate(mp4ff_t * f)
{
return f->stream->truncate(f->stream->user_data);
}
int32_t mp4ff_write_data(mp4ff_t *f, int8_t *data, uint32_t size)
{
int32_t result = 1;
result = f->stream->write(f->stream->user_data, data, size);
f->current_position += size;
return result;
}
int32_t mp4ff_write_int32(mp4ff_t *f,const uint32_t data)
{
uint32_t result;
uint32_t a, b, c, d;
int8_t temp[4];
*(uint32_t*)temp = data;
a = (uint8_t)temp[0];
b = (uint8_t)temp[1];
c = (uint8_t)temp[2];
d = (uint8_t)temp[3];
result = (a<<24) | (b<<16) | (c<<8) | d;
return mp4ff_write_data(f,(uint8_t*)&result,sizeof(result));
}
int32_t mp4ff_set_position(mp4ff_t *f, const int64_t position)
{
f->stream->seek(f->stream->user_data, position);
f->current_position = position;
return 0;
}
int64_t mp4ff_position(const mp4ff_t *f)
{
return f->current_position;
}
uint64_t mp4ff_read_int64(mp4ff_t *f)
{
uint8_t data[8];
uint64_t result = 0;
int8_t i;
mp4ff_read_data(f, data, 8);
for (i = 0; i < 8; i++)
{
result |= ((uint64_t)data[i]) << ((7 - i) * 8);
}
return result;
}
uint32_t mp4ff_read_int32(mp4ff_t *f)
{
uint32_t result;
uint32_t a, b, c, d;
int8_t data[4];
mp4ff_read_data(f, data, 4);
a = (uint8_t)data[0];
b = (uint8_t)data[1];
c = (uint8_t)data[2];
d = (uint8_t)data[3];
result = (a<<24) | (b<<16) | (c<<8) | d;
return (uint32_t)result;
}
uint32_t mp4ff_read_int24(mp4ff_t *f)
{
uint32_t result;
uint32_t a, b, c;
int8_t data[4];
mp4ff_read_data(f, data, 3);
a = (uint8_t)data[0];
b = (uint8_t)data[1];
c = (uint8_t)data[2];
result = (a<<16) | (b<<8) | c;
return (uint32_t)result;
}
uint16_t mp4ff_read_int16(mp4ff_t *f)
{
uint32_t result;
uint32_t a, b;
int8_t data[2];
mp4ff_read_data(f, data, 2);
a = (uint8_t)data[0];
b = (uint8_t)data[1];
result = (a<<8) | b;
return (uint16_t)result;
}
char * mp4ff_read_string(mp4ff_t * f,uint32_t length)
{
char * str = (char*)malloc(length + 1);
if (str!=0)
{
if ((uint32_t)mp4ff_read_data(f,str,length)!=length)
{
free(str);
str = 0;
}
else
{
str[length] = 0;
}
}
return str;
}
uint8_t mp4ff_read_char(mp4ff_t *f)
{
uint8_t output;
mp4ff_read_data(f, &output, 1);
return output;
}
uint32_t mp4ff_read_mp4_descr_length(mp4ff_t *f)
{
uint8_t b;
uint8_t numBytes = 0;
uint32_t length = 0;
do
{
b = mp4ff_read_char(f);
numBytes++;
length = (length << 7) | (b & 0x7F);
} while ((b & 0x80) && numBytes < 4);
return length;
}
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