From ff8d019d58cfb45fd5094b6c8d9ef5b529ea639d Mon Sep 17 00:00:00 2001
From: Fredrik Mellbin
Date: Tue, 30 Dec 2008 23:57:22 +0000
Subject: [PATCH] FFMS2 beta 4 This commit breaks the shit out of linux
Originally committed to SVN as r2571.
---
FFmpegSource2/coparser.h | 121 +++++++++++++++
FFmpegSource2/ffaudiosource.cpp | 2 +-
FFmpegSource2/ffavsfilters.cpp | 6 +
FFmpegSource2/ffms.cpp | 1 +
FFmpegSource2/ffms.h | 2 +-
FFmpegSource2/ffms2.html | 21 ++-
FFmpegSource2/ffvideosource.cpp | 233 ++++++++++++++++++++++++++++-
FFmpegSource2/ffvideosource.h | 23 +++
FFmpegSource2/guids.h | 138 +++++++++++++++++
FFmpegSource2/indexing.cpp | 257 +++++++++++++++++++++++++++++++-
FFmpegSource2/indexing.h | 10 +-
FFmpegSource2/utils.cpp | 11 +-
FFmpegSource2/utils.h | 7 +-
13 files changed, 805 insertions(+), 27 deletions(-)
create mode 100644 FFmpegSource2/coparser.h
create mode 100644 FFmpegSource2/guids.h
diff --git a/FFmpegSource2/coparser.h b/FFmpegSource2/coparser.h
new file mode 100644
index 000000000..078e29d37
--- /dev/null
+++ b/FFmpegSource2/coparser.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2004-2008 Mike Matsnev. All Rights Reserved.
+ *
+ * $Id: CoParser.h,v 1.21 2008/03/29 15:41:28 mike Exp $
+ *
+ */
+
+#ifndef COPARSER_H
+#define COPARSER_H
+
+// Generic multimedia container parsers support
+
+// random access stream, this will be provided by
+// IMMContainer's client
+[uuid("8E192E9F-E536-4027-8D46-664CC7A102C5")]
+interface IMMStream : public IUnknown {
+ // read count bytes starting at position
+ STDMETHOD(Read)( unsigned long long position,
+ void *buffer,
+ unsigned int *count) = 0;
+
+ // scan the file starting at position for the signature
+ // signature can't have zero bytes
+ STDMETHOD(Scan)( unsigned long long *position,
+ unsigned int signature) = 0;
+};
+
+[uuid("A237C873-C6AD-422E-90DB-7CB4627DCFD9")]
+interface IMMStreamOpen : public IUnknown {
+ STDMETHOD(Open)(LPCWSTR name) = 0;
+};
+
+[uuid("D8FF7213-6E09-4256-A2E5-5872C798B128")]
+interface IMMFrame : public IMediaSample2 {
+ // track number must be the same as returned by
+ // IMMContainer->EnumTracks() iterator
+ STDMETHOD_(unsigned, GetTrack)() = 0;
+ STDMETHOD(SetTrack)(unsigned) = 0;
+
+ STDMETHOD_(unsigned, GetPre)() = 0;
+ STDMETHOD(SetPre)(unsigned) = 0;
+};
+
+[uuid("B8324E2A-21A9-46A1-8922-70C55D06311A")]
+interface IMMErrorInfo : public IUnknown {
+ STDMETHOD(LogError)(BSTR message) = 0; // message is owned by the caller
+ STDMETHOD(LogWarning)(BSTR message) = 0;
+};
+
+[uuid("C7120EDB-528C-4ebe-BB53-DA8E70E618EE")]
+interface IMemAlloc : public IUnknown {
+ STDMETHOD(GetBuffer)(HANDLE hAbortEvt, DWORD size, IMMFrame **pS) = 0;
+};
+
+// container itself should support IPropertyBag and return
+// at least Duration[UI8] (in ns) property
+// if a containter supports multiple segments in the same
+// physical file it should return SegmentTop[UI8] property
+// that return the offset of the first byte after this
+// segment's end
+[uuid("A369001B-F292-45f7-A942-84F9C8C0718A")]
+interface IMMContainer : public IUnknown {
+ STDMETHOD(Open)( IMMStream *stream,
+ unsigned long long position,
+ IMMErrorInfo *einfo,
+ IMemAlloc *alloc) = 0;
+ STDMETHOD(GetProgress)(unsigned long long *cur,unsigned long long *max) = 0;
+ STDMETHOD(AbortOpen)() = 0;
+
+ // pu->Next() returns objects supporting IPropertyBag interface
+ STDMETHOD(EnumTracks)(IEnumUnknown **pu) = 0;
+
+ // pu->Next() returns objects supporting IProperyBag and IEnumUnknown interfaces
+ STDMETHOD(EnumEditions)(IEnumUnknown **pu) = 0;
+
+ // pu->Next() returns objects supporting IProperyBag and IMMStream interfaces
+ STDMETHOD(EnumAttachments)(IEnumUnknown **pu) = 0;
+
+ // S_FALSE is end of stream, S_OK next valid frame returned, E_ABORT wait aborted
+ STDMETHOD(ReadFrame)(HANDLE hAbortEvt, IMMFrame **frame) = 0;
+
+ // seeking
+ STDMETHOD(Seek)(unsigned long long timecode,unsigned flags) = 0;
+};
+
+/* FIXME: duplicated in matroska parser
+enum { // Track type
+ TT_VIDEO = 1,
+ TT_AUDIO = 2,
+ TT_SUBS = 17,
+
+ TT_INTERLEAVED = 0x10001,
+};
+*/
+
+enum { // Seek flags
+ MMSF_PREV_KF = 1,
+ MMSF_NEXT_KF = 2
+};
+
+/* Track properties [IPropertyBag from EnumTracks->Next()]
+ Name Type Optional
+ DefaultDuration UI8 Yes in ns
+ Video.Interlaced BOOL Yes
+ Video.DisplayWidth UI4 Yes
+ Video.DisplayHeight UI4 Yes
+ Video.PixelWidth UI4 No
+ Video.PixelHeight UI4 No
+ CodecID BSTR No
+ Type UI4 No TT_* enumeration
+ CodecPrivate ARRAY|UI1 Yes
+ Audio.Channels UI4 No
+ Audio.BitDepth UI4 Yes
+ Audio.SamplingFreq UI4 No
+ Audio.OutputSamplingFreq UI4 Yes
+ Language BSTR Yes
+ Name BSTR Yes
+ FOURCC UI4 Yes
+*/
+
+#endif
\ No newline at end of file
diff --git a/FFmpegSource2/ffaudiosource.cpp b/FFmpegSource2/ffaudiosource.cpp
index 6dbaa9585..6a1968971 100644
--- a/FFmpegSource2/ffaudiosource.cpp
+++ b/FFmpegSource2/ffaudiosource.cpp
@@ -264,7 +264,7 @@ MatroskaAudioSource::MatroskaAudioSource(const char *SourceFile, int Track, Fram
CodecContext->extradata = (uint8_t *)TI->CodecPrivate;
CodecContext->extradata_size = TI->CodecPrivateSize;
- Codec = avcodec_find_decoder(MatroskaToFFCodecID(TI));
+ Codec = avcodec_find_decoder(MatroskaToFFCodecID(TI->CodecID, TI->CodecPrivate));
if (Codec == NULL) {
Free(false);
_snprintf(ErrorMsg, MsgSize, "Video codec not found");
diff --git a/FFmpegSource2/ffavsfilters.cpp b/FFmpegSource2/ffavsfilters.cpp
index 5e005ce7f..7f078ed59 100644
--- a/FFmpegSource2/ffavsfilters.cpp
+++ b/FFmpegSource2/ffavsfilters.cpp
@@ -219,12 +219,18 @@ AVSValue __cdecl CreateSWScale(AVSValue Args, void* UserData, IScriptEnvironment
return new SWScale(Args[0].AsClip(), Args[1].AsInt(0), Args[2].AsInt(0), Args[3].AsString("BICUBIC"), Args[4].AsString(""), Env);
}
+AVSValue __cdecl FFNoLog(AVSValue Args, void* UserData, IScriptEnvironment* Env) {
+ av_log_set_level(AV_LOG_QUIET);
+ return 0;
+}
+
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* Env) {
Env->AddFunction("FFIndex", "[source]s[cachefile]s[indexmask]i[dumpmask]i[audiofile]s[overwrite]b", CreateFFIndex, 0);
Env->AddFunction("FFVideoSource", "[source]s[track]i[cache]b[cachefile]s[fpsnum]i[fpsden]i[pp]s[threads]i[timecodes]s[seekmode]i", CreateFFVideoSource, 0);
Env->AddFunction("FFAudioSource", "[source]s[track]i[cache]b[cachefile]s", CreateFFAudioSource, 0);
Env->AddFunction("FFPP", "c[pp]s", CreateFFPP, 0);
Env->AddFunction("SWScale", "c[width]i[height]i[resizer]s[colorspace]s", CreateSWScale, 0);
+ Env->AddFunction("FFNoLog", "", FFNoLog, 0);
return "FFmpegSource - The Second Coming";
}
diff --git a/FFmpegSource2/ffms.cpp b/FFmpegSource2/ffms.cpp
index c60634e39..82de48fee 100644
--- a/FFmpegSource2/ffms.cpp
+++ b/FFmpegSource2/ffms.cpp
@@ -59,6 +59,7 @@ FFMS_API(VideoBase *) FFMS_CreateVideoSource(const char *SourceFile, int Track,
switch (TrackIndices->Decoder) {
case 0: return new FFVideoSource(SourceFile, Track, TrackIndices, PP, Threads, SeekMode, ErrorMsg, MsgSize);
case 1: return new MatroskaVideoSource(SourceFile, Track, TrackIndices, PP, Threads, ErrorMsg, MsgSize);
+ case 2: return new HaaliTSVideoSource(SourceFile, Track, TrackIndices, PP, Threads, ErrorMsg, MsgSize);
default:
_snprintf(ErrorMsg, MsgSize, "Unsupported format");
return NULL;
diff --git a/FFmpegSource2/ffms.h b/FFmpegSource2/ffms.h
index 44b64c30d..8f2acfc6a 100644
--- a/FFmpegSource2/ffms.h
+++ b/FFmpegSource2/ffms.h
@@ -55,7 +55,7 @@ enum TrackType {
FFMS_TYPE_AUDIO = 1,
};
-// PixelFormat declarations from avutil.h so external libraries don't necessarily have to include and ffmpeg headers
+// PixelFormat declarations from avutil.h so external libraries don't necessarily have to include ffmpeg headers
enum FFMS_PixelFormat {
FFMS_PIX_FMT_NONE= -1,
FFMS_PIX_FMT_YUV420P, ///< Planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
diff --git a/FFmpegSource2/ffms2.html b/FFmpegSource2/ffms2.html
index 8a33c01d8..e1da0a2ff 100644
--- a/FFmpegSource2/ffms2.html
+++ b/FFmpegSource2/ffms2.html
@@ -29,7 +29,7 @@ Opens files using ffmpeg and nothing else. May be frame accurate on good days. T
Usage
-FFIndex("string source, string cachefile = source + ".ffindex", int indexmask = 0, int dumpmask = 0, string audiofile = source, bool overwrite = false)
+FFIndex(string source, string cachefile = source + ".ffindex", int indexmask = 0, int dumpmask = 0, string audiofile = source, bool overwrite = false)
Used to invoke indexing separately and to write audio tracks to disk as wave64 files
@@ -38,6 +38,11 @@ Opens files using ffmpeg and nothing else. May be frame accurate on good days. T
Opens video, will invoke indexing with the defaults if no preexisting index is found
+
+FFAudioSource(string source, int track, bool cache = true, string cachefile = source + ".ffindex")
+ Opens audio, if an index already exists it needs to contain a suitable audio index or empty audio will be returned, will invoke indexing with the defaults if no preexisting index is found
+
+
FFPP(clip, string pp)
Separate postprocessing which also seems to include a few simple deinterlacers
@@ -48,6 +53,11 @@ Opens files using ffmpeg and nothing else. May be frame accurate on good days. T
Separate postprocessing which also seems to include a few simple deinterlacers
+FFNoLog()
+ Disable all logging output from FFmpeg
+
+
+
source:
Source file.
@@ -191,13 +201,19 @@ Note that --enable-w32threads is required for multithreaded decoding to work.
Changes
+- 2.00 beta 4
+- Added the function FFNoLog which suppresses all messages from ffmpeg
+- Experimental new TS parsing using Haali's splitter (with bugs)
+- Everything is now compiled with VS2008 and GCC 4.3.2
+- Updated FFmpeg to rev 16383 (no libfaad2 this time)
+
- 2.00 beta 3
- Compiled with libfaad2 again (has anyone seen a single aac file lavc can open right now?)
- More API changes (and even more are likely to come)
- Several access violations and memory leaks on opening and indexing files fixed
- Added a VFR to CFR mode
-- Readded FFAudioSource support for other containers (glitches still present now and then but no separate raw cache is required and possibly less buggy
+- Readded FFAudioSource support for other containers (glitches still present now and then but no separate raw cache is required and possibly less buggy)
- Renamed the dll to FFMS2.dll, FFMS2 is now the official short name of the project
- Updated FFmpeg to rev 15522
@@ -220,4 +236,3 @@ Note that --enable-w32threads is required for multithreaded decoding to work.