FFMS2: api change so the logging level can be set arbitrarily, it also defaults to quiet now

Originally committed to SVN as r2918.
This commit is contained in:
Fredrik Mellbin 2009-05-12 20:50:40 +00:00
parent 3ddf48665a
commit 68123167fe
6 changed files with 40 additions and 13 deletions

View file

@ -219,9 +219,13 @@ 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); 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) { AVSValue __cdecl FFGetLogLevel(AVSValue Args, void* UserData, IScriptEnvironment* Env) {
FFMS_NoLog(); return FFMS_GetLogLevel();
return 0; }
AVSValue __cdecl FFSetLogLevel(AVSValue Args, void* UserData, IScriptEnvironment* Env) {
FFMS_SetLogLevel(Args[0].AsInt());
return FFMS_GetLogLevel();
} }
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* Env) { extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* Env) {
@ -230,7 +234,8 @@ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScri
Env->AddFunction("FFAudioSource", "[source]s[track]i[cache]b[cachefile]s", CreateFFAudioSource, 0); Env->AddFunction("FFAudioSource", "[source]s[track]i[cache]b[cachefile]s", CreateFFAudioSource, 0);
Env->AddFunction("FFPP", "c[pp]s", CreateFFPP, 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("SWScale", "c[width]i[height]i[resizer]s[colorspace]s", CreateSWScale, 0);
Env->AddFunction("FFNoLog", "", FFNoLog, 0); Env->AddFunction("FFGetLogLevel", "", FFGetLogLevel, 0);
Env->AddFunction("FFSetLogLevel", "i", FFSetLogLevel, 0);
return "FFmpegSource - The Second Coming"; return "FFmpegSource - The Second Coming";
} }

View file

@ -57,12 +57,18 @@ FrameInfo::FrameInfo(int64_t SampleStart, int64_t FilePos, unsigned int FrameSiz
FFMS_API(void) FFMS_Init() { FFMS_API(void) FFMS_Init() {
static bool InitDone = false; static bool InitDone = false;
if (!InitDone) if (!InitDone) {
av_register_all(); av_register_all();
av_log_set_level(AV_LOG_QUIET);
}
InitDone = true; InitDone = true;
} }
FFMS_API(void) FFMS_NoLog() { FFMS_API(int) FFMS_GetLogLevel() {
return av_log_get_level();
}
FFMS_API(void) FFMS_SetLogLevel(int Level) {
av_log_set_level(AV_LOG_QUIET); av_log_set_level(AV_LOG_QUIET);
} }

View file

@ -46,6 +46,7 @@ class AudioBase;
class FrameIndex; class FrameIndex;
class FrameInfoVector; class FrameInfoVector;
typedef int (FFMS_CC *IndexCallback)(int State, int64_t Current, int64_t Total, void *Private);
typedef int (FFMS_CC *IndexCallback)(int State, int64_t Current, int64_t Total, void *Private); typedef int (FFMS_CC *IndexCallback)(int State, int64_t Current, int64_t Total, void *Private);
enum FFMS_SeekMode { enum FFMS_SeekMode {
@ -112,6 +113,7 @@ struct AudioProperties {
int SampleRate; int SampleRate;
int Channels; int Channels;
int BitsPerSample; int BitsPerSample;
int Delay;
bool Float; bool Float;
int64_t NumSamples; int64_t NumSamples;
}; };
@ -119,7 +121,8 @@ struct AudioProperties {
// Most functions return 0 on success // Most functions return 0 on success
// Functions without error message output can be assumed to never fail // Functions without error message output can be assumed to never fail
FFMS_API(void) FFMS_Init(); FFMS_API(void) FFMS_Init();
FFMS_API(void) FFMS_NoLog(); FFMS_API(int) FFMS_GetLogLevel();
FFMS_API(void) FFMS_SetLogLevel(int Level);
FFMS_API(VideoBase *) FFMS_CreateVideoSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, const char *PP, int Threads, int SeekMode, char *ErrorMsg, unsigned MsgSize); FFMS_API(VideoBase *) FFMS_CreateVideoSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, const char *PP, int Threads, int SeekMode, char *ErrorMsg, unsigned MsgSize);
FFMS_API(AudioBase *) FFMS_CreateAudioSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize); FFMS_API(AudioBase *) FFMS_CreateAudioSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize);
FFMS_API(void) FFMS_DestroyVideoSource(VideoBase *VB); FFMS_API(void) FFMS_DestroyVideoSource(VideoBase *VB);
@ -147,4 +150,5 @@ FFMS_API(FrameIndex *) FFMS_MakeIndex(const char *SourceFile, int IndexMask, int
FFMS_API(FrameIndex *) FFMS_ReadIndex(const char *IndexFile, char *ErrorMsg, unsigned MsgSize); FFMS_API(FrameIndex *) FFMS_ReadIndex(const char *IndexFile, char *ErrorMsg, unsigned MsgSize);
FFMS_API(int) FFMS_WriteIndex(const char *IndexFile, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize); FFMS_API(int) FFMS_WriteIndex(const char *IndexFile, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize);
FFMS_API(int) FFMS_GetPixFmt(const char *Name); FFMS_API(int) FFMS_GetPixFmt(const char *Name);
//FFMS_API(int) FFMS_DefaultAudioName(const char *SourceFile, int Track, const AudioProperties *AP, char *FileName, unsigned FNSize);
#endif #endif

View file

@ -60,10 +60,13 @@ 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 Separate postprocessing which also seems to include a few simple deinterlacers
</p> </p>
<b>FFNoLog()</b><br /> <b>FFSetLogLevel(int Level)</b><br />
Disable all logging output from FFmpeg Sets the log FFmpeg logging level, defaults to quiet (-8) and the FFmpeg default is 16, all different values can be found in avutil/log.h
</p> </p>
<b>FFGetLogLevel()</b><br />
Returns the current level of logging as an int
</p>
<p> <p>
<b>source:</b> <b>source:</b>
@ -233,6 +236,11 @@ Note that --enable-w32threads is required for multithreaded decoding to work.
<h2>Changes</h2> <h2>Changes</h2>
<ul> <ul>
<li>2.00 beta 9<ul>
<li>Removed FFNoLog and replaced it with FFSetLogLevel and FFGetLogLevel, the default logging is now also set to quiet, the magical numbers to supply it can be found in avutil/log.h</li>
<li>Updated FFmpeg to rev X</li>
</ul></li>
<li>2.00 beta 8<ul> <li>2.00 beta 8<ul>
<li>Improved the audio decoding quality a lot by adding a simple cache, no more seeking is done when playing a file linearly and pops and other artifacts should be much more uncommon</li> <li>Improved the audio decoding quality a lot by adding a simple cache, no more seeking is done when playing a file linearly and pops and other artifacts should be much more uncommon</li>
<li>Fixed a bug that would most of the time drop frame 0 and sometimes frame 1</li> <li>Fixed a bug that would most of the time drop frame 0 and sometimes frame 1</li>

View file

@ -19,6 +19,7 @@
// THE SOFTWARE. // THE SOFTWARE.
extern "C" { extern "C" {
#include <libavutil/log.h>
#include <libavutil/md5.h> #include <libavutil/md5.h>
} }
@ -56,8 +57,8 @@ int main(int argc, char *argv[]) {
return -1; return -1;
FFMS_Init(); FFMS_Init();
#ifndef VERBOSE #ifdef VERBOSE
FFMS_NoLog(); FFMS_SetLogLevel(AV_LOG_INFO);
#endif #endif
int FMT_YV12A = FFMS_GetPixFmt("yuv420p"); int FMT_YV12A = FFMS_GetPixFmt("yuv420p");

View file

@ -18,6 +18,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
extern "C" {
#include <libavutil/log.h>
}
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -185,8 +188,8 @@ int main(int argc, char *argv[]) {
FFMS_Init(); FFMS_Init();
if (!Verbose) if (Verbose)
FFMS_NoLog(); FFMS_SetLogLevel(AV_LOG_INFO);
try { try {
DoIndexing(); DoIndexing();