VSVideoSource::VSVideoSource(const char *SourceFile, int Track, FFMS_Index *Index, int AFPSNum, int AFPSDen, int Threads, int SeekMode, int /*RFFMode*/, int ResizeToWidth, int ResizeToHeight, const char *ResizerName, int Format, bool OutputAlpha, const VSAPI *vsapi, VSCore *core) : FPSNum(AFPSNum), FPSDen(AFPSDen), OutputAlpha(OutputAlpha) { VI[0] = {}; VI[1] = {}; char ErrorMsg[1024]; FFMS_ErrorInfo E; E.Buffer = ErrorMsg; E.BufferSize = sizeof(ErrorMsg); V = FFMS_CreateVideoSource(SourceFile, Track, Index, Threads, SeekMode, &E); if (!V) { throw std::runtime_error(std::string("Source: ") + E.Buffer); } try { InitOutputFormat(ResizeToWidth, ResizeToHeight, ResizerName, Format, vsapi, core); } catch (std::exception &) { FFMS_DestroyVideoSource(V); throw; } const FFMS_VideoProperties *VP = FFMS_GetVideoProperties(V); if (FPSNum > 0 && FPSDen > 0) { muldivRational(&FPSNum, &FPSDen, 1, 1); VI[0].fpsDen = FPSDen; VI[0].fpsNum = FPSNum; if (VP->NumFrames > 1) { VI[0].numFrames = static_cast<int>((VP->LastTime - VP->FirstTime) * (1 + 1. / (VP->NumFrames - 1)) * FPSNum / FPSDen + 0.5); if (VI[0].numFrames < 1) VI[0].numFrames = 1; } else { VI[0].numFrames = 1; } } else { VI[0].fpsDen = VP->FPSDenominator; VI[0].fpsNum = VP->FPSNumerator; VI[0].numFrames = VP->NumFrames; muldivRational(&VI[0].fpsNum, &VI[0].fpsDen, 1, 1); } if (OutputAlpha) { VI[1] = VI[0]; VI[1].format = vsapi->registerFormat(cmGray, VI[0].format->sampleType, VI[0].format->bitsPerSample, VI[0].format->subSamplingW, VI[0].format->subSamplingH, core); } SARNum = VP->SARNum; SARDen = VP->SARDen; }
AvisynthVideoSource::AvisynthVideoSource(const char *SourceFile, int Track, FFMS_Index *Index, int FPSNum, int FPSDen, int Threads, int SeekMode, int RFFMode, int ResizeToWidth, int ResizeToHeight, const char *ResizerName, const char *ConvertToFormatName, const char *VarPrefix, IScriptEnvironment* Env) : FPSNum(FPSNum) , FPSDen(FPSDen) , RFFMode(RFFMode) , VarPrefix(VarPrefix) { VI = {}; // check if the two functions we need for many bits are present VI.pixel_type = VideoInfo::CS_Y16; HighBitDepth = (VI.ComponentSize() == 2 && VI.IsY()); VI.pixel_type = VideoInfo::CS_UNKNOWN; ErrorInfo E; V = FFMS_CreateVideoSource(SourceFile, Track, Index, Threads, SeekMode, &E); if (!V) Env->ThrowError("FFVideoSource: %s", E.Buffer); try { InitOutputFormat(ResizeToWidth, ResizeToHeight, ResizerName, ConvertToFormatName, Env); } catch (AvisynthError &) { FFMS_DestroyVideoSource(V); throw; } const FFMS_VideoProperties *VP = FFMS_GetVideoProperties(V); if (RFFMode > 0) { // This part assumes things, and so should you FFMS_Track *VTrack = FFMS_GetTrackFromVideo(V); if (FFMS_GetFrameInfo(VTrack, 0)->RepeatPict < 0) { FFMS_DestroyVideoSource(V); Env->ThrowError("FFVideoSource: No RFF flags present"); } int RepeatMin = FFMS_GetFrameInfo(VTrack, 0)->RepeatPict;; int NumFields = 0; for (int i = 0; i < VP->NumFrames; i++) { int RepeatPict = FFMS_GetFrameInfo(VTrack, i)->RepeatPict; NumFields += RepeatPict + 1; RepeatMin = std::min(RepeatMin, RepeatPict); } for (int i = 0; i < VP->NumFrames; i++) { int RepeatPict = FFMS_GetFrameInfo(VTrack, i)->RepeatPict; if (((RepeatPict + 1) * 2) % (RepeatMin + 1)) { FFMS_DestroyVideoSource(V); Env->ThrowError("FFVideoSource: Unsupported RFF flag pattern"); } } VI.fps_denominator = VP->RFFDenominator * (RepeatMin + 1); VI.fps_numerator = VP->RFFNumerator; VI.num_frames = (NumFields + RepeatMin) / (RepeatMin + 1); int DestField = 0; FieldList.resize(VI.num_frames); for (int i = 0; i < VP->NumFrames; i++) { int RepeatPict = FFMS_GetFrameInfo(VTrack, i)->RepeatPict; int RepeatFields = ((RepeatPict + 1) * 2) / (RepeatMin + 1); for (int j = 0; j < RepeatFields; j++) { if ((DestField + (VP->TopFieldFirst ? 0 : 1)) & 1) FieldList[DestField / 2].Top = i; else FieldList[DestField / 2].Bottom = i; DestField++; } } if (RFFMode == 2) { VI.num_frames = (VI.num_frames * 4) / 5; VI.fps_denominator *= 5; VI.fps_numerator *= 4; int OutputFrames = 0; for (int i = 0; i < VI.num_frames / 4; i++) { bool HasDropped = false; FieldList[OutputFrames].Top = FieldList[i * 5].Top; FieldList[OutputFrames].Bottom = FieldList[i * 5].Top; OutputFrames++; for (int j = 1; j < 5; j++) { if (!HasDropped && FieldList[i * 5 + j - 1].Top == FieldList[i * 5 + j].Top) { HasDropped = true; continue; } FieldList[OutputFrames].Top = FieldList[i * 5 + j].Top; FieldList[OutputFrames].Bottom = FieldList[i * 5 + j].Top; OutputFrames++; } if (!HasDropped) OutputFrames--; } if (OutputFrames > 0) for (int i = OutputFrames - 1; i < static_cast<int>(FieldList.size()); i++) { FieldList[i].Top = FieldList[OutputFrames - 1].Top; FieldList[i].Bottom = FieldList[OutputFrames - 1].Top; } FieldList.resize(VI.num_frames); } } else { if (FPSNum > 0 && FPSDen > 0) { VI.fps_denominator = FPSDen; VI.fps_numerator = FPSNum; if (VP->NumFrames > 1) { VI.num_frames = static_cast<int>((VP->LastTime - VP->FirstTime) * (1 + 1. / (VP->NumFrames - 1)) * FPSNum / FPSDen + 0.5); if (VI.num_frames < 1) VI.num_frames = 1; } else { VI.num_frames = 1; } } else { VI.fps_denominator = VP->FPSDenominator; VI.fps_numerator = VP->FPSNumerator; VI.num_frames = VP->NumFrames; } } // Set AR variables Env->SetVar(Env->Sprintf("%s%s", this->VarPrefix, "FFSAR_NUM"), VP->SARNum); Env->SetVar(Env->Sprintf("%s%s", this->VarPrefix, "FFSAR_DEN"), VP->SARDen); if (VP->SARNum > 0 && VP->SARDen > 0) Env->SetVar(Env->Sprintf("%s%s", this->VarPrefix, "FFSAR"), VP->SARNum / (double)VP->SARDen); // Set crop variables Env->SetVar(Env->Sprintf("%s%s", this->VarPrefix, "FFCROP_LEFT"), VP->CropLeft); Env->SetVar(Env->Sprintf("%s%s", this->VarPrefix, "FFCROP_RIGHT"), VP->CropRight); Env->SetVar(Env->Sprintf("%s%s", this->VarPrefix, "FFCROP_TOP"), VP->CropTop); Env->SetVar(Env->Sprintf("%s%s", this->VarPrefix, "FFCROP_BOTTOM"), VP->CropBottom); Env->SetGlobalVar("FFVAR_PREFIX", this->VarPrefix); }
/************************************************************************** Description : Einlesen des Loggen Bereiches der INI Datei Parameter : (none) Return-Value : (none) Changes : Author, Date, Version, Reason ******************************************************** Dotterweich, 21.08.2007, 0.1, Created **************************************************************************/ void LoggenINI(void) { int Zaehler = 1; char Temp[100] = {0}; { LogGesamtOutputTypeAnzahl = InitAnzahl("Loggen.LogGesamtOutputTypeAnzahl", OUTPUTTYPEMAX); InitOutputType(LogGesamtOutputTypeAnzahl, LogGesamtOutputType, "Loggen.LogGesamtOutputType"); for(Zaehler = 1; Zaehler <= LogGesamtOutputTypeAnzahl; Zaehler++) { sprintf(Temp, "Loggen.LogGesamtOutput_%i", Zaehler); TRepository_GetElementStr( Temp, "", LogGesamtOutput[Zaehler - 1], sizeof(LogGesamtOutput[Zaehler - 1])-1); } InitOutputFormat(LogGesamtOutputTypeAnzahl, LogGesamtOutputFormat, "Loggen.LogGesamtOutputFormat"); LogGesamtIntervallZeit = TRepository_GetElementInt("Loggen.LogGesamtIntervall", 0); } { LogOutputTypeAnzahl = InitAnzahl("Loggen.LogOutputTypeAnzahl", OUTPUTTYPEMAX); InitOutputType(LogOutputTypeAnzahl, LogOutputType, "Loggen.LogOutputType"); for(Zaehler = 1; Zaehler <= LogOutputTypeAnzahl; Zaehler++) { sprintf(Temp, "Loggen.LogOutput_%i", Zaehler); TRepository_GetElementStr( Temp, "", LogOutput[Zaehler - 1], sizeof(LogOutput[Zaehler - 1])-1); } InitOutputFormat(LogOutputTypeAnzahl, LogOutputFormat, "Loggen.LogOutputFormat"); LogIntervallZeit = TRepository_GetElementInt("Loggen.LogIntervall", 0); LogKanalAnzahl = InitAnzahl("Loggen.LogKanalAnzahl", KANALMAX); for(Zaehler = 1; Zaehler <= LogKanalAnzahl; Zaehler++) { sprintf(Temp, "Loggen.LogKanal_%i", Zaehler); TRepository_GetElementStr( Temp, "", LogKanal[Zaehler - 1], sizeof(LogKanal[Zaehler - 1])-1); } } { LogMonatOutputTypeAnzahl = InitAnzahl("Loggen.LogMonatOutputTypeAnzahl", OUTPUTTYPEMAX); InitOutputType(LogMonatOutputTypeAnzahl, LogMonatOutputType, "Loggen.LogMonatOutputType"); for(Zaehler = 1; Zaehler <= LogMonatOutputTypeAnzahl; Zaehler++) { sprintf(Temp, "Loggen.LogMonatOutput_%i", Zaehler); TRepository_GetElementStr( Temp, "", LogMonatOutput[Zaehler - 1], sizeof(LogMonatOutput[Zaehler - 1])-1); } InitOutputFormat(LogMonatOutputTypeAnzahl, LogMonatOutputFormat, "Loggen.LogMonatOutputFormat"); LogMonatLetzteIntervallZeit = TagZeit; // LogMonat erst um 0:00 wieder starten LogMonatWRAnzahl = InitAnzahl("Loggen.LogMonatWRAnzahl", KANALMAX); for(Zaehler = 1; Zaehler <= LogMonatWRAnzahl; Zaehler++) { sprintf(Temp, "Loggen.LogMonatWR_%i", Zaehler); TRepository_GetElementStr( Temp, "", LogMonatWR[Zaehler - 1], sizeof(LogMonatWR[Zaehler - 1])-1); } LogMonatKanalAnzahl = InitAnzahl("Loggen.LogMonatKanalAnzahl", KANALMAX); for(Zaehler = 1; Zaehler <= LogMonatKanalAnzahl; Zaehler++) { sprintf(Temp, "Loggen.LogMonatKanal_%i", Zaehler); TRepository_GetElementStr( Temp, "", LogMonatKanal[Zaehler - 1], sizeof(LogMonatKanal[Zaehler - 1])-1); } } }