Closed FreezyLemon closed 1 year ago
Rebased & addressed the feedback. The Mutex now also guards a usize that is incremented every time both decoders successfully decode and return a frame to the score calculation. This frame index is used to guarantee scores in frame decode order (graphing is reliable again). And the verbose println exists again
The basic idea is that we hide the two decoders behind a
Mutex
, and let the worker threads decode two frames (one per decoder) to calculate the SSIMU2 score. It's written so that the Mutex lock is dropped as quickly as possible after decoding the frames, so another worker thread can start decoding ASAP. The resulting score value is sent viaresult_tx
toresult_rx
, which is used in the main thread to accumulate the scores and handle the terminal output.Some notes:
threads
value. I've thought about clamping the parameter to something like(1, 20)
but then decided against it, as this is a user error.drop
like that. Other languages with "automatic" memory management generally discourage manual deletion of variables. There's other ways to drop the value (move some of the code into a new scope, for example) but this seemed to be the easiest and most obvious way