-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multithreading HowTo #8
Comments
It is an extremely simple front-end. You should first gain knowledge how "worker thread pools" work in general, then you will be able to implement it. My own implementation looks like this, but it needs custom-programmed thread pool and worker thread objects that call Workload -> process(). class CThreadPool : public avir :: CImageResizerThreadPool,
}; |
Thanks for your answer. In past I implemented a thread pool for another topic, so I will have a look if that helps here too. What I did not understand yet: does this strategy help a) to render a single picture faster, or does it b) help to render e.g. 4 pictures at nearly the same time like one (on a QuadCore CPU)? |
On a 4-core processor the resizing speed increases by a factor of 3.2, so it does help to resize images faster. Algorithm divides the image automatically. |
How do you initialize the thread pool? |
Which thread library are you using? |
It looks like not all threads are actually being executed, maybe some workload queue mistake. |
You also probably need to remove items from _tasks if they are not autoremoved. |
Here is the library that I use (attached to the message). Just rename it to *.hpp |
The thread pool is utilized like this:
|
Removing tasks didn't help:
|
Make sure thread_pool_base::size() returns correct value - should be the number of processors in the system. I have doubts that thread pool actually runs all workloads, make sure thread pool is functioning correctly. Test it by replacing |
It does. It returns the right number of cores. |
the size of pool: 16 Workload... Workload... Workload... Workload... Workload... Workload... Workload... Workload... Workload... Workload... Workload... Workload... Workload... Workload... Workload... |
It prints 15 times... |
I changed the default value from:
to
It didn't change anything. The picture is still striped. |
Okay. I've fixed it!
|
I'm glad you've got it working, I'll leave this issue opened for others to learn. |
Thank you! |
Thanks at all! Got it working now too! |
@masc4ii Hello! I've registered myself on the magiclantern.fm forum, and posted a couple of messages there, still waiting for moderation approval. Anyway, to get the information faster to you, here's what I've posted there: "Hi! Have the MLV App authors tried to apply non-linear "saturation" image transformations in a higher resolution, with a later downsizing step? This is not a common technique, but from the DSP standpoint it should look much better. "Aliasing" is not the whole story like in image resizing, there's also "harmonic distortion", which is not as apparent with images as it is with audio. Maybe worth a try. A follow-up: the same actually applies to "linearization" or sRGB->linear conversion. It's a non-conventional approach and is resource-heavy, but probably it will fix the feel of all these gamma corrections being "not right"." I would like to add that making e.g. 3x upsampling followed by 3x downsampling is completely safe with AVIR regarding the dynamic range. What is affected is frequency response, but this is "visible" when resizing smaller images mostly. Any high-resolution photo in most cases is already lacking in the highest frequencies due to limitations of the lenses mainly. |
@masc4ii It's even a lot more safer with 2x upsample-downsample cycle (retains an unbelievable 120 dB range), but for best results I think 3x is needed. |
@masc4ii To optimize the things in the pipeline it may be useful to just first upsample, then process the pipeline, then downsample. I do this in professional audio software, that's a very important feature for the users. |
Hi @avaneev , thank you! We'll see when the mods enable your account... 😄 ...yes, here I can read already. Until now all operations are done on the original resolution of the RAW image. For the final export after processing with ffmpeg we upscale with AVIR. I can imagine, that doing all those processing operations on a upscaled image could give better quality - but that would probably slow down the processing a lot, or am I wrong? One of the biggest downsides of our app currently is processing time for most users. In your example (3x upscaling): I would expect the application to be ~9x slower - am I correct, or didn't I understand correct? Do you own a ML capable camera? If you want, I could send you some MLV samples, so you could play with the app a little - if you like. Thanks so much for your ideas! |
Yes, that will slow-down all processing, maybe not by a factor of 9, but easily by a factor of 7. linear->sRGB conversion is the same situation, it's a non-linear sample mapping, so my proposal applies there, too. I do not have an ML capable camera now, but I did a lot of "photography" when I had some Canon EOS middlerange camera and a couple of lenses in the past. Here you can see my "photoworks", on my audio samples product pages: https://www.voxengo.com/group/drum-samples/ |
@masc4ii This option can be made switchable, e.g. 1x, 2x or 3x oversampling. For short videos or nightly renders one could select 2x or 3x, 1x for other cases. This is a "transparent" option, it does not change things too much, but probably improves perceived dynamic range and "smoothness" of the footage. |
@masc4ii One more note: my subjective feeling says that an image becomes apparently "more vivid" when non-linear sample mapping is applied at an increased resolution, and indeed it looks "smoother", but not in a "blurry" meaning. Dynamic range improvement is not too perceptible for me. |
@masc4ii It looks more "cinematic" I would also say, closer to the "vintage" than "eye-popping" crispness of "modern". |
@masc4ii Of course, it's important to apply any saturation/gamma transformation before the final resize, applying them afterwards won't make things look much better. |
Thank you for sharing this great resizing library! Results look so good!
Now I would like to get it a little faster using multithreading, but I don't know how. In your documentation I found class CImageResizerThreadPool... is this the right class for multithreading? Unfortunately I have no idea how to use it. Could you please share a small example, how to realize multithreaded resizing with your library? Thanks in advance for your help!
The text was updated successfully, but these errors were encountered: