Skip to content

Commit

Permalink
Set variables FFSAR_NUM, FFSAR_DEN, FFSAR
Browse files Browse the repository at this point in the history
  • Loading branch information
Asd-g committed Dec 1, 2020
1 parent 30508c3 commit 7ba1d7f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


## Exported variables:

FFSAR_NUM, FFSAR_DEN, FFSAR.
30 changes: 26 additions & 4 deletions src/AVISynthAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
#include <algorithm>
#include <stdexcept>
#include <malloc.h>
#include <sstream>

#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)
{
Expand Down Expand Up @@ -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)
Expand All @@ -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());
}
Expand Down Expand Up @@ -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<int> 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<double>(den));
}


Expand Down
8 changes: 4 additions & 4 deletions src/d2vsource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <ntdef.h>

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
Expand All @@ -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"
Expand Down

0 comments on commit 7ba1d7f

Please sign in to comment.