Skip to content

Commit

Permalink
Fix regression for relative file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Asd-g committed Dec 11, 2021
1 parent a52ca7d commit ff818d1
Show file tree
Hide file tree
Showing 23 changed files with 658 additions and 621 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.4:
Fixed regression for relative file paths.

##### 1.2.3:
Fixed FFSAR_NUM, FFSAR_DEN, FFSAR.

Expand Down
7 changes: 5 additions & 2 deletions msvc/D2VSource.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,19 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<BufferSecurityCheck>true</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<FloatingPointModel>Precise</FloatingPointModel>
<LanguageStandard>stdcpp17</LanguageStandard>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -121,16 +122,18 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<BufferSecurityCheck>true</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<LanguageStandard>stdcpp17</LanguageStandard>
<WholeProgramOptimization>true</WholeProgramOptimization>
<FloatingPointModel>Precise</FloatingPointModel>
</ClCompile>
<Link>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand Down
52 changes: 27 additions & 25 deletions src/AVISynthAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
*
*/

#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <stdexcept>
#include <cstdlib>
#include <cstring>
#include <malloc.h>
#include <sstream>
#include <stdexcept>
#include <string>
#include <valarray>

#include "AVISynthAPI.h"
Expand All @@ -48,7 +48,7 @@

#define VERSION "D2VSource 1.2.3"

bool PutHintingData(uint8_t *video, uint32_t hint)
bool PutHintingData(uint8_t* video, uint32_t hint)
{
constexpr uint32_t MAGIC_NUMBER = 0xdeadbeef;

Expand Down Expand Up @@ -86,7 +86,7 @@ static void show_info(int n, CMPEG2Decoder& d, PVideoFrame& frame,
uint32_t gop = 0;
do {
if (raw >= d.GOPList[gop].number)
if (raw < d.GOPList[static_cast<int64_t>(gop)+1].number)
if (raw < d.GOPList[static_cast<int64_t>(gop) + 1].number)
break;
} while (++gop < d.GOPList.size() - 1);

Expand All @@ -109,7 +109,7 @@ static void show_info(int n, CMPEG2Decoder& d, PVideoFrame& frame,

if (d.info == 1) {
char msg1[1024];
sprintf_s(msg1,"%s\n"
sprintf_s(msg1, "%s\n"
"---------------------------------------\n"
"Source: %s\n"
"Frame Rate: %3.6f fps (%u/%u) %s\n"
Expand Down Expand Up @@ -150,7 +150,8 @@ static void show_info(int n, CMPEG2Decoder& d, PVideoFrame& frame,
d.avgquant, d.minquant, d.maxquant);
env->ApplyMessage(&frame, vi, msg1, 150, 0xdfffbf, 0x0, 0x0);

} else if (d.info == 2) {
}
else if (d.info == 2) {
dprintf(const_cast<char*>("MPEG2DecPlus: %s\n"), VERSION);
dprintf(const_cast<char*>("MPEG2DecPlus: Source: %s\n"), d.Infilename[rgop.file].c_str());
dprintf(const_cast<char*>("MPEG2DecPlus: Frame Rate: %3.6f fps (%u/%u) %s\n"),
Expand All @@ -170,7 +171,8 @@ static void show_info(int n, CMPEG2Decoder& d, PVideoFrame& frame,
dprintf(const_cast<char*>("MPEG2DecPlus: Colorimetry: %s (%d)\n"), matrix[rgop.matrix], rgop.matrix);
dprintf(const_cast<char*>("MPEG2DecPlus: Quants: %d/%d/%d (avg/min/max)\n"), d.avgquant, d.minquant, d.maxquant);

} else if (d.info == 3) {
}
else if (d.info == 3) {
constexpr uint32_t PROGRESSIVE = 0x00000001;
constexpr int COLORIMETRY_SHIFT = 2;

Expand Down Expand Up @@ -320,16 +322,16 @@ PVideoFrame __stdcall D2VSource::GetFrame(int n, IScriptEnvironment* env)

d.Decode(n, out);

if (luminanceFlag )
if (luminanceFlag)
luminance_filter(out.y, out.ywidth, out.yheight, out.ypitch, luminanceTable);

if (d.upConv == 2) { // convert 4:2:2 (planar) to 4:4:4 (planar)
env->BitBlt(frame->GetWritePtr(PLANAR_Y), frame->GetPitch(PLANAR_Y),
bufY, out.ypitch, vi.width, vi.height);
bufY, out.ypitch, vi.width, vi.height);
conv422to444(out.u, frame->GetWritePtr(PLANAR_U), out.uvpitch,
frame->GetPitch(PLANAR_U), vi.width, vi.height);
frame->GetPitch(PLANAR_U), vi.width, vi.height);
conv422to444(out.v, frame->GetWritePtr(PLANAR_V), out.uvpitch,
frame->GetPitch(PLANAR_V), vi.width, vi.height);
frame->GetPitch(PLANAR_V), vi.width, vi.height);
}

if (d.info != 0)
Expand Down Expand Up @@ -393,7 +395,7 @@ PVideoFrame __stdcall D2VSource::GetFrame(int n, IScriptEnvironment* env)


static void set_user_default(FILE* def, char* d2v, int& idct, bool& showq,
int& info, int upcnv, bool& i420, int& icc)
int& info, int upcnv, bool& i420, int& icc)
{
char buf[512];
auto load_str = [&buf](char* var, const char* name, int len) {
Expand Down Expand Up @@ -424,7 +426,7 @@ static void set_user_default(FILE* def, char* d2v, int& idct, bool& showq,
}
};

while(fgets(buf, 511, def) != 0) {
while (fgets(buf, 511, def) != 0) {
load_str(d2v, "d2v=%s", 4);
load_int(idct, "idct=%d", 5);
load_bool(showq, "showQ=%s", 6);
Expand Down Expand Up @@ -462,17 +464,17 @@ AVSValue __cdecl D2VSource::create(AVSValue args, void*, IScriptEnvironment* env
// check for uninitialised strings
if (strlen(d2v) >= _MAX_PATH) d2v[0] = 0;

D2VSource *dec = new D2VSource( args[0].AsString(d2v),
args[1].AsInt(idct),
args[2].AsBool(showQ),
args[3].AsInt(info),
args[4].AsInt(upConv),
args[5].AsBool(i420),
iCC,
env );
D2VSource* dec = new D2VSource(args[0].AsString(d2v),
args[1].AsInt(idct),
args[2].AsBool(showQ),
args[3].AsInt(info),
args[4].AsInt(upConv),
args[5].AsBool(i420),
iCC,
env);
// Only bother invoking crop if we have to.
auto& d = *dec->decoder;
if (d.Clip_Top || d.Clip_Bottom || d.Clip_Left || d.Clip_Right ||
if (d.Clip_Top || d.Clip_Bottom || d.Clip_Left || d.Clip_Right ||
// This is cheap but it works. The intent is to allow the
// display size to be different from the encoded size, while
// not requiring massive revisions to the code. So we detect the
Expand Down Expand Up @@ -504,7 +506,7 @@ AVSValue __cdecl D2VSource::create(AVSValue args, void*, IScriptEnvironment* env
const AVS_Linkage* AVS_linkage = nullptr;

extern "C" __declspec(dllexport) const char* __stdcall
AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors)
AvisynthPluginInit3(IScriptEnvironment * env, const AVS_Linkage* const vectors)
{
AVS_linkage = vectors;

Expand Down
20 changes: 10 additions & 10 deletions src/AVISynthAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@
#include "MPEG2Decoder.h"


class D2VSource: public IClip {
class D2VSource : public IClip {
VideoInfo vi;
//int _PP_MODE;
uint8_t *bufY, *bufU, *bufV; // for 4:2:2 input support
uint8_t* bufY, * bufU, * bufV; // for 4:2:2 input support
CMPEG2Decoder* decoder;
bool luminanceFlag;
uint8_t luminanceTable[256];
bool has_at_least_v8;

public:
D2VSource(const char* d2v, int idct, bool showQ, int _info, int _upConv, bool _i420, int iCC, IScriptEnvironment* env);
~D2VSource() {}
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
bool __stdcall GetParity(int n);
void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) {};
const VideoInfo& __stdcall GetVideoInfo() { return vi; }
int __stdcall SetCacheHints(int hints, int) { return hints == CACHE_GET_MTMODE ? MT_SERIALIZED : 0; };
static AVSValue __cdecl create(AVSValue args, void*, IScriptEnvironment* env);
D2VSource(const char* d2v, int idct, bool showQ, int _info, int _upConv, bool _i420, int iCC, IScriptEnvironment* env);
~D2VSource() {}
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
bool __stdcall GetParity(int n);
void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) {};
const VideoInfo& __stdcall GetVideoInfo() { return vi; }
int __stdcall SetCacheHints(int hints, int) { return hints == CACHE_GET_MTMODE ? MT_SERIALIZED : 0; };
static AVSValue __cdecl create(AVSValue args, void*, IScriptEnvironment* env);
};

#endif
Loading

0 comments on commit ff818d1

Please sign in to comment.