PDA

View Full Version : new Filter: Convert3d


hanfrunz
16th March 2003, 22:25
Hello,

thanks to Simon Walters "SimpleSample" i was able to code my first avisynth2 filter:

Convert3d v1.0
this filter converts interlaced 3D Movies (one field left, other field right picture) to anaglyph (red/cyan) format using photoshops "screen"-blend method. It needs RGB24 input!

http://www.geocities.com/hanfrunz/convert3dv1.zip

I am very new in c++/windows programming so if anybody could give me hints for speedoptimization i would be very happy :-)

thanks

hanfrunz

Si
16th March 2003, 23:34
Have you published your final working code?

(I'm not very good at understanding someone elses code but I wonder if you have made a small error?)

Could you post a few frames of an interlaced 3D movie to test your filter on?

regards
Simon

sh0dan
17th March 2003, 00:53
It seems fine - minor things:

- It will crash if height isn't mod2. Insert:

if (!vi.IsRGB24())
env->ThrowError("Convert3d: input to filter must be RGB24");
if (vi.height%2) {
env->ThrowError("Convert3D: Input height is not even!");


Code can be made faster:
- Much pitch code can be moved outside the loop - thus avoiding many multiplies per pixel. In general most expressions could be mathematically simplified.

- The "/255" will be very slow. An alternative could be:

b3=255-((255-b1)*(255-b2)/255);
~=
255-(((255-b1)*(255-b2)*257+32768)>>16);

257 Is calculated by doing (65536/255). ">>16" is the same as /65536 - just much faster.
This is known as dividing by multiplying by the inverse value.

hanfrunz
17th March 2003, 00:56
Hi Simon,

here you can find some testframes:
http://www.geocities.com/hanfrunz/test3d.zip

thanks for testing,
hanfrunz

[EDIT: now download should work...]

Si
17th March 2003, 01:37
maybe I've been staring at a screen for too long but ..

...
b1=*(srcp+w+ h*src_pitch); //get blue on field1 -yes?
g1=*(srcp+w+1+h*src_pitch); //get green on field1 - yes?
r1=0; //ignore red on field1 - why?????

b2=0; // ignore blue on field2 - why?
g2=0; // ignore green on field2 - why ?
r2=*(srcp+w+2+(h+1)*src_pitch); // get red from field2


b3=255-((255-b1)*(255-b2)/255); // merge blue from field1 and field2
// why do a complicated calculation if b2=0
// the code would just be b3=255-((255-b1)*(255-0)/255)
// == b3=255-((255-b1)*255/255)
// == b3=255-((255-b1))
// == b3=255-255+b1
// == b3=b1
...


Or have I completely missed whats going on? :confused:
regards
Simon

hanfrunz
17th March 2003, 01:54
Hello Simon,

yes you are absolutely right! I was just stupidly using my formulas without thinking about them... The only thing you have to do is take the red-channel form one field and the blue+green from the other! Then you have the result picture, which you can see with red/cyan glasses...

a new version will be there tomorrow. Good night.

hanfrunz

Bidoche
17th March 2003, 01:57
You can remove the IsRGB24 test in the GetFrame method
You already checked that in the constructor, it won't change.

hanfrunz
22nd March 2003, 03:35
Hello,

there is a new version of convert3D: http://www.geocities.com/hanfrunz/convert3dv1.1.zip

Now there is RGB24 and RGB32 support.

On my P3-800 i can't get realtime playback from a mpeg2 (29,97fps 720x480) source (only ~16fps). The convert2rgb slows it down to ~20fps
already :-(

Do you see a chance to use yuy2 or yv12 mode without converting all pixels to rgb (i only need the red channel of field1 and blue and green channel of field2)?

Thanks for your help,

hanfrunz

Si
22nd March 2003, 19:20
Looking at your sample source - do not both fields contain a "proper" picture (i.e they both have R G and B in them)?

If so, then I'd thought you should take the Y information from each field and convert it to red or cyan.

If you did this you could try working in YV12 (or YUY2 to start with) and get the Y values from each field and then "pretend" they are red and cyan and merge them back into the YUV colourspace.

Its more complex but it might be quicker than doing the convert2rgb but YMMV :)

(And you'd probably lose horizontal Y resolution - buts lets face it - you are viewing the result through coloured glasses so who cares :p )

regards
Simon

hanfrunz
22nd March 2003, 23:03
Hi Simon,

if i would take the Luma only and color it, the final result would be a monochrome anaglyph video. (i should add a paramter to do that!)
But i like to have colorfull pictures...
And by the way it looks pretty cool through red/cyan glasses because the brain mixes the colors back together and you see nearly original colors and it's 3D :)

hanfrunz

Si
23rd March 2003, 02:49
if i would take the Luma only and color it, the final result would be a monochrome anaglyph video.

Fair enough - you are probably stuck with the low speed then :(

regards
Simon

Jeff D
25th March 2003, 20:41
Anyone got a mirror to the filter and samples? Seems the geocities site isn't going to work.

DDogg
25th March 2003, 20:46
tried right click, save as?

Jeff D
25th March 2003, 21:38
DDogg, thanks!

stupid geocities, or do I blame IE?

Looks good with the sample, now to try the IMAX 3d dvds.

Blight
2nd April 2003, 18:39
sh0dan:
I just tried your "257" trick. It's about 3 times faster, but it leads to slightly inaccurate results.

hanfrunz
2nd April 2003, 20:50
Hello everyone,

a new version is out:
http://www.geocities.com/hanfrunz/convert3dv1.3.zip

-added swap parameter (swaps left/right)
-added yuy2 input --> rgb32 monochrome anaglyph output

hanfrunz

Wilbert
3rd April 2003, 13:33
I wanted to add your filter to the faq, but the zip file of your last version is invalid. Btw, is it a v2.5 filter?

hanfrunz
3rd April 2003, 19:24
mmmh i just unziped it with winrar 3.11 without any problems, which programm do you use? And yes, it is a 2.5 filter.

hanfrunz

Jeff D
4th April 2003, 02:15
Would there be any difference with where the flip vertical is done in the script?

Used VTS_01_1.VOB from the Haunted Castle disc as a test...

I've tried to do the convert3d then flip vertical. Several of us at work were unimpressed (of course this is a well lit environment with a small monitor that's not super bright.)

But I was curious if it matters when the convert3d filter is executed?

Jeff D
4th April 2003, 02:18
Maybe it would help if I read the new read me before asking qestions about previous releases....

I guess I'd still like to know if that would have caused any problems with the conversion to 3d.

Wilbert
4th April 2003, 17:36
mmmh i just unziped it with winrar 3.11 without any problems,
I don't know what you did, but it works now :)