diff --git a/CHANGELOG.md b/CHANGELOG.md index 6403ad5..7c5e387 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +##### 1.2.0: + Added variables (ffms2 like) - FFSAR_NUM, FFSAR_DEN, FFSAR. + ##### 1.1.0: Set frame properties - _DurationNum, _DurationDen, _FieldBased, _AspectRatio, _GOPNumber, _GOPPosition, _GOPClosed, _EncodedFrameTop, _EncodedFrameBottom, _PictType, _Matrix, _QuantsAverage, _QuantsAverage, _QuantsMax. diff --git a/README.md b/README.md index 61d73a3..7f46304 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,7 @@ This is a project (previously named as MPEG2DecPlus) to modify DGDecode.dll for True: Force field-based upsampling.\ False: Forse progressive upsampling.\ Default: Auto determination based on the frame flag. - \ No newline at end of file + +## Exported variables: + +FFSAR_NUM, FFSAR_DEN, FFSAR. diff --git a/src/AVISynthAPI.cpp b/src/AVISynthAPI.cpp index fb8a627..f242298 100644 --- a/src/AVISynthAPI.cpp +++ b/src/AVISynthAPI.cpp @@ -32,12 +32,13 @@ #include #include #include +#include #include "AVISynthAPI.h" #include "color_convert.h" #include "misc.h" -#define VERSION "D2VSource 1.0.0" +#define VERSION "D2VSource 1.2.0" bool PutHintingData(uint8_t *video, uint32_t hint) { @@ -170,8 +171,8 @@ static void show_info(int n, CMPEG2Decoder& d, PVideoFrame& frame, MPEG2Source::MPEG2Source(const char* d2v, int idct, bool showQ, - int _info, int _upConv, bool _i420, int iCC, - IScriptEnvironment* env) : + int _info, int _upConv, bool _i420, int iCC, + IScriptEnvironment* env) : bufY(nullptr), bufU(nullptr), bufV(nullptr), decoder(nullptr) { if (iCC != -1 && iCC != 0 && iCC != 1) @@ -190,7 +191,8 @@ MPEG2Source::MPEG2Source(const char* d2v, int idct, bool showQ, try { decoder = new CMPEG2Decoder(f, d2v, idct, iCC, _upConv, _info, showQ, _i420); - } catch (std::runtime_error& e) { + } + catch (std::runtime_error& e) { if (f) fclose(f); env->ThrowError("MPEG2Source: %s", e.what()); } @@ -248,6 +250,26 @@ MPEG2Source::MPEG2Source(const char* d2v, int idct, bool showQ, has_at_least_v8 = true; try { env->CheckVersion(8); } catch (const AvisynthError&) { has_at_least_v8 = false; } + + std::string ar = d.Aspect_Ratio; + std::vector sar; + sar.reserve(2); + std::stringstream str(ar); + int n; + char ch; + while (str >> n) + { + if (str >> ch) + sar.push_back(n); + else + sar.push_back(n); + } + int num = sar[0]; + int den = sar[1]; + env->SetVar(env->Sprintf("%s", "FFSAR_NUM"), num); + env->SetVar(env->Sprintf("%s", "FFSAR_DEN"), den); + if (num > 0 && den > 0) + env->SetVar(env->Sprintf("%s", "FFSAR"), num / static_cast(den)); } diff --git a/src/d2vsource.rc b/src/d2vsource.rc index 628e668..6329da3 100644 --- a/src/d2vsource.rc +++ b/src/d2vsource.rc @@ -2,8 +2,8 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 1,1,0,0 -PRODUCTVERSION 1,1,0,0 +FILEVERSION 1,2,0,0 +PRODUCTVERSION 1,2,0,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0x0L FILEOS VOS__WINDOWS32 @@ -16,11 +16,11 @@ BEGIN BEGIN VALUE "Comments", "Modified DGDecode." VALUE "FileDescription", "D2VSource for AviSynth 2.6 / AviSynth+" - VALUE "FileVersion", "1.1.0" + VALUE "FileVersion", "1.2.0" VALUE "InternalName", "D2VSource" VALUE "OriginalFilename", "D2VSource.dll" VALUE "ProductName", "D2VSource" - VALUE "ProductVersion", "1.1.0" + VALUE "ProductVersion", "1.2.0" END END BLOCK "VarFileInfo"