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);
}
AVSValue __cdecl FFNoLog(AVSValue Args, void* UserData, IScriptEnvironment* Env) {
FFMS_NoLog();
return 0;
AVSValue __cdecl FFGetLogLevel(AVSValue Args, void* UserData, IScriptEnvironment* Env) {
return FFMS_GetLogLevel();
}
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) {
@ -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("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);
Env->AddFunction("FFGetLogLevel", "", FFGetLogLevel, 0);
Env->AddFunction("FFSetLogLevel", "i", FFSetLogLevel, 0);
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() {
static bool InitDone = false;
if (!InitDone)
if (!InitDone) {
av_register_all();
av_log_set_level(AV_LOG_QUIET);
}
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);
}

View File

@ -46,6 +46,7 @@ class AudioBase;
class FrameIndex;
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);
enum FFMS_SeekMode {
@ -112,6 +113,7 @@ struct AudioProperties {
int SampleRate;
int Channels;
int BitsPerSample;
int Delay;
bool Float;
int64_t NumSamples;
};
@ -119,7 +121,8 @@ struct AudioProperties {
// Most functions return 0 on success
// Functions without error message output can be assumed to never fail
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(AudioBase *) FFMS_CreateAudioSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize);
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(int) FFMS_WriteIndex(const char *IndexFile, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize);
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

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
</p>
<b>FFNoLog()</b><br />
Disable all logging output from FFmpeg
<b>FFSetLogLevel(int Level)</b><br />
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>
<b>FFGetLogLevel()</b><br />
Returns the current level of logging as an int
</p>
<p>
<b>source:</b>
@ -233,6 +236,11 @@ Note that --enable-w32threads is required for multithreaded decoding to work.
<h2>Changes</h2>
<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>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>

View File

@ -19,6 +19,7 @@
// THE SOFTWARE.
extern "C" {
#include <libavutil/log.h>
#include <libavutil/md5.h>
}
@ -56,8 +57,8 @@ int main(int argc, char *argv[]) {
return -1;
FFMS_Init();
#ifndef VERBOSE
FFMS_NoLog();
#ifdef VERBOSE
FFMS_SetLogLevel(AV_LOG_INFO);
#endif
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
// THE SOFTWARE.
extern "C" {
#include <libavutil/log.h>
}
#include <iostream>
#include <string>
@ -185,8 +188,8 @@ int main(int argc, char *argv[]) {
FFMS_Init();
if (!Verbose)
FFMS_NoLog();
if (Verbose)
FFMS_SetLogLevel(AV_LOG_INFO);
try {
DoIndexing();