Log in

View Full Version : How would you make this code 64 bit compatible?


Jeremy Duncan
17th January 2010, 22:19
Here is the original file. It's from the svn for ffdshow trunk
link (http://ffdshow-tryout.svn.sourceforge.net/viewvc/ffdshow-tryout/trunk/src/imgFilters/avisynth/TimgFilterAvisynth.h)

Here is the Diff File code. Note it's for x86 machines.
Index: src/imgFilters/avisynth/TimgFilterAvisynth.h
===================================================================
--- src/imgFilters/avisynth/TimgFilterAvisynth.h (revision 2975)
+++ src/imgFilters/avisynth/TimgFilterAvisynth.h (working copy)
@@ -99,7 +99,12 @@

static AVS_VideoFrame* AVSC_CC get_frame(AVS_FilterInfo *, int n);
static int AVSC_CC get_parity(AVS_FilterInfo *, int n) {return 0;}
- static int AVSC_CC set_cache_hints(AVS_FilterInfo *, int cachehints, int frame_range) {return 0;}
+ static int AVSC_CC set_cache_hints(AVS_FilterInfo *_this, int cachehints, int frame_range)
+ {
+// if (cachehints == 0x8666 && frame_range) // identify as Cache instance
+// *(int*)frame_range = (int)(INT_PTR)_this;
+ return 0;
+ }
static void AVSC_CC free_filter(AVS_FilterInfo *);

public:

The diff file I made is in post #10

IanB
18th January 2010, 06:05
The // is for end of line comments, so the 2 diffs have no net code change, only some thought exercise comments.

Jeremy Duncan
18th January 2010, 07:37
IanB, Your right, I forgot about that.

Groucho2004
18th January 2010, 09:55
@Jeremy Duncan
You remind me of the "The infinite monkey theorem"

It states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type a given text, such as the complete works of William Shakespeare.

IanB
18th January 2010, 10:48
Yes the code you have un-commented is wrong. The _this pointer is not appropriate. Also if you intend to mate this with Squids 64 bit Avisynth, then you need to base it on that code base, not any of the current 32 bit versions.

Jeremy Duncan
18th January 2010, 11:36
The diff file I made was built for use with the ffdshow svn trunk imgfilters, avisynth folder.
I made a ffdshow installer and tried it in windows 7 64 bit and the problem I had using the old diff file was gone and there was no problems with the picture.

I am amazed that even though there is incorrect code in the diff file as seen in post 3, the problem is gone.
I wonder what would happen if the code was correct?
The problem I was getting using the old diff file was the resizing was wrong, all bad, no definition worth speaking of, but this diff file I uploaded fixes that problem so windows 7 64 bit acts just like xp mce 32 bit.

Groucho2004, I have done as you said. But I am only one munkey on a typewritter. :D

kemuri-_9
19th January 2010, 16:22
you are continuing to prove you have absolutely no clue about what you're doing when attempting to alter code.

I would ask you to stop fruitless efforts but you have continued to do so from others' warnings, so it seems you'll never take the hint.

Jeremy Duncan
20th January 2010, 01:36
I didn't understand what you meant by the word Pointer, so I looked it up taday and saw you were referring to the int in 64 bits. ha ha.

Kemuri, I asked for help but nobody made the code for me.
In that case I just went out and did it myself. :p

kemuri-_9
20th January 2010, 02:23
Kemuri, I asked for help but nobody made the code for me.
In that case I just went out and did it myself. :p

A) if you're going to paste an entire file and it's already available on the internet, just link to the file (http://ffdshow-tryout.svn.sourceforge.net/viewvc/ffdshow-tryout/trunk/src/imgFilters/avisynth/TimgFilterAvisynth.h)
B) there was no real code change in the difference in the original diff
C) the indicated file gives no indication of even being x86_64 incompatible in the first place.
D) you obviously don't know what you're doing if you're changing set_cache_hints for a source filter
E) excluding above points, the code you made can be better done by monkeys; including myself, everyone has been dumbfounded at how illogical it is.

Jeremy Duncan
20th January 2010, 07:27
Hi Kemuri-_9, I will try to answer your abc list to the best of my ability.
a.) Never thought about that.
b.) Don't know what you mean. With that bit the code broke ffdshow in windows 7 64 bit, without the diff file the ffdshow works in windows 7 64 bit.
I alter this bit of code from the diff file and it works again in windows 7 64 bit.
So this bit of code from the diff file we are talking about does have a effect in windows 7 64 bit.
c.) That doesn't mean it works. I ttested it. Other people I help with ffdshow tested it in windows 7 64 it and the diff file with no alterations does not work in windows 7 64 bit.
d.) Funny that as when I munkey around with it the windows 7 64 bit using 32 bit ffdshow and diff file works again.
e.) Good for you. Now I made a new code I tested to work in xp mce and will post it below. I am now going to test it in windows 7 64 bit. Edit, it works in windows 7 64 bit:


static AVS_VideoFrame* AVSC_CC get_frame(AVS_FilterInfo *, int n);
static int AVSC_CC get_parity(AVS_FilterInfo *, int n) {return 0;}
- static int AVSC_CC set_cache_hints(AVS_FilterInfo *, int cachehints, int frame_range) {return 0;}
+ static int AVSC_CC set_cache_hints(AVS_FilterInfo *_this, int cachehints, int frame_range)
+ {
+ if (cachehints == 0x64 && frame_range) // identify as Cache instance
+ *(int64*)frame_range = (int64)(INT_PTR)_this, int64 cachehints, int64 frame_range;
+ return 0;
continue;
+ else if (cachehints == 0x8666 && frame_range) // identify as Cache instance
+ *(int*)frame_range = (int)(INT_PTR)_this, int cachehints, int frame_range;
+ return 0;
+ }
static void AVSC_CC free_filter(AVS_FilterInfo *);

public:


diff file i made (http://www.mediafire.com/?dnljddfjzlm)

IanB
20th January 2010, 07:50
Jeremy :confused:

The code you are randomising is just plain wrong. It is supposed to simply be :- static int AVSC_CC set_cache_hints(AVS_FilterInfo *, int cachehints, int frame_range) {return 0;}

The comments in the original diff are just that, comments someone added as an incomplete thought marker. If you really want to know about it then chase the person who first checked in the comments and ask them what they were intending for the complete thought process.


And as I said if you are going to play with 64 bit Avisynth then you must use Squid's source base, which is a functional subset somewhere between 2.5.5 and 2.5.6 feature wise but yet a little bit different from either.

Jeremy Duncan
20th January 2010, 08:24
I thought about deleting that section of the diff file so the code remains as IanB said in post #11, but I got the diff file working with the code in post #10 in 32 bit xp mce and 64 bit windows 7, so I have no real reason to delete that part of the code, other than to be efficient.

Why should I use the code IanB suggests if the code in post #10 works? I'm interested to read your comments, especially kemuri-_9's.

IanB
20th January 2010, 08:54
Fine include strange random code that you have no idea what it's purpose is. While you are at it here is some other real beaut code. I think it is something to do with capturing credit card numbers for the Russian Mafia, please include this as well. :devil: @@ -626,25 +634,26 @@
AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env,
const AVS_VideoInfo * vi)
{return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
+#endif

-AVSC_API(int) avs_make_writable(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);
+AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);

-AVSC_API(void) avs_bit_blt(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height);
+AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height);

typedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env);
-AVSC_API(void) avs_at_exit(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data);
+AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data);

-AVSC_API(AVS_VideoFrame *) avs_subframe(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height);
+AVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height);
// The returned video frame must be be released

-AVSC_API(int) avs_set_memory_max(AVS_ScriptEnvironment *, int mem);
+AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem);

-AVSC_API(int) avs_set_working_dir(AVS_ScriptEnvironment *, const char * newdir);
+AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir);

// avisynth.dll exports this; it's a way to use it as a library, without
// writing an AVS script or without going through AVIFile.
-AVSC_API(AVS_ScriptEnvironment *) avs_create_script_environment(int version);
+AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version);

// this symbol is the entry point for the plugin and must
// be defined
...

Groucho2004
20th January 2010, 12:20
Jeremy, I told you before that your ability to download Visual Studio and install it does not automatically enable you to know everything about C/C++.

Even the fact that you read about pointers on Wikipedia and that you now know what a code comment looks like won't change that.

kemuri-_9
20th January 2010, 17:06
Why should I use the code IanB suggests if the code in post #10 works? I'm interested to read your comments, especially kemuri-_9's.

how about the fact that your code in that block is never used or called, it's plainly a waste of space?

hanfrunz
20th January 2010, 18:10
you can add

// voodoo
// make it work


this will do the same...

Jeremy Duncan
22nd January 2010, 10:07
I have made a mistake with the code in post #10.
I discovered my mistake like so: I downloaded the ffdshow trunk svn 3215 and from the diff file this thread is about I added the changes directly to the files then made a installer and it ran ok in xp mce but in windows 7 the frame doubler ran at 8 fps, so I thought I had to include the code in the file from post ten, so I made a new file with the code and visual studio through a error at me and wouldn't compile ffdshow.ax

So adding the code from post 10 directly to the file showed my error, when I used the diff file including the code from post 10 in the 3200 svn the video ran flawlessly in xp 32 bit and windows 7 64 bit.

I don't know why one svn that used the diff ran ok and the other didn't.
And the funny thing is I had to tweak the code in the code from post ten if the 3200 svn played the video ok or not.

So you were right and I was wrong. I'm sorry for doubting you. :p

Groucho2004
23rd January 2010, 00:36
Please, somebody make him stop.

thetoof
23rd January 2010, 01:36
^+1 :p

osgZach
26th January 2010, 18:58
Wha....what just happened?

Wilbert
26th January 2010, 23:03
I kinda hoped this thread would die in silence. Pretty much every post (including the first one) in this thread violates rule 11 and 2. So, closed.