From b36a6ab3fefcda233d90a79ee6f8f380b4ea765b Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 21 Jul 2022 23:39:19 +0200 Subject: [PATCH] Remove the --http-uncompressed-video flag. This is probably unused; it is so expensive to send uncompressed data across sockets, and it was made at a time where it was envisioned that we do most of our encoding externally. --- nageru/flags.cpp | 12 +++--------- nageru/flags.h | 1 - nageru/quicksync_encoder.cpp | 23 ++--------------------- nageru/quicksync_encoder_impl.h | 1 - nageru/video_encoder.cpp | 4 +--- shared/mux.cpp | 3 --- shared/mux.h | 1 - 7 files changed, 6 insertions(+), 39 deletions(-) diff --git a/nageru/flags.cpp b/nageru/flags.cpp index bd80731..2a31422 100644 --- a/nageru/flags.cpp +++ b/nageru/flags.cpp @@ -163,7 +163,6 @@ void usage(Program program) fprintf(stderr, " --default-hdmi-input default to HDMI over SDI inputs for cards that have both\n"); fprintf(stderr, " --fake-cards-audio make fake (disconnected) cards output a simple tone\n"); fprintf(stderr, " --v4l-output DEVICE send video (no audio) to V4L2 output/loopback\n"); - fprintf(stderr, " --http-uncompressed-video send uncompressed NV12 video to HTTP clients\n"); fprintf(stderr, " --http-x264-video send x264-compressed video to HTTP clients\n"); fprintf(stderr, " --record-x264-video store x264-compressed video to disk (implies --http-x264-video,\n"); fprintf(stderr, " removes the need for working VA-API encoding)\n"); @@ -285,7 +284,6 @@ void parse_flags(Program program, int argc, char * const argv[]) { "default-hdmi-input", no_argument, 0, OPTION_DEFAULT_HDMI_INPUT }, { "fake-cards-audio", no_argument, 0, OPTION_FAKE_CARDS_AUDIO }, { "v4l-output", required_argument, 0, OPTION_V4L_OUTPUT }, - { "http-uncompressed-video", no_argument, 0, OPTION_HTTP_UNCOMPRESSED_VIDEO }, { "http-x264-video", no_argument, 0, OPTION_HTTP_X264_VIDEO }, { "record-x264-video", no_argument, 0, OPTION_RECORD_X264_VIDEO }, { "separate-x264-disk-encode", no_argument, 0, OPTION_SEPARATE_X264_DISK_ENCODE }, @@ -427,9 +425,6 @@ void parse_flags(Program program, int argc, char * const argv[]) case OPTION_V4L_OUTPUT: global_flags.v4l_output_device = optarg; break; - case OPTION_HTTP_UNCOMPRESSED_VIDEO: - global_flags.uncompressed_video_to_http = true; - break; case OPTION_HTTP_MUX: global_flags.stream_mux_name = optarg; break; @@ -697,10 +692,9 @@ void parse_flags(Program program, int argc, char * const argv[]) } } - if (global_flags.uncompressed_video_to_http + - global_flags.x264_video_to_http + + if (global_flags.x264_video_to_http + global_flags.av1_video_to_http > 1) { - fprintf(stderr, "ERROR: --http-{uncompressed,x264,av1}-video are mutually incompatible\n"); + fprintf(stderr, "ERROR: --http-{x264,av1}-video are mutually incompatible\n"); exit(1); } if (global_flags.bit_depth == 10) { @@ -709,7 +703,7 @@ void parse_flags(Program program, int argc, char * const argv[]) global_flags.x264_video_to_http = true; } } - if (global_flags.x264_video_to_disk && !global_flags.uncompressed_video_to_http && !global_flags.av1_video_to_http) { + if (global_flags.x264_video_to_disk && !global_flags.av1_video_to_http) { global_flags.x264_video_to_http = true; // Quick Sync to HTTP but x264 to disk doesn't make sense. } if (global_flags.min_num_cards <= 0) { diff --git a/nageru/flags.h b/nageru/flags.h index baecb7a..40f88f3 100644 --- a/nageru/flags.h +++ b/nageru/flags.h @@ -16,7 +16,6 @@ struct Flags { int max_num_cards = MAX_VIDEO_CARDS; std::string va_display; bool fake_cards_audio = false; - bool uncompressed_video_to_http = false; bool x264_video_to_http = false; bool x264_video_to_disk = false; // Disables Quick Sync entirely. Implies x264_video_to_http == true. bool x264_separate_disk_encode = false; // Disables Quick Sync entirely. Implies x264_video_to_disk == true. diff --git a/nageru/quicksync_encoder.cpp b/nageru/quicksync_encoder.cpp index d0ca914..9a6bd6d 100644 --- a/nageru/quicksync_encoder.cpp +++ b/nageru/quicksync_encoder.cpp @@ -713,9 +713,6 @@ void QuickSyncEncoderImpl::enable_zerocopy_if_possible() if (global_flags.x264_video_to_disk) { // Quick Sync is entirely disabled. use_zerocopy = false; - } else if (global_flags.uncompressed_video_to_http) { - fprintf(stderr, "Disabling zerocopy H.264 encoding due to --http-uncompressed-video.\n"); - use_zerocopy = false; } else if (global_flags.x264_video_to_http) { fprintf(stderr, "Disabling zerocopy H.264 encoding due to --http-x264-video.\n"); use_zerocopy = false; @@ -1344,8 +1341,7 @@ void QuickSyncEncoderImpl::save_codeddata(GLSurface *surf, storage_task task) if (file_mux) { file_mux->add_packet(pkt, task.pts + global_delay(), task.dts + global_delay()); } - if (!global_flags.uncompressed_video_to_http && - !global_flags.x264_video_to_http && + 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()); } @@ -1860,19 +1856,6 @@ void QuickSyncEncoderImpl::encode_remaining_frames_as_p(int encoding_frame_num, } } -void QuickSyncEncoderImpl::add_packet_for_uncompressed_frame(int64_t pts, int64_t duration, const uint8_t *data) -{ - AVPacket pkt; - memset(&pkt, 0, sizeof(pkt)); - pkt.buf = nullptr; - pkt.data = const_cast(data); - pkt.size = frame_width * frame_height * 2; - pkt.stream_index = 0; - pkt.flags = AV_PKT_FLAG_KEY; - pkt.duration = duration; - stream_mux->add_packet(pkt, pts, pts); -} - void memcpy_with_pitch(uint8_t *dst, const uint8_t *src, size_t src_width, size_t dst_pitch, size_t height) { if (src_width == dst_pitch) { @@ -1915,9 +1898,7 @@ void QuickSyncEncoderImpl::pass_frame(QuickSyncEncoderImpl::PendingFrame frame, assert(surf != nullptr); } uint8_t *data = reinterpret_cast(surf->y_ptr); - if (global_flags.uncompressed_video_to_http) { - add_packet_for_uncompressed_frame(pts, duration, data); - } else if (http_encoder != nullptr) { + if (http_encoder != nullptr) { http_encoder->add_frame(pts, duration, frame.ycbcr_coefficients, data, received_ts); } if (disk_encoder != nullptr && disk_encoder != http_encoder) { disk_encoder->add_frame(pts, duration, frame.ycbcr_coefficients, data, received_ts); diff --git a/nageru/quicksync_encoder_impl.h b/nageru/quicksync_encoder_impl.h index 4c82131..421ff95 100644 --- a/nageru/quicksync_encoder_impl.h +++ b/nageru/quicksync_encoder_impl.h @@ -111,7 +111,6 @@ private: void open_output_file(const std::string &filename); void encode_thread_func(); void encode_remaining_frames_as_p(int encoding_frame_num, int gop_start_display_frame_num, int64_t last_dts); - void add_packet_for_uncompressed_frame(int64_t pts, int64_t duration, const uint8_t *data); void pass_frame(PendingFrame frame, int display_frame_num, int64_t pts, int64_t duration); void encode_frame(PendingFrame frame, int encoding_frame_num, int display_frame_num, int gop_start_display_frame_num, int frame_type, int64_t pts, int64_t dts, int64_t duration, movit::YCbCrLumaCoefficients ycbcr_coefficients); diff --git a/nageru/video_encoder.cpp b/nageru/video_encoder.cpp index 31c6b4d..877cbff 100644 --- a/nageru/video_encoder.cpp +++ b/nageru/video_encoder.cpp @@ -213,9 +213,7 @@ void VideoEncoder::open_output_stream() avctx->pb->ignore_boundary_point = 1; Mux::Codec video_codec; - if (global_flags.uncompressed_video_to_http) { - video_codec = Mux::CODEC_NV12; - } else if (global_flags.av1_video_to_http) { + if (global_flags.av1_video_to_http) { video_codec = Mux::CODEC_AV1; } else { video_codec = Mux::CODEC_H264; diff --git a/shared/mux.cpp b/shared/mux.cpp index 0a2eaef..2130752 100644 --- a/shared/mux.cpp +++ b/shared/mux.cpp @@ -61,9 +61,6 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const avstream_video->codecpar->codec_id = AV_CODEC_ID_H264; } else if (video_codec == CODEC_AV1) { avstream_video->codecpar->codec_id = AV_CODEC_ID_AV1; - } else if (video_codec == CODEC_NV12) { - avstream_video->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; - avstream_video->codecpar->codec_tag = avcodec_pix_fmt_to_codec_tag(AV_PIX_FMT_NV12); } else { assert(video_codec == CODEC_MJPEG); avstream_video->codecpar->codec_id = AV_CODEC_ID_MJPEG; diff --git a/shared/mux.h b/shared/mux.h index 075da16..e85cac2 100644 --- a/shared/mux.h +++ b/shared/mux.h @@ -51,7 +51,6 @@ public: enum Codec { CODEC_H264, CODEC_AV1, - CODEC_NV12, // Uncompressed 4:2:0. CODEC_MJPEG }; enum WriteStrategy { -- 2.39.2