CRI Sofdec2  Last Updated: 2022-11-21 16:25 p
Threads

Sofdec2 Thread Framework

The Sofdec2 library uses the thread system so that video decoding can be efficiently executed in parallel with the application.
Decoding operates according to the thread framework you specified when you initialized the Sofdec2 library. You can specify the application's thread frame type as thread model.

Sofdec2 has two types of thread models that you can use. Set the thread model as the thread_model member of the parameter structure CriManaLibConfig for library initialization.

Sofdec2 Thread Framework Type
Thread model Explanation initialization constant
Multi-thread framework Create thread in library CRIMANA_THREAD_MODEL_MULTI
Single thread framework Thread not used CRIMANA_THREAD_MODEL_SINGLE

The ability to specify the Sofdec2 thread framework operation is limited to handling Sofdec2 decoding.
Threads for reading files and outputting sound are in accordance with specified ADX2 thread framework.

In settings (default) to use multiple cores in decoding, create a temporary thread when executing the decoding, regardless of the specified thread framework.
Creating or not creating this thread cannot be controlled in the thread framework. You can stop thread creation in setting multi-core decoding, but performance will suffer and is not recommended.

Sofdec2 Multi-thread Framework

When selecting a multi-thread framework during Sofdec2 initialization, the library will create an internal thread and decode on this thread.
This decoding thread will be created at a low priority level instead of a main priority level.

Even when a multi-thread framework is used, periodically call the criMana_ExecuteMain function in the main loop on the main thread side.
You do not need to call the criMana_ExecuteVideoProcess with a multi-thread framework. Nothing will happen if it is called.

Sofdec2 Single Thread Framework

When selecting a single thread framework during Sofdec2 initialization, the library will not create a decoding thread.
Call the criMana_ExecuteVideoProcess function and directly decode the movie.
You will need to periodically call the criMana_ExecuteMain function in the main loop on the main thread side.

Because the criMana_ExecuteVideoProcess function is a process that puts a very high load on the CPU, executing a thread framework will cause slowdown.
Basically, be aware that it is a setting for using debugging applications and so on.
If you are creating an application in a single thread framework, take care to create a low resolution movie or so on to prevent slowdown.

Are They Thread Safe?

Sofdec2 functions are in principle not thread safe. Be sure to call each function from the same thread.