From dbb5577ff761cfd25f154fc54c2dc7e111a31c77 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 12 Aug 2020 23:41:33 +0200 Subject: [PATCH] Magic value DecodePasses=22 makes worst case decode times much less, can play BT@ER with ~3 dropped frames. --- src/lib/cpu_player_video_preparer.cc | 2 +- src/lib/fastvideo_player_video_preparer.cc | 18 +++++++++--------- src/wx/gl_video_view.cc | 14 +++----------- src/wx/video_view.cc | 2 +- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/lib/cpu_player_video_preparer.cc b/src/lib/cpu_player_video_preparer.cc index 0891189b3..adddfd866 100644 --- a/src/lib/cpu_player_video_preparer.cc +++ b/src/lib/cpu_player_video_preparer.cc @@ -43,7 +43,7 @@ try LOG_TIMING("start-prepare in %1", thread_id()); video->prepare (_pixel_format, _aligned, _fast); LOG_TIMING("finish-prepare in %1", thread_id()); - timestamped_printf("cpu finishes %d\n", video->time.frames_round(24)); + //timestamped_printf("cpu finishes %d\n", video->time.frames_round(24)); } } catch (...) diff --git a/src/lib/fastvideo_player_video_preparer.cc b/src/lib/fastvideo_player_video_preparer.cc index 6e092c060..13b78bfad 100644 --- a/src/lib/fastvideo_player_video_preparer.cc +++ b/src/lib/fastvideo_player_video_preparer.cc @@ -108,18 +108,15 @@ FastvideoPlayerVideoPreparer::send_to_gpu (shared_ptr pv, shared_pt _setup_done = true; } - //std::cout << "add to batch.\n"; - timestamped_printf("fv sends %d to gpu\n", pv->time.frames_round(24)); + //timestamped_printf("fv sends %d to gpu\n", pv->time.frames_round(24)); fastDecoderJ2kAddImageToBatch(_decoder, proxy->j2k().data().get(), proxy->j2k().size()); _batch.push_back (pv); int free_slots = 0; fastDecoderJ2kFreeSlotsInBatch(_decoder, &free_slots); - timestamped_printf("now %d slots left.\n", free_slots); - //std::cout << free_slots << " left in batch.\n"; if (free_slots == 0) { /* Do some decoding */ - timestamped_printf("tx & extract\n"); + PeriodTimer pt("tx/extract"); transform_and_extract (); } @@ -130,6 +127,7 @@ FastvideoPlayerVideoPreparer::send_to_gpu (shared_ptr pv, shared_pt void FastvideoPlayerVideoPreparer::transform_and_extract () { + StateTimer st("transform_and_extract", "tx"); fastDecoderJ2kReport_t report; fastStatus_t r = fastDecoderJ2kTransformBatch(_decoder, &report); if (r != FAST_OK) { @@ -142,8 +140,7 @@ FastvideoPlayerVideoPreparer::transform_and_extract () DCPOMATIC_ASSERT (index <= _batch.size()); shared_ptr pv = _batch[index].lock(); if (pv) { - //std::cout << "got a pv for batch number " << index << "\n"; - /* XXX: this should be memlocked or whatever fastMalloc does */ + st.set("copy gpu -> host"); shared_ptr proxy = const_pointer_cast(dynamic_pointer_cast(pv->image_proxy())); DCPOMATIC_ASSERT (proxy); fastExportParameters_t export_parameters; @@ -153,7 +150,9 @@ FastvideoPlayerVideoPreparer::transform_and_extract () if (r != FAST_OK) { throw FastvideoError ("ExportToHostCopy", r); } + //timestamped_printf("fv copies _decoded to Image\n"); + st.set("convert to Image"); shared_ptr image(new dcpomatic::Image(AV_PIX_FMT_XYZ12LE, size, true)); uint8_t* from = reinterpret_cast(_decoded); uint16_t* to = reinterpret_cast(image->data()[0]); @@ -169,7 +168,7 @@ FastvideoPlayerVideoPreparer::transform_and_extract () to += image->stride()[0] / 2; } - timestamped_printf("fv sets image for %d\n", pv->time.frames_round(24)); + //timestamped_printf("fv sets image for %d\n", pv->time.frames_round(24)); proxy->set_image (image); _cpu.request (pv); @@ -178,6 +177,7 @@ FastvideoPlayerVideoPreparer::transform_and_extract () if (images_left == 0) { break; } + st.set("get next"); fastStatus_t r = fastDecoderJ2kGetNextDecodedImage(_decoder, &report, &images_left); if (r != FAST_OK) { throw FastvideoError ("DecoderJ2kGetNextDecodedImage", r); @@ -218,7 +218,7 @@ FastvideoPlayerVideoPreparer::setup (dcp::Data sample) parameters.truncationMode = 0; parameters.truncationRate = 0; - parameters.DecodePasses = 0; + parameters.DecodePasses = 22; parameters.imageInfo = &info; parameters.maxStreamSize = max_stream_size; diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index 5f3e3b468..2220ecdb3 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -295,9 +295,7 @@ GLVideoView::stop () void GLVideoView::thread_playing () { - StateTimer st("wake to done"); if (length() != dcpomatic::DCPTime()) { - st.set("get next time"); dcpomatic::DCPTime const next = position() + one_video_frame(); if (next >= length()) { @@ -305,12 +303,10 @@ GLVideoView::thread_playing () return; } - st.set("get next frame"); get_next_frame (false); - st.set("set im and draw"); set_image_and_draw (); } - printf("done that frame: time til next frame %d\n", time_until_next_frame().get_value_or(0)); + //printf("done that frame: time til next frame %d\n", time_until_next_frame().get_value_or(0)); while (true) { optional n = time_until_next_frame(); @@ -319,6 +315,7 @@ GLVideoView::thread_playing () } get_next_frame (true); add_dropped (); + timestamped_printf("_____________DROP______________________\n"); } } @@ -326,15 +323,11 @@ GLVideoView::thread_playing () void GLVideoView::set_image_and_draw () { - StateTimer st("set_image_and_draw"); shared_ptr pv = player_video().first; if (pv) { - timestamped_printf("view gets image for %d\n", pv->time.frames_round(24)); - st.set("get-image"); + //timestamped_printf("view gets image for %d\n", pv->time.frames_round(24)); shared_ptr im = pv->image(bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true); - st.set("set-image"); set_image (im); - st.set("draw"); draw (pv->inter_position(), pv->inter_size()); } } @@ -395,7 +388,6 @@ try _thread_work_condition.wait (lm); } lm.unlock (); - printf("awake: time til next frame %d\n", time_until_next_frame().get_value_or(0)); if (_playing) { thread_playing (); diff --git a/src/wx/video_view.cc b/src/wx/video_view.cc index b6e805c26..63217daa9 100644 --- a/src/wx/video_view.cc +++ b/src/wx/video_view.cc @@ -93,7 +93,7 @@ VideoView::get_next_frame (bool non_blocking) ++_errored; } - timestamped_printf("get_next_frame %d\n", _player_video.first->time.frames_round(24)); + //timestamped_printf("get_next_frame %d\n", _player_video.first->time.frames_round(25)); return true; } -- 2.30.2