- try {
- LOG_TIMING ("start-local-encode thread=%1 frame=%2", thread_id(), vf->index());
- encoded = vf->encode_locally ();
- LOG_TIMING ("finish-local-encode thread=%1 frame=%2", thread_id(), vf->index());
- } catch (std::exception& e) {
- /* This is very bad, so don't cope with it, just pass it on */
- LOG_ERROR (N_("Local encode failed (%1)"), e.what ());
- throw;
+ if (_context) {
+ if (!_context->launch(vf, config->selected_gpu()) || !_context->scheduleCompress(vf)) {
+ LOG_GENERAL (N_("[%1] J2KEncoder thread pushes frame %2 back onto queue after failure"), thread_id(), vf.index());
+ _queue.push_front (vf);
+ }
+
+ } else {
+ try {
+ LOG_TIMING ("start-local-encode thread=%1 frame=%2", thread_id(), vf.index());
+ encoded = make_shared<dcp::ArrayData>(vf.encode_locally());
+ LOG_TIMING ("finish-local-encode thread=%1 frame=%2", thread_id(), vf.index());
+ } catch (std::exception& e) {
+ /* This is very bad, so don't cope with it, just pass it on */
+ LOG_ERROR (N_("Local encode failed (%1)"), e.what ());
+ throw;
+ }