About Store Forum Documentation Contact
Donations:
289$/mo



Post Reply 
Video processing in threads
Author Message
neuroliquid Offline
Member

Post: #1
Video processing in threads
Updating vid_anim blocks accessing vid_mask image in thread, the output mask freezes randomly

Code:
Video vid_anim, vid_mask;
Image *mask=null;
void InitPre(){EE_INIT();}
void Shut(){}

bool Init()
{
   vid_anim.create(UID(*** video ***),  true, true);
   vid_mask.create(UID(*** greyscale mask for video ***),  true, true);
   return true;
}

bool ThreadFunc(Thread &thread)
{
   ThreadMayUseGPUData();
   mask=&ConstCast(vid_mask.image()).alphaFromBrightness();
   return false;
}

bool Update()
{
   vid_mask.update(Time.stateTime());
   Thread thread(ThreadFunc);
   vid_anim.update(Time.stateTime());
   /* much more game stuff */
   thread.wait();
   thread.del();
   return true;
}

void Draw()
{
   D.clear(TURQ);
   vid_anim.image().drawMask(WHITE, BLACK, D.viewRect(), *mask, D.viewRect());
}

Do I have to copy the image from video first? I'm not sure if this way it will be any faster even with threads...
I have also tried other way around without success: update the other video in thread while computing mask in primary one.

Thanks for any help
08-21-2018 01:43 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Video processing in threads
Hi, do you have an Esenthel license?
08-22-2018 02:53 AM
Find all posts by this user Quote this message in a reply
neuroliquid Offline
Member

Post: #3
RE: Video processing in threads
Yes, you already asked in my thread about problems with compiler on Linux and I have PMed you with licence key in (sent at 05-25-2017, 10:11 AM). Thank you for clang!
08-22-2018 09:46 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Video processing in threads
Thank you.
It would be great if you had the same email for your account on the Forum as on Esenthel Store, this way your username would be displayed as a Licensed Developer on the forum.
Alright, let me check the code and what could be the problem.
08-22-2018 10:04 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Video processing in threads
Hi,

I've tried to use the code in the "Tutorials" included in the editor, but it works fine.
Code:
Video vid_anim, vid_mask;
Image *mask=null;
void InitPre(){EE_INIT();}
void Shut(){}

bool Init()
{
   vid_anim.create(UID(352823356, 1075274726, 2906837907, 348097182),  true, true);
   vid_mask.create(UID(352823356, 1075274726, 2906837907, 348097182),  true, true);
   return true;
}

bool ThreadFunc(Thread &thread)
{
   ThreadMayUseGPUData();
   mask=&ConstCast(vid_mask.image()).alphaFromBrightness();
   return false;
}

bool Update()
{
   vid_mask.update(Time.stateTime());
   Thread thread(ThreadFunc);
   vid_anim.update(Time.stateTime());
   thread.wait();
   thread.del();
   return true;
}

void Draw()
{
   D.clear(TURQ);
   vid_anim.image().drawMask(WHITE, BLACK, D.viewRect(), *mask, D.viewRect());
}

You could check on your computer this too, in the Tutorials projects with the Esenthel included video.

Perhaps the problem is related to something else.

You could send me privately the videos that you use, or the *.EsenthelProject with all files that you use.
08-22-2018 10:14 PM
Find all posts by this user Quote this message in a reply
neuroliquid Offline
Member

Post: #6
RE: Video processing in threads
Ok I will post in future from the other account.
In fact the code with video from tutorial works fine. Today I tried less dynamic one of our animations and this time it is even worse with updating. Even if some videos will work I am rather looking for generic solution... I have PMed you with project with this animation.
08-27-2018 10:32 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: Video processing in threads
Hi,
I've tested this on Win 64 - DX11, but all works fine (both A and B apps)
Please tell me what platform are you using that has issues?
08-27-2018 10:40 AM
Find all posts by this user Quote this message in a reply
neuroliquid Offline
Member

Post: #8
RE: Video processing in threads
Ubuntu 18.04
(This post was last modified: 08-27-2018 10:46 AM by neuroliquid.)
08-27-2018 10:45 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: Video processing in threads
OK thank you, I'll test this on Linux tomorrow morning. Now time for sleep
08-27-2018 10:46 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: Video processing in threads
Hi,

OpenGL has some limitations that cause this problem.

I've just added some new functionality, it will work well, and much faster too.
So please wait for next release with the update, it will have a tutorial too.
08-28-2018 02:33 AM
Find all posts by this user Quote this message in a reply
neuroliquid Offline
Member

Post: #11
RE: Video processing in threads
Wow, the best I could hear from you! Thanks!
08-28-2018 10:36 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #12
RE: Video processing in threads
This is now available
10-26-2018 11:31 PM
Find all posts by this user Quote this message in a reply
Post Reply