Skip to content

Commit

Permalink
[64bit] Link-time error fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pylorak committed Oct 15, 2013
1 parent d8bac75 commit ea695de
Show file tree
Hide file tree
Showing 16 changed files with 350 additions and 101 deletions.
32 changes: 27 additions & 5 deletions avs_core/convert/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,25 +276,47 @@ PVideoFrame __stdcall ConvertToYV12::GetFrame(int n, IScriptEnvironment* env) {
PVideoFrame dst = env->NewVideoFrame(vi);

if (interlaced) {
if ((env->GetCPUFlags() & CPUF_INTEGER_SSE)) {
#ifdef X86_32
if ((env->GetCPUFlags() & CPUF_INTEGER_SSE))
{
isse_yuy2_i_to_yv12(src->GetReadPtr(), src->GetRowSize(), src->GetPitch(),
dst->GetWritePtr(PLANAR_Y), dst->GetWritePtr(PLANAR_U), dst->GetWritePtr(PLANAR_V),
dst->GetPitch(PLANAR_Y), dst->GetPitch(PLANAR_U), src->GetHeight());
} else {
}
else if ((env->GetCPUFlags() & CPUF_MMX))
{
mmx_yuy2_i_to_yv12(src->GetReadPtr(), src->GetRowSize(), src->GetPitch(),
dst->GetWritePtr(PLANAR_Y), dst->GetWritePtr(PLANAR_U), dst->GetWritePtr(PLANAR_V),
dst->GetPitch(PLANAR_Y), dst->GetPitch(PLANAR_U), src->GetHeight());
}
} else {
if ((env->GetCPUFlags() & CPUF_INTEGER_SSE)) {
else
#endif
{
// TODO
env->ThrowError("ConvertToYV12::GetFrame is not yet ported to 64-bit.");
}
}
else
{
#ifdef X86_32
if ((env->GetCPUFlags() & CPUF_INTEGER_SSE))
{
isse_yuy2_to_yv12(src->GetReadPtr(), src->GetRowSize(), src->GetPitch(),
dst->GetWritePtr(PLANAR_Y), dst->GetWritePtr(PLANAR_U), dst->GetWritePtr(PLANAR_V),
dst->GetPitch(PLANAR_Y), dst->GetPitch(PLANAR_U), src->GetHeight());
} else {
}
else if ((env->GetCPUFlags() & CPUF_MMX))
{
mmx_yuy2_to_yv12(src->GetReadPtr(), src->GetRowSize(), src->GetPitch(),
dst->GetWritePtr(PLANAR_Y), dst->GetWritePtr(PLANAR_U), dst->GetWritePtr(PLANAR_V),
dst->GetPitch(PLANAR_Y), dst->GetPitch(PLANAR_U), src->GetHeight());
}
else
#endif
{
// TODO
env->ThrowError("ConvertToYV12::GetFrame is not yet ported to 64-bit.");
}
}

return dst;
Expand Down
52 changes: 36 additions & 16 deletions avs_core/convert/convert_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,31 +336,51 @@ void __stdcall ConvertAudio::GetAudio(void* buf, __int64 start, __int64 count, I
}

if (src_format != SAMPLE_FLOAT) { // Skip initial copy, if samples are already float
// Someone with an AMD beast decide which code runs better SSE2 or 3DNow :: FIXME
if (((((int)tmp_fb) & 3) == 0) && (env->GetCPUFlags() & CPUF_SSE2)) {
// Someone with an AMD beast decide which code runs better SSE2 or 3DNow :: FIXME

#ifdef X86_32
if (((((int)tmp_fb) & 3) == 0) && (env->GetCPUFlags() & CPUF_SSE2))
{
convertToFloat_SSE2(tempbuffer, tmp_fb, src_format, (int)count*channels);
} else if ((env->GetCPUFlags() & CPUF_3DNOW_EXT)) {
}
else if ((env->GetCPUFlags() & CPUF_3DNOW_EXT))
{
convertToFloat_3DN(tempbuffer, tmp_fb, src_format, (int)count*channels);
} else if ((env->GetCPUFlags() & CPUF_SSE)) {
}
else if ((env->GetCPUFlags() & CPUF_SSE))
{
convertToFloat_SSE(tempbuffer, tmp_fb, src_format, (int)count*channels);
} else {
}
else
#endif
{
convertToFloat(tempbuffer, tmp_fb, src_format, (int)count*channels);
}
} else {
tmp_fb = (float*)tempbuffer;
}

if (dst_format != SAMPLE_FLOAT) { // Skip final copy, if samples are to be float
// Someone with an AMD beast decide which code runs better SSE2 or 3DNow :: FIXME
if ((env->GetCPUFlags() & CPUF_SSE2)) {
convertFromFloat_SSE2(tmp_fb, buf, dst_format, (int)count*channels);
} else if ((env->GetCPUFlags() & CPUF_3DNOW_EXT)) {
convertFromFloat_3DN(tmp_fb, buf, dst_format, (int)count*channels);
} else if ((env->GetCPUFlags() & CPUF_SSE)) {
convertFromFloat_SSE(tmp_fb, buf, dst_format, (int)count*channels);
} else {
convertFromFloat(tmp_fb, buf, dst_format, (int)count*channels);
}
if (dst_format != SAMPLE_FLOAT)
{ // Skip final copy, if samples are to be float
// Someone with an AMD beast decide which code runs better SSE2 or 3DNow :: FIXME
#ifdef X86_32
if ((env->GetCPUFlags() & CPUF_SSE2))
{
convertFromFloat_SSE2(tmp_fb, buf, dst_format, (int)count*channels);
}
else if ((env->GetCPUFlags() & CPUF_3DNOW_EXT))
{
convertFromFloat_3DN(tmp_fb, buf, dst_format, (int)count*channels);
}
else if ((env->GetCPUFlags() & CPUF_SSE))
{
convertFromFloat_SSE(tmp_fb, buf, dst_format, (int)count*channels);
}
else
#endif
{
convertFromFloat(tmp_fb, buf, dst_format, (int)count*channels);
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions avs_core/convert/convert_planar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ PVideoFrame __stdcall ConvertToY8::GetFrame(int n, IScriptEnvironment* env) {
BYTE* dstY = dst->GetWritePtr(PLANAR_Y);
const int dstPitch = dst->GetPitch(PLANAR_Y);

#ifdef X86_32
if (!(awidth & 7)) {
this->convYUV422toY8(srcP, dstY, srcPitch, dstPitch, awidth, vi.height);
return dst;
}
#endif

const int w = dst->GetRowSize(PLANAR_Y);
const int h = dst->GetHeight(PLANAR_Y);
Expand Down Expand Up @@ -707,11 +709,13 @@ PVideoFrame __stdcall ConvertYUY2ToYV16::GetFrame(int n, IScriptEnvironment* env
BYTE* dstU = dst->GetWritePtr(PLANAR_U);
BYTE* dstV = dst->GetWritePtr(PLANAR_V);

#ifdef X86_32
if (!(awidth&7)) { // Use MMX
this->convYUV422to422(srcP, dstY, dstU, dstV, src->GetPitch(), dst->GetPitch(PLANAR_Y),
dst->GetPitch(PLANAR_U), awidth, vi.height);
return dst;
}
#endif

const int w = vi.width/2;

Expand Down Expand Up @@ -816,10 +820,12 @@ PVideoFrame __stdcall ConvertYV16ToYUY2::GetFrame(int n, IScriptEnvironment* env

BYTE* dstp = dst->GetWritePtr();

#ifdef X86_32
if (!(awidth&7)) { // Use MMX
this->conv422toYUV422(srcY, srcU, srcV, dstp, src->GetPitch(PLANAR_Y), src->GetPitch(PLANAR_U),
dst->GetPitch(), awidth, vi.height);
}
#endif

const int w = vi.width/2;

Expand Down
28 changes: 24 additions & 4 deletions avs_core/convert/convert_yuy2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,45 @@ PVideoFrame __stdcall ConvertToYUY2::GetFrame(int n, IScriptEnvironment* env)
PVideoFrame dst = env->NewVideoFrame(vi,32); // We need a bit more pitch here.
BYTE* yuv = dst->GetWritePtr();
if (interlaced) {
if ((env->GetCPUFlags() & CPUF_INTEGER_SSE)) {
#ifdef X86_32
if (env->GetCPUFlags() & CPUF_INTEGER_SSE)
{
isse_yv12_i_to_yuy2(src->GetReadPtr(PLANAR_Y), src->GetReadPtr(PLANAR_U), src->GetReadPtr(PLANAR_V),
src->GetRowSize(PLANAR_Y_ALIGNED), src->GetPitch(PLANAR_Y), src->GetPitch(PLANAR_U),
yuv, dst->GetPitch() ,src->GetHeight());
} else {
}
else if (env->GetCPUFlags() & CPUF_MMX)
{
mmx_yv12_i_to_yuy2(src->GetReadPtr(PLANAR_Y), src->GetReadPtr(PLANAR_U), src->GetReadPtr(PLANAR_V),
src->GetRowSize(PLANAR_Y_ALIGNED), src->GetPitch(PLANAR_Y), src->GetPitch(PLANAR_U),
yuv, dst->GetPitch() ,src->GetHeight());
}
else
#endif
{
// TODO
env->ThrowError("ConvertToYUY2::GetFrame is not yet ported to 64-bit.");
}
} else {
if ((env->GetCPUFlags() & CPUF_INTEGER_SSE)) {
#ifdef X86_32
if (env->GetCPUFlags() & CPUF_INTEGER_SSE)
{
isse_yv12_to_yuy2(src->GetReadPtr(PLANAR_Y), src->GetReadPtr(PLANAR_U), src->GetReadPtr(PLANAR_V),
src->GetRowSize(PLANAR_Y_ALIGNED), src->GetPitch(PLANAR_Y), src->GetPitch(PLANAR_U),
yuv, dst->GetPitch() ,src->GetHeight());
} else {
}
else if (env->GetCPUFlags() & CPUF_MMX)
{
mmx_yv12_to_yuy2(src->GetReadPtr(PLANAR_Y), src->GetReadPtr(PLANAR_U), src->GetReadPtr(PLANAR_V),
src->GetRowSize(PLANAR_Y_ALIGNED), src->GetPitch(PLANAR_Y), src->GetPitch(PLANAR_U),
yuv, dst->GetPitch() ,src->GetHeight());
}
else
#endif
{
// TODO
env->ThrowError("ConvertToYUY2::GetFrame is not yet ported to 64-bit.");
}
}
return dst;
}
Expand Down
10 changes: 10 additions & 0 deletions avs_core/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,22 +693,28 @@ bool CAVIFileSynth::DelayInit2() {
delete[] szScriptName;
szScriptName = NULL;
_clear87();
#ifdef X86_32
_mm_empty();
#endif
_control87( fp_state, 0xffffffff );
return true;
#ifndef _DEBUG
}
catch (...) {
_RPT0(1,"DelayInit() caught general exception!\n");
_clear87();
#ifdef X86_32
_mm_empty();
#endif
_control87( fp_state, 0xffffffff );
return false;
}
#endif
} else {
_clear87();
#ifdef X86_32
_mm_empty();
#endif
_control87( fp_state, 0xffffffff );
return (env && filter_graph && vi);
}
Expand Down Expand Up @@ -1177,13 +1183,17 @@ HRESULT CAVIStreamSynth::Read2(LONG lStart, LONG lSamples, LPVOID lpBuffer, LONG
}
catch (...) {
_clear87();
#ifdef X86_32
_mm_empty();
#endif
_control87( fp_state, 0xffffffff );
return E_FAIL;
}
#endif
_clear87();
#ifdef X86_32
_mm_empty();
#endif
_control87( fp_state, 0xffffffff );
return S_OK;
}
Expand Down
28 changes: 25 additions & 3 deletions avs_core/filters/conditional/conditional_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ AVSValue __cdecl AveragePlane::Create_v(AVSValue args, void* user_data, IScriptE
return AvgPlane(args[0],user_data, PLANAR_V, env);
}

AVSValue AveragePlane::AvgPlane(AVSValue clip, void* user_data, int plane, IScriptEnvironment* env) {
AVSValue AveragePlane::AvgPlane(AVSValue clip, void* user_data, int plane, IScriptEnvironment* env)
{
#ifdef X86_32
if (!clip.IsClip())
env->ThrowError("Average Plane: No clip supplied!");
if (!(env->GetCPUFlags() & CPUF_INTEGER_SSE))
Expand Down Expand Up @@ -154,6 +156,11 @@ AVSValue AveragePlane::AvgPlane(AVSValue clip, void* user_data, int plane, IScri
float f = (float)((double)b / (h * w));

return (AVSValue)f;
#else
//TODO
env->ThrowError("AveragePlane::AvgPlane is not yet ported to 64-bit.");
return (AVSValue)0.0f;
#endif
}

// Average plane
Expand Down Expand Up @@ -266,7 +273,10 @@ AVSValue __cdecl ComparePlane::Create_next_rgb(AVSValue args, void* user_data, I
}


AVSValue ComparePlane::CmpPlane(AVSValue clip, AVSValue clip2, void* user_data, int plane, IScriptEnvironment* env) {
AVSValue ComparePlane::CmpPlane(AVSValue clip, AVSValue clip2, void* user_data, int plane, IScriptEnvironment* env)
{
#ifdef X86_32

if (!clip.IsClip())
env->ThrowError("Plane Difference: No clip supplied!");
if (!clip2.IsClip())
Expand Down Expand Up @@ -338,10 +348,17 @@ AVSValue ComparePlane::CmpPlane(AVSValue clip, AVSValue clip2, void* user_data,
f = (float)((double)b / (h * w));

return (AVSValue)f;
#else
//TODO
env->ThrowError("ComparePlane::CmpPlane is not yet ported to 64-bit.");
return (AVSValue)0.0f;
#endif
}


AVSValue ComparePlane::CmpPlaneSame(AVSValue clip, void* user_data, int offset, int plane, IScriptEnvironment* env) {
AVSValue ComparePlane::CmpPlaneSame(AVSValue clip, void* user_data, int offset, int plane, IScriptEnvironment* env)
{
#ifdef X86_32
if (!clip.IsClip())
env->ThrowError("Plane Difference: No clip supplied!");

Expand Down Expand Up @@ -401,6 +418,11 @@ AVSValue ComparePlane::CmpPlaneSame(AVSValue clip, void* user_data, int offset,
f = (float)((double)b / (h * w));

return (AVSValue)f;
#else
//TODO
env->ThrowError("ComparePlane::CmpPlaneSame is not yet ported to 64-bit.");
return (AVSValue)0.0f;
#endif
}


Expand Down
5 changes: 4 additions & 1 deletion avs_core/filters/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,9 @@ PVideoFrame Dissolve::GetFrame(int n, IScriptEnvironment* env)

const int multiplier = n - video_fade_end + overlap;

if ((env->GetCPUFlags() & CPUF_MMX) && (!(a->GetRowSize(PLANAR_Y_ALIGNED)&7)) ) { // MMX and Video is mod 8
#ifdef X86_32
if ((env->GetCPUFlags() & CPUF_MMX) && (!(a->GetRowSize(PLANAR_Y_ALIGNED)&7)) ) // MMX and Video is mod 8
{
int weight = (multiplier * 32767) / (overlap+1);
int invweight = 32767-weight;
env->MakeWritable(&a);
Expand All @@ -632,6 +634,7 @@ PVideoFrame Dissolve::GetFrame(int n, IScriptEnvironment* env)
}
return a;
}
#endif


PVideoFrame c;
Expand Down

0 comments on commit ea695de

Please sign in to comment.