Initial WMA framework and plugin structure added to project.

CQTexperiment
areff 2008-02-26 20:53:18 +00:00
parent 0aa5b56250
commit 37d159e009
43 changed files with 21131 additions and 8 deletions

View File

@ -143,7 +143,8 @@
8E9A2E860BA78B500091081B /* SecondsFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A2E840BA78B500091081B /* SecondsFormatter.m */; };
8E9A2EDA0BA78D9D0091081B /* IndexFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */; };
8E9A30160BA792DC0091081B /* NSFileHandle+CreateFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E9A30140BA792DC0091081B /* NSFileHandle+CreateFile.m */; };
B09E93000D7316850064F138 /* stop_current.png in Resources */ = {isa = PBXBuildFile; fileRef = B09E92FF0D7316850064F138 /* stop_current.png */; };
B09E964C0D74A6680064F138 /* WMA.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = B09E94350D747F7B0064F138 /* WMA.bundle */; };
B09E96630D74A7BC0064F138 /* stop_current.png in Resources */ = {isa = PBXBuildFile; fileRef = B09E96620D74A7BC0064F138 /* stop_current.png */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -427,6 +428,20 @@
remoteGlobalIDString = 8D5B49AC048680CD000E48DA;
remoteInfo = Pls;
};
B09E94340D747F7B0064F138 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = B09E94300D747F7B0064F138 /* WMA.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 8D5B49B6048680CD000E48DA;
remoteInfo = WMA;
};
B09E959A0D749FF90064F138 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = B09E94300D747F7B0064F138 /* WMA.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 8D5B49AC048680CD000E48DA;
remoteInfo = "WMA Plugin";
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@ -436,6 +451,7 @@
dstPath = "";
dstSubfolderSpec = 13;
files = (
B09E964C0D74A6680064F138 /* WMA.bundle in CopyFiles */,
17C8F7D80CBEF3EF008D969D /* Dumb.bundle in CopyFiles */,
17C8F3CF0CBED66C008D969D /* GME.bundle in CopyFiles */,
17F3BB890CBC565900864489 /* CueSheet.bundle in CopyFiles */,
@ -668,7 +684,8 @@
8E9A2ED80BA78D9D0091081B /* IndexFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IndexFormatter.m; sourceTree = "<group>"; };
8E9A30130BA792DC0091081B /* NSFileHandle+CreateFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSFileHandle+CreateFile.h"; sourceTree = "<group>"; };
8E9A30140BA792DC0091081B /* NSFileHandle+CreateFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSFileHandle+CreateFile.m"; sourceTree = "<group>"; };
B09E92FF0D7316850064F138 /* stop_current.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = stop_current.png; path = Images/stop_current.png; sourceTree = "<group>"; };
B09E94300D747F7B0064F138 /* WMA.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = WMA.xcodeproj; path = Plugins/WMA/WMA.xcodeproj; sourceTree = "<group>"; };
B09E96620D74A7BC0064F138 /* stop_current.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = stop_current.png; path = Images/stop_current.png; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -855,7 +872,7 @@
177EC02D0B8BC2E60000BC8C /* Images */ = {
isa = PBXGroup;
children = (
B09E92FF0D7316850064F138 /* stop_current.png */,
B09E96620D74A7BC0064F138 /* stop_current.png */,
17A8F7190D6A89730095DA13 /* repeat_album.png */,
17A8F6820D6A7FCA0095DA13 /* repeat_all.png */,
17A8F6830D6A7FCA0095DA13 /* repeat_none.png */,
@ -905,6 +922,7 @@
17B619FF0B909ED400BC003F /* PlugIns */ = {
isa = PBXGroup;
children = (
B09E94300D747F7B0064F138 /* WMA.xcodeproj */,
566D32160D538550004466A5 /* APL.xcodeproj */,
17C8F7D20CBEF3E8008D969D /* Dumb.xcodeproj */,
17C8F3C80CBED663008D969D /* GME.xcodeproj */,
@ -1265,6 +1283,14 @@
name = Products;
sourceTree = "<group>";
};
B09E94310D747F7B0064F138 /* Products */ = {
isa = PBXGroup;
children = (
B09E94350D747F7B0064F138 /* WMA.bundle */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -1301,6 +1327,7 @@
17C8F7DA0CBEF3F9008D969D /* PBXTargetDependency */,
17BF2B3A0CDD7827007E1295 /* PBXTargetDependency */,
17643CBC0D5BD44900F0A9FE /* PBXTargetDependency */,
B09E959B0D749FF90064F138 /* PBXTargetDependency */,
);
name = Cog;
productInstallPath = "$(HOME)/Applications";
@ -1409,6 +1436,10 @@
ProductGroup = 17C808C10C3BD1DD005707C4 /* Products */;
ProjectRef = 17C808C00C3BD1DD005707C4 /* WavPack.xcodeproj */;
},
{
ProductGroup = B09E94310D747F7B0064F138 /* Products */;
ProjectRef = B09E94300D747F7B0064F138 /* WMA.xcodeproj */;
},
);
projectRoot = "";
targets = (
@ -1558,6 +1589,13 @@
remoteRef = 8E8D41C60CBB0DA000135C1B /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
B09E94350D747F7B0064F138 /* WMA.bundle */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = WMA.bundle;
remoteRef = B09E94340D747F7B0064F138 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
@ -1615,7 +1653,7 @@
17A8F6860D6A7FCA0095DA13 /* repeat_none.png in Resources */,
17A8F6870D6A7FCA0095DA13 /* repeat_one.png in Resources */,
17A8F71A0D6A89730095DA13 /* repeat_album.png in Resources */,
B09E93000D7316850064F138 /* stop_current.png in Resources */,
B09E96630D74A7BC0064F138 /* stop_current.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1790,6 +1828,11 @@
name = Pls;
targetProxy = 8E8D41CB0CBB0DD200135C1B /* PBXContainerItemProxy */;
};
B09E959B0D749FF90064F138 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = "WMA Plugin";
targetProxy = B09E959A0D749FF90064F138 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
@ -1856,7 +1899,10 @@
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = ThirdParty/Frameworks/;
FRAMEWORK_SEARCH_PATHS = (
ThirdParty/Frameworks/,
"\"$(SRCROOT)/build/Release\"",
);
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
@ -1864,7 +1910,10 @@
GCC_OPTIMIZATION_LEVEL = 0;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = "";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/build/Release/WMA.framework\"",
);
OTHER_CFLAGS = (
"-D__MACOSX__",
"-DHAVE_CONFIG_H",
@ -1887,13 +1936,19 @@
ppc,
i386,
);
FRAMEWORK_SEARCH_PATHS = ThirdParty/Frameworks/;
FRAMEWORK_SEARCH_PATHS = (
ThirdParty/Frameworks/,
"\"$(SRCROOT)/build/Release\"",
);
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = "";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/build/Release/WMA.framework\"",
);
OTHER_CFLAGS = (
"-D__MACOSX__",
"-DHAVE_CONFIG_H",

Binary file not shown.

26
Frameworks/WMA/Info.plist Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.yourcocoaframework</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -0,0 +1,392 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 42;
objects = {
/* Begin PBXBuildFile section */
8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
B09E94880D74834B0064F138 /* allcodecs.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94670D74834B0064F138 /* allcodecs.c */; };
B09E94890D74834B0064F138 /* allformats.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94680D74834B0064F138 /* allformats.c */; };
B09E948A0D74834B0064F138 /* asf.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94690D74834B0064F138 /* asf.c */; };
B09E948B0D74834B0064F138 /* avcodec.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E946A0D74834B0064F138 /* avcodec.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E948C0D74834B0064F138 /* avformat.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E946B0D74834B0064F138 /* avformat.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E948D0D74834B0064F138 /* avi.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E946C0D74834B0064F138 /* avi.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E948E0D74834B0064F138 /* avio.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E946D0D74834B0064F138 /* avio.c */; };
B09E948F0D74834B0064F138 /* avio.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E946E0D74834B0064F138 /* avio.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E94900D74834B0064F138 /* aviobuf.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E946F0D74834B0064F138 /* aviobuf.c */; };
B09E94910D74834B0064F138 /* bswap.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E94700D74834B0064F138 /* bswap.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E94920D74834B0064F138 /* common.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94710D74834B0064F138 /* common.c */; };
B09E94930D74834B0064F138 /* common.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E94720D74834B0064F138 /* common.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E94940D74834B0064F138 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E94730D74834B0064F138 /* config.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E94980D74834B0064F138 /* cutils.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94770D74834B0064F138 /* cutils.c */; };
B09E94990D74834B0064F138 /* dsputil.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94780D74834B0064F138 /* dsputil.c */; };
B09E949A0D74834B0064F138 /* dsputil.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E94790D74834B0064F138 /* dsputil.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E949B0D74834B0064F138 /* fft.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E947A0D74834B0064F138 /* fft.c */; };
B09E949C0D74834B0064F138 /* file.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E947B0D74834B0064F138 /* file.c */; };
B09E949D0D74834B0064F138 /* futils.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E947C0D74834B0064F138 /* futils.c */; };
B09E949F0D74834B0064F138 /* mdct.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E947E0D74834B0064F138 /* mdct.c */; };
B09E94A10D74834B0064F138 /* os_support.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94800D74834B0064F138 /* os_support.c */; };
B09E94A20D74834B0064F138 /* os_support.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E94810D74834B0064F138 /* os_support.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E94A30D74834B0064F138 /* parser.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94820D74834B0064F138 /* parser.c */; };
B09E94A40D74834B0064F138 /* simple_idct.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94830D74834B0064F138 /* simple_idct.c */; };
B09E94A50D74834B0064F138 /* simple_idct.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E94840D74834B0064F138 /* simple_idct.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E94A60D74834B0064F138 /* utils.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94850D74834B0064F138 /* utils.c */; };
B09E94A70D74834B0064F138 /* wmadata.h in Headers */ = {isa = PBXBuildFile; fileRef = B09E94860D74834B0064F138 /* wmadata.h */; settings = {ATTRIBUTES = (Public, ); }; };
B09E94A80D74834B0064F138 /* wmadec.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94870D74834B0064F138 /* wmadec.c */; };
B09E94F00D748DEE0064F138 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B09E94EF0D748DEE0064F138 /* libiconv.dylib */; };
B09E94F80D748EB80064F138 /* mem.c in Sources */ = {isa = PBXBuildFile; fileRef = B09E94F70D748EB80064F138 /* mem.c */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
32DBCF5E0370ADEE00C91783 /* WMA_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMA_Prefix.pch; sourceTree = "<group>"; };
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* WMA.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WMA.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B09E94670D74834B0064F138 /* allcodecs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = allcodecs.c; sourceTree = "<group>"; };
B09E94680D74834B0064F138 /* allformats.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = allformats.c; sourceTree = "<group>"; };
B09E94690D74834B0064F138 /* asf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = asf.c; sourceTree = "<group>"; };
B09E946A0D74834B0064F138 /* avcodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = avcodec.h; sourceTree = "<group>"; };
B09E946B0D74834B0064F138 /* avformat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = avformat.h; sourceTree = "<group>"; };
B09E946C0D74834B0064F138 /* avi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = avi.h; sourceTree = "<group>"; };
B09E946D0D74834B0064F138 /* avio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = avio.c; sourceTree = "<group>"; };
B09E946E0D74834B0064F138 /* avio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = avio.h; sourceTree = "<group>"; };
B09E946F0D74834B0064F138 /* aviobuf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = aviobuf.c; sourceTree = "<group>"; };
B09E94700D74834B0064F138 /* bswap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bswap.h; sourceTree = "<group>"; };
B09E94710D74834B0064F138 /* common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = common.c; sourceTree = "<group>"; };
B09E94720D74834B0064F138 /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; };
B09E94730D74834B0064F138 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
B09E94770D74834B0064F138 /* cutils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cutils.c; sourceTree = "<group>"; };
B09E94780D74834B0064F138 /* dsputil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dsputil.c; sourceTree = "<group>"; };
B09E94790D74834B0064F138 /* dsputil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dsputil.h; sourceTree = "<group>"; };
B09E947A0D74834B0064F138 /* fft.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fft.c; sourceTree = "<group>"; };
B09E947B0D74834B0064F138 /* file.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = file.c; sourceTree = "<group>"; };
B09E947C0D74834B0064F138 /* futils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = futils.c; sourceTree = "<group>"; };
B09E947E0D74834B0064F138 /* mdct.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mdct.c; sourceTree = "<group>"; };
B09E94800D74834B0064F138 /* os_support.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = os_support.c; sourceTree = "<group>"; };
B09E94810D74834B0064F138 /* os_support.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = os_support.h; sourceTree = "<group>"; };
B09E94820D74834B0064F138 /* parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = parser.c; sourceTree = "<group>"; };
B09E94830D74834B0064F138 /* simple_idct.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = simple_idct.c; sourceTree = "<group>"; };
B09E94840D74834B0064F138 /* simple_idct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simple_idct.h; sourceTree = "<group>"; };
B09E94850D74834B0064F138 /* utils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = utils.c; sourceTree = "<group>"; };
B09E94860D74834B0064F138 /* wmadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wmadata.h; sourceTree = "<group>"; };
B09E94870D74834B0064F138 /* wmadec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = wmadec.c; sourceTree = "<group>"; };
B09E94EF0D748DEE0064F138 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = /usr/lib/libiconv.dylib; sourceTree = "<absolute>"; };
B09E94F70D748EB80064F138 /* mem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mem.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8DC2EF560486A6940098B216 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B09E94F00D748DEE0064F138 /* libiconv.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
034768DFFF38A50411DB9C8B /* Products */ = {
isa = PBXGroup;
children = (
8DC2EF5B0486A6940098B216 /* WMA.framework */,
);
name = Products;
sourceTree = "<group>";
};
0867D691FE84028FC02AAC07 /* WMA */ = {
isa = PBXGroup;
children = (
B09E94EF0D748DEE0064F138 /* libiconv.dylib */,
B09E94660D74834B0064F138 /* ffmpeg-strip-wma */,
32C88DFF0371C24200C91783 /* Other Sources */,
089C1665FE841158C02AAC07 /* Resources */,
0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */,
034768DFFF38A50411DB9C8B /* Products */,
);
name = WMA;
sourceTree = "<group>";
};
0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
1058C7B0FEA5585E11CA2CBB /* Linked Frameworks */,
1058C7B2FEA5585E11CA2CBB /* Other Frameworks */,
);
name = "External Frameworks and Libraries";
sourceTree = "<group>";
};
089C1665FE841158C02AAC07 /* Resources */ = {
isa = PBXGroup;
children = (
8DC2EF5A0486A6940098B216 /* Info.plist */,
089C1666FE841158C02AAC07 /* InfoPlist.strings */,
);
name = Resources;
sourceTree = "<group>";
};
1058C7B0FEA5585E11CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
);
name = "Linked Frameworks";
sourceTree = "<group>";
};
1058C7B2FEA5585E11CA2CBB /* Other Frameworks */ = {
isa = PBXGroup;
children = (
);
name = "Other Frameworks";
sourceTree = "<group>";
};
32C88DFF0371C24200C91783 /* Other Sources */ = {
isa = PBXGroup;
children = (
32DBCF5E0370ADEE00C91783 /* WMA_Prefix.pch */,
);
name = "Other Sources";
sourceTree = "<group>";
};
B09E94660D74834B0064F138 /* ffmpeg-strip-wma */ = {
isa = PBXGroup;
children = (
B09E94F70D748EB80064F138 /* mem.c */,
B09E946D0D74834B0064F138 /* avio.c */,
B09E94670D74834B0064F138 /* allcodecs.c */,
B09E94680D74834B0064F138 /* allformats.c */,
B09E94690D74834B0064F138 /* asf.c */,
B09E946A0D74834B0064F138 /* avcodec.h */,
B09E946B0D74834B0064F138 /* avformat.h */,
B09E946C0D74834B0064F138 /* avi.h */,
B09E946E0D74834B0064F138 /* avio.h */,
B09E946F0D74834B0064F138 /* aviobuf.c */,
B09E94700D74834B0064F138 /* bswap.h */,
B09E94710D74834B0064F138 /* common.c */,
B09E94720D74834B0064F138 /* common.h */,
B09E94730D74834B0064F138 /* config.h */,
B09E94770D74834B0064F138 /* cutils.c */,
B09E94780D74834B0064F138 /* dsputil.c */,
B09E94790D74834B0064F138 /* dsputil.h */,
B09E947A0D74834B0064F138 /* fft.c */,
B09E947B0D74834B0064F138 /* file.c */,
B09E947C0D74834B0064F138 /* futils.c */,
B09E947E0D74834B0064F138 /* mdct.c */,
B09E94800D74834B0064F138 /* os_support.c */,
B09E94810D74834B0064F138 /* os_support.h */,
B09E94820D74834B0064F138 /* parser.c */,
B09E94830D74834B0064F138 /* simple_idct.c */,
B09E94840D74834B0064F138 /* simple_idct.h */,
B09E94850D74834B0064F138 /* utils.c */,
B09E94860D74834B0064F138 /* wmadata.h */,
B09E94870D74834B0064F138 /* wmadec.c */,
);
path = "ffmpeg-strip-wma";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
8DC2EF500486A6940098B216 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
B09E948B0D74834B0064F138 /* avcodec.h in Headers */,
B09E948C0D74834B0064F138 /* avformat.h in Headers */,
B09E948D0D74834B0064F138 /* avi.h in Headers */,
B09E948F0D74834B0064F138 /* avio.h in Headers */,
B09E94910D74834B0064F138 /* bswap.h in Headers */,
B09E94930D74834B0064F138 /* common.h in Headers */,
B09E94940D74834B0064F138 /* config.h in Headers */,
B09E949A0D74834B0064F138 /* dsputil.h in Headers */,
B09E94A20D74834B0064F138 /* os_support.h in Headers */,
B09E94A50D74834B0064F138 /* simple_idct.h in Headers */,
B09E94A70D74834B0064F138 /* wmadata.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
8DC2EF4F0486A6940098B216 /* WMA Framework */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "WMA Framework" */;
buildPhases = (
8DC2EF500486A6940098B216 /* Headers */,
8DC2EF520486A6940098B216 /* Resources */,
8DC2EF540486A6940098B216 /* Sources */,
8DC2EF560486A6940098B216 /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = "WMA Framework";
productInstallPath = "$(HOME)/Library/Frameworks";
productName = WMA;
productReference = 8DC2EF5B0486A6940098B216 /* WMA.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "WMA" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 0867D691FE84028FC02AAC07 /* WMA */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
8DC2EF4F0486A6940098B216 /* WMA Framework */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
8DC2EF520486A6940098B216 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
8DC2EF540486A6940098B216 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B09E94880D74834B0064F138 /* allcodecs.c in Sources */,
B09E94890D74834B0064F138 /* allformats.c in Sources */,
B09E948A0D74834B0064F138 /* asf.c in Sources */,
B09E948E0D74834B0064F138 /* avio.c in Sources */,
B09E94900D74834B0064F138 /* aviobuf.c in Sources */,
B09E94920D74834B0064F138 /* common.c in Sources */,
B09E94980D74834B0064F138 /* cutils.c in Sources */,
B09E94990D74834B0064F138 /* dsputil.c in Sources */,
B09E949B0D74834B0064F138 /* fft.c in Sources */,
B09E949C0D74834B0064F138 /* file.c in Sources */,
B09E949D0D74834B0064F138 /* futils.c in Sources */,
B09E949F0D74834B0064F138 /* mdct.c in Sources */,
B09E94A10D74834B0064F138 /* os_support.c in Sources */,
B09E94A30D74834B0064F138 /* parser.c in Sources */,
B09E94A40D74834B0064F138 /* simple_idct.c in Sources */,
B09E94A60D74834B0064F138 /* utils.c in Sources */,
B09E94A80D74834B0064F138 /* wmadec.c in Sources */,
B09E94F80D748EB80064F138 /* mem.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
089C1666FE841158C02AAC07 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
089C1667FE841158C02AAC07 /* English */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
1DEB91AE08733DA50010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_32_BIT)";
COPY_PHASE_STRIP = NO;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = WMA_Prefix.pch;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/Frameworks";
PRODUCT_NAME = WMA;
SYMROOT = ../../build;
WRAPPER_EXTENSION = framework;
ZERO_LINK = YES;
};
name = Debug;
};
1DEB91AF08733DA50010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = WMA_Prefix.pch;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/Frameworks";
PRODUCT_NAME = WMA;
SYMROOT = ../../build;
WRAPPER_EXTENSION = framework;
};
name = Release;
};
1DEB91B208733DA50010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
};
name = Debug;
};
1DEB91B308733DA50010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
ppc,
i386,
);
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
SYMROOT = ../../build;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "WMA Framework" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB91AE08733DA50010E9CD /* Debug */,
1DEB91AF08733DA50010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "WMA" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB91B208733DA50010E9CD /* Debug */,
1DEB91B308733DA50010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
}

View File

@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'WMA' target in the 'WMA' project.
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

View File

@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -0,0 +1,24 @@
This file contains the name of the people who have contributed to
ffmpeg. The names are sorted alphabetically.
Fabrice Bellard
BERO
Mario Brito
Alex Beregszaszi
Tim Ferguson
Brian Foley
Arpad Gereoffy
Philip Gladstone
Vladimir Gneushev
Falk Hueffner
Zdenek Kabelac
Robin Kay
Nick Kurshev
Mike Melanson
Michael Niedermayer
François Revol
Dieter Shirley
Juan J. Sierralta
Ewald Snel
Roberto Togni
Lionel Ulmer

View File

@ -0,0 +1,49 @@
/*
* Utils for libavcodec
* Copyright (c) 2002 Fabrice Bellard.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @file allcodecs.c
* Utils for libavcodec.
*/
#include "avcodec.h"
/* If you do not call this function, then you can select exactly which
formats you want to support */
/**
* simple call to register all the codecs.
*/
void avcodec_register_all(void)
{
static int inited = 0;
if (inited != 0)
return;
inited = 1;
/* decoders */
#ifdef CONFIG_DECODERS
#ifdef CONFIG_RISKY
register_avcodec(&wmav1_decoder);
register_avcodec(&wmav2_decoder);
#endif
#endif
}

View File

@ -0,0 +1,127 @@
/*
* Register all the formats and protocols
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "avformat.h"
/* If you do not call this function, then you can select exactly which
formats you want to support */
/**
* Initialize libavcodec and register all the codecs and formats.
*/
void av_register_all(void)
{
avcodec_init();
avcodec_register_all();
//mpegps_init();
//mpegts_init();
#ifdef CONFIG_ENCODERS
crc_init();
img_init();
#endif //CONFIG_ENCODERS
//raw_init();
//mp3_init();
//rm_init();
#ifdef CONFIG_RISKY
asf_init();
#endif
#ifdef CONFIG_ENCODERS
avienc_init();
#endif //CONFIG_ENCODERS
//avidec_init();
//wav_init();
//swf_init();
//au_init();
#ifdef CONFIG_ENCODERS
gif_init();
#endif //CONFIG_ENCODERS
//mov_init();
#ifdef CONFIG_ENCODERS
movenc_init();
jpeg_init();
#endif //CONFIG_ENCODERS
//dv_init();
//fourxm_init();
#ifdef CONFIG_ENCODERS
flvenc_init();
#endif //CONFIG_ENCODERS
//flvdec_init();
//str_init();
//roq_init();
//ipmovie_init();
//wc3_init();
//westwood_init();
//film_init();
//idcin_init();
//flic_init();
//vmd_init();
#if defined(AMR_NB) || defined(AMR_NB_FIXED) || defined(AMR_WB)
amr_init();
#endif
//yuv4mpeg_init();
#ifdef CONFIG_VORBIS
ogg_init();
#endif
#ifndef CONFIG_WIN32
//ffm_init();
#endif
#ifdef CONFIG_VIDEO4LINUX
video_grab_init();
#endif
#if defined(CONFIG_AUDIO_OSS) || defined(CONFIG_AUDIO_BEOS)
audio_init();
#endif
#ifdef CONFIG_DV1394
dv1394_init();
#endif
//nut_init();
#ifdef CONFIG_ENCODERS
/* image formats */
av_register_image_format(&pnm_image_format);
av_register_image_format(&pbm_image_format);
av_register_image_format(&pgm_image_format);
av_register_image_format(&ppm_image_format);
av_register_image_format(&pam_image_format);
av_register_image_format(&pgmyuv_image_format);
av_register_image_format(&yuv_image_format);
#ifdef CONFIG_ZLIB
av_register_image_format(&png_image_format);
#endif
av_register_image_format(&jpeg_image_format);
av_register_image_format(&gif_image_format);
#endif //CONFIG_ENCODERS
/* file protocols */
register_protocol(&file_protocol);
register_protocol(&pipe_protocol);
#ifdef CONFIG_NETWORK
rtsp_init();
rtp_init();
register_protocol(&udp_protocol);
register_protocol(&rtp_protocol);
register_protocol(&tcp_protocol);
register_protocol(&http_protocol);
#endif
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,637 @@
#ifndef AVFORMAT_H
#define AVFORMAT_H
#ifdef __cplusplus
extern "C" {
#endif
#define LIBAVFORMAT_BUILD 4611
#define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVFORMAT_VERSION FFMPEG_VERSION
#define LIBAVFORMAT_IDENT "FFmpeg" FFMPEG_VERSION "b" AV_STRINGIFY(LIBAVFORMAT_BUILD)
#include <time.h>
#include <stdio.h> /* FILE */
#include "avcodec.h"
#include "avio.h"
/* packet functions */
#ifndef MAXINT64
#define MAXINT64 int64_t_C(0x7fffffffffffffff)
#endif
#ifndef MININT64
#define MININT64 int64_t_C(0x8000000000000000)
#endif
#define AV_NOPTS_VALUE MININT64
#define AV_TIME_BASE 1000000
typedef struct AVPacket {
int64_t pts; /* presentation time stamp in AV_TIME_BASE units (or
pts_den units in muxers or demuxers) */
int64_t dts; /* decompression time stamp in AV_TIME_BASE units (or
pts_den units in muxers or demuxers) */
uint8_t *data;
int size;
int stream_index;
int flags;
int duration; /* presentation duration (0 if not available) */
void (*destruct)(struct AVPacket *);
void *priv;
} AVPacket;
#define PKT_FLAG_KEY 0x0001
/* initialize optional fields of a packet */
static inline void av_init_packet(AVPacket *pkt)
{
pkt->pts = AV_NOPTS_VALUE;
pkt->dts = AV_NOPTS_VALUE;
pkt->duration = 0;
pkt->flags = 0;
pkt->stream_index = 0;
}
int av_new_packet(AVPacket *pkt, int size);
int av_dup_packet(AVPacket *pkt);
/**
* Free a packet
*
* @param pkt packet to free
*/
static inline void av_free_packet(AVPacket *pkt)
{
if (pkt && pkt->destruct) {
pkt->destruct(pkt);
}
}
/*************************************************/
/* fractional numbers for exact pts handling */
/* the exact value of the fractional number is: 'val + num / den'. num
is assumed to be such as 0 <= num < den */
typedef struct AVFrac {
int64_t val, num, den;
} AVFrac;
void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den);
void av_frac_add(AVFrac *f, int64_t incr);
void av_frac_set(AVFrac *f, int64_t val);
/*************************************************/
/* input/output formats */
struct AVFormatContext;
/* this structure contains the data a format has to probe a file */
typedef struct AVProbeData {
const char *filename;
unsigned char *buf;
int buf_size;
} AVProbeData;
#define AVPROBE_SCORE_MAX 100
typedef struct AVFormatParameters {
int frame_rate;
int frame_rate_base;
int sample_rate;
int channels;
int width;
int height;
enum PixelFormat pix_fmt;
struct AVImageFormat *image_format;
int channel; /* used to select dv channel */
const char *device; /* video4linux, audio or DV device */
const char *standard; /* tv standard, NTSC, PAL, SECAM */
int mpeg2ts_raw:1; /* force raw MPEG2 transport stream output, if possible */
int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport
stream packet (only meaningful if
mpeg2ts_raw is TRUE */
int initial_pause:1; /* do not begin to play the stream
immediately (RTSP only) */
} AVFormatParameters;
#define AVFMT_NOFILE 0x0001 /* no file should be opened */
#define AVFMT_NEEDNUMBER 0x0002 /* needs '%d' in filename */
#define AVFMT_SHOW_IDS 0x0008 /* show format stream IDs numbers */
#define AVFMT_RAWPICTURE 0x0020 /* format wants AVPicture structure for
raw picture data */
typedef struct AVOutputFormat {
const char *name;
const char *long_name;
const char *mime_type;
const char *extensions; /* comma separated extensions */
/* size of private data so that it can be allocated in the wrapper */
int priv_data_size;
/* output support */
enum CodecID audio_codec; /* default audio codec */
enum CodecID video_codec; /* default video codec */
int (*write_header)(struct AVFormatContext *);
int (*write_packet)(struct AVFormatContext *,
int stream_index,
const uint8_t *buf, int size, int64_t pts);
int (*write_trailer)(struct AVFormatContext *);
/* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
int flags;
/* currently only used to set pixel format if not YUV420P */
int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
/* private fields */
struct AVOutputFormat *next;
} AVOutputFormat;
typedef struct AVInputFormat {
const char *name;
const char *long_name;
/* size of private data so that it can be allocated in the wrapper */
int priv_data_size;
/* tell if a given file has a chance of being parsing by this format */
int (*read_probe)(AVProbeData *);
/* read the format header and initialize the AVFormatContext
structure. Return 0 if OK. 'ap' if non NULL contains
additionnal paramters. Only used in raw format right
now. 'av_new_stream' should be called to create new streams. */
int (*read_header)(struct AVFormatContext *,
AVFormatParameters *ap);
/* read one packet and put it in 'pkt'. pts and flags are also
set. 'av_new_stream' can be called only if the flag
AVFMTCTX_NOHEADER is used. */
int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
/* close the stream. The AVFormatContext and AVStreams are not
freed by this function */
int (*read_close)(struct AVFormatContext *);
/* seek at or before a given timestamp (given in AV_TIME_BASE
units) relative to the frames in stream component stream_index */
int (*read_seek)(struct AVFormatContext *,
int stream_index, int64_t timestamp);
/* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
int flags;
/* if extensions are defined, then no probe is done. You should
usually not use extension format guessing because it is not
reliable enough */
const char *extensions;
/* general purpose read only value that the format can use */
int value;
/* start/resume playing - only meaningful if using a network based format
(RTSP) */
int (*read_play)(struct AVFormatContext *);
/* pause playing - only meaningful if using a network based format
(RTSP) */
int (*read_pause)(struct AVFormatContext *);
/* private fields */
struct AVInputFormat *next;
} AVInputFormat;
typedef struct AVIndexEntry {
int64_t pos;
int64_t timestamp;
#define AVINDEX_KEYFRAME 0x0001
/* the following 2 flags indicate that the next/prev keyframe is known, and scaning for it isnt needed */
int flags;
int min_distance; /* min distance between this and the previous keyframe, used to avoid unneeded searching */
} AVIndexEntry;
typedef struct AVStream {
int index; /* stream index in AVFormatContext */
int id; /* format specific stream id */
AVCodecContext codec; /* codec context */
int r_frame_rate; /* real frame rate of the stream */
int r_frame_rate_base;/* real frame rate base of the stream */
void *priv_data;
/* internal data used in av_find_stream_info() */
int64_t codec_info_duration;
int codec_info_nb_frames;
/* encoding: PTS generation when outputing stream */
AVFrac pts;
/* ffmpeg.c private use */
int stream_copy; /* if TRUE, just copy stream */
/* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
* MN:dunno if thats the right place, for it */
float quality;
/* decoding: position of the first frame of the component, in
AV_TIME_BASE fractional seconds. */
int64_t start_time;
/* decoding: duration of the stream, in AV_TIME_BASE fractional
seconds. */
int64_t duration;
/* av_read_frame() support */
int need_parsing;
struct AVCodecParserContext *parser;
int64_t cur_dts;
int last_IP_duration;
/* av_seek_frame() support */
AVIndexEntry *index_entries; /* only used if the format does not
support seeking natively */
int nb_index_entries;
int index_entries_allocated_size;
} AVStream;
#define AVFMTCTX_NOHEADER 0x0001 /* signal that no header is present
(streams are added dynamically) */
#define MAX_STREAMS 20
/* format I/O context */
typedef struct AVFormatContext {
/* can only be iformat or oformat, not both at the same time */
struct AVInputFormat *iformat;
struct AVOutputFormat *oformat;
void *priv_data;
ByteIOContext pb;
int nb_streams;
AVStream *streams[MAX_STREAMS];
char filename[1024]; /* input or output filename */
/* stream info */
char title[512];
char author[512];
char copyright[512];
char comment[512];
char album[512];
int year; /* ID3 year, 0 if none */
int track; /* track number, 0 if none */
char genre[32]; /* ID3 genre */
int ctx_flags; /* format specific flags, see AVFMTCTX_xx */
/* private data for pts handling (do not modify directly) */
int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
int pts_num, pts_den; /* value to convert to seconds */
/* This buffer is only needed when packets were already buffered but
not decoded, for example to get the codec parameters in mpeg
streams */
struct AVPacketList *packet_buffer;
/* decoding: position of the first frame of the component, in
AV_TIME_BASE fractional seconds. NEVER set this value directly:
it is deduced from the AVStream values. */
int64_t start_time;
/* decoding: duration of the stream, in AV_TIME_BASE fractional
seconds. NEVER set this value directly: it is deduced from the
AVStream values. */
int64_t duration;
/* decoding: total file size. 0 if unknown */
int64_t file_size;
/* decoding: total stream bitrate in bit/s, 0 if not
available. Never set it directly if the file_size and the
duration are known as ffmpeg can compute it automatically. */
int bit_rate;
/* av_read_frame() support */
AVStream *cur_st;
const uint8_t *cur_ptr;
int cur_len;
AVPacket cur_pkt;
/* the following are used for pts/dts unit conversion */
int64_t last_pkt_stream_pts;
int64_t last_pkt_stream_dts;
int64_t last_pkt_pts;
int64_t last_pkt_dts;
int last_pkt_pts_frac;
int last_pkt_dts_frac;
/* av_seek_frame() support */
int64_t data_offset; /* offset of the first packet */
int index_built;
} AVFormatContext;
typedef struct AVPacketList {
AVPacket pkt;
struct AVPacketList *next;
} AVPacketList;
extern AVInputFormat *first_iformat;
extern AVOutputFormat *first_oformat;
/* still image support */
struct AVInputImageContext;
typedef struct AVInputImageContext AVInputImageContext;
typedef struct AVImageInfo {
enum PixelFormat pix_fmt; /* requested pixel format */
int width; /* requested width */
int height; /* requested height */
int interleaved; /* image is interleaved (e.g. interleaved GIF) */
AVPicture pict; /* returned allocated image */
} AVImageInfo;
/* AVImageFormat.flags field constants */
#define AVIMAGE_INTERLEAVED 0x0001 /* image format support interleaved output */
typedef struct AVImageFormat {
const char *name;
const char *extensions;
/* tell if a given file has a chance of being parsing by this format */
int (*img_probe)(AVProbeData *);
/* read a whole image. 'alloc_cb' is called when the image size is
known so that the caller can allocate the image. If 'allo_cb'
returns non zero, then the parsing is aborted. Return '0' if
OK. */
int (*img_read)(ByteIOContext *,
int (*alloc_cb)(void *, AVImageInfo *info), void *);
/* write the image */
int supported_pixel_formats; /* mask of supported formats for output */
int (*img_write)(ByteIOContext *, AVImageInfo *);
int flags;
struct AVImageFormat *next;
} AVImageFormat;
void av_register_image_format(AVImageFormat *img_fmt);
AVImageFormat *av_probe_image_format(AVProbeData *pd);
AVImageFormat *guess_image_format(const char *filename);
int av_read_image(ByteIOContext *pb, const char *filename,
AVImageFormat *fmt,
int (*alloc_cb)(void *, AVImageInfo *info), void *opaque);
int av_write_image(ByteIOContext *pb, AVImageFormat *fmt, AVImageInfo *img);
extern AVImageFormat *first_image_format;
extern AVImageFormat pnm_image_format;
extern AVImageFormat pbm_image_format;
extern AVImageFormat pgm_image_format;
extern AVImageFormat ppm_image_format;
extern AVImageFormat pam_image_format;
extern AVImageFormat pgmyuv_image_format;
extern AVImageFormat yuv_image_format;
#ifdef CONFIG_ZLIB
extern AVImageFormat png_image_format;
#endif
extern AVImageFormat jpeg_image_format;
extern AVImageFormat gif_image_format;
/* XXX: use automatic init with either ELF sections or C file parser */
/* modules */
/* mpeg.c */
extern AVInputFormat mpegps_demux;
int mpegps_init(void);
/* mpegts.c */
extern AVInputFormat mpegts_demux;
int mpegts_init(void);
/* rm.c */
int rm_init(void);
/* crc.c */
int crc_init(void);
/* img.c */
int img_init(void);
/* asf.c */
int asf_init(void);
/* avienc.c */
int avienc_init(void);
/* avidec.c */
int avidec_init(void);
/* swf.c */
int swf_init(void);
/* mov.c */
int mov_init(void);
/* movenc.c */
int movenc_init(void);
/* flvenc.c */
int flvenc_init(void);
/* flvdec.c */
int flvdec_init(void);
/* jpeg.c */
int jpeg_init(void);
/* gif.c */
int gif_init(void);
/* au.c */
int au_init(void);
/* amr.c */
int amr_init(void);
/* wav.c */
int wav_init(void);
/* raw.c */
int pcm_read_seek(AVFormatContext *s,
int stream_index, int64_t timestamp);
int raw_init(void);
/* mp3.c */
int mp3_init(void);
/* yuv4mpeg.c */
int yuv4mpeg_init(void);
/* ogg.c */
int ogg_init(void);
/* dv.c */
int dv_init(void);
/* ffm.c */
int ffm_init(void);
/* rtsp.c */
extern AVInputFormat redir_demux;
int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f);
/* 4xm.c */
int fourxm_init(void);
/* psxstr.c */
int str_init(void);
/* idroq.c */
int roq_init(void);
/* ipmovie.c */
int ipmovie_init(void);
/* nut.c */
int nut_init(void);
/* wc3movie.c */
int wc3_init(void);
/* westwood.c */
int westwood_init(void);
/* segafilm.c */
int film_init(void);
/* idcin.c */
int idcin_init(void);
/* flic.c */
int flic_init(void);
/* sierravmd.c */
int vmd_init(void);
//#include "rtp.h"
//#include "rtsp.h"
/* yuv4mpeg.c */
extern AVOutputFormat yuv4mpegpipe_oformat;
/* utils.c */
void av_register_input_format(AVInputFormat *format);
void av_register_output_format(AVOutputFormat *format);
AVOutputFormat *guess_stream_format(const char *short_name,
const char *filename, const char *mime_type);
AVOutputFormat *guess_format(const char *short_name,
const char *filename, const char *mime_type);
void av_hex_dump(FILE *f, uint8_t *buf, int size);
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
void av_register_all(void);
typedef struct FifoBuffer {
uint8_t *buffer;
uint8_t *rptr, *wptr, *end;
} FifoBuffer;
int fifo_init(FifoBuffer *f, int size);
void fifo_free(FifoBuffer *f);
int fifo_size(FifoBuffer *f, uint8_t *rptr);
int fifo_read(FifoBuffer *f, uint8_t *buf, int buf_size, uint8_t **rptr_ptr);
void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr);
/* media file input */
AVInputFormat *av_find_input_format(const char *short_name);
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
int av_open_input_stream(AVFormatContext **ic_ptr,
ByteIOContext *pb, const char *filename,
AVInputFormat *fmt, AVFormatParameters *ap);
int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
AVInputFormat *fmt,
int buf_size,
AVFormatParameters *ap);
#define AVERROR_UNKNOWN (-1) /* unknown error */
#define AVERROR_IO (-2) /* i/o error */
#define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */
#define AVERROR_INVALIDDATA (-4) /* invalid data found */
#define AVERROR_NOMEM (-5) /* not enough memory */
#define AVERROR_NOFMT (-6) /* unknown format */
#define AVERROR_NOTSUPP (-7) /* operation not supported */
int av_find_stream_info(AVFormatContext *ic);
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
int av_read_frame(AVFormatContext *s, AVPacket *pkt);
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp);
int av_read_play(AVFormatContext *s);
int av_read_pause(AVFormatContext *s);
void av_close_input_file(AVFormatContext *s);
AVStream *av_new_stream(AVFormatContext *s, int id);
void av_set_pts_info(AVFormatContext *s, int pts_wrap_bits,
int pts_num, int pts_den);
int av_find_default_stream_index(AVFormatContext *s);
int av_index_search_timestamp(AVStream *st, int timestamp);
int av_add_index_entry(AVStream *st,
int64_t pos, int64_t timestamp, int distance, int flags);
/* media file output */
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
int av_write_header(AVFormatContext *s);
int av_write_frame(AVFormatContext *s, int stream_index, const uint8_t *buf,
int size);
int av_write_trailer(AVFormatContext *s);
void dump_format(AVFormatContext *ic,
int index,
const char *url,
int is_output);
int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
int64_t parse_date(const char *datestr, int duration);
int64_t av_gettime(void);
/* ffm specific for ffserver */
#define FFM_PACKET_SIZE 4096
offset_t ffm_read_write_index(int fd);
void ffm_write_write_index(int fd, offset_t pos);
void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
int get_frame_filename(char *buf, int buf_size,
const char *path, int number);
int filename_number_test(const char *filename);
/* grab specific */
int video_grab_init(void);
int audio_init(void);
/* DV1394 */
int dv1394_init(void);
//#ifdef HAVE_AV_CONFIG_H
#include "os_support.h"
int strstart(const char *str, const char *val, const char **ptr);
int stristart(const char *str, const char *val, const char **ptr);
void pstrcpy(char *buf, int buf_size, const char *str);
char *pstrcat(char *buf, int buf_size, const char *s);
void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem);
#ifdef __GNUC__
#define dynarray_add(tab, nb_ptr, elem)\
do {\
typeof(tab) _tab = (tab);\
typeof(elem) _elem = (elem);\
(void)sizeof(**_tab == _elem); /* check that types are compatible */\
__dynarray_add((unsigned long **)_tab, nb_ptr, (unsigned long)_elem);\
} while(0)
#else
#define dynarray_add(tab, nb_ptr, elem)\
do {\
__dynarray_add((unsigned long **)(tab), nb_ptr, (unsigned long)(elem));\
} while(0)
//#endif
time_t mktimegm(struct tm *tm);
const char *small_strptime(const char *p, const char *fmt,
struct tm *dt);
struct in_addr;
int resolve_host(struct in_addr *sin_addr, const char *hostname);
void url_split(char *proto, int proto_size,
char *hostname, int hostname_size,
int *port_ptr,
char *path, int path_size,
const char *url);
int match_ext(const char *filename, const char *extensions);
#endif /* HAVE_AV_CONFIG_H */
#ifdef __cplusplus
}
#endif
#endif /* AVFORMAT_H */

View File

@ -0,0 +1,43 @@
#ifndef FFMPEG_AVI_H
#define FFMPEG_AVI_H
#include "avcodec.h"
#define AVIF_HASINDEX 0x00000010 // Index at end of file?
#define AVIF_MUSTUSEINDEX 0x00000020
#define AVIF_ISINTERLEAVED 0x00000100
#define AVIF_TRUSTCKTYPE 0x00000800 // Use CKType to find key frames?
#define AVIF_WASCAPTUREFILE 0x00010000
#define AVIF_COPYRIGHTED 0x00020000
#define AVI_MAX_RIFF_SIZE 0x40000000LL
#define AVI_MASTER_INDEX_SIZE 256
/* index flags */
#define AVIIF_INDEX 0x10
offset_t start_tag(ByteIOContext *pb, const char *tag);
void end_tag(ByteIOContext *pb, offset_t start);
typedef struct CodecTag {
int id;
unsigned int tag;
unsigned int invalid_asf : 1;
} CodecTag;
void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const CodecTag *tags, int for_asf);
int put_wav_header(ByteIOContext *pb, AVCodecContext *enc);
int wav_codec_get_id(unsigned int tag, int bps);
void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size);
extern const CodecTag codec_bmp_tags[];
extern const CodecTag codec_wav_tags[];
unsigned int codec_get_tag(const CodecTag *tags, int id);
enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag);
unsigned int codec_get_bmp_tag(int id);
unsigned int codec_get_wav_tag(int id);
enum CodecID codec_get_bmp_id(unsigned int tag);
enum CodecID codec_get_wav_id(unsigned int tag);
#endif /* FFMPEG_AVI_H */

View File

@ -0,0 +1,191 @@
/*
* Unbuffered io for ffmpeg system
* Copyright (c) 2001 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "avformat.h"
#include <errno.h>
static int default_interrupt_cb(void);
URLProtocol *first_protocol = NULL;
URLInterruptCB *url_interrupt_cb = default_interrupt_cb;
int register_protocol(URLProtocol *protocol)
{
URLProtocol **p;
p = &first_protocol;
while (*p != NULL) p = &(*p)->next;
*p = protocol;
protocol->next = NULL;
return 0;
}
int url_open(URLContext **puc, const char *filename, int flags)
{
URLContext *uc;
URLProtocol *up;
const char *p;
char proto_str[128], *q;
int err;
p = filename;
q = proto_str;
while (*p != '\0' && *p != ':') {
/* protocols can only contain alphabetic chars */
if (!isalpha(*p))
goto file_proto;
if ((q - proto_str) < sizeof(proto_str) - 1)
*q++ = *p;
p++;
}
/* if the protocol has length 1, we consider it is a dos drive */
if (*p == '\0' || (q - proto_str) <= 1) {
file_proto:
strcpy(proto_str, "file");
} else {
*q = '\0';
}
up = first_protocol;
while (up != NULL) {
if (!strcmp(proto_str, up->name))
goto found;
up = up->next;
}
err = -ENOENT;
goto fail;
found:
uc = av_malloc(sizeof(URLContext) + strlen(filename));
if (!uc) {
err = -ENOMEM;
goto fail;
}
strcpy(uc->filename, filename);
uc->prot = up;
uc->flags = flags;
uc->is_streamed = 0; /* default = not streamed */
uc->max_packet_size = 0; /* default: stream file */
err = up->url_open(uc, filename, flags);
if (err < 0) {
av_free(uc);
*puc = NULL;
return err;
}
*puc = uc;
return 0;
fail:
*puc = NULL;
return err;
}
int url_read(URLContext *h, unsigned char *buf, int size)
{
int ret;
if (h->flags & URL_WRONLY)
return -EIO;
ret = h->prot->url_read(h, buf, size);
return ret;
}
#ifdef CONFIG_ENCODERS
int url_write(URLContext *h, unsigned char *buf, int size)
{
int ret;
if (!(h->flags & (URL_WRONLY | URL_RDWR)))
return -EIO;
/* avoid sending too big packets */
if (h->max_packet_size && size > h->max_packet_size)
return -EIO;
ret = h->prot->url_write(h, buf, size);
return ret;
}
#endif //CONFIG_ENCODERS
offset_t url_seek(URLContext *h, offset_t pos, int whence)
{
offset_t ret;
if (!h->prot->url_seek)
return -EPIPE;
ret = h->prot->url_seek(h, pos, whence);
return ret;
}
int url_close(URLContext *h)
{
int ret;
ret = h->prot->url_close(h);
av_free(h);
return ret;
}
int url_exist(const char *filename)
{
URLContext *h;
if (url_open(&h, filename, URL_RDONLY) < 0)
return 0;
url_close(h);
return 1;
}
offset_t url_filesize(URLContext *h)
{
offset_t pos, size;
pos = url_seek(h, 0, SEEK_CUR);
size = url_seek(h, 0, SEEK_END);
url_seek(h, pos, SEEK_SET);
return size;
}
/*
* Return the maximum packet size associated to packetized file
* handle. If the file is not packetized (stream like http or file on
* disk), then 0 is returned.
*
* @param h file handle
* @return maximum packet size in bytes
*/
int url_get_max_packet_size(URLContext *h)
{
return h->max_packet_size;
}
void url_get_filename(URLContext *h, char *buf, int buf_size)
{
pstrcpy(buf, buf_size, h->filename);
}
static int default_interrupt_cb(void)
{
return 0;
}
/**
* The callback is called in blocking functions to test regulary if
* asynchronous interruption is needed. -EINTR is returned in this
* case by the interrupted function. 'NULL' means no interrupt
* callback is given.
*/
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)
{
if (!interrupt_cb)
interrupt_cb = default_interrupt_cb;
url_interrupt_cb = interrupt_cb;
}

View File

@ -0,0 +1,169 @@
#ifndef AVIO_H
#define AVIO_H
/* output byte stream handling */
typedef int64_t offset_t;
/* unbuffered I/O */
struct URLContext {
struct URLProtocol *prot;
int flags;
int is_streamed; /* true if streamed (no seek possible), default = false */
int max_packet_size; /* if non zero, the stream is packetized with this max packet size */
void *priv_data;
char filename[1]; /* specified filename */
};
typedef struct URLContext URLContext;
typedef struct URLPollEntry {
URLContext *handle;
int events;
int revents;
} URLPollEntry;
#define URL_RDONLY 0
#define URL_WRONLY 1
#define URL_RDWR 2
typedef int URLInterruptCB(void);
int url_open(URLContext **h, const char *filename, int flags);
int url_read(URLContext *h, unsigned char *buf, int size);
int url_write(URLContext *h, unsigned char *buf, int size);
offset_t url_seek(URLContext *h, offset_t pos, int whence);
int url_close(URLContext *h);
int url_exist(const char *filename);
offset_t url_filesize(URLContext *h);
int url_get_max_packet_size(URLContext *h);
void url_get_filename(URLContext *h, char *buf, int buf_size);
/* the callback is called in blocking functions to test regulary if
asynchronous interruption is needed. -EINTR is returned in this
case by the interrupted function. 'NULL' means no interrupt
callback is given. */
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
/* not implemented */
int url_poll(URLPollEntry *poll_table, int n, int timeout);
typedef struct URLProtocol {
const char *name;
int (*url_open)(URLContext *h, const char *filename, int flags);
int (*url_read)(URLContext *h, unsigned char *buf, int size);
int (*url_write)(URLContext *h, unsigned char *buf, int size);
offset_t (*url_seek)(URLContext *h, offset_t pos, int whence);
int (*url_close)(URLContext *h);
struct URLProtocol *next;
} URLProtocol;
extern URLProtocol *first_protocol;
extern URLInterruptCB *url_interrupt_cb;
int register_protocol(URLProtocol *protocol);
typedef struct {
unsigned char *buffer;
int buffer_size;
unsigned char *buf_ptr, *buf_end;
void *opaque;
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
void (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
int (*seek)(void *opaque, offset_t offset, int whence);
offset_t pos; /* position in the file of the current buffer */
int must_flush; /* true if the next seek should flush */
int eof_reached; /* true if eof reached */
int write_flag; /* true if open for writing */
int is_streamed;
int max_packet_size;
} ByteIOContext;
int init_put_byte(ByteIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,
void *opaque,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
void (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*seek)(void *opaque, offset_t offset, int whence));
void put_byte(ByteIOContext *s, int b);
void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
void put_le64(ByteIOContext *s, uint64_t val);
void put_be64(ByteIOContext *s, uint64_t val);
void put_le32(ByteIOContext *s, unsigned int val);
void put_be32(ByteIOContext *s, unsigned int val);
void put_le16(ByteIOContext *s, unsigned int val);
void put_be16(ByteIOContext *s, unsigned int val);
void put_tag(ByteIOContext *s, const char *tag);
void put_be64_double(ByteIOContext *s, double val);
void put_strz(ByteIOContext *s, const char *buf);
offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence);
void url_fskip(ByteIOContext *s, offset_t offset);
offset_t url_ftell(ByteIOContext *s);
int url_feof(ByteIOContext *s);
#define URL_EOF (-1)
int url_fgetc(ByteIOContext *s);
#ifdef __GNUC__
int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
#else
int url_fprintf(ByteIOContext *s, const char *fmt, ...);
#endif
char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
void put_flush_packet(ByteIOContext *s);
int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
int get_byte(ByteIOContext *s);
unsigned int get_le32(ByteIOContext *s);
uint64_t get_le64(ByteIOContext *s);
unsigned int get_le16(ByteIOContext *s);
double get_be64_double(ByteIOContext *s);
char *get_strz(ByteIOContext *s, char *buf, int maxlen);
unsigned int get_be16(ByteIOContext *s);
unsigned int get_be32(ByteIOContext *s);
uint64_t get_be64(ByteIOContext *s);
static inline int url_is_streamed(ByteIOContext *s)
{
return s->is_streamed;
}
int url_fdopen(ByteIOContext *s, URLContext *h);
int url_setbufsize(ByteIOContext *s, int buf_size);
int url_fopen(ByteIOContext *s, const char *filename, int flags);
int url_fclose(ByteIOContext *s);
URLContext *url_fileno(ByteIOContext *s);
int url_fget_max_packet_size(ByteIOContext *s);
int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags);
int url_close_buf(ByteIOContext *s);
int url_open_dyn_buf(ByteIOContext *s);
int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size);
int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
/* file.c */
extern URLProtocol file_protocol;
extern URLProtocol pipe_protocol;
/* udp.c */
extern URLProtocol udp_protocol;
int udp_set_remote_url(URLContext *h, const char *uri);
int udp_get_local_port(URLContext *h);
int udp_get_file_handle(URLContext *h);
/* tcp.c */
extern URLProtocol tcp_protocol;
/* http.c */
extern URLProtocol http_protocol;
#endif

View File

@ -0,0 +1,700 @@
/*
* Buffered I/O for ffmpeg system
* Copyright (c) 2000,2001 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "avformat.h"
#include "avio.h"
#include <stdarg.h>
#include <errno.h>
#define IO_BUFFER_SIZE 32768
int init_put_byte(ByteIOContext *s,
unsigned char *buffer,
int buffer_size,
int write_flag,
void *opaque,
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
void (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
int (*seek)(void *opaque, offset_t offset, int whence))
{
s->buffer = buffer;
s->buffer_size = buffer_size;
s->buf_ptr = buffer;
s->write_flag = write_flag;
if (!s->write_flag)
s->buf_end = buffer;
else
s->buf_end = buffer + buffer_size;
s->opaque = opaque;
s->write_packet = write_packet;
s->read_packet = read_packet;
s->seek = seek;
s->pos = 0;
s->must_flush = 0;
s->eof_reached = 0;
s->is_streamed = 0;
s->max_packet_size = 0;
return 0;
}
#ifdef CONFIG_ENCODERS
static void flush_buffer(ByteIOContext *s)
{
if (s->buf_ptr > s->buffer) {
if (s->write_packet)
s->write_packet(s->opaque, s->buffer, s->buf_ptr - s->buffer);
s->pos += s->buf_ptr - s->buffer;
}
s->buf_ptr = s->buffer;
}
void put_byte(ByteIOContext *s, int b)
{
*(s->buf_ptr)++ = b;
if (s->buf_ptr >= s->buf_end)
flush_buffer(s);
}
void put_buffer(ByteIOContext *s, const unsigned char *buf, int size)
{
int len;
while (size > 0) {
len = (s->buf_end - s->buf_ptr);
if (len > size)
len = size;
memcpy(s->buf_ptr, buf, len);
s->buf_ptr += len;
if (s->buf_ptr >= s->buf_end)
flush_buffer(s);
buf += len;
size -= len;
}
}
void put_flush_packet(ByteIOContext *s)
{
flush_buffer(s);
s->must_flush = 0;
}
#endif //CONFIG_ENCODERS
offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence)
{
offset_t offset1;
if (whence != SEEK_CUR && whence != SEEK_SET)
return -EINVAL;
#ifdef CONFIG_ENCODERS
if (s->write_flag) {
if (whence == SEEK_CUR) {
offset1 = s->pos + (s->buf_ptr - s->buffer);
if (offset == 0)
return offset1;
offset += offset1;
}
offset1 = offset - s->pos;
if (!s->must_flush &&
offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) {
/* can do the seek inside the buffer */
s->buf_ptr = s->buffer + offset1;
} else {
if (!s->seek)
return -EPIPE;
flush_buffer(s);
s->must_flush = 1;
s->buf_ptr = s->buffer;
s->seek(s->opaque, offset, SEEK_SET);
s->pos = offset;
}
} else
#endif //CONFIG_ENCODERS
{
if (whence == SEEK_CUR) {
offset1 = s->pos - (s->buf_end - s->buffer) + (s->buf_ptr - s->buffer);
if (offset == 0)
return offset1;
offset += offset1;
}
offset1 = offset - (s->pos - (s->buf_end - s->buffer));
if (offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) {
/* can do the seek inside the buffer */
s->buf_ptr = s->buffer + offset1;
} else {
if (!s->seek)
return -EPIPE;
s->buf_ptr = s->buffer;
s->buf_end = s->buffer;
s->seek(s->opaque, offset, SEEK_SET);
s->pos = offset;
}
s->eof_reached = 0;
}
return offset;
}
void url_fskip(ByteIOContext *s, offset_t offset)
{
url_fseek(s, offset, SEEK_CUR);
}
offset_t url_ftell(ByteIOContext *s)
{
return url_fseek(s, 0, SEEK_CUR);
}
int url_feof(ByteIOContext *s)
{
return s->eof_reached;
}
#ifdef CONFIG_ENCODERS
void put_le32(ByteIOContext *s, unsigned int val)
{
put_byte(s, val);
put_byte(s, val >> 8);
put_byte(s, val >> 16);
put_byte(s, val >> 24);
}
void put_be32(ByteIOContext *s, unsigned int val)
{
put_byte(s, val >> 24);
put_byte(s, val >> 16);
put_byte(s, val >> 8);
put_byte(s, val);
}
/* IEEE format is assumed */
void put_be64_double(ByteIOContext *s, double val)
{
union {
double d;
uint64_t ull;
} u;
u.d = val;
put_be64(s, u.ull);
}
void put_strz(ByteIOContext *s, const char *str)
{
if (str)
put_buffer(s, (const unsigned char *) str, strlen(str) + 1);
else
put_byte(s, 0);
}
void put_le64(ByteIOContext *s, uint64_t val)
{
put_le32(s, (uint32_t)(val & 0xffffffff));
put_le32(s, (uint32_t)(val >> 32));
}
void put_be64(ByteIOContext *s, uint64_t val)
{
put_be32(s, (uint32_t)(val >> 32));
put_be32(s, (uint32_t)(val & 0xffffffff));
}
void put_le16(ByteIOContext *s, unsigned int val)
{
put_byte(s, val);
put_byte(s, val >> 8);
}
void put_be16(ByteIOContext *s, unsigned int val)
{
put_byte(s, val >> 8);
put_byte(s, val);
}
void put_tag(ByteIOContext *s, const char *tag)
{
while (*tag) {
put_byte(s, *tag++);
}
}
#endif //CONFIG_ENCODERS
/* Input stream */
static void fill_buffer(ByteIOContext *s)
{
int len;
/* no need to do anything if EOF already reached */
if (s->eof_reached)
return;
len = s->read_packet(s->opaque, s->buffer, s->buffer_size);
if (len <= 0) {
/* do not modify buffer if EOF reached so that a seek back can
be done without rereading data */
s->eof_reached = 1;
} else {
s->pos += len;
s->buf_ptr = s->buffer;
s->buf_end = s->buffer + len;
}
}
/* NOTE: return 0 if EOF, so you cannot use it if EOF handling is
necessary */
/* XXX: put an inline version */
int get_byte(ByteIOContext *s)
{
if (s->buf_ptr < s->buf_end) {
return *s->buf_ptr++;
} else {
fill_buffer(s);
if (s->buf_ptr < s->buf_end)
return *s->buf_ptr++;
else
return 0;
}
}
/* NOTE: return URL_EOF (-1) if EOF */
int url_fgetc(ByteIOContext *s)
{
if (s->buf_ptr < s->buf_end) {
return *s->buf_ptr++;
} else {
fill_buffer(s);
if (s->buf_ptr < s->buf_end)
return *s->buf_ptr++;
else
return URL_EOF;
}
}
int get_buffer(ByteIOContext *s, unsigned char *buf, int size)
{
int len, size1;
size1 = size;
while (size > 0) {
len = s->buf_end - s->buf_ptr;
if (len > size)
len = size;
if (len == 0) {
fill_buffer(s);
len = s->buf_end - s->buf_ptr;
if (len == 0)
break;
} else {
memcpy(buf, s->buf_ptr, len);
buf += len;
s->buf_ptr += len;
size -= len;
}
}
return size1 - size;
}
unsigned int get_le16(ByteIOContext *s)
{
unsigned int val;
val = get_byte(s);
val |= get_byte(s) << 8;
return val;
}
unsigned int get_le32(ByteIOContext *s)
{
unsigned int val;
val = get_byte(s);
val |= get_byte(s) << 8;
val |= get_byte(s) << 16;
val |= get_byte(s) << 24;
return val;
}
uint64_t get_le64(ByteIOContext *s)
{
uint64_t val;
val = (uint64_t)get_le32(s);
val |= (uint64_t)get_le32(s) << 32;
return val;
}
unsigned int get_be16(ByteIOContext *s)
{
unsigned int val;
val = get_byte(s) << 8;
val |= get_byte(s);
return val;
}
unsigned int get_be32(ByteIOContext *s)
{
unsigned int val;
val = get_byte(s) << 24;
val |= get_byte(s) << 16;
val |= get_byte(s) << 8;
val |= get_byte(s);
return val;
}
double get_be64_double(ByteIOContext *s)
{
union {
double d;
uint64_t ull;
} u;
u.ull = get_be64(s);
return u.d;
}
char *get_strz(ByteIOContext *s, char *buf, int maxlen)
{
int i = 0;
char c;
while ((c = get_byte(s))) {
if (i < maxlen-1)
buf[i++] = c;
}
buf[i] = 0; /* Ensure null terminated, but may be truncated */
return buf;
}
uint64_t get_be64(ByteIOContext *s)
{
uint64_t val;
val = (uint64_t)get_be32(s) << 32;
val |= (uint64_t)get_be32(s);
return val;
}
/* link with avio functions */
#ifdef CONFIG_ENCODERS
static void url_write_packet(void *opaque, uint8_t *buf, int buf_size)
{
URLContext *h = opaque;
url_write(h, buf, buf_size);
}
#else
#define url_write_packet NULL
#endif //CONFIG_ENCODERS
static int url_read_packet(void *opaque, uint8_t *buf, int buf_size)
{
URLContext *h = opaque;
return url_read(h, buf, buf_size);
}
static int url_seek_packet(void *opaque, int64_t offset, int whence)
{
URLContext *h = opaque;
url_seek(h, offset, whence);
return 0;
}
int url_fdopen(ByteIOContext *s, URLContext *h)
{
uint8_t *buffer;
int buffer_size, max_packet_size;
max_packet_size = url_get_max_packet_size(h);
if (max_packet_size) {
buffer_size = max_packet_size; /* no need to bufferize more than one packet */
} else {
buffer_size = IO_BUFFER_SIZE;
}
buffer = av_malloc(buffer_size);
if (!buffer)
return -ENOMEM;
if (init_put_byte(s, buffer, buffer_size,
(h->flags & URL_WRONLY) != 0, h,
url_read_packet, url_write_packet, url_seek_packet) < 0) {
av_free(buffer);
return -EIO;
}
s->is_streamed = h->is_streamed;
s->max_packet_size = max_packet_size;
return 0;
}
/* XXX: must be called before any I/O */
int url_setbufsize(ByteIOContext *s, int buf_size)
{
uint8_t *buffer;
buffer = av_malloc(buf_size);
if (!buffer)
return -ENOMEM;
av_free(s->buffer);
s->buffer = buffer;
s->buffer_size = buf_size;
s->buf_ptr = buffer;
if (!s->write_flag)
s->buf_end = buffer;
else
s->buf_end = buffer + buf_size;
return 0;
}
/* NOTE: when opened as read/write, the buffers are only used for
reading */
int url_fopen(ByteIOContext *s, const char *filename, int flags)
{
URLContext *h;
int err;
err = url_open(&h, filename, flags);
if (err < 0)
return err;
err = url_fdopen(s, h);
if (err < 0) {
url_close(h);
return err;
}
return 0;
}
int url_fclose(ByteIOContext *s)
{
URLContext *h = s->opaque;
av_free(s->buffer);
memset(s, 0, sizeof(ByteIOContext));
return url_close(h);
}
URLContext *url_fileno(ByteIOContext *s)
{
return s->opaque;
}
#ifdef CONFIG_ENCODERS
/* XXX: currently size is limited */
int url_fprintf(ByteIOContext *s, const char *fmt, ...)
{
va_list ap;
char buf[4096];
int ret;
va_start(ap, fmt);
ret = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
put_buffer(s, buf, strlen(buf));
return ret;
}
#endif //CONFIG_ENCODERS
/* note: unlike fgets, the EOL character is not returned and a whole
line is parsed. return NULL if first char read was EOF */
char *url_fgets(ByteIOContext *s, char *buf, int buf_size)
{
int c;
char *q;
c = url_fgetc(s);
if (c == EOF)
return NULL;
q = buf;
for(;;) {
if (c == EOF || c == '\n')
break;
if ((q - buf) < buf_size - 1)
*q++ = c;
c = url_fgetc(s);
}
if (buf_size > 0)
*q = '\0';
return buf;
}
/*
* Return the maximum packet size associated to packetized buffered file
* handle. If the file is not packetized (stream like http or file on
* disk), then 0 is returned.
*
* @param h buffered file handle
* @return maximum packet size in bytes
*/
int url_fget_max_packet_size(ByteIOContext *s)
{
return s->max_packet_size;
}
#ifdef CONFIG_ENCODERS
/* buffer handling */
int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags)
{
return init_put_byte(s, buf, buf_size,
(flags & URL_WRONLY) != 0, NULL, NULL, NULL, NULL);
}
/* return the written or read size */
int url_close_buf(ByteIOContext *s)
{
put_flush_packet(s);
return s->buf_ptr - s->buffer;
}
/* output in a dynamic buffer */
typedef struct DynBuffer {
int pos, size, allocated_size;
uint8_t *buffer;
int io_buffer_size;
uint8_t io_buffer[1];
} DynBuffer;
static void dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
{
DynBuffer *d = opaque;
int new_size, new_allocated_size;
/* reallocate buffer if needed */
new_size = d->pos + buf_size;
new_allocated_size = d->allocated_size;
while (new_size > new_allocated_size) {
if (!new_allocated_size)
new_allocated_size = new_size;
else
new_allocated_size = (new_allocated_size * 3) / 2 + 1;
}
if (new_allocated_size > d->allocated_size) {
d->buffer = av_realloc(d->buffer, new_allocated_size);
if(d->buffer == NULL)
return ;
d->allocated_size = new_allocated_size;
}
memcpy(d->buffer + d->pos, buf, buf_size);
d->pos = new_size;
if (d->pos > d->size)
d->size = d->pos;
}
static void dyn_packet_buf_write(void *opaque, uint8_t *buf, int buf_size)
{
unsigned char buf1[4];
/* packetized write: output the header */
buf1[0] = (buf_size >> 24);
buf1[1] = (buf_size >> 16);
buf1[2] = (buf_size >> 8);
buf1[3] = (buf_size);
dyn_buf_write(opaque, buf1, 4);
/* then the data */
dyn_buf_write(opaque, buf, buf_size);
}
static int dyn_buf_seek(void *opaque, offset_t offset, int whence)
{
DynBuffer *d = opaque;
if (whence == SEEK_CUR)
offset += d->pos;
else if (whence == SEEK_END)
offset += d->size;
if (offset < 0 || offset > 0x7fffffffLL)
return -1;
d->pos = offset;
return 0;
}
static int url_open_dyn_buf_internal(ByteIOContext *s, int max_packet_size)
{
DynBuffer *d;
int io_buffer_size, ret;
if (max_packet_size)
io_buffer_size = max_packet_size;
else
io_buffer_size = 1024;
d = av_malloc(sizeof(DynBuffer) + io_buffer_size);
if (!d)
return -1;
d->io_buffer_size = io_buffer_size;
d->buffer = NULL;
d->pos = 0;
d->size = 0;
d->allocated_size = 0;
ret = init_put_byte(s, d->io_buffer, io_buffer_size,
1, d, NULL,
max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
max_packet_size ? NULL : dyn_buf_seek);
if (ret == 0) {
s->max_packet_size = max_packet_size;
}
return ret;
}
/*
* Open a write only memory stream.
*
* @param s new IO context
* @return zero if no error.
*/
int url_open_dyn_buf(ByteIOContext *s)
{
return url_open_dyn_buf_internal(s, 0);
}
/*
* Open a write only packetized memory stream with a maximum packet
* size of 'max_packet_size'. The stream is stored in a memory buffer
* with a big endian 4 byte header giving the packet size in bytes.
*
* @param s new IO context
* @param max_packet_size maximum packet size (must be > 0)
* @return zero if no error.
*/
int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size)
{
if (max_packet_size <= 0)
return -1;
return url_open_dyn_buf_internal(s, max_packet_size);
}
/*
* Return the written size and a pointer to the buffer. The buffer
* must be freed with av_free().
* @param s IO context
* @param pointer to a byte buffer
* @return the length of the byte buffer
*/
int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)
{
DynBuffer *d = s->opaque;
int size;
put_flush_packet(s);
*pbuffer = d->buffer;
size = d->size;
av_free(d);
return size;
}
#endif //CONFIG_ENCODERS

View File

@ -0,0 +1,129 @@
/**
* @file bswap.h
* byte swap.
*/
#ifndef __BSWAP_H__
#define __BSWAP_H__
#ifdef HAVE_BYTESWAP_H
#include <byteswap.h>
#else
#ifdef ARCH_X86
//static inline unsigned short ByteSwap16(unsigned short x)
//{
// __asm("xchgb %b0,%h0" :
// "=q" (x) :
// "0" (x));
// return x;
//}
//#define bswap_16(x) ByteSwap16(x)
//
//static inline unsigned int ByteSwap32(unsigned int x)
//{
//#if __CPU__ > 386
// __asm("bswap %0":
// "=r" (x) :
//#else
// __asm("xchgb %b0,%h0\n"
// " rorl $16,%0\n"
// " xchgb %b0,%h0":
// "=q" (x) :
//#endif
// "0" (x));
// return x;
//}
//#define bswap_32(x) ByteSwap32(x)
//
//static inline unsigned long long int ByteSwap64(unsigned long long int x)
//{
// register union { __extension__ uint64_t __ll;
// uint32_t __l[2]; } __x;
// asm("xchgl %0,%1":
// "=r"(__x.__l[0]),"=r"(__x.__l[1]):
// "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
// return __x.__ll;
//}
//#define bswap_64(x) ByteSwap64(x)
//
//#elif defined(ARCH_SH4)
//
//static inline uint16_t ByteSwap16(uint16_t x) {
// __asm__("swap.b %0,%0":"=r"(x):"0"(x));
// return x;
//}
//
//static inline uint32_t ByteSwap32(uint32_t x) {
// __asm__(
// "swap.b %0,%0\n"
// "swap.w %0,%0\n"
// "swap.b %0,%0\n"
// :"=r"(x):"0"(x));
// return x;
//}
//
//#define bswap_16(x) ByteSwap16(x)
//#define bswap_32(x) ByteSwap32(x)
//
//static inline uint64_t ByteSwap64(uint64_t x)
//{
// union {
// uint64_t ll;
// struct {
// uint32_t l,h;
// } l;
// } r;
// r.l.l = bswap_32 (x);
// r.l.h = bswap_32 (x>>32);
// return r.ll;
//}
//#define bswap_64(x) ByteSwap64(x)
//
//#else
//
#define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8)
// code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc.
#define bswap_32(x) \
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
static inline uint64_t ByteSwap64(uint64_t x)
{
union {
uint64_t ll;
uint32_t l[2];
} w, r;
w.ll = x;
r.l[0] = bswap_32 (w.l[1]);
r.l[1] = bswap_32 (w.l[0]);
return r.ll;
}
#define bswap_64(x) ByteSwap64(x)
#endif /* !ARCH_X86 */
#endif /* !HAVE_BYTESWAP_H */
// be2me ... BigEndian to MachineEndian
// le2me ... LittleEndian to MachineEndian
#ifdef WORDS_BIGENDIAN
#define be2me_16(x) (x)
#define be2me_32(x) (x)
#define be2me_64(x) (x)
#define le2me_16(x) bswap_16(x)
#define le2me_32(x) bswap_32(x)
#define le2me_64(x) bswap_64(x)
#else
#define be2me_16(x) bswap_16(x)
#define be2me_32(x) bswap_32(x)
#define be2me_64(x) bswap_64(x)
#define le2me_16(x) (x)
#define le2me_32(x) (x)
#define le2me_64(x) (x)
#endif
#endif /* __BSWAP_H__ */

View File

@ -0,0 +1,390 @@
/*
* Common bit i/o utils
* Copyright (c) 2000, 2001 Fabrice Bellard.
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at>
*/
/**
* @file common.c
* common internal api.
*/
#include "avcodec.h"
const uint8_t ff_sqrt_tab[128]={
0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11
};
const uint8_t ff_log2_tab[256]={
0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
};
void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
{
s->buf = buffer;
s->buf_end = s->buf + buffer_size;
#ifdef ALT_BITSTREAM_WRITER
s->index=0;
((uint32_t*)(s->buf))[0]=0;
// memset(buffer, 0, buffer_size);
#else
s->buf_ptr = s->buf;
s->bit_left=32;
s->bit_buf=0;
#endif
}
//#ifdef CONFIG_ENCODERS
#if 1
/* return the number of bits output */
int get_bit_count(PutBitContext *s)
{
#ifdef ALT_BITSTREAM_WRITER
return s->index;
#else
return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left;
#endif
}
void align_put_bits(PutBitContext *s)
{
#ifdef ALT_BITSTREAM_WRITER
put_bits(s,( - s->index) & 7,0);
#else
put_bits(s,s->bit_left & 7,0);
#endif
}
#endif //CONFIG_ENCODERS
/* pad the end of the output stream with zeros */
void flush_put_bits(PutBitContext *s)
{
#ifdef ALT_BITSTREAM_WRITER
align_put_bits(s);
#else
s->bit_buf<<= s->bit_left;
while (s->bit_left < 32) {
/* XXX: should test end of buffer */
*s->buf_ptr++=s->bit_buf >> 24;
s->bit_buf<<=8;
s->bit_left+=8;
}
s->bit_left=32;
s->bit_buf=0;
#endif
}
#ifdef CONFIG_ENCODERS
void put_string(PutBitContext * pbc, char *s)
{
while(*s){
put_bits(pbc, 8, *s);
s++;
}
put_bits(pbc, 8, 0);
}
/* bit input functions */
#endif //CONFIG_ENCODERS
/**
* init GetBitContext.
* @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
* because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
* @param bit_size the size of the buffer in bits
*/
void init_get_bits(GetBitContext *s,
const uint8_t *buffer, int bit_size)
{
const int buffer_size= (bit_size+7)>>3;
s->buffer= buffer;
s->size_in_bits= bit_size;
s->buffer_end= buffer + buffer_size;
#ifdef ALT_BITSTREAM_READER
s->index=0;
#elif defined LIBMPEG2_BITSTREAM_READER
#ifdef LIBMPEG2_BITSTREAM_READER_HACK
if ((int)buffer&1) {
/* word alignment */
s->cache = (*buffer++)<<24;
s->buffer_ptr = buffer;
s->bit_count = 16-8;
} else
#endif
{
s->buffer_ptr = buffer;
s->bit_count = 16;
s->cache = 0;
}
#elif defined A32_BITSTREAM_READER
s->buffer_ptr = (uint32_t*)buffer;
s->bit_count = 32;
s->cache0 = 0;
s->cache1 = 0;
#endif
{
OPEN_READER(re, s)
UPDATE_CACHE(re, s)
UPDATE_CACHE(re, s)
CLOSE_READER(re, s)
}
#ifdef A32_BITSTREAM_READER
s->cache1 = 0;
#endif
}
/**
* reads 0-32 bits.
*/
unsigned int get_bits_long(GetBitContext *s, int n){
if(n<=17) return get_bits(s, n);
else{
int ret= get_bits(s, 16) << (n-16);
return ret | get_bits(s, n-16);
}
}
/**
* shows 0-32 bits.
*/
unsigned int show_bits_long(GetBitContext *s, int n){
if(n<=17) return show_bits(s, n);
else{
GetBitContext gb= *s;
int ret= get_bits_long(s, n);
*s= gb;
return ret;
}
}
void align_get_bits(GetBitContext *s)
{
int n= (-get_bits_count(s)) & 7;
if(n) skip_bits(s, n);
}
int check_marker(GetBitContext *s, const char *msg)
{
int bit= get_bits1(s);
if(!bit)
av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
return bit;
}
/* VLC decoding */
//#define DEBUG_VLC
#define GET_DATA(v, table, i, wrap, size) \
{\
const uint8_t *ptr = (const uint8_t *)table + i * wrap;\
switch(size) {\
case 1:\
v = *(const uint8_t *)ptr;\
break;\
case 2:\
v = *(const uint16_t *)ptr;\
break;\
default:\
v = *(const uint32_t *)ptr;\
break;\
}\
}
static int alloc_table(VLC *vlc, int size)
{
int index;
index = vlc->table_size;
vlc->table_size += size;
if (vlc->table_size > vlc->table_allocated) {
vlc->table_allocated += (1 << vlc->bits);
vlc->table = av_realloc(vlc->table,
sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
if (!vlc->table)
return -1;
}
return index;
}
static int build_table(VLC *vlc, int table_nb_bits,
int nb_codes,
const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size,
uint32_t code_prefix, int n_prefix)
{
int i, j, k, n, table_size, table_index, nb, n1, index;
uint32_t code;
VLC_TYPE (*table)[2];
table_size = 1 << table_nb_bits;
table_index = alloc_table(vlc, table_size);
#ifdef DEBUG_VLC
printf("new table index=%d size=%d code_prefix=%x n=%d\n",
table_index, table_size, code_prefix, n_prefix);
#endif
if (table_index < 0)
return -1;
table = &vlc->table[table_index];
for(i=0;i<table_size;i++) {
table[i][1] = 0; //bits
table[i][0] = -1; //codes
}
/* first pass: map codes and compute auxillary table sizes */
for(i=0;i<nb_codes;i++) {
GET_DATA(n, bits, i, bits_wrap, bits_size);
GET_DATA(code, codes, i, codes_wrap, codes_size);
/* we accept tables with holes */
if (n <= 0)
continue;
#if defined(DEBUG_VLC) && 0
printf("i=%d n=%d code=0x%x\n", i, n, code);
#endif
/* if code matches the prefix, it is in the table */
n -= n_prefix;
if (n > 0 && (code >> n) == code_prefix) {
if (n <= table_nb_bits) {
/* no need to add another table */
j = (code << (table_nb_bits - n)) & (table_size - 1);
nb = 1 << (table_nb_bits - n);
for(k=0;k<nb;k++) {
#ifdef DEBUG_VLC
av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
j, i, n);
#endif
if (table[j][1] /*bits*/ != 0) {
av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
av_abort();
}
table[j][1] = n; //bits
table[j][0] = i; //code
j++;
}
} else {
n -= table_nb_bits;
j = (code >> n) & ((1 << table_nb_bits) - 1);
#ifdef DEBUG_VLC
printf("%4x: n=%d (subtable)\n",
j, n);
#endif
/* compute table size */
n1 = -table[j][1]; //bits
if (n > n1)
n1 = n;
table[j][1] = -n1; //bits
}
}
}
/* second pass : fill auxillary tables recursively */
for(i=0;i<table_size;i++) {
n = table[i][1]; //bits
if (n < 0) {
n = -n;
if (n > table_nb_bits) {
n = table_nb_bits;
table[i][1] = -n; //bits
}
index = build_table(vlc, n, nb_codes,
bits, bits_wrap, bits_size,
codes, codes_wrap, codes_size,
(code_prefix << table_nb_bits) | i,
n_prefix + table_nb_bits);
if (index < 0)
return -1;
/* note: realloc has been done, so reload tables */
table = &vlc->table[table_index];
table[i][0] = index; //code
}
}
return table_index;
}
/* Build VLC decoding tables suitable for use with get_vlc().
'nb_bits' set thee decoding table size (2^nb_bits) entries. The
bigger it is, the faster is the decoding. But it should not be too
big to save memory and L1 cache. '9' is a good compromise.
'nb_codes' : number of vlcs codes
'bits' : table which gives the size (in bits) of each vlc code.
'codes' : table which gives the bit pattern of of each vlc code.
'xxx_wrap' : give the number of bytes between each entry of the
'bits' or 'codes' tables.
'xxx_size' : gives the number of bytes of each entry of the 'bits'
or 'codes' tables.
'wrap' and 'size' allows to use any memory configuration and types
(byte/word/long) to store the 'bits' and 'codes' tables.
*/
int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size)
{
vlc->bits = nb_bits;
vlc->table = NULL;
vlc->table_allocated = 0;
vlc->table_size = 0;
#ifdef DEBUG_VLC
printf("build table nb_codes=%d\n", nb_codes);
#endif
if (build_table(vlc, nb_bits, nb_codes,
bits, bits_wrap, bits_size,
codes, codes_wrap, codes_size,
0, 0) < 0) {
av_free(vlc->table);
return -1;
}
return 0;
}
void free_vlc(VLC *vlc)
{
av_free(vlc->table);
}
int64_t ff_gcd(int64_t a, int64_t b){
if(b) return ff_gcd(b, a%b);
else return a;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
/* Automatically generated by configure - do not modify */
#define ARCH_X86 1
#define TUNECPU generic
#undef HAVE_MMX
#define __CPU__ 586
#define HAVE_BUILTIN_VECTOR 1
#define HAVE_LOCALTIME_R 1
#define HAVE_LRINTF 1
#undef HAVE_VHOOK
#undef CONFIG_ENCODERS
#define CONFIG_DECODERS 1
#undef CONFIG_MPEGAUDIO_HP
#undef CONFIG_VIDEO4LINUX
#undef CONFIG_DV1394
#define CONFIG_HAVE_DLOPEN 1
#define CONFIG_HAVE_DLFCN 1
#undef CONFIG_AUDIO_OSS
#undef CONFIG_NETWORK
#undef CONFIG_ZLIB
#define HAVE_MALLOC_H 1
#define HAVE_MEMALIGN 1
#define SIMPLE_IDCT 1
#undef CONFIG_FFSERVER
#define CONFIG_RISKY 1
#define restrict __restrict__

View File

@ -0,0 +1,239 @@
/*
* Various simple utilities for ffmpeg system
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "avformat.h"
#if !defined(CONFIG_NOCUTILS)
/**
* Return TRUE if val is a prefix of str. If it returns TRUE, ptr is
* set to the next character in 'str' after the prefix.
*
* @param str input string
* @param val prefix to test
* @param ptr updated after the prefix in str in there is a match
* @return TRUE if there is a match
*/
int strstart(const char *str, const char *val, const char **ptr)
{
const char *p, *q;
p = str;
q = val;
while (*q != '\0') {
if (*p != *q)
return 0;
p++;
q++;
}
if (ptr)
*ptr = p;
return 1;
}
/**
* Return TRUE if val is a prefix of str (case independent). If it
* returns TRUE, ptr is set to the next character in 'str' after the
* prefix.
*
* @param str input string
* @param val prefix to test
* @param ptr updated after the prefix in str in there is a match
* @return TRUE if there is a match */
int stristart(const char *str, const char *val, const char **ptr)
{
const char *p, *q;
p = str;
q = val;
while (*q != '\0') {
if (toupper(*(const unsigned char *)p) != toupper(*(const unsigned char *)q))
return 0;
p++;
q++;
}
if (ptr)
*ptr = p;
return 1;
}
/**
* Copy the string str to buf. If str length is bigger than buf_size -
* 1 then it is clamped to buf_size - 1.
* NOTE: this function does what strncpy should have done to be
* useful. NEVER use strncpy.
*
* @param buf destination buffer
* @param buf_size size of destination buffer
* @param str source string
*/
void pstrcpy(char *buf, int buf_size, const char *str)
{
int c;
char *q = buf;
if (buf_size <= 0)
return;
for(;;) {
c = *str++;
if (c == 0 || q >= buf + buf_size - 1)
break;
*q++ = c;
}
*q = '\0';
}
/* strcat and truncate. */
char *pstrcat(char *buf, int buf_size, const char *s)
{
int len;
len = strlen(buf);
if (len < buf_size)
pstrcpy(buf + len, buf_size - len, s);
return buf;
}
#endif
/* add one element to a dynamic array */
void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem)
{
int nb, nb_alloc;
unsigned long *tab;
nb = *nb_ptr;
tab = *tab_ptr;
if ((nb & (nb - 1)) == 0) {
if (nb == 0)
nb_alloc = 1;
else
nb_alloc = nb * 2;
tab = av_realloc(tab, nb_alloc * sizeof(unsigned long));
*tab_ptr = tab;
}
tab[nb++] = elem;
*nb_ptr = nb;
}
time_t mktimegm(struct tm *tm)
{
time_t t;
int y = tm->tm_year + 1900, m = tm->tm_mon + 1, d = tm->tm_mday;
if (m < 3) {
m += 12;
y--;
}
t = 86400 *
(d + (153 * m - 457) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 719469);
t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
return t;
}
/* get a positive number between n_min and n_max, for a maximum length
of len_max. Return -1 if error. */
static int date_get_num(const char **pp,
int n_min, int n_max, int len_max)
{
int i, val, c;
const char *p;
p = *pp;
val = 0;
for(i = 0; i < len_max; i++) {
c = *p;
if (!isdigit(c))
break;
val = (val * 10) + c - '0';
p++;
}
/* no number read ? */
if (p == *pp)
return -1;
if (val < n_min || val > n_max)
return -1;
*pp = p;
return val;
}
/* small strptime for ffmpeg */
const char *small_strptime(const char *p, const char *fmt,
struct tm *dt)
{
int c, val;
for(;;) {
c = *fmt++;
if (c == '\0') {
return p;
} else if (c == '%') {
c = *fmt++;
switch(c) {
case 'H':
val = date_get_num(&p, 0, 23, 2);
if (val == -1)
return NULL;
dt->tm_hour = val;
break;
case 'M':
val = date_get_num(&p, 0, 59, 2);
if (val == -1)
return NULL;
dt->tm_min = val;
break;
case 'S':
val = date_get_num(&p, 0, 59, 2);
if (val == -1)
return NULL;
dt->tm_sec = val;
break;
case 'Y':
val = date_get_num(&p, 0, 9999, 4);
if (val == -1)
return NULL;
dt->tm_year = val - 1900;
break;
case 'm':
val = date_get_num(&p, 1, 12, 2);
if (val == -1)
return NULL;
dt->tm_mon = val - 1;
break;
case 'd':
val = date_get_num(&p, 1, 31, 2);
if (val == -1)
return NULL;
dt->tm_mday = val;
break;
case '%':
goto match;
default:
return NULL;
}
} else {
match:
if (c != *p)
return NULL;
p++;
}
}
return p;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,527 @@
/*
* DSP utils
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @file dsputil.h
* DSP utils.
* note, many functions in here may use MMX which trashes the FPU state, it is
* absolutely necessary to call emms_c() between dsp & float/double code
*/
#ifndef DSPUTIL_H
#define DSPUTIL_H
#include "common.h"
#include "avcodec.h"
//#define DEBUG
/* dct code */
typedef short DCTELEM;
void fdct_ifast (DCTELEM *data);
void fdct_ifast248 (DCTELEM *data);
void ff_jpeg_fdct_islow (DCTELEM *data);
void ff_fdct248_islow (DCTELEM *data);
void j_rev_dct (DCTELEM *data);
void ff_fdct_mmx(DCTELEM *block);
void ff_fdct_mmx2(DCTELEM *block);
void ff_fdct_sse2(DCTELEM *block);
/* encoding scans */
extern const uint8_t ff_alternate_horizontal_scan[64];
extern const uint8_t ff_alternate_vertical_scan[64];
extern const uint8_t ff_zigzag_direct[64];
extern const uint8_t ff_zigzag248_direct[64];
/* pixel operations */
#define MAX_NEG_CROP 384
/* temporary */
extern uint32_t squareTbl[512];
extern uint8_t cropTbl[256 + 2 * MAX_NEG_CROP];
/* minimum alignment rules ;)
if u notice errors in the align stuff, need more alignment for some asm code for some cpu
or need to use a function with less aligned data then send a mail to the ffmpeg-dev list, ...
!warning these alignments might not match reallity, (missing attribute((align)) stuff somewhere possible)
i (michael) didnt check them, these are just the alignents which i think could be reached easily ...
!future video codecs might need functions with less strict alignment
*/
/*
void get_pixels_c(DCTELEM *block, const uint8_t *pixels, int line_size);
void diff_pixels_c(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride);
void put_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size);
void add_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size);
void clear_blocks_c(DCTELEM *blocks);
*/
/* add and put pixel (decoding) */
// blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16
//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller then 4
typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h);
typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h);
typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y);
#define DEF_OLD_QPEL(name)\
void ff_put_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
void ff_avg_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
DEF_OLD_QPEL(qpel16_mc11_old_c)
DEF_OLD_QPEL(qpel16_mc31_old_c)
DEF_OLD_QPEL(qpel16_mc12_old_c)
DEF_OLD_QPEL(qpel16_mc32_old_c)
DEF_OLD_QPEL(qpel16_mc13_old_c)
DEF_OLD_QPEL(qpel16_mc33_old_c)
DEF_OLD_QPEL(qpel8_mc11_old_c)
DEF_OLD_QPEL(qpel8_mc31_old_c)
DEF_OLD_QPEL(qpel8_mc12_old_c)
DEF_OLD_QPEL(qpel8_mc32_old_c)
DEF_OLD_QPEL(qpel8_mc13_old_c)
DEF_OLD_QPEL(qpel8_mc33_old_c)
#define CALL_2X_PIXELS(a, b, n)\
static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
b(block , pixels , line_size, h);\
b(block+n, pixels+n, line_size, h);\
}
/* motion estimation */
// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller then 2
// allthough currently h<4 is not used as functions with width <8 are not used and neither implemented
typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size, int h)/* __attribute__ ((const))*/;
/**
* DSPContext.
*/
typedef struct DSPContext {
/* pixel ops : interface with DCT */
void (*get_pixels)(DCTELEM *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size);
void (*diff_pixels)(DCTELEM *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride);
void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
void (*add_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
/**
* translational global motion compensation.
*/
void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder);
/**
* global motion compensation.
*/
void (*gmc )(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int ox, int oy,
int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
void (*clear_blocks)(DCTELEM *blocks/*align 16*/);
int (*pix_sum)(uint8_t * pix, int line_size);
int (*pix_norm1)(uint8_t * pix, int line_size);
// 16x16 8x8 4x4 2x2 16x8 8x4 4x2 8x16 4x8 2x4
me_cmp_func sad[5]; /* identical to pix_absAxA except additional void * */
me_cmp_func sse[5];
me_cmp_func hadamard8_diff[5];
me_cmp_func dct_sad[5];
me_cmp_func quant_psnr[5];
me_cmp_func bit[5];
me_cmp_func rd[5];
me_cmp_func vsad[5];
me_cmp_func vsse[5];
me_cmp_func me_pre_cmp[5];
me_cmp_func me_cmp[5];
me_cmp_func me_sub_cmp[5];
me_cmp_func mb_cmp[5];
me_cmp_func ildct_cmp[5]; //only width 16 used
/**
* Halfpel motion compensation with rounding (a+b+1)>>1.
* this is an array[4][4] of motion compensation funcions for 4
* horizontal blocksizes (8,16) and the 4 halfpel positions<br>
* *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
* @param block destination where the result is stored
* @param pixels source
* @param line_size number of bytes in a horizontal line of block
* @param h height
*/
op_pixels_func put_pixels_tab[4][4];
/**
* Halfpel motion compensation with rounding (a+b+1)>>1.
* This is an array[4][4] of motion compensation functions for 4
* horizontal blocksizes (8,16) and the 4 halfpel positions<br>
* *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
* @param block destination into which the result is averaged (a+b+1)>>1
* @param pixels source
* @param line_size number of bytes in a horizontal line of block
* @param h height
*/
op_pixels_func avg_pixels_tab[4][4];
/**
* Halfpel motion compensation with no rounding (a+b)>>1.
* this is an array[2][4] of motion compensation funcions for 2
* horizontal blocksizes (8,16) and the 4 halfpel positions<br>
* *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
* @param block destination where the result is stored
* @param pixels source
* @param line_size number of bytes in a horizontal line of block
* @param h height
*/
op_pixels_func put_no_rnd_pixels_tab[2][4];
/**
* Halfpel motion compensation with no rounding (a+b)>>1.
* this is an array[2][4] of motion compensation funcions for 2
* horizontal blocksizes (8,16) and the 4 halfpel positions<br>
* *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
* @param block destination into which the result is averaged (a+b)>>1
* @param pixels source
* @param line_size number of bytes in a horizontal line of block
* @param h height
*/
op_pixels_func avg_no_rnd_pixels_tab[2][4];
/**
* Thirdpel motion compensation with rounding (a+b+1)>>1.
* this is an array[12] of motion compensation funcions for the 9 thirdpel positions<br>
* *pixels_tab[ xthirdpel + 4*ythirdpel ]
* @param block destination where the result is stored
* @param pixels source
* @param line_size number of bytes in a horizontal line of block
* @param h height
*/
tpel_mc_func put_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
tpel_mc_func avg_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
qpel_mc_func put_qpel_pixels_tab[2][16];
qpel_mc_func avg_qpel_pixels_tab[2][16];
qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
qpel_mc_func avg_no_rnd_qpel_pixels_tab[2][16];
qpel_mc_func put_mspel_pixels_tab[8];
/**
* h264 Chram MC
*/
h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
qpel_mc_func put_h264_qpel_pixels_tab[3][16];
qpel_mc_func avg_h264_qpel_pixels_tab[3][16];
me_cmp_func pix_abs[2][4];
/* huffyuv specific */
void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w);
/**
* subtract huffyuv's variant of median prediction
* note, this might read from src1[-1], src2[-1]
*/
void (*sub_hfyu_median_prediction)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top);
void (*bswap_buf)(uint32_t *dst, uint32_t *src, int w);
void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
/* (I)DCT */
void (*fdct)(DCTELEM *block/* align 16*/);
void (*fdct248)(DCTELEM *block/* align 16*/);
/* IDCT really*/
void (*idct)(DCTELEM *block/* align 16*/);
/**
* block -> idct -> clip to unsigned 8 bit -> dest.
* (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
* @param line_size size in bytes of a horizotal line of dest
*/
void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
/**
* block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
* @param line_size size in bytes of a horizotal line of dest
*/
void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
/**
* idct input permutation.
* several optimized IDCTs need a permutated input (relative to the normal order of the reference
* IDCT)
* this permutation must be performed before the idct_put/add, note, normally this can be merged
* with the zigzag/alternate scan<br>
* an example to avoid confusion:
* - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...)
* - (x -> referece dct -> reference idct -> x)
* - (x -> referece dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x)
* - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...)
*/
uint8_t idct_permutation[64];
int idct_permutation_type;
#define FF_NO_IDCT_PERM 1
#define FF_LIBMPEG2_IDCT_PERM 2
#define FF_SIMPLE_IDCT_PERM 3
#define FF_TRANSPOSE_IDCT_PERM 4
int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale);
void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
#define BASIS_SHIFT 16
#define RECON_SHIFT 6
} DSPContext;
void dsputil_static_init(void);
void dsputil_init(DSPContext* p, AVCodecContext *avctx);
/**
* permute block according to permuatation.
* @param last last non zero element in scantable order
*/
void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last);
void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
#define BYTE_VEC32(c) ((c)*0x01010101UL)
static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
{
return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
}
static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b)
{
return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
}
/**
* Empty mmx state.
* this must be called between any dsp function and float/double code.
* for example sin(); dsp->idct_put(); emms_c(); cos()
*/
#define emms_c()
/* should be defined by architectures supporting
one or more MultiMedia extension */
int mm_support(void);
#if defined(HAVE_MMX)
#undef emms_c
#define MM_MMX 0x0001 /* standard MMX */
#define MM_3DNOW 0x0004 /* AMD 3DNOW */
#define MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
#define MM_SSE 0x0008 /* SSE functions */
#define MM_SSE2 0x0010 /* PIV SSE2 functions */
extern int mm_flags;
void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
static inline void emms(void)
{
__asm __volatile ("emms;":::"memory");
}
#define emms_c() \
{\
if (mm_flags & MM_MMX)\
emms();\
}
#define __align8 __attribute__ ((aligned (8)))
void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx);
#elif defined(ARCH_ARMV4L)
/* This is to use 4 bytes read to the IDCT pointers for some 'zero'
line ptimizations */
#define __align8 __attribute__ ((aligned (4)))
void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx);
#elif defined(HAVE_MLIB)
/* SPARC/VIS IDCT needs 8-byte aligned DCT blocks */
#define __align8 __attribute__ ((aligned (8)))
void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx);
#elif defined(ARCH_ALPHA)
#define __align8 __attribute__ ((aligned (8)))
void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
#elif defined(ARCH_POWERPC)
#define MM_ALTIVEC 0x0001 /* standard AltiVec */
extern int mm_flags;
#if defined(HAVE_ALTIVEC) && !defined(CONFIG_DARWIN)
#define pixel altivec_pixel
#include <altivec.h>
#undef pixel
#endif
#define __align8 __attribute__ ((aligned (16)))
void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
#elif defined(HAVE_MMI)
#define __align8 __attribute__ ((aligned (16)))
void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx);
#elif defined(ARCH_SH4)
#define __align8 __attribute__ ((aligned (8)))
void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
#else
#define __align8
#endif
#ifdef __GNUC__
struct unaligned_64 { uint64_t l; } __attribute__((packed));
struct unaligned_32 { uint32_t l; } __attribute__((packed));
struct unaligned_16 { uint16_t l; } __attribute__((packed));
#define LD16(a) (((const struct unaligned_16 *) (a))->l)
#define LD32(a) (((const struct unaligned_32 *) (a))->l)
#define LD64(a) (((const struct unaligned_64 *) (a))->l)
#define ST32(a, b) (((struct unaligned_32 *) (a))->l) = (b)
#else /* __GNUC__ */
#define LD16(a) (*((uint16_t*)(a)))
#define LD32(a) (*((uint32_t*)(a)))
#define LD64(a) (*((uint64_t*)(a)))
#define ST32(a, b) *((uint32_t*)(a)) = (b)
#endif /* !__GNUC__ */
/* PSNR */
void get_psnr(uint8_t *orig_image[3], uint8_t *coded_image[3],
int orig_linesize[3], int coded_linesize,
AVCodecContext *avctx);
/* FFT computation */
/* NOTE: soon integer code will be added, so you must use the
FFTSample type */
typedef float FFTSample;
typedef struct FFTComplex {
FFTSample re, im;
} FFTComplex;
typedef struct FFTContext {
int nbits;
int inverse;
uint16_t *revtab;
FFTComplex *exptab;
FFTComplex *exptab1; /* only used by SSE code */
void (*fft_calc)(struct FFTContext *s, FFTComplex *z);
} FFTContext;
int fft_inits(FFTContext *s, int nbits, int inverse);
void fft_permute(FFTContext *s, FFTComplex *z);
void fft_calc_c(FFTContext *s, FFTComplex *z);
void fft_calc_sse(FFTContext *s, FFTComplex *z);
void fft_calc_altivec(FFTContext *s, FFTComplex *z);
static inline void fft_calc(FFTContext *s, FFTComplex *z)
{
s->fft_calc(s, z);
}
void fft_end(FFTContext *s);
/* MDCT computation */
typedef struct MDCTContext {
int n; /* size of MDCT (i.e. number of input data * 2) */
int nbits; /* n = 2^nbits */
/* pre/post rotation tables */
FFTSample *tcos;
FFTSample *tsin;
FFTContext fft;
} MDCTContext;
int ff_mdct_init(MDCTContext *s, int nbits, int inverse);
void ff_imdct_calc(MDCTContext *s, FFTSample *output,
const FFTSample *input, FFTSample *tmp);
void ff_mdct_calc(MDCTContext *s, FFTSample *out,
const FFTSample *input, FFTSample *tmp);
void ff_mdct_end(MDCTContext *s);
#define WARPER8_16(name8, name16)\
static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
return name8(s, dst , src , stride, h)\
+name8(s, dst+8 , src+8 , stride, h);\
}
#define WARPER8_16_SQ(name8, name16)\
static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
int score=0;\
score +=name8(s, dst , src , stride, 8);\
score +=name8(s, dst+8 , src+8 , stride, 8);\
if(h==16){\
dst += 8*stride;\
src += 8*stride;\
score +=name8(s, dst , src , stride, 8);\
score +=name8(s, dst+8 , src+8 , stride, 8);\
}\
return score;\
}
#ifndef HAVE_LRINTF
/* XXX: add ISOC specific test to avoid specific BSD testing. */
/* better than nothing implementation. */
/* btw, rintf() is existing on fbsd too -- alex */
static inline long int lrintf(float x)
{
#ifdef CONFIG_WIN32
/* XXX: incorrect, but make it compile */
return (int)(x);
#else
return (int)(rint(x));
#endif
}
#endif
#endif

View File

@ -0,0 +1,249 @@
/*
* FFT/IFFT transforms
* Copyright (c) 2002 Fabrice Bellard.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @file fft.c
* FFT/IFFT transforms.
*/
#include "dsputil.h"
/**
* The size of the FFT is 2^nbits. If inverse is TRUE, inverse FFT is
* done
*/
int fft_inits(FFTContext *s, int nbits, int inverse)
{
int i, j, m, n;
float alpha, c1, s1, s2;
s->nbits = nbits;
n = 1 << nbits;
s->exptab = av_malloc((n / 2) * sizeof(FFTComplex));
if (!s->exptab)
goto fail;
s->revtab = av_malloc(n * sizeof(uint16_t));
if (!s->revtab)
goto fail;
s->inverse = inverse;
s2 = inverse ? 1.0 : -1.0;
for(i=0;i<(n/2);i++) {
alpha = 2 * M_PI * (float)i / (float)n;
c1 = cos(alpha);
s1 = sin(alpha) * s2;
s->exptab[i].re = c1;
s->exptab[i].im = s1;
}
s->fft_calc = fft_calc_c;
s->exptab1 = NULL;
/* compute constant table for HAVE_SSE version */
#if (defined(HAVE_MMX) && defined(HAVE_BUILTIN_VECTOR)) || defined(HAVE_ALTIVEC)
{
int has_vectors = 0;
#if defined(HAVE_MMX)
has_vectors = mm_support() & MM_SSE;
#endif
#if defined(HAVE_ALTIVEC) && !defined(ALTIVEC_USE_REFERENCE_C_CODE)
has_vectors = mm_support() & MM_ALTIVEC;
#endif
if (has_vectors) {
int np, nblocks, np2, l;
FFTComplex *q;
np = 1 << nbits;
nblocks = np >> 3;
np2 = np >> 1;
s->exptab1 = av_malloc(np * 2 * sizeof(FFTComplex));
if (!s->exptab1)
goto fail;
q = s->exptab1;
do {
for(l = 0; l < np2; l += 2 * nblocks) {
*q++ = s->exptab[l];
*q++ = s->exptab[l + nblocks];
q->re = -s->exptab[l].im;
q->im = s->exptab[l].re;
q++;
q->re = -s->exptab[l + nblocks].im;
q->im = s->exptab[l + nblocks].re;
q++;
}
nblocks = nblocks >> 1;
} while (nblocks != 0);
av_freep(&s->exptab);
#if defined(HAVE_MMX)
s->fft_calc = fft_calc_sse;
#else
s->fft_calc = fft_calc_altivec;
#endif
}
}
#endif
/* compute bit reverse table */
for(i=0;i<n;i++) {
m=0;
for(j=0;j<nbits;j++) {
m |= ((i >> j) & 1) << (nbits-j-1);
}
s->revtab[i]=m;
}
return 0;
fail:
av_freep(&s->revtab);
av_freep(&s->exptab);
av_freep(&s->exptab1);
return -1;
}
/* butter fly op */
#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \
{\
FFTSample ax, ay, bx, by;\
bx=pre1;\
by=pim1;\
ax=qre1;\
ay=qim1;\
pre = (bx + ax);\
pim = (by + ay);\
qre = (bx - ax);\
qim = (by - ay);\
}
#define MUL16(a,b) ((a) * (b))
#define CMUL(pre, pim, are, aim, bre, bim) \
{\
pre = (MUL16(are, bre) - MUL16(aim, bim));\
pim = (MUL16(are, bim) + MUL16(bre, aim));\
}
/**
* Do a complex FFT with the parameters defined in fft_init(). The
* input data must be permuted before with s->revtab table. No
* 1.0/sqrt(n) normalization is done.
*/
void fft_calc_c(FFTContext *s, FFTComplex *z)
{
int ln = s->nbits;
int j, np, np2;
int nblocks, nloops;
register FFTComplex *p, *q;
FFTComplex *exptab = s->exptab;
int l;
FFTSample tmp_re, tmp_im;
np = 1 << ln;
/* pass 0 */
p=&z[0];
j=(np >> 1);
do {
BF(p[0].re, p[0].im, p[1].re, p[1].im,
p[0].re, p[0].im, p[1].re, p[1].im);
p+=2;
} while (--j != 0);
/* pass 1 */
p=&z[0];
j=np >> 2;
if (s->inverse) {
do {
BF(p[0].re, p[0].im, p[2].re, p[2].im,
p[0].re, p[0].im, p[2].re, p[2].im);
BF(p[1].re, p[1].im, p[3].re, p[3].im,
p[1].re, p[1].im, -p[3].im, p[3].re);
p+=4;
} while (--j != 0);
} else {
do {
BF(p[0].re, p[0].im, p[2].re, p[2].im,
p[0].re, p[0].im, p[2].re, p[2].im);
BF(p[1].re, p[1].im, p[3].re, p[3].im,
p[1].re, p[1].im, p[3].im, -p[3].re);
p+=4;
} while (--j != 0);
}
/* pass 2 .. ln-1 */
nblocks = np >> 3;
nloops = 1 << 2;
np2 = np >> 1;
do {
p = z;
q = z + nloops;
for (j = 0; j < nblocks; ++j) {
BF(p->re, p->im, q->re, q->im,
p->re, p->im, q->re, q->im);
p++;
q++;
for(l = nblocks; l < np2; l += nblocks) {
CMUL(tmp_re, tmp_im, exptab[l].re, exptab[l].im, q->re, q->im);
BF(p->re, p->im, q->re, q->im,
p->re, p->im, tmp_re, tmp_im);
p++;
q++;
}
p += nloops;
q += nloops;
}
nblocks = nblocks >> 1;
nloops = nloops << 1;
} while (nblocks != 0);
}
/**
* Do the permutation needed BEFORE calling fft_calc()
*/
void fft_permute(FFTContext *s, FFTComplex *z)
{
int j, k, np;
FFTComplex tmp;
const uint16_t *revtab = s->revtab;
/* reverse */
np = 1 << s->nbits;
for(j=0;j<np;j++) {
k = revtab[j];
if (k < j) {
tmp = z[k];
z[k] = z[j];
z[j] = tmp;
}
}
}
void fft_end(FFTContext *s)
{
av_freep(&s->revtab);
av_freep(&s->exptab);
av_freep(&s->exptab1);
}

View File

@ -0,0 +1,132 @@
/*
* Buffered file io for ffmpeg system
* Copyright (c) 2001 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "avformat.h"
#include <fcntl.h>
#ifndef CONFIG_WIN32
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#else
#include <io.h>
#define open(fname,oflag,pmode) _open(fname,oflag,pmode)
#endif /* CONFIG_WIN32 */
/* standard file protocol */
static int file_open(URLContext *h, const char *filename, int flags)
{
int access;
int fd;
strstart(filename, "file:", &filename);
if (flags & URL_WRONLY) {
access = O_CREAT | O_TRUNC | O_WRONLY;
} else {
access = O_RDONLY;
}
#if defined(CONFIG_WIN32) || defined(CONFIG_OS2) || defined(__CYGWIN__)
access |= O_BINARY;
#endif
fd = open(filename, access, 0666);
if (fd < 0)
return -ENOENT;
h->priv_data = (void *)fd;
return 0;
}
static int file_read(URLContext *h, unsigned char *buf, int size)
{
int fd = (int)h->priv_data;
return read(fd, buf, size);
}
static int file_write(URLContext *h, unsigned char *buf, int size)
{
int fd = (int)h->priv_data;
return write(fd, buf, size);
}
/* XXX: use llseek */
static offset_t file_seek(URLContext *h, offset_t pos, int whence)
{
int fd = (int)h->priv_data;
#ifdef CONFIG_WIN32
return _lseeki64(fd, pos, whence);
#else
return lseek(fd, pos, whence);
#endif
}
static int file_close(URLContext *h)
{
int fd = (int)h->priv_data;
return close(fd);
}
URLProtocol file_protocol = {
"file",
file_open,
file_read,
file_write,
file_seek,
file_close,
};
/* pipe protocol */
static int pipe_open(URLContext *h, const char *filename, int flags)
{
int fd;
if (flags & URL_WRONLY) {
fd = 1;
} else {
fd = 0;
}
h->priv_data = (void *)fd;
return 0;
}
static int pipe_read(URLContext *h, unsigned char *buf, int size)
{
int fd = (int)h->priv_data;
return read(fd, buf, size);
}
static int pipe_write(URLContext *h, unsigned char *buf, int size)
{
int fd = (int)h->priv_data;
return write(fd, buf, size);
}
static int pipe_close(URLContext *h)
{
return 0;
}
URLProtocol pipe_protocol = {
"pipe",
pipe_open,
pipe_read,
pipe_write,
NULL,
pipe_close,
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,175 @@
/*
* MDCT/IMDCT transforms
* Copyright (c) 2002 Fabrice Bellard.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "dsputil.h"
/**
* @file mdct.c
* MDCT/IMDCT transforms.
*/
/**
* init MDCT or IMDCT computation.
*/
int ff_mdct_init(MDCTContext *s, int nbits, int inverse)
{
int n, n4, i;
float alpha;
memset(s, 0, sizeof(*s));
n = 1 << nbits;
s->nbits = nbits;
s->n = n;
n4 = n >> 2;
s->tcos = av_malloc(n4 * sizeof(FFTSample));
if (!s->tcos)
goto fail;
s->tsin = av_malloc(n4 * sizeof(FFTSample));
if (!s->tsin)
goto fail;
for(i=0;i<n4;i++) {
alpha = 2 * M_PI * (i + 1.0 / 8.0) / n;
s->tcos[i] = -cos(alpha);
s->tsin[i] = -sin(alpha);
}
if (fft_inits(&s->fft, s->nbits - 2, inverse) < 0)
goto fail;
return 0;
fail:
av_freep(&s->tcos);
av_freep(&s->tsin);
return -1;
}
/* complex multiplication: p = a * b */
#define CMUL(pre, pim, are, aim, bre, bim) \
{\
float _are = (are);\
float _aim = (aim);\
float _bre = (bre);\
float _bim = (bim);\
(pre) = _are * _bre - _aim * _bim;\
(pim) = _are * _bim + _aim * _bre;\
}
/**
* Compute inverse MDCT of size N = 2^nbits
* @param output N samples
* @param input N/2 samples
* @param tmp N/2 samples
*/
void ff_imdct_calc(MDCTContext *s, FFTSample *output,
const FFTSample *input, FFTSample *tmp)
{
int k, n8, n4, n2, n, j;
const uint16_t *revtab = s->fft.revtab;
const FFTSample *tcos = s->tcos;
const FFTSample *tsin = s->tsin;
const FFTSample *in1, *in2;
FFTComplex *z = (FFTComplex *)tmp;
n = 1 << s->nbits;
n2 = n >> 1;
n4 = n >> 2;
n8 = n >> 3;
/* pre rotation */
in1 = input;
in2 = input + n2 - 1;
for(k = 0; k < n4; k++) {
j=revtab[k];
CMUL(z[j].re, z[j].im, *in2, *in1, tcos[k], tsin[k]);
in1 += 2;
in2 -= 2;
}
fft_calc(&s->fft, z);
/* post rotation + reordering */
/* XXX: optimize */
for(k = 0; k < n4; k++) {
CMUL(z[k].re, z[k].im, z[k].re, z[k].im, tcos[k], tsin[k]);
}
for(k = 0; k < n8; k++) {
output[2*k] = -z[n8 + k].im;
output[n2-1-2*k] = z[n8 + k].im;
output[2*k+1] = z[n8-1-k].re;
output[n2-1-2*k-1] = -z[n8-1-k].re;
output[n2 + 2*k]=-z[k+n8].re;
output[n-1- 2*k]=-z[k+n8].re;
output[n2 + 2*k+1]=z[n8-k-1].im;
output[n-2 - 2 * k] = z[n8-k-1].im;
}
}
/**
* Compute MDCT of size N = 2^nbits
* @param input N samples
* @param out N/2 samples
* @param tmp temporary storage of N/2 samples
*/
void ff_mdct_calc(MDCTContext *s, FFTSample *out,
const FFTSample *input, FFTSample *tmp)
{
int i, j, n, n8, n4, n2, n3;
FFTSample re, im, re1, im1;
const uint16_t *revtab = s->fft.revtab;
const FFTSample *tcos = s->tcos;
const FFTSample *tsin = s->tsin;
FFTComplex *x = (FFTComplex *)tmp;
n = 1 << s->nbits;
n2 = n >> 1;
n4 = n >> 2;
n8 = n >> 3;
n3 = 3 * n4;
/* pre rotation */
for(i=0;i<n8;i++) {
re = -input[2*i+3*n4] - input[n3-1-2*i];
im = -input[n4+2*i] + input[n4-1-2*i];
j = revtab[i];
CMUL(x[j].re, x[j].im, re, im, -tcos[i], tsin[i]);
re = input[2*i] - input[n2-1-2*i];
im = -(input[n2+2*i] + input[n-1-2*i]);
j = revtab[n8 + i];
CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]);
}
fft_calc(&s->fft, x);
/* post rotation */
for(i=0;i<n4;i++) {
re = x[i].re;
im = x[i].im;
CMUL(re1, im1, re, im, -tsin[i], -tcos[i]);
out[2*i] = im1;
out[n2-1-2*i] = re1;
}
}
void ff_mdct_end(MDCTContext *s)
{
av_freep(&s->tcos);
av_freep(&s->tsin);
fft_end(&s->fft);
}

View File

@ -0,0 +1,71 @@
/*
* default memory allocator for libavcodec
* Copyright (c) 2002 Fabrice Bellard.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @file mem.c
* default memory allocator for libavcodec.
*/
#include "avcodec.h"
/* here we can use OS dependant allocation functions */
#undef malloc
#undef free
#undef realloc
//#ifdef HAVE_MALLOC_H
//#include <malloc.h>
//#endif
/* you can redefine av_malloc and av_free in your project to use your
memory allocator. You do not need to suppress this file because the
linker will do it automatically */
/**
* Memory allocation of size byte with alignment suitable for all
* memory accesses (including vectors if available on the
* CPU). av_malloc(0) must return a non NULL pointer.
*/
void *av_malloc(unsigned int size)
{
void *ptr;
ptr = malloc(size);
return ptr;
}
/**
* av_realloc semantics (same as glibc): if ptr is NULL and size > 0,
* identical to malloc(size). If size is zero, it is identical to
* free(ptr) and NULL is returned.
*/
void *av_realloc(void *ptr, unsigned int size)
{
return realloc(ptr, size);
}
/* NOTE: ptr = NULL is explicetly allowed */
void av_free(void *ptr)
{
/* XXX: this test should not be needed on most libcs */
if (ptr)
free(ptr);
}

View File

@ -0,0 +1,57 @@
/*
* Various utilities for ffmpeg system
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "avformat.h"
#ifdef CONFIG_WIN32
#include <sys/types.h>
#include <sys/timeb.h>
#elif defined(CONFIG_OS2)
#include <string.h>
#include <sys/time.h>
#else
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#endif
#include <time.h>
int64_t av_gettime(void)
{
#ifdef CONFIG_WIN32
struct _timeb tb;
_ftime(&tb);
return ((int64_t)tb.time * int64_t_C(1000) + (int64_t)tb.millitm) * int64_t_C(1000);
#else
struct timeval tv;
gettimeofday(&tv,NULL);
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
#endif
}
#if !defined(HAVE_LOCALTIME_R)
struct tm *localtime_r(const time_t *t, struct tm *tp)
{
struct tm *l;
l = localtime(t);
if (!l)
return 0;
*tp = *l;
return tp;
}
#endif /* !defined(HAVE_LOCALTIME_R) */

View File

@ -0,0 +1,33 @@
#ifndef _OS_SUPPORT_H
#define _OS_SUPPORT_H
/**
* @file os_support.h
* miscellaneous OS support macros and functions.
*
* - usleep() (Win32, BeOS, OS/2)
* - floatf() (OS/2)
* - strcasecmp() (OS/2)
*/
#ifdef __MINGW32__
# undef DATADIR /* clashes with /usr/include/w32api/objidl.h */
__declspec(dllimport) void __stdcall Sleep(unsigned long dwMilliseconds);
// # include <windows.h>
# define usleep(t) Sleep((t) / 1000)
#endif
#ifdef __BEOS__
# ifndef usleep
# include <OS.h>
# define usleep(t) snooze((bigtime_t)(t))
# endif
#endif
#if defined(CONFIG_OS2)
#include <stdlib.h>
static inline int usleep(unsigned int t) { return _sleep2(t / 1000); }
static inline int strcasecmp(const char* s1, const char* s2) { return stricmp(s1,s2); }
#endif
#endif /* _OS_SUPPORT_H */

View File

@ -0,0 +1,960 @@
/*
* Audio and Video frame extraction
* Copyright (c) 2003 Fabrice Bellard.
* Copyright (c) 2003 Michael Niedermayer.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "avcodec.h"
//#include "mpegvideo.h"
//#include "mpegaudio.h"
AVCodecParser *av_first_parser = NULL;
void av_register_codec_parser(AVCodecParser *parser)
{
parser->next = av_first_parser;
av_first_parser = parser;
}
AVCodecParserContext *av_parser_init(int codec_id)
{
AVCodecParserContext *s;
AVCodecParser *parser;
int ret;
for(parser = av_first_parser; parser != NULL; parser = parser->next) {
if (parser->codec_ids[0] == codec_id ||
parser->codec_ids[1] == codec_id ||
parser->codec_ids[2] == codec_id)
goto found;
}
return NULL;
found:
s = av_mallocz(sizeof(AVCodecParserContext));
if (!s)
return NULL;
s->parser = parser;
s->priv_data = av_mallocz(parser->priv_data_size);
if (!s->priv_data) {
av_free(s);
return NULL;
}
if (parser->parser_init) {
ret = parser->parser_init(s);
if (ret != 0) {
av_free(s->priv_data);
av_free(s);
return NULL;
}
}
return s;
}
/* NOTE: buf_size == 0 is used to signal EOF so that the last frame
can be returned if necessary */
int av_parser_parse(AVCodecParserContext *s,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size,
int64_t pts, int64_t dts)
{
int index, i, k;
uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE];
if (buf_size == 0) {
/* padding is always necessary even if EOF, so we add it here */
memset(dummy_buf, 0, sizeof(dummy_buf));
buf = dummy_buf;
} else {
/* add a new packet descriptor */
k = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
s->cur_frame_start_index = k;
s->cur_frame_offset[k] = s->cur_offset;
s->cur_frame_pts[k] = pts;
s->cur_frame_dts[k] = dts;
/* fill first PTS/DTS */
if (s->cur_offset == 0) {
s->last_pts = pts;
s->last_dts = dts;
}
}
/* WARNING: the returned index can be negative */
index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size);
/* update the file pointer */
if (*poutbuf_size) {
/* fill the data for the current frame */
s->frame_offset = s->last_frame_offset;
s->pts = s->last_pts;
s->dts = s->last_dts;
/* offset of the next frame */
s->last_frame_offset = s->cur_offset + index;
/* find the packet in which the new frame starts. It
is tricky because of MPEG video start codes
which can begin in one packet and finish in
another packet. In the worst case, an MPEG
video start code could be in 4 different
packets. */
k = s->cur_frame_start_index;
for(i = 0; i < AV_PARSER_PTS_NB; i++) {
if (s->last_frame_offset >= s->cur_frame_offset[k])
break;
k = (k - 1) & (AV_PARSER_PTS_NB - 1);
}
s->last_pts = s->cur_frame_pts[k];
s->last_dts = s->cur_frame_dts[k];
}
if (index < 0)
index = 0;
s->cur_offset += index;
return index;
}
void av_parser_close(AVCodecParserContext *s)
{
if (s->parser->parser_close)
s->parser->parser_close(s);
av_free(s->priv_data);
av_free(s);
}
#if 0
/*****************************************************/
//#define END_NOT_FOUND (-100)
#define PICTURE_START_CODE 0x00000100
#define SEQ_START_CODE 0x000001b3
#define EXT_START_CODE 0x000001b5
#define SLICE_MIN_START_CODE 0x00000101
#define SLICE_MAX_START_CODE 0x000001af
typedef struct ParseContext1{
uint8_t *buffer;
int index;
int last_index;
int buffer_size;
uint32_t state; ///< contains the last few bytes in MSB order
int frame_start_found;
int overread; ///< the number of bytes which where irreversibly read from the next frame
int overread_index; ///< the index into ParseContext1.buffer of the overreaded bytes
/* MPEG2 specific */
int frame_rate;
int progressive_sequence;
int width, height;
/* XXX: suppress that, needed by MPEG4 */
MpegEncContext *enc;
int first_picture;
} ParseContext1;
/**
* combines the (truncated) bitstream to a complete frame
* @returns -1 if no complete frame could be created
*/
static int ff_combine_frame1(ParseContext1 *pc, int next, uint8_t **buf, int *buf_size)
{
#if 0
if(pc->overread){
printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
}
#endif
/* copy overreaded bytes from last frame into buffer */
for(; pc->overread>0; pc->overread--){
pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
}
pc->last_index= pc->index;
/* copy into buffer end return */
if(next == END_NOT_FOUND){
pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(&pc->buffer[pc->index], *buf, *buf_size);
pc->index += *buf_size;
return -1;
}
*buf_size=
pc->overread_index= pc->index + next;
/* append to buffer */
if(pc->index){
pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE );
pc->index = 0;
*buf= pc->buffer;
}
/* store overread bytes */
for(;next < 0; next++){
pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];
pc->overread++;
}
#if 0
if(pc->overread){
printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
}
#endif
return 0;
}
/**
* finds the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or -1
*/
static int mpeg1_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size)
{
int i;
uint32_t state;
state= pc->state;
i=0;
if(!pc->frame_start_found){
for(i=0; i<buf_size; i++){
state= (state<<8) | buf[i];
if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){
i++;
pc->frame_start_found=1;
break;
}
}
}
if(pc->frame_start_found){
/* EOF considered as end of frame */
if (buf_size == 0)
return 0;
for(; i<buf_size; i++){
state= (state<<8) | buf[i];
if((state&0xFFFFFF00) == 0x100){
if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){
pc->frame_start_found=0;
pc->state=-1;
return i-3;
}
}
}
}
pc->state= state;
return END_NOT_FOUND;
}
static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end)
{
const uint8_t *buf_ptr;
unsigned int state=0xFFFFFFFF, v;
int val;
buf_ptr = *pbuf_ptr;
while (buf_ptr < buf_end) {
v = *buf_ptr++;
if (state == 0x000001) {
state = ((state << 8) | v) & 0xffffff;
val = state;
goto found;
}
state = ((state << 8) | v) & 0xffffff;
}
val = -1;
found:
*pbuf_ptr = buf_ptr;
return val;
}
/* XXX: merge with libavcodec ? */
#define MPEG1_FRAME_RATE_BASE 1001
static const int frame_rate_tab[16] = {
0,
24000,
24024,
25025,
30000,
30030,
50050,
60000,
60060,
// Xing's 15fps: (9)
15015,
// libmpeg3's "Unofficial economy rates": (10-13)
5005,
10010,
12012,
15015,
// random, just to avoid segfault !never encode these
25025,
25025,
};
static void mpegvideo_extract_headers(AVCodecParserContext *s,
AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
ParseContext1 *pc = s->priv_data;
const uint8_t *buf_end;
int32_t start_code;
int frame_rate_index, ext_type, bytes_left;
int frame_rate_ext_n, frame_rate_ext_d;
int top_field_first, repeat_first_field, progressive_frame;
int horiz_size_ext, vert_size_ext;
s->repeat_pict = 0;
buf_end = buf + buf_size;
while (buf < buf_end) {
start_code = find_start_code(&buf, buf_end);
bytes_left = buf_end - buf;
switch(start_code) {
case PICTURE_START_CODE:
if (bytes_left >= 2) {
s->pict_type = (buf[1] >> 3) & 7;
}
break;
case SEQ_START_CODE:
if (bytes_left >= 4) {
pc->width = avctx->width = (buf[0] << 4) | (buf[1] >> 4);
pc->height = avctx->height = ((buf[1] & 0x0f) << 8) | buf[2];
frame_rate_index = buf[3] & 0xf;
pc->frame_rate = avctx->frame_rate = frame_rate_tab[frame_rate_index];
avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE;
avctx->codec_id = CODEC_ID_MPEG1VIDEO;
avctx->sub_id = 1;
}
break;
case EXT_START_CODE:
if (bytes_left >= 1) {
ext_type = (buf[0] >> 4);
switch(ext_type) {
case 0x1: /* sequence extension */
if (bytes_left >= 6) {
horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7);
vert_size_ext = (buf[2] >> 5) & 3;
frame_rate_ext_n = (buf[5] >> 5) & 3;
frame_rate_ext_d = (buf[5] & 0x1f);
pc->progressive_sequence = buf[1] & (1 << 3);
avctx->width = pc->width | (horiz_size_ext << 12);
avctx->height = pc->height | (vert_size_ext << 12);
avctx->frame_rate = pc->frame_rate * (frame_rate_ext_n + 1);
avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1);
avctx->codec_id = CODEC_ID_MPEG2VIDEO;
avctx->sub_id = 2; /* forces MPEG2 */
}
break;
case 0x8: /* picture coding extension */
if (bytes_left >= 5) {
top_field_first = buf[3] & (1 << 7);
repeat_first_field = buf[3] & (1 << 1);
progressive_frame = buf[4] & (1 << 7);
/* check if we must repeat the frame */
if (repeat_first_field) {
if (pc->progressive_sequence) {
if (top_field_first)
s->repeat_pict = 4;
else
s->repeat_pict = 2;
} else if (progressive_frame) {
s->repeat_pict = 1;
}
}
}
break;
}
}
break;
case -1:
goto the_end;
default:
/* we stop parsing when we encounter a slice. It ensures
that this function takes a negligible amount of time */
if (start_code >= SLICE_MIN_START_CODE &&
start_code <= SLICE_MAX_START_CODE)
goto the_end;
break;
}
}
the_end: ;
}
static int mpegvideo_parse(AVCodecParserContext *s,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
ParseContext1 *pc = s->priv_data;
int next;
next= mpeg1_find_frame_end(pc, buf, buf_size);
if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
/* we have a full frame : we just parse the first few MPEG headers
to have the full timing information. The time take by this
function should be negligible for uncorrupted streams */
mpegvideo_extract_headers(s, avctx, buf, buf_size);
#if 0
printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
s->pict_type, (double)avctx->frame_rate / avctx->frame_rate_base, s->repeat_pict);
#endif
*poutbuf = (uint8_t *)buf;
*poutbuf_size = buf_size;
return next;
}
static void mpegvideo_parse_close(AVCodecParserContext *s)
{
ParseContext1 *pc = s->priv_data;
av_free(pc->buffer);
av_free(pc->enc);
}
/*************************/
/**
* finds the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or -1
*/
static int mpeg4_find_frame_end(ParseContext1 *pc,
const uint8_t *buf, int buf_size)
{
int vop_found, i;
uint32_t state;
vop_found= pc->frame_start_found;
state= pc->state;
i=0;
if(!vop_found){
for(i=0; i<buf_size; i++){
state= (state<<8) | buf[i];
if(state == 0x1B6){
i++;
vop_found=1;
break;
}
}
}
if(vop_found){
/* EOF considered as end of frame */
if (buf_size == 0)
return 0;
for(; i<buf_size; i++){
state= (state<<8) | buf[i];
if((state&0xFFFFFF00) == 0x100){
pc->frame_start_found=0;
pc->state=-1;
return i-3;
}
}
}
pc->frame_start_found= vop_found;
pc->state= state;
return END_NOT_FOUND;
}
/* used by parser */
/* XXX: make it use less memory */
#if 0
static int av_mpeg4_decode_header(AVCodecParserContext *s1,
AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
ParseContext1 *pc = s1->priv_data;
MpegEncContext *s = pc->enc;
GetBitContext gb1, *gb = &gb1;
int ret;
s->avctx = avctx;
s->current_picture_ptr = &s->current_picture;
if (avctx->extradata_size && pc->first_picture){
init_get_bits(gb, avctx->extradata, avctx->extradata_size*8);
ret = ff_mpeg4_decode_picture_header(s, gb);
}
init_get_bits(gb, buf, 8 * buf_size);
ret = ff_mpeg4_decode_picture_header(s, gb);
if (s->width) {
avctx->width = s->width;
avctx->height = s->height;
}
pc->first_picture = 0;
return ret;
}
#endif
int mpeg4video_parse_init(AVCodecParserContext *s)
{
ParseContext1 *pc = s->priv_data;
pc->enc = av_mallocz(sizeof(MpegEncContext));
if (!pc->enc)
return -1;
pc->first_picture = 1;
return 0;
}
static int mpeg4video_parse(AVCodecParserContext *s,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
ParseContext1 *pc = s->priv_data;
int next;
next= mpeg4_find_frame_end(pc, buf, buf_size);
if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
av_mpeg4_decode_header(s, avctx, buf, buf_size);
*poutbuf = (uint8_t *)buf;
*poutbuf_size = buf_size;
return next;
}
/*************************/
static int h263_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size)
{
int vop_found, i;
uint32_t state;
vop_found= pc->frame_start_found;
state= pc->state;
i=0;
if(!vop_found){
for(i=0; i<buf_size; i++){
state= (state<<8) | buf[i];
if(state>>(32-22) == 0x20){
i++;
vop_found=1;
break;
}
}
}
if(vop_found){
for(; i<buf_size; i++){
state= (state<<8) | buf[i];
if(state>>(32-22) == 0x20){
pc->frame_start_found=0;
pc->state=-1;
return i-3;
}
}
}
pc->frame_start_found= vop_found;
pc->state= state;
return END_NOT_FOUND;
}
static int h263_parse(AVCodecParserContext *s,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
ParseContext1 *pc = s->priv_data;
int next;
next= h263_find_frame_end(pc, buf, buf_size);
if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
*poutbuf = (uint8_t *)buf;
*poutbuf_size = buf_size;
return next;
}
/*************************/
/**
* finds the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or -1
*/
static int h264_find_frame_end(ParseContext1 *pc, const uint8_t *buf, int buf_size)
{
int i;
uint32_t state;
//printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]);
// mb_addr= pc->mb_addr - 1;
state= pc->state;
//FIXME this will fail with slices
for(i=0; i<buf_size; i++){
state= (state<<8) | buf[i];
if((state&0xFFFFFF1F) == 0x101 || (state&0xFFFFFF1F) == 0x102 || (state&0xFFFFFF1F) == 0x105){
if(pc->frame_start_found){
pc->state=-1;
pc->frame_start_found= 0;
return i-3;
}
pc->frame_start_found= 1;
}
}
pc->state= state;
return END_NOT_FOUND;
}
static int h264_parse(AVCodecParserContext *s,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
ParseContext1 *pc = s->priv_data;
int next;
next= h264_find_frame_end(pc, buf, buf_size);
if (ff_combine_frame1(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
*poutbuf = NULL;
*poutbuf_size = 0;
return buf_size;
}
*poutbuf = (uint8_t *)buf;
*poutbuf_size = buf_size;
return next;
}
/*************************/
typedef struct MpegAudioParseContext {
uint8_t inbuf[MPA_MAX_CODED_FRAME_SIZE]; /* input buffer */
uint8_t *inbuf_ptr;
int frame_size;
int free_format_frame_size;
int free_format_next_header;
} MpegAudioParseContext;
#define MPA_HEADER_SIZE 4
/* header + layer + bitrate + freq + lsf/mpeg25 */
#define SAME_HEADER_MASK \
(0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19))
static int mpegaudio_parse_init(AVCodecParserContext *s1)
{
MpegAudioParseContext *s = s1->priv_data;
s->inbuf_ptr = s->inbuf;
return 0;
}
static int mpegaudio_parse(AVCodecParserContext *s1,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
MpegAudioParseContext *s = s1->priv_data;
int len, ret;
uint32_t header;
const uint8_t *buf_ptr;
*poutbuf = NULL;
*poutbuf_size = 0;
buf_ptr = buf;
while (buf_size > 0) {
len = s->inbuf_ptr - s->inbuf;
if (s->frame_size == 0) {
/* special case for next header for first frame in free
format case (XXX: find a simpler method) */
if (s->free_format_next_header != 0) {
s->inbuf[0] = s->free_format_next_header >> 24;
s->inbuf[1] = s->free_format_next_header >> 16;
s->inbuf[2] = s->free_format_next_header >> 8;
s->inbuf[3] = s->free_format_next_header;
s->inbuf_ptr = s->inbuf + 4;
s->free_format_next_header = 0;
goto got_header;
}
/* no header seen : find one. We need at least MPA_HEADER_SIZE
bytes to parse it */
len = MPA_HEADER_SIZE - len;
if (len > buf_size)
len = buf_size;
if (len > 0) {
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr += len;
}
if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) {
got_header:
header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
(s->inbuf[2] << 8) | s->inbuf[3];
ret = mpa_decode_header(avctx, header);
if (ret < 0) {
/* no sync found : move by one byte (inefficient, but simple!) */
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
dprintf("skip %x\n", header);
/* reset free format frame size to give a chance
to get a new bitrate */
s->free_format_frame_size = 0;
} else {
s->frame_size = ret;
#if 0
/* free format: prepare to compute frame size */
if (decode_header(s, header) == 1) {
s->frame_size = -1;
}
#endif
}
}
} else
#if 0
if (s->frame_size == -1) {
/* free format : find next sync to compute frame size */
len = MPA_MAX_CODED_FRAME_SIZE - len;
if (len > buf_size)
len = buf_size;
if (len == 0) {
/* frame too long: resync */
s->frame_size = 0;
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
s->inbuf_ptr--;
} else {
uint8_t *p, *pend;
uint32_t header1;
int padding;
memcpy(s->inbuf_ptr, buf_ptr, len);
/* check for header */
p = s->inbuf_ptr - 3;
pend = s->inbuf_ptr + len - 4;
while (p <= pend) {
header = (p[0] << 24) | (p[1] << 16) |
(p[2] << 8) | p[3];
header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
(s->inbuf[2] << 8) | s->inbuf[3];
/* check with high probability that we have a
valid header */
if ((header & SAME_HEADER_MASK) ==
(header1 & SAME_HEADER_MASK)) {
/* header found: update pointers */
len = (p + 4) - s->inbuf_ptr;
buf_ptr += len;
buf_size -= len;
s->inbuf_ptr = p;
/* compute frame size */
s->free_format_next_header = header;
s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
padding = (header1 >> 9) & 1;
if (s->layer == 1)
s->free_format_frame_size -= padding * 4;
else
s->free_format_frame_size -= padding;
dprintf("free frame size=%d padding=%d\n",
s->free_format_frame_size, padding);
decode_header(s, header1);
goto next_data;
}
p++;
}
/* not found: simply increase pointers */
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
} else
#endif
if (len < s->frame_size) {
if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
len = s->frame_size - len;
if (len > buf_size)
len = buf_size;
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
}
// next_data:
if (s->frame_size > 0 &&
(s->inbuf_ptr - s->inbuf) >= s->frame_size) {
*poutbuf = s->inbuf;
*poutbuf_size = s->inbuf_ptr - s->inbuf;
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
break;
}
}
return buf_ptr - buf;
}
#ifdef CONFIG_AC3
extern int a52_syncinfo (const uint8_t * buf, int * flags,
int * sample_rate, int * bit_rate);
typedef struct AC3ParseContext {
uint8_t inbuf[4096]; /* input buffer */
uint8_t *inbuf_ptr;
int frame_size;
int flags;
} AC3ParseContext;
#define AC3_HEADER_SIZE 7
#define A52_LFE 16
static int ac3_parse_init(AVCodecParserContext *s1)
{
AC3ParseContext *s = s1->priv_data;
s->inbuf_ptr = s->inbuf;
return 0;
}
static int ac3_parse(AVCodecParserContext *s1,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
AC3ParseContext *s = s1->priv_data;
const uint8_t *buf_ptr;
int len, sample_rate, bit_rate;
static const int ac3_channels[8] = {
2, 1, 2, 3, 3, 4, 4, 5
};
*poutbuf = NULL;
*poutbuf_size = 0;
buf_ptr = buf;
while (buf_size > 0) {
len = s->inbuf_ptr - s->inbuf;
if (s->frame_size == 0) {
/* no header seen : find one. We need at least 7 bytes to parse it */
len = AC3_HEADER_SIZE - len;
if (len > buf_size)
len = buf_size;
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
if ((s->inbuf_ptr - s->inbuf) == AC3_HEADER_SIZE) {
len = a52_syncinfo(s->inbuf, &s->flags, &sample_rate, &bit_rate);
if (len == 0) {
/* no sync found : move by one byte (inefficient, but simple!) */
memmove(s->inbuf, s->inbuf + 1, AC3_HEADER_SIZE - 1);
s->inbuf_ptr--;
} else {
s->frame_size = len;
/* update codec info */
avctx->sample_rate = sample_rate;
avctx->channels = ac3_channels[s->flags & 7];
if (s->flags & A52_LFE)
avctx->channels++;
avctx->bit_rate = bit_rate;
avctx->frame_size = 6 * 256;
}
}
} else if (len < s->frame_size) {
len = s->frame_size - len;
if (len > buf_size)
len = buf_size;
memcpy(s->inbuf_ptr, buf_ptr, len);
buf_ptr += len;
s->inbuf_ptr += len;
buf_size -= len;
} else {
*poutbuf = s->inbuf;
*poutbuf_size = s->frame_size;
s->inbuf_ptr = s->inbuf;
s->frame_size = 0;
break;
}
}
return buf_ptr - buf;
}
#endif
AVCodecParser mpegvideo_parser = {
{ CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO },
sizeof(ParseContext1),
NULL,
mpegvideo_parse,
mpegvideo_parse_close,
};
AVCodecParser mpeg4video_parser = {
{ CODEC_ID_MPEG4 },
sizeof(ParseContext1),
mpeg4video_parse_init,
mpeg4video_parse,
mpegvideo_parse_close,
};
AVCodecParser h263_parser = {
{ CODEC_ID_H263 },
sizeof(ParseContext1),
NULL,
h263_parse,
mpegvideo_parse_close,
};
AVCodecParser h264_parser = {
{ CODEC_ID_H264 },
sizeof(ParseContext1),
NULL,
h264_parse,
mpegvideo_parse_close,
};
AVCodecParser mpegaudio_parser = {
{ CODEC_ID_MP2, CODEC_ID_MP3 },
sizeof(MpegAudioParseContext),
mpegaudio_parse_init,
mpegaudio_parse,
NULL,
};
#ifdef CONFIG_AC3
AVCodecParser ac3_parser = {
{ CODEC_ID_AC3 },
sizeof(AC3ParseContext),
ac3_parse_init,
ac3_parse,
NULL,
};
#endif
#endif

View File

@ -0,0 +1,585 @@
/*
* Simple IDCT
*
* Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @file simple_idct.c
* simpleidct in C.
*/
/*
based upon some outcommented c code from mpeg2dec (idct_mmx.c
written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
*/
#include "avcodec.h"
#include "dsputil.h"
#include "simple_idct.h"
#if 0
#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */
#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */
#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */
#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */
#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */
#define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */
#define ROW_SHIFT 8
#define COL_SHIFT 17
#else
#define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define W4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define W5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define W6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define W7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
#define ROW_SHIFT 11
#define COL_SHIFT 20 // 6
#endif
#if defined(ARCH_POWERPC_405)
/* signed 16x16 -> 32 multiply add accumulate */
#define MAC16(rt, ra, rb) \
asm ("maclhw %0, %2, %3" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb));
/* signed 16x16 -> 32 multiply */
#define MUL16(rt, ra, rb) \
asm ("mullhw %0, %1, %2" : "=r" (rt) : "r" (ra), "r" (rb));
#else
/* signed 16x16 -> 32 multiply add accumulate */
#define MAC16(rt, ra, rb) rt += (ra) * (rb)
/* signed 16x16 -> 32 multiply */
#define MUL16(rt, ra, rb) rt = (ra) * (rb)
#endif
static inline void idctRowCondDC (DCTELEM * row)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
#ifdef FAST_64BIT
uint64_t temp;
#else
uint32_t temp;
#endif
#ifdef FAST_64BIT
#ifdef WORDS_BIGENDIAN
#define ROW0_MASK 0xffff000000000000LL
#else
#define ROW0_MASK 0xffffLL
#endif
if(sizeof(DCTELEM)==2){
if ( ((((uint64_t *)row)[0] & ~ROW0_MASK) |
((uint64_t *)row)[1]) == 0) {
temp = (row[0] << 3) & 0xffff;
temp += temp << 16;
temp += temp << 32;
((uint64_t *)row)[0] = temp;
((uint64_t *)row)[1] = temp;
return;
}
}else{
if (!(row[1]|row[2]|row[3]|row[4]|row[5]|row[6]|row[7])) {
row[0]=row[1]=row[2]=row[3]=row[4]=row[5]=row[6]=row[7]= row[0] << 3;
return;
}
}
#else
if(sizeof(DCTELEM)==2){
if (!(((uint32_t*)row)[1] |
((uint32_t*)row)[2] |
((uint32_t*)row)[3] |
row[1])) {
temp = (row[0] << 3) & 0xffff;
temp += temp << 16;
((uint32_t*)row)[0]=((uint32_t*)row)[1] =
((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
return;
}
}else{
if (!(row[1]|row[2]|row[3]|row[4]|row[5]|row[6]|row[7])) {
row[0]=row[1]=row[2]=row[3]=row[4]=row[5]=row[6]=row[7]= row[0] << 3;
return;
}
}
#endif
a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
a1 = a0;
a2 = a0;
a3 = a0;
/* no need to optimize : gcc does it */
a0 += W2 * row[2];
a1 += W6 * row[2];
a2 -= W6 * row[2];
a3 -= W2 * row[2];
MUL16(b0, W1, row[1]);
MAC16(b0, W3, row[3]);
MUL16(b1, W3, row[1]);
MAC16(b1, -W7, row[3]);
MUL16(b2, W5, row[1]);
MAC16(b2, -W1, row[3]);
MUL16(b3, W7, row[1]);
MAC16(b3, -W5, row[3]);
#ifdef FAST_64BIT
temp = ((uint64_t*)row)[1];
#else
temp = ((uint32_t*)row)[2] | ((uint32_t*)row)[3];
#endif
if (temp != 0) {
a0 += W4*row[4] + W6*row[6];
a1 += - W4*row[4] - W2*row[6];
a2 += - W4*row[4] + W2*row[6];
a3 += W4*row[4] - W6*row[6];
MAC16(b0, W5, row[5]);
MAC16(b0, W7, row[7]);
MAC16(b1, -W1, row[5]);
MAC16(b1, -W5, row[7]);
MAC16(b2, W7, row[5]);
MAC16(b2, W3, row[7]);
MAC16(b3, W3, row[5]);
MAC16(b3, -W1, row[7]);
}
row[0] = (a0 + b0) >> ROW_SHIFT;
row[7] = (a0 - b0) >> ROW_SHIFT;
row[1] = (a1 + b1) >> ROW_SHIFT;
row[6] = (a1 - b1) >> ROW_SHIFT;
row[2] = (a2 + b2) >> ROW_SHIFT;
row[5] = (a2 - b2) >> ROW_SHIFT;
row[3] = (a3 + b3) >> ROW_SHIFT;
row[4] = (a3 - b3) >> ROW_SHIFT;
}
static inline void idctSparseColPut (uint8_t *dest, int line_size,
DCTELEM * col)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
/* XXX: I did that only to give same values as previous code */
a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
a1 = a0;
a2 = a0;
a3 = a0;
a0 += + W2*col[8*2];
a1 += + W6*col[8*2];
a2 += - W6*col[8*2];
a3 += - W2*col[8*2];
MUL16(b0, W1, col[8*1]);
MUL16(b1, W3, col[8*1]);
MUL16(b2, W5, col[8*1]);
MUL16(b3, W7, col[8*1]);
MAC16(b0, + W3, col[8*3]);
MAC16(b1, - W7, col[8*3]);
MAC16(b2, - W1, col[8*3]);
MAC16(b3, - W5, col[8*3]);
if(col[8*4]){
a0 += + W4*col[8*4];
a1 += - W4*col[8*4];
a2 += - W4*col[8*4];
a3 += + W4*col[8*4];
}
if (col[8*5]) {
MAC16(b0, + W5, col[8*5]);
MAC16(b1, - W1, col[8*5]);
MAC16(b2, + W7, col[8*5]);
MAC16(b3, + W3, col[8*5]);
}
if(col[8*6]){
a0 += + W6*col[8*6];
a1 += - W2*col[8*6];
a2 += + W2*col[8*6];
a3 += - W6*col[8*6];
}
if (col[8*7]) {
MAC16(b0, + W7, col[8*7]);
MAC16(b1, - W5, col[8*7]);
MAC16(b2, + W3, col[8*7]);
MAC16(b3, - W1, col[8*7]);
}
dest[0] = cm[(a0 + b0) >> COL_SHIFT];
dest += line_size;
dest[0] = cm[(a1 + b1) >> COL_SHIFT];
dest += line_size;
dest[0] = cm[(a2 + b2) >> COL_SHIFT];
dest += line_size;
dest[0] = cm[(a3 + b3) >> COL_SHIFT];
dest += line_size;
dest[0] = cm[(a3 - b3) >> COL_SHIFT];
dest += line_size;
dest[0] = cm[(a2 - b2) >> COL_SHIFT];
dest += line_size;
dest[0] = cm[(a1 - b1) >> COL_SHIFT];
dest += line_size;
dest[0] = cm[(a0 - b0) >> COL_SHIFT];
}
static inline void idctSparseColAdd (uint8_t *dest, int line_size,
DCTELEM * col)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
uint8_t *cm = cropTbl + MAX_NEG_CROP;
/* XXX: I did that only to give same values as previous code */
a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
a1 = a0;
a2 = a0;
a3 = a0;
a0 += + W2*col[8*2];
a1 += + W6*col[8*2];
a2 += - W6*col[8*2];
a3 += - W2*col[8*2];
MUL16(b0, W1, col[8*1]);
MUL16(b1, W3, col[8*1]);
MUL16(b2, W5, col[8*1]);
MUL16(b3, W7, col[8*1]);
MAC16(b0, + W3, col[8*3]);
MAC16(b1, - W7, col[8*3]);
MAC16(b2, - W1, col[8*3]);
MAC16(b3, - W5, col[8*3]);
if(col[8*4]){
a0 += + W4*col[8*4];
a1 += - W4*col[8*4];
a2 += - W4*col[8*4];
a3 += + W4*col[8*4];
}
if (col[8*5]) {
MAC16(b0, + W5, col[8*5]);
MAC16(b1, - W1, col[8*5]);
MAC16(b2, + W7, col[8*5]);
MAC16(b3, + W3, col[8*5]);
}
if(col[8*6]){
a0 += + W6*col[8*6];
a1 += - W2*col[8*6];
a2 += + W2*col[8*6];
a3 += - W6*col[8*6];
}
if (col[8*7]) {
MAC16(b0, + W7, col[8*7]);
MAC16(b1, - W5, col[8*7]);
MAC16(b2, + W3, col[8*7]);
MAC16(b3, - W1, col[8*7]);
}
dest[0] = cm[dest[0] + ((a0 + b0) >> COL_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((a1 + b1) >> COL_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((a2 + b2) >> COL_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((a3 + b3) >> COL_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((a3 - b3) >> COL_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((a2 - b2) >> COL_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)];
}
static inline void idctSparseCol (DCTELEM * col)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
/* XXX: I did that only to give same values as previous code */
a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
a1 = a0;
a2 = a0;
a3 = a0;
a0 += + W2*col[8*2];
a1 += + W6*col[8*2];
a2 += - W6*col[8*2];
a3 += - W2*col[8*2];
MUL16(b0, W1, col[8*1]);
MUL16(b1, W3, col[8*1]);
MUL16(b2, W5, col[8*1]);
MUL16(b3, W7, col[8*1]);
MAC16(b0, + W3, col[8*3]);
MAC16(b1, - W7, col[8*3]);
MAC16(b2, - W1, col[8*3]);
MAC16(b3, - W5, col[8*3]);
if(col[8*4]){
a0 += + W4*col[8*4];
a1 += - W4*col[8*4];
a2 += - W4*col[8*4];
a3 += + W4*col[8*4];
}
if (col[8*5]) {
MAC16(b0, + W5, col[8*5]);
MAC16(b1, - W1, col[8*5]);
MAC16(b2, + W7, col[8*5]);
MAC16(b3, + W3, col[8*5]);
}
if(col[8*6]){
a0 += + W6*col[8*6];
a1 += - W2*col[8*6];
a2 += + W2*col[8*6];
a3 += - W6*col[8*6];
}
if (col[8*7]) {
MAC16(b0, + W7, col[8*7]);
MAC16(b1, - W5, col[8*7]);
MAC16(b2, + W3, col[8*7]);
MAC16(b3, - W1, col[8*7]);
}
col[0 ] = ((a0 + b0) >> COL_SHIFT);
col[8 ] = ((a1 + b1) >> COL_SHIFT);
col[16] = ((a2 + b2) >> COL_SHIFT);
col[24] = ((a3 + b3) >> COL_SHIFT);
col[32] = ((a3 - b3) >> COL_SHIFT);
col[40] = ((a2 - b2) >> COL_SHIFT);
col[48] = ((a1 - b1) >> COL_SHIFT);
col[56] = ((a0 - b0) >> COL_SHIFT);
}
void simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
for(i=0; i<8; i++)
idctRowCondDC(block + i*8);
for(i=0; i<8; i++)
idctSparseColPut(dest + i, line_size, block + i);
}
void simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
for(i=0; i<8; i++)
idctRowCondDC(block + i*8);
for(i=0; i<8; i++)
idctSparseColAdd(dest + i, line_size, block + i);
}
void simple_idct(DCTELEM *block)
{
int i;
for(i=0; i<8; i++)
idctRowCondDC(block + i*8);
for(i=0; i<8; i++)
idctSparseCol(block + i);
}
/* 2x4x8 idct */
#define CN_SHIFT 12
#define C_FIX(x) ((int)((x) * (1 << CN_SHIFT) + 0.5))
#define C1 C_FIX(0.6532814824)
#define C2 C_FIX(0.2705980501)
/* row idct is multiple by 16 * sqrt(2.0), col idct4 is normalized,
and the butterfly must be multiplied by 0.5 * sqrt(2.0) */
#define C_SHIFT (4+1+12)
static inline void idct4col(uint8_t *dest, int line_size, const DCTELEM *col)
{
int c0, c1, c2, c3, a0, a1, a2, a3;
const uint8_t *cm = cropTbl + MAX_NEG_CROP;
a0 = col[8*0];
a1 = col[8*2];
a2 = col[8*4];
a3 = col[8*6];
c0 = ((a0 + a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));
c2 = ((a0 - a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));
c1 = a1 * C1 + a3 * C2;
c3 = a1 * C2 - a3 * C1;
dest[0] = cm[(c0 + c1) >> C_SHIFT];
dest += line_size;
dest[0] = cm[(c2 + c3) >> C_SHIFT];
dest += line_size;
dest[0] = cm[(c2 - c3) >> C_SHIFT];
dest += line_size;
dest[0] = cm[(c0 - c1) >> C_SHIFT];
}
#define BF(k) \
{\
int a0, a1;\
a0 = ptr[k];\
a1 = ptr[8 + k];\
ptr[k] = a0 + a1;\
ptr[8 + k] = a0 - a1;\
}
/* only used by DV codec. The input must be interlaced. 128 is added
to the pixels before clamping to avoid systematic error
(1024*sqrt(2)) offset would be needed otherwise. */
/* XXX: I think a 1.0/sqrt(2) normalization should be needed to
compensate the extra butterfly stage - I don't have the full DV
specification */
void simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
DCTELEM *ptr;
/* butterfly */
ptr = block;
for(i=0;i<4;i++) {
BF(0);
BF(1);
BF(2);
BF(3);
BF(4);
BF(5);
BF(6);
BF(7);
ptr += 2 * 8;
}
/* IDCT8 on each line */
for(i=0; i<8; i++) {
idctRowCondDC(block + i*8);
}
/* IDCT4 and store */
for(i=0;i<8;i++) {
idct4col(dest + i, 2 * line_size, block + i);
idct4col(dest + line_size + i, 2 * line_size, block + 8 + i);
}
}
/* 8x4 & 4x8 WMV2 IDCT */
#undef CN_SHIFT
#undef C_SHIFT
#undef C_FIX
#undef C1
#undef C2
#define CN_SHIFT 12
#define C_FIX(x) ((int)((x) * 1.414213562 * (1 << CN_SHIFT) + 0.5))
#define C1 C_FIX(0.6532814824)
#define C2 C_FIX(0.2705980501)
#define C3 C_FIX(0.5)
#define C_SHIFT (4+1+12)
static inline void idct4col_add(uint8_t *dest, int line_size, const DCTELEM *col)
{
int c0, c1, c2, c3, a0, a1, a2, a3;
const uint8_t *cm = cropTbl + MAX_NEG_CROP;
a0 = col[8*0];
a1 = col[8*1];
a2 = col[8*2];
a3 = col[8*3];
c0 = (a0 + a2)*C3 + (1 << (C_SHIFT - 1));
c2 = (a0 - a2)*C3 + (1 << (C_SHIFT - 1));
c1 = a1 * C1 + a3 * C2;
c3 = a1 * C2 - a3 * C1;
dest[0] = cm[dest[0] + ((c0 + c1) >> C_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((c2 + c3) >> C_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((c2 - c3) >> C_SHIFT)];
dest += line_size;
dest[0] = cm[dest[0] + ((c0 - c1) >> C_SHIFT)];
}
#define RN_SHIFT 15
#define R_FIX(x) ((int)((x) * 1.414213562 * (1 << RN_SHIFT) + 0.5))
#define R1 R_FIX(0.6532814824)
#define R2 R_FIX(0.2705980501)
#define R3 R_FIX(0.5)
#define R_SHIFT 11
static inline void idct4row(DCTELEM *row)
{
int c0, c1, c2, c3, a0, a1, a2, a3;
//const uint8_t *cm = cropTbl + MAX_NEG_CROP;
a0 = row[0];
a1 = row[1];
a2 = row[2];
a3 = row[3];
c0 = (a0 + a2)*R3 + (1 << (R_SHIFT - 1));
c2 = (a0 - a2)*R3 + (1 << (R_SHIFT - 1));
c1 = a1 * R1 + a3 * R2;
c3 = a1 * R2 - a3 * R1;
row[0]= (c0 + c1) >> R_SHIFT;
row[1]= (c2 + c3) >> R_SHIFT;
row[2]= (c2 - c3) >> R_SHIFT;
row[3]= (c0 - c1) >> R_SHIFT;
}
void simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
/* IDCT8 on each line */
for(i=0; i<4; i++) {
idctRowCondDC(block + i*8);
}
/* IDCT4 and store */
for(i=0;i<8;i++) {
idct4col_add(dest + i, line_size, block + i);
}
}
void simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block)
{
int i;
/* IDCT4 on each line */
for(i=0; i<8; i++) {
idct4row(block + i*8);
}
/* IDCT8 and store */
for(i=0; i<4; i++){
idctSparseColAdd(dest + i, line_size, block + i);
}
}

View File

@ -0,0 +1,36 @@
/*
* Simple IDCT
*
* Copyright (c) 2001 Michael Niedermayer <michaelni@gmx.at>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @file simple_idct.h
* simple idct header.
*/
void simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block);
void simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block);
void ff_simple_idct_mmx(int16_t *block);
void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block);
void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block);
void simple_idct(DCTELEM *block);
void simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block);
void simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block);
void simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block);

View File

@ -0,0 +1,861 @@
/*
* utils for libavcodec
* Copyright (c) 2001 Fabrice Bellard.
* Copyright (c) 2003 Michel Bardiaux for the av_log API
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @file utils.c
* utils.
*/
#include "avcodec.h"
#include "dsputil.h"
//#include "mpegvideo.h"
#include <stdarg.h>
void *av_mallocz(unsigned int size)
{
void *ptr;
ptr = av_malloc(size);
if (!ptr)
return NULL;
memset(ptr, 0, size);
return ptr;
}
char *av_strdup(const char *s)
{
char *ptr;
int len;
len = strlen(s) + 1;
ptr = av_malloc(len);
if (!ptr)
return NULL;
memcpy(ptr, s, len);
return ptr;
}
/**
* realloc which does nothing if the block is large enough
*/
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
{
if(min_size < *size)
return ptr;
*size= min_size + 10*1024;
return av_realloc(ptr, *size);
}
/* allocation of static arrays - do not use for normal allocation */
static unsigned int last_static = 0;
static char*** array_static = NULL;
static const unsigned int grow_static = 64; // ^2
void *__av_mallocz_static(void** location, unsigned int size)
{
unsigned int l = (last_static + grow_static) & ~(grow_static - 1);
void *ptr = av_mallocz(size);
if (!ptr)
return NULL;
if (location)
{
if (l > last_static)
array_static = av_realloc(array_static, l);
array_static[last_static++] = (char**) location;
*location = ptr;
}
return ptr;
}
/* free all static arrays and reset pointers to 0 */
void av_free_static(void)
{
if (array_static)
{
unsigned i;
for (i = 0; i < last_static; i++)
{
av_free(*array_static[i]);
*array_static[i] = NULL;
}
av_free(array_static);
array_static = 0;
}
last_static = 0;
}
/* cannot call it directly because of 'void **' casting is not automatic */
void __av_freep(void **ptr)
{
av_free(*ptr);
*ptr = NULL;
}
/* encoder management */
AVCodec *first_avcodec;
void register_avcodec(AVCodec *format)
{
AVCodec **p;
p = &first_avcodec;
while (*p != NULL) p = &(*p)->next;
*p = format;
format->next = NULL;
}
typedef struct InternalBuffer{
int last_pic_num;
uint8_t *base[4];
uint8_t *data[4];
int linesize[4];
}InternalBuffer;
#define INTERNAL_BUFFER_SIZE 32
#define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
int w_align= 1;
int h_align= 1;
switch(s->pix_fmt){
case PIX_FMT_YUV420P:
case PIX_FMT_YUV422:
case PIX_FMT_YUV422P:
case PIX_FMT_YUV444P:
case PIX_FMT_GRAY8:
case PIX_FMT_YUVJ420P:
case PIX_FMT_YUVJ422P:
case PIX_FMT_YUVJ444P:
w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
h_align= 16;
break;
case PIX_FMT_YUV411P:
w_align=32;
h_align=8;
break;
case PIX_FMT_YUV410P:
if(s->codec_id == CODEC_ID_SVQ1){
w_align=64;
h_align=64;
}
break;
default:
w_align= 1;
h_align= 1;
break;
}
*width = ALIGN(*width , w_align);
*height= ALIGN(*height, h_align);
}
#if 0
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
int i;
int w= s->width;
int h= s->height;
InternalBuffer *buf;
int *picture_number;
assert(pic->data[0]==NULL);
assert(INTERNAL_BUFFER_SIZE > s->internal_buffer_count);
if(s->internal_buffer==NULL){
s->internal_buffer= av_mallocz(INTERNAL_BUFFER_SIZE*sizeof(InternalBuffer));
}
#if 0
s->internal_buffer= av_fast_realloc(
s->internal_buffer,
&s->internal_buffer_size,
sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/
);
#endif
buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num; //FIXME ugly hack
(*picture_number)++;
if(buf->base[0]){
pic->age= *picture_number - buf->last_pic_num;
buf->last_pic_num= *picture_number;
}else{
int h_chroma_shift, v_chroma_shift;
int s_align, pixel_size;
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
switch(s->pix_fmt){
case PIX_FMT_RGB555:
case PIX_FMT_RGB565:
case PIX_FMT_YUV422:
pixel_size=2;
break;
case PIX_FMT_RGB24:
case PIX_FMT_BGR24:
pixel_size=3;
break;
case PIX_FMT_RGBA32:
pixel_size=4;
break;
default:
pixel_size=1;
}
avcodec_align_dimensions(s, &w, &h);
#if defined(ARCH_POWERPC) || defined(HAVE_MMI) //FIXME some cleaner check
s_align= 16;
#else
s_align= 8;
#endif
#if 0
if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
w+= EDGE_WIDTH*2;
h+= EDGE_WIDTH*2;
}
#endif
buf->last_pic_num= -256*256*256*64;
for(i=0; i<3; i++){
const int h_shift= i==0 ? 0 : h_chroma_shift;
const int v_shift= i==0 ? 0 : v_chroma_shift;
buf->linesize[i]= ALIGN(pixel_size*w>>h_shift, s_align);
buf->base[i]= av_mallocz((buf->linesize[i]*h>>v_shift)+16); //FIXME 16
if(buf->base[i]==NULL) return -1;
memset(buf->base[i], 128, buf->linesize[i]*h>>v_shift);
#if 0
if(s->flags&CODEC_FLAG_EMU_EDGE)
buf->data[i] = buf->base[i];
else
buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), s_align);
#endif
}
pic->age= 256*256*256*64;
}
pic->type= FF_BUFFER_TYPE_INTERNAL;
for(i=0; i<4; i++){
pic->base[i]= buf->base[i];
pic->data[i]= buf->data[i];
pic->linesize[i]= buf->linesize[i];
}
s->internal_buffer_count++;
return 0;
}
#endif
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
int i;
InternalBuffer *buf, *last, temp;
assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
assert(s->internal_buffer_count);
buf = NULL; /* avoids warning */
for(i=0; i<s->internal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize
buf= &((InternalBuffer*)s->internal_buffer)[i];
if(buf->data[0] == pic->data[0])
break;
}
assert(i < s->internal_buffer_count);
s->internal_buffer_count--;
last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
temp= *buf;
*buf= *last;
*last= temp;
for(i=0; i<3; i++){
pic->data[i]=NULL;
// pic->base[i]=NULL;
}
//printf("R%X\n", pic->opaque);
}
#if 0
int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){
AVFrame temp_pic;
int i;
/* If no picture return a new buffer */
if(pic->data[0] == NULL) {
/* We will copy from buffer, so must be readable */
pic->buffer_hints |= FF_BUFFER_HINTS_READABLE;
return s->get_buffer(s, pic);
}
/* If internal buffer type return the same buffer */
if(pic->type == FF_BUFFER_TYPE_INTERNAL)
return 0;
/*
* Not internal type and reget_buffer not overridden, emulate cr buffer
*/
temp_pic = *pic;
for(i = 0; i < 4; i++)
pic->data[i] = pic->base[i] = NULL;
pic->opaque = NULL;
/* Allocate new frame */
if (s->get_buffer(s, pic))
return -1;
/* Copy image data from old buffer to new buffer */
img_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width,
s->height);
s->release_buffer(s, &temp_pic); // Release old frame
return 0;
}
#endif
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, enum PixelFormat * fmt){
return fmt[0];
}
void avcodec_get_context_defaults(AVCodecContext *s){
s->bit_rate= 800*1000;
s->bit_rate_tolerance= s->bit_rate*10;
s->qmin= 2;
s->qmax= 31;
s->mb_qmin= 2;
s->mb_qmax= 31;
s->rc_eq= "tex^qComp";
s->qcompress= 0.5;
s->max_qdiff= 3;
s->b_quant_factor=1.25;
s->b_quant_offset=1.25;
s->i_quant_factor=-0.8;
s->i_quant_offset=0.0;
s->error_concealment= 3;
s->error_resilience= 1;
s->workaround_bugs= FF_BUG_AUTODETECT;
s->frame_rate_base= 1;
s->frame_rate = 25;
s->gop_size= 50;
s->me_method= ME_EPZS;
//s->get_buffer= avcodec_default_get_buffer;
s->release_buffer= avcodec_default_release_buffer;
s->get_format= avcodec_default_get_format;
s->me_subpel_quality=8;
s->lmin= FF_QP2LAMBDA * s->qmin;
s->lmax= FF_QP2LAMBDA * s->qmax;
//s->sample_aspect_ratio= (AVRational){0,1};
s->ildct_cmp= FF_CMP_VSAD;
s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS;
s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
s->palctrl = NULL;
//s->reget_buffer= avcodec_default_reget_buffer;
}
/**
* allocates a AVCodecContext and set it to defaults.
* this can be deallocated by simply calling free()
*/
AVCodecContext *avcodec_alloc_context(void){
AVCodecContext *avctx= av_mallocz(sizeof(AVCodecContext));
if(avctx==NULL) return NULL;
avcodec_get_context_defaults(avctx);
return avctx;
}
/**
* allocates a AVPFrame and set it to defaults.
* this can be deallocated by simply calling free()
*/
AVFrame *avcodec_alloc_frame(void){
AVFrame *pic= av_mallocz(sizeof(AVFrame));
return pic;
}
int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
{
int ret;
if(avctx->codec)
return -1;
avctx->codec = codec;
avctx->codec_id = codec->id;
avctx->frame_number = 0;
if (codec->priv_data_size > 0) {
avctx->priv_data = av_mallocz(codec->priv_data_size);
if (!avctx->priv_data)
return -ENOMEM;
} else {
avctx->priv_data = NULL;
}
ret = avctx->codec->init(avctx);
if (ret < 0) {
av_freep(&avctx->priv_data);
return ret;
}
return 0;
}
int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const short *samples)
{
int ret;
ret = avctx->codec->encode(avctx, buf, buf_size, (void *)samples);
avctx->frame_number++;
return ret;
}
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVFrame *pict)
{
int ret;
ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict);
emms_c(); //needed to avoid a emms_c() call before every return;
avctx->frame_number++;
return ret;
}
/**
* decode a frame.
* @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes
* because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
* @param buf_size the size of the buffer in bytes
* @param got_picture_ptr zero if no frame could be decompressed, Otherwise, it is non zero
* @return -1 if error, otherwise return the number of
* bytes used.
*/
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
int *got_picture_ptr,
uint8_t *buf, int buf_size)
{
int ret;
ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
buf, buf_size);
emms_c(); //needed to avoid a emms_c() call before every return;
if (*got_picture_ptr)
avctx->frame_number++;
return ret;
}
/* decode an audio frame. return -1 if error, otherwise return the
*number of bytes used. If no frame could be decompressed,
*frame_size_ptr is zero. Otherwise, it is the decompressed frame
*size in BYTES. */
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
uint8_t *buf, int buf_size)
{
int ret;
ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
buf, buf_size);
avctx->frame_number++;
return ret;
}
int avcodec_close(AVCodecContext *avctx)
{
if (avctx->codec->close)
avctx->codec->close(avctx);
av_freep(&avctx->priv_data);
avctx->codec = NULL;
return 0;
}
AVCodec *avcodec_find_encoder(enum CodecID id)
{
AVCodec *p;
p = first_avcodec;
while (p) {
if (p->encode != NULL && p->id == id)
return p;
p = p->next;
}
return NULL;
}
AVCodec *avcodec_find_encoder_by_name(const char *name)
{
AVCodec *p;
p = first_avcodec;
while (p) {
if (p->encode != NULL && strcmp(name,p->name) == 0)
return p;
p = p->next;
}
return NULL;
}
AVCodec *avcodec_find_decoder(enum CodecID id)
{
AVCodec *p;
p = first_avcodec;
while (p) {
if (p->decode != NULL && p->id == id)
return p;
p = p->next;
}
return NULL;
}
AVCodec *avcodec_find_decoder_by_name(const char *name)
{
AVCodec *p;
p = first_avcodec;
while (p) {
if (p->decode != NULL && strcmp(name,p->name) == 0)
return p;
p = p->next;
}
return NULL;
}
AVCodec *avcodec_find(enum CodecID id)
{
AVCodec *p;
p = first_avcodec;
while (p) {
if (p->id == id)
return p;
p = p->next;
}
return NULL;
}
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
{
const char *codec_name;
AVCodec *p;
char buf1[32];
char channels_str[100];
int bitrate;
if (encode)
p = avcodec_find_encoder(enc->codec_id);
else
p = avcodec_find_decoder(enc->codec_id);
if (p) {
codec_name = p->name;
if (!encode && enc->codec_id == CODEC_ID_MP3) {
if (enc->sub_id == 2)
codec_name = "mp2";
else if (enc->sub_id == 1)
codec_name = "mp1";
}
} else if (enc->codec_id == CODEC_ID_MPEG2TS) {
/* fake mpeg2 transport stream codec (currently not
registered) */
codec_name = "mpeg2ts";
} else if (enc->codec_name[0] != '\0') {
codec_name = enc->codec_name;
} else {
/* output avi tags */
if (enc->codec_type == CODEC_TYPE_VIDEO) {
snprintf(buf1, sizeof(buf1), "%c%c%c%c",
enc->codec_tag & 0xff,
(enc->codec_tag >> 8) & 0xff,
(enc->codec_tag >> 16) & 0xff,
(enc->codec_tag >> 24) & 0xff);
} else {
snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag);
}
codec_name = buf1;
}
switch(enc->codec_type) {
#if 0
case CODEC_TYPE_VIDEO:
snprintf(buf, buf_size,
"Video: %s%s",
codec_name, enc->mb_decision ? " (hq)" : "");
if (enc->codec_id == CODEC_ID_RAWVIDEO) {
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %s",
avcodec_get_pix_fmt_name(enc->pix_fmt));
}
if (enc->width) {
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %dx%d, %0.2f fps",
enc->width, enc->height,
(float)enc->frame_rate / enc->frame_rate_base);
}
if (encode) {
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", q=%d-%d", enc->qmin, enc->qmax);
}
bitrate = enc->bit_rate;
break;
#endif
case CODEC_TYPE_AUDIO:
snprintf(buf, buf_size,
"Audio: %s",
codec_name);
switch (enc->channels) {
case 1:
strcpy(channels_str, "mono");
break;
case 2:
strcpy(channels_str, "stereo");
break;
case 6:
strcpy(channels_str, "5:1");
break;
default:
sprintf(channels_str, "%d channels", enc->channels);
break;
}
if (enc->sample_rate) {
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %d Hz, %s",
enc->sample_rate,
channels_str);
}
/* for PCM codecs, compute bitrate directly */
switch(enc->codec_id) {
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_U16BE:
bitrate = enc->sample_rate * enc->channels * 16;
break;
case CODEC_ID_PCM_S8:
case CODEC_ID_PCM_U8:
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
bitrate = enc->sample_rate * enc->channels * 8;
break;
default:
bitrate = enc->bit_rate;
break;
}
break;
case CODEC_TYPE_DATA:
snprintf(buf, buf_size, "Data: %s", codec_name);
bitrate = enc->bit_rate;
break;
default:
av_abort();
}
if (encode) {
if (enc->flags & CODEC_FLAG_PASS1)
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", pass 1");
if (enc->flags & CODEC_FLAG_PASS2)
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", pass 2");
}
if (bitrate != 0) {
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %d kb/s", bitrate / 1000);
}
}
unsigned avcodec_version( void )
{
return LIBAVCODEC_VERSION_INT;
}
unsigned avcodec_build( void )
{
return LIBAVCODEC_BUILD;
}
/* must be called before any other functions */
void avcodec_init(void)
{
static int inited = 0;
if (inited != 0)
return;
inited = 1;
dsputil_static_init();
}
/**
* Flush buffers, should be called when seeking or when swicthing to a different stream.
*/
void avcodec_flush_buffers(AVCodecContext *avctx)
{
if(avctx->codec->flush)
avctx->codec->flush(avctx);
}
void avcodec_default_free_buffers(AVCodecContext *s){
int i, j;
if(s->internal_buffer==NULL) return;
for(i=0; i<INTERNAL_BUFFER_SIZE; i++){
InternalBuffer *buf= &((InternalBuffer*)s->internal_buffer)[i];
for(j=0; j<4; j++){
av_freep(&buf->base[j]);
buf->data[j]= NULL;
}
}
av_freep(&s->internal_buffer);
s->internal_buffer_count=0;
}
#if 0
char av_get_pict_type_char(int pict_type){
switch(pict_type){
case I_TYPE: return 'I';
case P_TYPE: return 'P';
case B_TYPE: return 'B';
case S_TYPE: return 'S';
case SI_TYPE:return 'i';
case SP_TYPE:return 'p';
default: return '?';
}
}
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
int exact=1, sign=0;
int64_t gcd;
assert(den != 0);
if(den < 0){
den= -den;
nom= -nom;
}
if(nom < 0){
nom= -nom;
sign= 1;
}
gcd = ff_gcd(nom, den);
nom /= gcd;
den /= gcd;
if(nom > max || den > max){
AVRational a0={0,1}, a1={1,0};
exact=0;
for(;;){
int64_t x= nom / den;
int64_t a2n= x*a1.num + a0.num;
int64_t a2d= x*a1.den + a0.den;
if(a2n > max || a2d > max) break;
nom %= den;
a0= a1;
a1= (AVRational){a2n, a2d};
if(nom==0) break;
x= nom; nom=den; den=x;
}
nom= a1.num;
den= a1.den;
}
assert(ff_gcd(nom, den) == 1);
if(sign) nom= -nom;
*dst_nom = nom;
*dst_den = den;
return exact;
}
#endif
int64_t av_rescale(int64_t a, int b, int c){
uint64_t h, l;
assert(c > 0);
assert(b >=0);
if(a<0) return -av_rescale(-a, b, c);
h= a>>32;
if(h==0) return a*b/c;
l= a&0xFFFFFFFF;
l *= b;
h *= b;
l += (h%c)<<32;
return ((h/c)<<32) + l/c;
}
/* av_log API */
#ifdef AV_LOG_TRAP_PRINTF
#undef stderr
#undef fprintf
#endif
static int av_log_level = AV_LOG_DEBUG;
static void av_log_default_callback(AVCodecContext* avctx, int level, const char* fmt, va_list vl)
{
static int print_prefix=1;
if(level>av_log_level)
return;
if(avctx && print_prefix)
fprintf(stderr, "[%s @ %p]", avctx->codec ? avctx->codec->name : "?", avctx);
print_prefix= strstr(fmt, "\n") != NULL;
vfprintf(stderr, fmt, vl);
}
static void (*av_log_callback)(AVCodecContext*, int, const char*, va_list) = av_log_default_callback;
void av_log(AVCodecContext* avctx, int level, const char *fmt, ...)
{
va_list vl;
va_start(vl, fmt);
av_vlog(avctx, level, fmt, vl);
va_end(vl);
}
void av_vlog(AVCodecContext* avctx, int level, const char *fmt, va_list vl)
{
av_log_callback(avctx, level, fmt, vl);
}
int av_log_get_level(void)
{
return av_log_level;
}
void av_log_set_level(int level)
{
av_log_level = level;
}
void av_log_set_callback(void (*callback)(AVCodecContext*, int, const char*, va_list))
{
av_log_callback = callback;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.Frameworks</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>

26
Plugins/WMA/Info.plist Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.yourcocoabundle</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -0,0 +1,345 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 44;
objects = {
/* Begin PBXBuildFile section */
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
B09E942F0D747F410064F138 /* WMADecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = B09E942E0D747F410064F138 /* WMADecoder.m */; };
B09E95560D749A780064F138 /* WMA.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B09E95080D748F9B0064F138 /* WMA.framework */; };
B09E95E50D74A3000064F138 /* WMA.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = B09E95080D748F9B0064F138 /* WMA.framework */; };
B09E95E60D74A30E0064F138 /* Plugin.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = B09E94370D747FAD0064F138 /* Plugin.h */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
B09E95070D748F9B0064F138 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = B09E95030D748F9B0064F138 /* WMA.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 8DC2EF5B0486A6940098B216 /* WMA.framework */;
remoteInfo = WMA;
};
B09E95450D7496C60064F138 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = B09E95030D748F9B0064F138 /* WMA.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 8DC2EF4F0486A6940098B216 /* WMA Framework */;
remoteInfo = "WMA Framework";
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
B09E95E90D74A32C0064F138 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
B09E95E60D74A30E0064F138 /* Plugin.h in CopyFiles */,
B09E95E50D74A3000064F138 /* WMA.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
32DBCF630370AF2F00C91783 /* WMA_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMA_Prefix.pch; sourceTree = "<group>"; };
8D5B49B6048680CD000E48DA /* WMA.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WMA.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B09E942D0D747F410064F138 /* WMADecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMADecoder.h; sourceTree = "<group>"; };
B09E942E0D747F410064F138 /* WMADecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WMADecoder.m; sourceTree = "<group>"; };
B09E94370D747FAD0064F138 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../Audio/Plugin.h; sourceTree = SOURCE_ROOT; };
B09E95030D748F9B0064F138 /* WMA.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = WMA.xcodeproj; path = ../../Frameworks/WMA/WMA.xcodeproj; sourceTree = SOURCE_ROOT; };
B09E958A0D749E890064F138 /* WMA.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WMA.framework; path = ../../build/Release/WMA.framework; sourceTree = SOURCE_ROOT; };
B09E95F50D74A3ED0064F138 /* Frameworks-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Frameworks-Info.plist"; sourceTree = "<group>"; };
D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8D5B49B3048680CD000E48DA /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B09E95560D749A780064F138 /* WMA.framework in Frameworks */,
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
089C166AFE841209C02AAC07 /* WMA */ = {
isa = PBXGroup;
children = (
B09E958A0D749E890064F138 /* WMA.framework */,
08FB77AFFE84173DC02AAC07 /* Classes */,
32C88E010371C26100C91783 /* Other Sources */,
089C167CFE841241C02AAC07 /* Resources */,
089C1671FE841209C02AAC07 /* Frameworks and Libraries */,
19C28FB8FE9D52D311CA2CBB /* Products */,
B09E95F50D74A3ED0064F138 /* Frameworks-Info.plist */,
);
name = WMA;
sourceTree = "<group>";
};
089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */,
1058C7AEFEA557BF11CA2CBB /* Other Frameworks */,
);
name = "Frameworks and Libraries";
sourceTree = "<group>";
};
089C167CFE841241C02AAC07 /* Resources */ = {
isa = PBXGroup;
children = (
8D5B49B7048680CD000E48DA /* Info.plist */,
);
name = Resources;
sourceTree = "<group>";
};
08FB77AFFE84173DC02AAC07 /* Classes */ = {
isa = PBXGroup;
children = (
B09E94370D747FAD0064F138 /* Plugin.h */,
B09E942D0D747F410064F138 /* WMADecoder.h */,
B09E942E0D747F410064F138 /* WMADecoder.m */,
);
name = Classes;
sourceTree = "<group>";
};
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
B09E95030D748F9B0064F138 /* WMA.xcodeproj */,
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */,
);
name = "Linked Frameworks";
sourceTree = "<group>";
};
1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = {
isa = PBXGroup;
children = (
089C167FFE841241C02AAC07 /* AppKit.framework */,
D2F7E65807B2D6F200F64583 /* CoreData.framework */,
089C1672FE841209C02AAC07 /* Foundation.framework */,
);
name = "Other Frameworks";
sourceTree = "<group>";
};
19C28FB8FE9D52D311CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
8D5B49B6048680CD000E48DA /* WMA.bundle */,
);
name = Products;
sourceTree = "<group>";
};
32C88E010371C26100C91783 /* Other Sources */ = {
isa = PBXGroup;
children = (
32DBCF630370AF2F00C91783 /* WMA_Prefix.pch */,
);
name = "Other Sources";
sourceTree = "<group>";
};
B09E95040D748F9B0064F138 /* Products */ = {
isa = PBXGroup;
children = (
B09E95080D748F9B0064F138 /* WMA.framework */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
8D5B49AC048680CD000E48DA /* WMA Plugin */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "WMA Plugin" */;
buildPhases = (
8D5B49AF048680CD000E48DA /* Resources */,
8D5B49B1048680CD000E48DA /* Sources */,
8D5B49B3048680CD000E48DA /* Frameworks */,
B09E95E90D74A32C0064F138 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
B09E95460D7496C60064F138 /* PBXTargetDependency */,
);
name = "WMA Plugin";
productInstallPath = "$(HOME)/Library/Bundles";
productName = WMA;
productReference = 8D5B49B6048680CD000E48DA /* WMA.bundle */;
productType = "com.apple.product-type.bundle";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
089C1669FE841209C02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "WMA" */;
compatibilityVersion = "Xcode 3.0";
hasScannedForEncodings = 1;
mainGroup = 089C166AFE841209C02AAC07 /* WMA */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = B09E95040D748F9B0064F138 /* Products */;
ProjectRef = B09E95030D748F9B0064F138 /* WMA.xcodeproj */;
},
);
projectRoot = "";
targets = (
8D5B49AC048680CD000E48DA /* WMA Plugin */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
B09E95080D748F9B0064F138 /* WMA.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = WMA.framework;
remoteRef = B09E95070D748F9B0064F138 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
8D5B49AF048680CD000E48DA /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
8D5B49B1048680CD000E48DA /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B09E942F0D747F410064F138 /* WMADecoder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
B09E95460D7496C60064F138 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = "WMA Framework";
targetProxy = B09E95450D7496C60064F138 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
1DEB913B08733D840010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../Frameworks/WMA/build/Release\"",
"\"$(SRCROOT)/../../Frameworks/WMA/build/Debug\"",
"\"$(SRCROOT)/../../build/Release\"",
);
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = WMA_Prefix.pch;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/Bundles";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../Frameworks/WMA/build/Debug/WMA.framework\"",
);
PRODUCT_NAME = WMA;
SYMROOT = ../../build;
WRAPPER_EXTENSION = bundle;
ZERO_LINK = YES;
};
name = Debug;
};
1DEB913C08733D840010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../build/Release\"",
);
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = WMA_Prefix.pch;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/Bundles";
LIBRARY_SEARCH_PATHS = "";
PRODUCT_NAME = WMA;
SYMROOT = ../../build;
WRAPPER_EXTENSION = bundle;
};
name = Release;
};
1DEB913F08733D840010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
};
name = Debug;
};
1DEB914008733D840010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
ppc,
i386,
);
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
SYMROOT = ../../build;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "WMA Plugin" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB913B08733D840010E9CD /* Debug */,
1DEB913C08733D840010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "WMA" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB913F08733D840010E9CD /* Debug */,
1DEB914008733D840010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 089C1669FE841209C02AAC07 /* Project object */;
}

16
Plugins/WMA/WMADecoder.h Normal file
View File

@ -0,0 +1,16 @@
//
// WMADecoder.h
// WMA
//
// Created by Andre Reffhaug on 2/26/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "Plugin.h"
@interface WMADecoder : NSObject {
}
@end

15
Plugins/WMA/WMADecoder.m Normal file
View File

@ -0,0 +1,15 @@
//
// WMADecoder.m
// WMA
//
// Created by Andre Reffhaug on 2/26/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
// test
#import "WMADecoder.h"
@implementation WMADecoder
@end

View File

@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'WMA' target in the 'WMA' project.
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif