blob: 9398bcb85d034b114d1d4d85c093c0dc1c89b052 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include "dcp_video.h"
#include "dcpomatic_log.h"
#include "j2k_encoder.h"
#include "j2k_sync_encoder_thread.h"
#include "scope_guard.h"
J2KSyncEncoderThread::J2KSyncEncoderThread(J2KEncoder& encoder)
: J2KEncoderThread(encoder)
{
}
void
J2KSyncEncoderThread::run()
try
{
log_thread_start();
while (true) {
LOG_TIMING("encoder-sleep thread=%1", thread_id());
auto frame = _encoder.pop();
ScopeGuard frame_guard([this, &frame]() {
boost::this_thread::disable_interruption dis;
_encoder.retry(frame);
});
LOG_TIMING("encoder-pop thread=%1 frame=%2 eyes=%3", thread_id(), frame.index(), static_cast<int>(frame.eyes()));
auto encoded = encode(frame);
if (encoded) {
boost::this_thread::disable_interruption dis;
frame_guard.cancel();
_encoder.write(encoded, frame.index(), frame.eyes());
}
}
} catch (boost::thread_interrupted& e) {
} catch (...) {
store_current();
}
|