X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fquicksync_encoder.cpp;h=36bf15883a3db975f40e90118102950f0f083390;hb=44efd2eb014f80ad50533164882bcc37a5592c11;hp=32b82bb8ae3005a25cabe449371b16a9518717b6;hpb=f25cd0c98896013248b79db6ea6f19aaaf0c03ad;p=nageru diff --git a/nageru/quicksync_encoder.cpp b/nageru/quicksync_encoder.cpp index 32b82bb..36bf158 100644 --- a/nageru/quicksync_encoder.cpp +++ b/nageru/quicksync_encoder.cpp @@ -1,25 +1,24 @@ #include "quicksync_encoder.h" +#include +#include +#include +#include #include #include // Must be above the Xlib includes. #include #include -#include #include #include -#include #include #include #include #include #include -#include #include -#include #include #include -#include #include #include #include @@ -30,31 +29,36 @@ #include #include #include -#include #include #include #include +#include extern "C" { -#include +#include +#include +#include #include #include -#include } // namespace #include "audio_encoder.h" -#include "shared/context.h" #include "defs.h" -#include "shared/disk_space_estimator.h" -#include "shared/ffmpeg_raii.h" #include "flags.h" -#include "shared/mux.h" #include "print_latency.h" #include "quicksync_encoder_impl.h" #include "ref_counted_frame.h" +#include "shared/context.h" +#include "shared/disk_space_estimator.h" +#include "shared/ffmpeg_raii.h" +#include "shared/metrics.h" +#include "shared/mux.h" +#include "shared/ref_counted_gl_sync.h" #include "shared/timebase.h" +#include "shared/va_display.h" +#include "v4l_output.h" #include "x264_encoder.h" using namespace movit; @@ -699,9 +703,9 @@ public: void push_pts(int64_t pts) { if (buf.empty() && num_b_frames > 0) { // First frame. - int64_t base_dts = pts - num_b_frames * (TIMEBASE / MAX_FPS); + int64_t base_dts = pts - num_b_frames * (TIMEBASE / TYPICAL_FPS); for (int i = 0; i < num_b_frames; ++i) { - buf.push(base_dts + i * (TIMEBASE / MAX_FPS)); + buf.push(base_dts + i * (TIMEBASE / TYPICAL_FPS)); } } buf.push(pts); @@ -1352,7 +1356,10 @@ void QuickSyncEncoderImpl::save_codeddata(GLSurface *surf, storage_task task) } if (!global_flags.x264_video_to_http && !global_flags.av1_video_to_http) { - stream_mux->add_packet(pkt, task.pts + global_delay(), task.dts + global_delay()); + http_mux->add_packet(pkt, task.pts + global_delay(), task.dts + global_delay()); + if (srt_mux != nullptr) { + srt_mux->add_packet(pkt, task.pts + global_delay(), task.dts + global_delay()); + } } } } @@ -1855,8 +1862,7 @@ void QuickSyncEncoderImpl::encode_remaining_frames_as_p(int encoding_frame_num, int display_frame_num = pending_frame.first; assert(display_frame_num > 0); PendingFrame frame = move(pending_frame.second); - int64_t dts = last_dts + (TIMEBASE / MAX_FPS); - printf("Finalizing encode: Encoding leftover frame %d as P-frame instead of B-frame.\n", display_frame_num); + int64_t dts = last_dts + (TIMEBASE / TYPICAL_FPS); encode_frame(frame, encoding_frame_num++, display_frame_num, gop_start_display_frame_num, FRAME_P, frame.pts, dts, frame.duration, frame.ycbcr_coefficients); last_dts = dts; } @@ -2045,9 +2051,14 @@ void QuickSyncEncoder::close_file() impl->shutdown(); } -void QuickSyncEncoder::set_stream_mux(Mux *mux) +void QuickSyncEncoder::set_http_mux(Mux *mux) +{ + impl->set_http_mux(mux); +} + +void QuickSyncEncoder::set_srt_mux(Mux *mux) { - impl->set_stream_mux(mux); + impl->set_srt_mux(mux); } int64_t QuickSyncEncoder::global_delay() const {