]> git.sesse.net Git - nageru/blobdiff - futatabi/video_stream.cpp
Make cue in/out highlight the right cell. More logical, and also helps with jogging.
[nageru] / futatabi / video_stream.cpp
index 745da27486971b13414549033b3270fa00a37174..8b29794abe2ff7aca21eff8267b8e6a76092c13c 100644 (file)
@@ -241,6 +241,30 @@ VideoStream::~VideoStream()
        if (last_flow_tex != 0) {
                compute_flow->release_texture(last_flow_tex);
        }
+
+       for (const unique_ptr<InterpolatedFrameResources> &resource : interpolate_resources) {
+               glUnmapNamedBuffer(resource->pbo);
+               check_error();
+               glDeleteBuffers(1, &resource->pbo);
+               check_error();
+               glDeleteFramebuffers(2, resource->input_fbos);
+               check_error();
+               glDeleteFramebuffers(1, &resource->fade_fbo);
+               check_error();
+               glDeleteTextures(1, &resource->input_tex);
+               check_error();
+               glDeleteTextures(1, &resource->gray_tex);
+               check_error();
+               glDeleteTextures(1, &resource->fade_y_output_tex);
+               check_error();
+               glDeleteTextures(1, &resource->fade_cbcr_output_tex);
+               check_error();
+               glDeleteTextures(1, &resource->cb_tex);
+               check_error();
+               glDeleteTextures(1, &resource->cr_tex);
+               check_error();
+       }
+       assert(interpolate_resources.size() == num_interpolate_slots);
 }
 
 void VideoStream::start()
@@ -615,6 +639,20 @@ void VideoStream::encode_thread_func()
                        frame_queue.pop_front();
                }
 
+               // Hack: We mux the subtitle packet one time unit before the actual frame,
+               // so that Nageru is sure to get it first.
+               if (!qf.subtitle.empty()) {
+                       AVPacket pkt;
+                       av_init_packet(&pkt);
+                       pkt.stream_index = mux->get_subtitle_stream_idx();
+                       assert(pkt.stream_index != -1);
+                       pkt.data = (uint8_t *)qf.subtitle.data();
+                       pkt.size = qf.subtitle.size();
+                       pkt.flags = 0;
+                       pkt.duration = lrint(TIMEBASE / global_flags.output_framerate);  // Doesn't really matter for Nageru.
+                       mux->add_packet(pkt, qf.output_pts - 1, qf.output_pts - 1);
+               }
+
                if (qf.type == QueuedFrame::ORIGINAL) {
                        // Send the JPEG frame on, unchanged.
                        string jpeg = frame_reader.read_frame(qf.frame1);
@@ -681,19 +719,6 @@ void VideoStream::encode_thread_func()
                } else {
                        assert(false);
                }
-
-               if (!qf.subtitle.empty()) {
-                       AVPacket pkt;
-                       av_init_packet(&pkt);
-                       pkt.stream_index = mux->get_subtitle_stream_idx();
-                       assert(pkt.stream_index != -1);
-                       pkt.data = (uint8_t *)qf.subtitle.data();
-                       pkt.size = qf.subtitle.size();
-                       pkt.flags = 0;
-                       pkt.duration = lrint(TIMEBASE / global_flags.output_framerate);  // Doesn't really matter for Nageru.
-                       mux->add_packet(pkt, qf.output_pts, qf.output_pts);
-               }
-
                if (qf.display_func != nullptr) {
                        qf.display_func();
                }