Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
4th August 2007, 22:34 | #1 | Link |
Registered User
Join Date: May 2007
Posts: 7
|
New filter: Autolevels
Hi,
some time ago I needed an autogain/autolevels filter and was unsatisfied with what ColorYUV had to offer, so I wrote my own. The main improvement over ColorYUV(autogain=true) is that the amount of gain is averaged over a number of frames which helps with scenes that have flashing lights etc. This filter was useful for a VHS transfer I had to do recently. Maybe somebody else will find it useful, too. The parameters are explained on the web page and in the readme file. URL: http://ta41.zendurl.com/autolevels_en.php Comments are always welcome, of course. |
5th August 2007, 18:18 | #4 | Link |
Registered User
Join Date: May 2007
Posts: 7
|
I re-uploaded the zip file with the source code. This is my first c++ program, so apologies if the code is awkward to read. Also, I haven't translated the comments, so they are all in German.
As for HDRAGC, I tried it out but it didn't seem suited well for my purposes. I think it uses a more complex algorithm, where my plugin basically just stretches the luma histogram and applies some averaging, but it was exactly what I needed. |
6th August 2007, 00:20 | #5 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Thanks for the source code.
As your filter make very heavy use of the cache you may wish to use the NewVideoFrame model for this filter instead of the MakeWriteable model for your output frame. This will avoid possibly needing to rerender the middle frame on subsequent calls. Leak has brought to my attention some weaknesses in my algorithm for MakeWriteable VFB protection. It may be better not to depend on avisynth internals to defend against extreme cases of cache usage. |
10th September 2007, 04:55 | #6 | Link | |
Registered User
Join Date: May 2007
Posts: 7
|
Quote:
As for creating a new frame rather than modifying the original frame object, I see your point, but I'm assuming this isn't an issue any more, now that I'm doing my own caching (of the frame parameters), so I'm not calling GetFrame n times for each frame any more. But maybe I'm wrong and using NewVideoFrame would still make things more efficient. If so, let me know. Version 0.3 of the filter is up on my website. |
|
11th September 2007, 00:29 | #7 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Code:
boolean Autolevels::isSceneStart(int frameno, IScriptEnvironment* env) { ... if (frameno > 1) { PVideoFrame frame = child->GetFrame(frameno, env); PVideoFrame prevframe = child->GetFrame(frameno-1, env); Code:
IntPair Autolevels::getMinMax(int frameno, IScriptEnvironment* env) { PVideoFrame frame = child->GetFrame(frameno, env); const unsigned char* pY = frame->GetReadPtr(PLANAR_Y); ... hash_map<int, IntPair>::const_iterator mmIter = MinMaxCache.find(frameno); If you adjust your code to only fetch the "new" frame for the MinMaxCache and the "current" frame for outputing then the MakeWriteable model will be appropriate. Also check on the libraries implementation of hash_map you may need to manually clear them in your destructor code. |
11th September 2007, 07:55 | #8 | Link |
Registered User
Join Date: May 2007
Posts: 7
|
You are absolutely right, I don't know what I was thinking. Thanks for spotting this!
I uploaded the fixed version, it is still v0.3, same filename. With the unnecessary GetFrame calls are gone, the filter is a lot faster I tried calling the hash_map destructor in the Autolevels destructor, but that crashed VDub, so I left it out for now. I need to actually read the documentation when I have some time. |
11th September 2007, 08:16 | #9 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Yes, it should be very much faster
The short coming with some hash_map implementations is that it forgets the memory allocated to elements when it destructs. As a workaround you may need to do a MinMaxCache.clear(), etc, somewhere in your code, Autolevels::~Autolevels might be a good place. |
19th September 2007, 12:57 | #10 | Link |
Registered User
Join Date: Feb 2004
Posts: 743
|
Make Level Changes Slowly
This is by far the best "autolevels" filter. It does get fooled on rare occasions in changing low light conditions, snapping quickly up and down a couples of levels. What you might do is to have it fade up or down slowly in low light so not to be noticed.
Excellent filter, Richard photorecall.net |
21st September 2007, 07:00 | #13 | Link | |
Registered User
Join Date: May 2007
Posts: 7
|
Quote:
What you are seeing is the filter "detecting" a scene change when there is none. To get rid of this, you can set sceneChgThresh to a higher value. At sceneChgThresh >= 256, scene change detection is effectively disabled and the "snapping" effect should be completely gone. Of course, with scene change detection turned off, you may get undesirable effects at actual scene changes where the luma values change abruptly from one frame to the next. In these cases you don't want any fading to occur. So just try different values for sceneChgThresh to find out what works best in your situation. Possibly, maybe, you will find that fades around scene changes aren't a problem and that sceneChgThresh = 256 is the way to go for you. If you are a perfectionist, you can also deal with the false positives / false negatives by using the frameOverrides parameter, manually overriding the frames it falsely detects as scene changes or when it fails to detect one. Even better would be a more intelligent scene change algorithm. Right now it looks at the maximum and minimum luma values of consecutive frames. If someone knows a better algorithm that is not too complicated to implement, let me know. |
|
7th October 2007, 17:18 | #15 | Link |
Registered User
Join Date: May 2007
Posts: 7
|
You are right, ZendURL is having problems. This link works for me:
http://www.zendurl.com/t/ta41/autolevels_en.php |
29th October 2007, 06:58 | #18 | Link |
Registered User
Join Date: Sep 2006
Posts: 84
|
thanks T. Anschütz for the filter. works gr8. If possible can you spin out a version say simple levels and provide more control to the user by input paramaters for the filters such as:
- gain to be achieved - control for color control, if any, in luma and chroma plains (sorry this too much but thought may be will ask ) even in its native form filter is cool. thnxs again. |
13th January 2008, 17:58 | #19 | Link | |
Registered User
Join Date: May 2006
Posts: 237
|
Quote:
If I try to load the dll LoadPlugin("p:\autolevels.dll") I get an error message with some gibberish, as below. I'm using Avisynth 2.57 on Win2k. Also I note that the web page mentioned above has some problems, as the angle brackets used to indicate frame ranges are interpreted as HTML and thus invisible. |
|
11th May 2008, 20:34 | #20 | Link |
Registered User
Join Date: Feb 2004
Location: NTSC R1
Posts: 2,046
|
Does anyone have a working version of the latest version of Autolevels? If so, can they upload it somewhere, please? The previous URL is dead, and this don't seem to be hosted anywhere else.
__________________
|
Thread Tools | Search this Thread |
Display Modes | |
|
|