Magic value DecodePasses=22 makes worst case decode times much less, can play BT...
authorCarl Hetherington <cth@carlh.net>
Wed, 12 Aug 2020 21:41:33 +0000 (23:41 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 13 Sep 2020 18:22:44 +0000 (20:22 +0200)
src/lib/cpu_player_video_preparer.cc
src/lib/fastvideo_player_video_preparer.cc
src/wx/gl_video_view.cc
src/wx/video_view.cc

index 0891189b33d0d47a236b0f61d331cc00d7b2d7d1..adddfd866bbe51fc86a288eba64fdaee6d8dfea8 100644 (file)
@@ -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 (...)
index 6e092c0608610335142185c3ec98e9358d44368b..13b78bfad40e9e8bdf1bc9ce383eeeca1bd08722 100644 (file)
@@ -108,18 +108,15 @@ FastvideoPlayerVideoPreparer::send_to_gpu (shared_ptr<PlayerVideo> 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<PlayerVideo> 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<PlayerVideo> 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<J2KImageProxy> proxy = const_pointer_cast<J2KImageProxy>(dynamic_pointer_cast<const J2KImageProxy>(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<dcpomatic::Image> image(new dcpomatic::Image(AV_PIX_FMT_XYZ12LE, size, true));
                        uint8_t* from = reinterpret_cast<uint8_t*>(_decoded);
                        uint16_t* to = reinterpret_cast<uint16_t*>(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;
 
index 5f3e3b4688dd7069d6893bef723201d107af6602..2220ecdb326736976619f9775020437d56baced3 100644 (file)
@@ -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<int> 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<PlayerVideo> 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<Image> 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 ();
index b6e805c2609b7a99684f19d343645d34ea080484..63217daa97696e4253aef8bd4933089bf91191eb 100644 (file)
@@ -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;
 }