View Full Version : CopySame Filter
Marc FD
17th July 2002, 02:48
CopySame Filter (beta4) with a decent motion detection engine can be dl on my site.
If you want to encode real 0-frames :devil:
(and when the 0-frame droping feature would be integrated to XviD, you will be able to encode real variable framerate video content like RV9 do !!)
:confused: => see related Doom9 forum (http://forum.doom9.org/showthread.php?s=&threadid=28773)
Hope you'll enjoy it
Marc FD
18th July 2002, 20:58
Here i released the beta 6.
IT WORKS !!
Here is a TEST (http://ziquash.chez.tiscali.fr/cstest.html) on HQ anime the result is simply... hmmm... great. :cool: +:D
And when the XviD 0-frame dropping feature would be implemented, the size reduction would be bigger (about 10 to 30 % !!)
and all this WITHOUT any quality reduction if you want !!
(for dl use my signature)
Marc FD
21st July 2002, 12:34
beta7 released.
2x to 20x faster :devil:
Can do real-time now :cool:
if you need help, just post :D
SleepEXE
21st July 2002, 19:20
Just wanted to say thanks for the cool plugin. I've been hanging on to some Simpsons episodes in hopes something would come along that would allow them to be compressed more efficiently. I have some compression jobs running right now but I'm definitely going to give this plugin a whirl just as soon as I can. Good stuff.
Best regards,
SleepEXE
vlad59
21st July 2002, 20:45
Hi,
I just made a first test with your filter and I got good results. But can you explain what does mean the numbers in the debug mode ????
I got an idea on some but not for all !!
thanks in advance.
EDIT : I'm stupid, I've found the solution in your doc, sorry
vlad59
22nd July 2002, 08:00
I got a little problem with your filter, it cause avisynth to crash as soon as I want to compress my clip :
let's explain better :
- my avs filter is very simple :
a mpeg2source and your filter with those parameters :
CopySame(1,32,32,4,4,0.2,0.1,3)
or
CopySame(2,32,32,4,4,0.2,0.1,3)
No crop, no resize at all
- I load the script in virtualdub and I start scanning the result frame by frame, it work without any problem.
- But if I select the Xvid compressor and use the save to avi function, vdub reported me a avisynth read error. :(
If I remove your filter I can save my avs to a Xvid avi.
Just ask if I forgot to explain you something !
Marc FD
22nd July 2002, 11:44
Thx all :)
I'm going to improve it more.
But i'm definitively waiting for XviD 0-frames :)
See my test ;)
@vlad59
CopySame(1,32,32,4,4,0.2,0.1,3)
my default settings :D are not the best !
You want me to code or tweak ;) ?
the debug mode output...
shit, i forgot. need to take a look. hop, an .avs file :) (with tons of cnr2/psnr test lines)
oops ! avisynth read error :(
I see. i use SimpleResize(576,320) before my filter and it works...
I'll fix that this afternoon.. use 4x values should work. try to tweak with crop/resize :)
"Frame # 1608 96.85 (0.90) (1/3)+"
or
"Frame # 2165 0.00 (0.00) (2/3)-"
frame # , i think you know what it is :cool:
96.85 and 0.00 : rel (relative movement computed value based on brute pel motion estimation (diamond search))
(0.90) and (0.00) : relq = rel(n)/rel(n-1) where n is the frame number
(1/3)+ and (2/3)- the 0-frame count/max 0-frames row
+ normal frame
- 0-frame :)
Hope it helps :)
Marc FD
23rd July 2002, 17:52
Okay, i fixed it !! :cool:
i just checked the whole code and after that it worked like a charm :)
i've coded something who gives a lil'speedup on debug mode :D
You can now download CopySame beta8
Marc FD
24th July 2002, 16:31
CopySame beta9 is out :cool:
And beta-testers of previous versions will see that it has been totally rebuilded from scratch (no cute lil'white pels anymore..)
will make a big test as soon as Z-frames are Ok in XiD. it seems there is some issues with MC inertia...
MoonWalker
25th July 2002, 09:38
Originally posted by Marc FD
will make a big test as soon as Z-frames are Ok in XiD. it seems there is some issues with MC inertia...
What exaclty are Z-frames? We have I/P/B-frames.Never heard of Z-frames :)..
MoonWalker
Didée
25th July 2002, 11:39
Probably a joke, because "B-frames" was THE FORBIDDEN WORD some time ago?
Or is there something arising, to distinguish the (future) XviD-Bframes from the divX5 ones, because the latter are - - ah, don´t get the word here. In German, we say "hemdsärmelig" :) [meaning some kind of lazy implementation]
dividee
25th July 2002, 11:55
I think what he means by Z-frames (or 0-frames) are voluntarily dropped frames, to implement some kind of variable framerate.
Didée
25th July 2002, 12:05
Okay, now I found the button to switch my brain on, and did so.
Yes, dividee, that makes much more sense.
Let the topic continue ...
Marc FD
25th July 2002, 17:14
Exactly :
B-frames are constitued of B_VOPs
and Z-frames are in fact zero-frames (or 0-frames)
theorically, it should be name N-frames (N_VOP coded)
but i founded Z-frames as a liitle "something" :)
PS : i think DivX 4 or/and 5 is Z-frames capable, but i'm not relly sure of that.A Z-frame is only a 10 bytes big I-frames, in fact.
Hope it helps to understand....
Kaiousama
31st July 2002, 22:31
TNX to marcFD for the suggested settings (in the readme there are settings for an older beta wich accept more parameter, i don't know).
A little thing:
Because the filter is very useful for anime encoder like me, it would be good if it'll be the possibility to copysame not all the frame but leave a bottom and upper lines compressing normally and apply the copysame filter only to the rest of the frame, that's because mainly in the titles but even in the episode i have to put subtitles and toptitles with karaoke effect, this mean the frame is not exactly the same as the past frame (but at 85-90% is the same, ehy encode it all if it would be a potentially z-frame?)
Bye:p
Marc FD
31st July 2002, 23:15
A way to get what you want is to simply use a script like that :
(i assume 640x480 res here)
src=....
up=src.Crop(0,0,640,400).CopySame(...)
down=src.Crop(0,400,640,480)
return StackVertical(up,down)
hey, it's avisynth's power !! :devil: + :cool: !
BTW i attached a pre-release of CopySame 1.1
If you can't get CopySame 1.0 running, test it please :)
Kaiousama
1st August 2002, 20:56
a way to get what you want is to simply use a script like that :
Amazing :eek: i'm really without words :eek:
i'll try it soon, can I in this way apply different filters in different part of the frame (say yes and i'll marry you)?
BTW i attached a pre-release of CopySame 1.1
If you can't get CopySame 1.0 running, test it please :)
ehm..... the version 1.1 attached where?
Marc FD
1st August 2002, 22:09
Amazing i'm really without words
i'll try it soon, can I in this way apply different filters in different part of the frame (say yes and i'll marry you)?
Yes. "Hey, it's AviSynth's Power !! :cool: + :devil: "(tm)(R)
ehm..... the version 1.1 attached where?
a mod must accept the attachement...
and it's already an old version (more than 12 hours :D )
so i don't think it worth it. I gived the last 1.1 bin to vlad and it finally works "sans pb, impecable" (~like a charm) for him.
So i think i will release it the 2/8 . i'll improve the movement detection before.
Defiler
18th August 2002, 21:42
I'm having some difficulty getting CopySame to function.
Have the parameters changed since the beta?
Doing CopySame(1,35,35,0,350,10) yields a nasty access violation when the script is executed, as does CopySame(1,32,32,4,3,3).
(As you can see, I have no idea what types of numbers are valid for the second-to-last parameter.)
I am using AviSynth 2.04, and I've tried both 1.0 and 1.1 of CopySame.
I've read the HTML file included with the 1.0 download, but some of the parameters puzzle me. It would be nice to have some guidelines as to which numbers are valid/sane.
I've searched the forums, and pasted in every instance of CopySame() that I found mentioned, but none work for me.
Here's an example script:
LoadPlugin("C:\Bin\AviSynth\CopySame.dll")
AVISource("D:\Blah...")
CopySame(1,35,35,0,350,10)
crop(10,3,695,470)
BicubicResize(624,464,0,0.75)
Total failure when I try to handle that AVS file.
Belgabor
18th August 2002, 23:21
Hi MarcFD,
I know you somewhere said you don't want to work anymore on this filter, but nevertheless i have an improvement request which i think could be quite useful.
First my problem: the anime ep I'm currently using to test new filters has a scene which is over all pretty dark, not black, just dark. In one corner there's a flickering torch. If i tweak the Copysame filter that way that it recognizes the flickering as motion, other frames which are much brighter and are clearly the same are not copied because the noise "motion" was higher than the torch in the other scene.
So what would be the request? Well i though a possiblility would be to separate the picture in squares (2x2 or 3x3 perhaps) and call a frame "in motion" if the threshold is matched in just ONE of this sqares. This way you could ignore something more distributed across the whole frame like noise (= it would fall below the threshold).
I don't know if this is a totally weird idea or how much of a hassle it actually would be to code it, it's just a thought you might consider ;)
Cheers
Belgabor
P.S.: Some statistical function (DebugView output?) would be nice too ;) aka how much frames were actually "zeroed" in total.
spyder
19th August 2002, 06:14
very good idea Belgador. This would be a nice addition to CopySame.
Marc FD
19th August 2002, 08:49
In fact i was thinking of an optimised box search, who would scan all AxA blocks of the image (A would be a coef)
I was going for it in 1.1 :)
In fact i don't think i will break devellopement on CopySame, because the 1.1 is really too cool (MMX/ISSE optimised :D)
I will just split MAM in 2 filters, that's all.
My Mpack idea was just a dumb idea. i will stop it ...
PS : I'll think of a log output too :)
Defiler
20th August 2002, 00:51
Marc: Can you point out what I'm doing wrong there in my script?
Marc FD
20th August 2002, 01:47
@defiler
Simple : CopySame 1.0 is buggy, slow and less accurate than 1.1.
that's all :)
Don't worry i know this bug and i already corrected it in CopySame 1.1
@belgador
i think you'll be happy, i had already coded 50% of the algo. i've just finished the code and optimised it (but it's slower, ~20 fps).
@All
after 6 hours of coding (20h30-02h30), i'm finally almost (98%) ready for a pre-release (no src) of CopySame 1.1 :cool:
i'll do a lil MMX fix and udate the doc this morning, and i'll release.
Just need to sleep right now because i've a some MMX code to fix and i can't think at all ! now sleeeeeeeeeeeep ...............
Marc FD
20th August 2002, 10:15
Here it is :)
CopySame 1.1 official release out :cool:
don't thing a 0.1 increment in the version count mean it's a little update in the code : there are tons of improvements :
- All know bugs fixed (first-frame bug, random acces violations)
- Some cosmetics (new HUD)
- local MAD implemented and working (+debug mode lMAD info)
- low-level MMX/ISSE code optimisation
(should work around 25 fps without the lMAD algo)
- New spatial cleaning algo (fast and accurate)
- easy to use param list
in fact there are so much modifications between 1.0 and 1.1 that i don't remember them all !
Enjoy :devil: !
PS : I'm going to make some tests with XviD on some anime material, to update cstest.html (because the last test was made with beta6 !)
bb
20th August 2002, 10:34
Great! I'll test it ASAP (probably this weekend...).
Why didn't you name it CopySame 2.0?
bb
lark
20th August 2002, 10:54
at least i cannot find the copysame 1.1 from your download page.
actually 1.0 (the zip) seems to be gone as well...
is this a problem w/ our proxy?
regards
t :)
Marc FD
20th August 2002, 10:55
I don't like too boost version values.
i.e. having a CopySame v20.58 would not make it better than a v1.9
almost all coders are shy and avoid to show off ;)
Marc FD
20th August 2002, 10:56
@iark
hit on "update" :D
lark
20th August 2002, 10:59
thanks for almost real-time answer.
i tried to reload the page many times
and even with different browser, but
didn't see it... :-(
and after your post the miracle happened.
thanks a million.
(must have been our proxy that gave me
the old page regardless of the reload)
regards
t :)
Defiler
20th August 2002, 13:32
Thanks!
By the way; I took TomsMoComp out of the script, and suddenly CopySame started working. Conflicts ahoy!
Defiler
20th August 2002, 14:19
Sorry to keep replying to your thread here.. but I'm trying to use CopySame in the following way:
When there are two or more consecutive frames that are nearly identical, copy the second frame over the first one.
Here's an example.
Bad frame (first):
http://www.hellninjacommando.com/misc/goodframe.jpg
Good frame (immediately thereafter):
http://www.hellninjacommando.com/misc/badframe.jpg
Here's the entirety of the script I'm using:
LoadPlugin("D:\Programs\avisynth\CopySame.dll")
AVISource("D:\Temp\Test.avi")
ConvertToYUY2()
CopySame(mode=1,llt=256,lct=256,slt=256,minMAD=10.0,minlMAD=987654321,lxs=60,lys=60,mfs=10)
I started at the default settings, and worked my way up to the (very aggressive) settings you see above. I tried putting reverse() statements on either side of CopySame, but that doesn't help.
Any tips?
By the way.. 1.1 is MUCH more stable and well-documented than 1.0. Thanks.
In the "usage" portion of the help document, I did notice that the last three parameters are ",mlxs=0,mlys=0,mfs=3".. That should be ",lxs=0,lys=0,mfs=3", right?
Marc FD
20th August 2002, 17:17
@ALL
ARGH, there is indeed a bug in CopySame 1.1 who disables dropping.
a very dumb thing : a && in the place of a ||
download CopySame 1.1b, it should work now :)
Originally posted by Defiler
Sorry to keep replying to your thread here.. but I'm trying to use CopySame in the following way:
When there are two or more consecutive frames that are nearly identical, copy the second frame over the first one.
Here's an example.
Bad frame (first):
http://www.hellninjacommando.com/misc/goodframe.jpg
Good frame (immediately thereafter):
http://www.hellninjacommando.com/misc/badframe.jpg
i could add a reverse mode, because you're not he first user who tries to do it ;) (and it would be as fast than norm mode)
Here's the entirety of the script I'm using:
LoadPlugin("D:\Programs\avisynth\CopySame.dll")
AVISource("D:\Temp\Test.avi")
ConvertToYUY2()
CopySame(mode=1,llt=256,lct=256,slt=256,minMAD=10.0,minlMAD=987654321,lxs=60,lys=60,mfs=10)
I started at the default settings, and worked my way up to the (very aggressive) settings you see above. I tried putting reverse() statements on either side of CopySame, but that doesn't help.
dl CopySame 1.1b
Any tips?
By the way.. 1.1 is MUCH more stable and well-documented than 1.0. Thanks.
In the "usage" portion of the help document, I did notice that the last three parameters are ",mlxs=0,mlys=0,mfs=3".. That should be ",lxs=0,lys=0,mfs=3", right?
the param list is like decomb : you can enter them in any order, and you just need to type params who are not defaults :)
sorry for the buggy first releas.
kyousuke
20th August 2002, 17:39
i'll test this right now !
thks marco :D
Defiler
20th August 2002, 20:41
Works as advertised now. Amazingly great.
Stomps on those Divx 3.11 artifacts perfectly.
Maybe I wasn't clear enough in my previous post.. I meant that the parameter names in the example are incorrect. I know they can be used in any order.
Marc FD
20th August 2002, 21:15
i see. yep, mlys/mlxs is false. i renamed them recently.
i'm working on the blend/reverse feature now.
Marc FD
21st August 2002, 01:16
I worked late on some improvements for copysame.
so here is a beta bin of CopySame 1.2
new :
- reverse mode (use mode=2)
- blend mode :devil: (use mode=3)
there are some bugs when you use big max frame shifts with blend but it seems to work with mfs=3 (default)
- debugview info
will send a line to debugview each time it creates a Z-frame
i hope some experienced users of CopySame could test it ;)
I'm going to build a custom version of XviD with anime-specific ME
(EPZS16 mixed with PMVfast8 adv diamonds) and frame_drop_ratio activated (but without B-frames)
If anybody is interessed, i could post it
(it's just a little experimental build to get the best of XviD+CopySame)
"CopySame 1.2(beta) bin.zip" attached.
bb
21st August 2002, 06:16
I am interested in your XviD version. Please post it.
bb
Ivion
21st August 2002, 13:07
I totally agree with bb, please post it, I'm eager to test it. (In conjuction with the new CopySame, Decomb and Masked Smoother :D).
So I'm going to test many things, please post it Marc FD! :)
Defiler
21st August 2002, 14:06
Will we need to use this "test" Xvid build to both play and encode files with Z-frames, or just to encode them?
Either way, I want to test it. Heh.
I'm playing with CopySame 1.2b now.
Marc FD
21st August 2002, 17:25
just to _encode_ them !!
it would be a build with a different ME and the frame_drop_ratio enabled. so you would be able to play it with _any_ mpeg-4 decoder.
Defiler
21st August 2002, 17:35
That's so far beyond awesome, I'm not sure there's even a word for it. Voopy!
Marc FD
21st August 2002, 18:22
hey, ii's just a custom XviD build. no magic here. don't expect something else than better Z-frame dropping and maybe 1-2% gain with the ME !!
if Koepi help me, i could even give a intel compilator optimised version ;)
kyousuke
21st August 2002, 23:24
very interesting marc by your build !
i would test it on a recent raw and on my STaker dvd (the screen you saw last days :p)
all of this is really "sugoi" :p
kyousuke
21st August 2002, 23:51
your CopySame.dll don't want to be loaded !
v1.1 or v1.2b, my avs don't want it o_o
so i made a rapid test without all my plugins :
LoadPlugin("c:\test_encode\anime\MPEGDecoder.dll")
LoadPlugin("c:\test_encode\anime\CopySame.dll")
MPEGSource("c:\test_encode\anime\STopening.m2p")
CopySame(false,32,32,4,4,0.2,0.1,3)
vdub reply by : script error : invalid arguments "CopySame"
(c:\test_encode\anime\test.avs, line 4)
nothing to do...... that don't want to load the dll o__o,,,
Marc FD
22nd August 2002, 00:00
READ THE README !!!!
it's really dumb as that : the param list is a new one in v1.1 / v1.2
PS: using 32,32 could gives you a very poor fade detection. you should check that before doing real encoding.
about my XviD build, i'm doing intensive testing and the result are very ..... (you would know when you would test it ;) )
but currently i get ME-artifacts, so i need to fix that.
kyousuke
22nd August 2002, 00:09
for the PS, i c/c your exemple form your read me :p
wait i try to understand your plug
ok for your build, good luck
nb : for my problem with MAM on the other thread... i think i won't use TemporalSoften again. it seems the problem came from it... :(
update :
yes it works ;)
Kaiousama
22nd August 2002, 10:55
It would be a paradise to have an anime dedicated xvid version *_*
In my opinion an ideal anime codec has to have a full variable framerate support:
in that way you can save the maximum space in the 12 and 8 fps scenes and see the CG 30fps scenes fluid, not as the decimating IVTC process give.
For the detection of lower framerate scenes your copysame code is a good worker, it would flag this scenes and the codec decimate them.
I don't know how much is this an utopistic possibility ^_^
another good implementation for an anime codec would be an algorithm that identifies the edges in the scene and gives to the moving edge a bigger (much bigger) bitrate than the other motion vectors, that's to minimize the bad ringing effect that appears i.e. when a character moves the head or speaks (that actually only an higher total bitrare or an ugly blur filter can solve).
For now, i'm testing the copysame, can you explain more in detail, in the next readme, how the imad option work?
An idea for the developement would be to make the frame in many parts (i.e. 1part=1macroblock) and apply the copysame to each part,to have in every frame only the real changing portions, i mean: if in a frame there is only a character that speaks, copysame will copy the exact rest of the frame but the mouth field, in that way the background noise of the scene can be totally calcelled and the codec can use the lowest space possible to encode that frame.
You are making a great work,thanks!!
Marc FD
22nd August 2002, 11:12
Originally posted by Kaiousama
It would be a paradise to have an anime dedicated xvid version *_*
In my opinion an ideal anime codec has to have a full variable framerate support:
in that way you can save the maximum space in the 12 and 8 fps scenes and see the CG 30fps scenes fluid, not as the decimating IVTC process give.
For the detection of lower framerate scenes your copysame code is a good worker, it would flag this scenes and the codec decimate them.
I don't know how much is this an utopistic possibility ^_^
that's why i want frame_frop_ratio actived. with it XviD make 10 bytes big Z-frames
(hard to decimate more ;) )
another good implementation for an anime codec would be an algorithm that identifies the edge in the scene and give to the moving edge a bigger (much bigger) bitrate than the other motion vectors, that's to minimize the bad ringing effect that appears i.e. then a character moves the head.
that's what DCT coefs are for, and it's because the codec is edge sensible that you see ringing effects (or mosquito noise) it's due to the DCT high frequencies... it's not XviD specific nor anime specific (movie have edges too..)
For now, i'm testing the copysame, can you explain more in detail, in the next readme, how the imad option work?
i hope belgador would be able to use the power of this feature (because he had the almost same idea) so he could explain it to you. for me, there is nothing more to explain :(
An idea for the developement would be to make the frame in many parts (i.e. 1part=1macroblock) and apply the copysame to each part,to have in every frame only the real changing portions, i mean: if in a frame there is only a character that speaks, copysame will copy the exact rest of the frame but the mouth field, in that way the background noise of the scene can be totally calcelled and the codec can use the lowest space possible to encode that frame.
an easy way to do it right now : use a.MAM(a.temoralsoften(1,255,255,a) where a is your source clip. never tested it but should fix everything who isn't moving . maybe i would give an another try to the MAD concept, with temoralfixing and spatialsmoothing...
You are making a great work,thanks!!
thx
going to work on "MarcFD anime-spec XviD build" now :cool:
Suikun
22nd August 2002, 11:55
Originally posted by Kaiousama
another good implementation for an anime codec would be an algorithm that identifies the edges in the scene and gives to the moving edge a bigger (much bigger) bitrate than the other motion vectors, that's to minimize the bad ringing effect that appears i.e. when a character moves the head or speaks (that actually only an higher total bitrare or an ugly blur filter can solve).
In fact I actually implemented such a thing =). It somehow works like inversed luminance masking and lowers the quants for macroblocks with edges in it. I haven't tried to make it motion adaptive yet...
The problem is that the files most times get way too big (1.5 times the size for quant 5 o_O;) and it most likely completely screws the curve algorithms. Also it only seems to works with const quant (is someone who knows about the curve treatment able to help me there?)...
If someone (Marc FD? ;) ) wants the code, just ask.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.