Sunshine latest
Self-hosted game stream host for Moonlight.
video.h
Go to the documentation of this file.
1
5#pragma once
6
7// standard includes
8#include <chrono>
9#include <string_view>
10
11// local includes
12#include "input.h"
13#include "platform/common.h"
14#include "thread_safe.h"
15#include "video_colorspace.h"
16
17extern "C" {
18#include <libavcodec/avcodec.h>
19#include <libswscale/swscale.h>
20}
21
22struct AVPacket;
23
24namespace video {
25
43
44 namespace amf {
45
49 enum class coder_e : int {
50 auto_ = 0,
51 cabac = 1,
52 cavlc = 2,
53 };
54
55 } // namespace amf
56
65 int select_h264_profile(std::string_view encoder_name, const config_t &config, int amd_coder);
66
73 platf::mem_type_e map_base_dev_type(AVHWDeviceType type);
80 platf::pix_fmt_e map_pix_fmt(AVPixelFormat fmt);
81
87 void free_ctx(AVCodecContext *ctx);
93 void free_frame(AVFrame *frame);
99 void free_buffer(AVBufferRef *ref);
100
120 using img_event_t = std::shared_ptr<safe::event_t<std::shared_ptr<platf::img_t>>>;
121
126 public:
133 int convert(platf::img_t &img) override;
134
143 int set_frame(AVFrame *in_frame, AVBufferRef *hw_frames_ctx) override;
144
148 void apply_colorspace() override;
149
160 int init(int in_width, int in_height, AVFrame *in_frame, AVPixelFormat format, bool hardware);
161
162 private:
166 void prefill();
167
174 int reinit_sws(AVPixelFormat src_format);
175
176 // Store ownership when frame is hw_frame
177 avcodec_frame_t hw_frame;
178
179 avcodec_frame_t sw_frame;
180 avcodec_frame_t sws_input_frame;
181 avcodec_frame_t sws_output_frame;
182 sws_t sws;
183 AVPixelFormat sws_src_format {AV_PIX_FMT_BGR0};
184
185 // Offset of input image to output frame in pixels
186 int offsetW;
187 int offsetH;
188 };
189
201
209 using init_buffer_function_t = std::function<util::Either<avcodec_buffer_t, int>(platf::avcodec_encode_device_t *)>;
210
247
248 AVHWDeviceType avcodec_base_dev_type;
250 AVPixelFormat avcodec_dev_pix_fmt;
251 AVPixelFormat avcodec_pix_fmt_8bit;
252 AVPixelFormat avcodec_pix_fmt_10bit;
255
257 };
258
286
290 struct encoder_t {
291 std::string_view name;
292
305
312 static std::string_view from_flag(flag_e flag) {
313#ifndef DOXYGEN
314 #define _CONVERT(x) \
315 case flag_e::x: \
316 return std::string_view(#x)
317#endif
318 switch (flag) {
319 _CONVERT(PASSED);
320 _CONVERT(REF_FRAMES_RESTRICT);
321 _CONVERT(DYNAMIC_RANGE);
322 _CONVERT(YUV444);
323 _CONVERT(DYNAMIC_RANGE_YUV444);
324 _CONVERT(VUI_PARAMETERS);
325 _CONVERT(MAX_FLAGS);
326 }
327#undef _CONVERT
328
329 return {"unknown"};
330 }
331
335 struct option_t {
340 option_t(const option_t &) = default;
341
342 std::string name;
343 std::variant<int, int *, std::optional<int> *, std::function<int()>, std::string, std::string *, std::function<const std::string(const config_t &)>> value;
344
351 option_t(std::string &&name, decltype(value) &&value):
352 name {std::move(name)},
353 value {std::move(value)} {
354 }
355 };
356
357 const std::unique_ptr<const encoder_platform_formats_t> platform_formats;
358
362 struct codec_t {
363 std::vector<option_t> common_options;
364 std::vector<option_t> sdr_options;
365 std::vector<option_t> hdr_options;
366 std::vector<option_t> sdr444_options;
367 std::vector<option_t> hdr444_options;
368 std::vector<option_t> fallback_options;
369
370 std::string name;
371 std::bitset<MAX_FLAGS> capabilities;
372
379 bool operator[](flag_e flag) const {
380 return capabilities[(std::size_t) flag];
381 }
382
389 std::bitset<MAX_FLAGS>::reference operator[](flag_e flag) {
390 return capabilities[(std::size_t) flag];
391 }
392 };
393
397
404 const codec_t &codec_from_config(const config_t &config) const {
405 switch (config.videoFormat) {
406 default:
407 BOOST_LOG(error) << "Unknown video format " << config.videoFormat << ", falling back to H.264";
408 // fallthrough
409 case 0:
410 return h264;
411 case 1:
412 return hevc;
413 case 2:
414 return av1;
415 }
416 }
417
418 uint32_t flags;
419 };
420
425 virtual ~encode_session_t() = default;
426
433 virtual int convert(platf::img_t &img) = 0;
434
438 virtual void request_idr_frame() = 0;
439
443 virtual void request_normal_frame() = 0;
444
451 virtual void invalidate_ref_frames(int64_t first_frame, int64_t last_frame) = 0;
452 };
453
454 // encoders
455 extern encoder_t software;
456
457#if !defined(__APPLE__)
458 extern encoder_t nvenc; // available for windows and linux
459#endif
460
461#ifdef _WIN32
462 extern encoder_t amdvce;
463 extern encoder_t quicksync;
465#endif
466
467#if defined(__linux__) || defined(linux) || defined(__linux) || defined(__FreeBSD__)
468 extern encoder_t vaapi;
469#endif
470
471#ifdef __APPLE__
472 extern encoder_t videotoolbox;
473#endif
474
479 virtual ~packet_raw_t() = default;
480
486 virtual bool is_idr() = 0;
487
493 virtual int64_t frame_index() = 0;
494
500 virtual uint8_t *data() = 0;
501
507 virtual size_t data_size() = 0;
508
512 struct replace_t {
513 std::string_view old;
514 std::string_view _new;
515
517
518
524 replace_t(std::string_view old, std::string_view _new) noexcept:
525 old {std::move(old)},
526 _new {std::move(_new)} {
527 }
528 };
529
530 std::vector<replace_t> *replacements = nullptr;
531 void *channel_data = nullptr;
533 std::optional<std::chrono::steady_clock::time_point> frame_timestamp;
534 };
535
539 struct packet_raw_avcodec: packet_raw_t {
540 packet_raw_avcodec() {
541 av_packet = av_packet_alloc();
542 }
543
544 ~packet_raw_avcodec() {
545 av_packet_free(&this->av_packet);
546 }
547
553 bool is_idr() override {
554 return av_packet->flags & AV_PKT_FLAG_KEY;
555 }
556
562 int64_t frame_index() override {
563 return av_packet->pts;
564 }
565
571 uint8_t *data() override {
572 return av_packet->data;
573 }
574
580 size_t data_size() override {
581 return av_packet->size;
582 }
583
584 AVPacket *av_packet;
585 };
586
598 packet_raw_generic(std::vector<uint8_t> &&frame_data, int64_t frame_index, bool idr):
599 frame_data {std::move(frame_data)},
601 idr {idr} {
602 }
603
609 bool is_idr() override {
610 return idr;
611 }
612
618 int64_t frame_index() override {
619 return index;
620 }
621
627 uint8_t *data() override {
628 return frame_data.data();
629 }
630
636 size_t data_size() override {
637 return frame_data.size();
638 }
639
640 std::vector<uint8_t> frame_data;
641 int64_t index;
642 bool idr;
643 };
644
648 using packet_t = std::unique_ptr<packet_raw_t>;
649
659 explicit hdr_info_raw_t(bool enabled):
661 metadata {} {};
662
668 explicit hdr_info_raw_t(bool enabled, const SS_HDR_METADATA &metadata):
670 metadata {metadata} {};
671
672 bool enabled;
673 SS_HDR_METADATA metadata;
674 };
675
679 using hdr_info_t = std::unique_ptr<hdr_info_raw_t>;
680
681 extern int active_hevc_mode;
682 extern int active_av1_mode;
684 extern std::array<bool, 3> last_encoder_probe_supported_yuv444_for_codec; // 0 - H.264, 1 - HEVC, 2 - AV1
685
693 config_t resolve_dynamic_range(const encoder_t &encoder, config_t config);
694
702 void capture(
704 config_t config,
705 void *channel_data
706 );
707
715 bool validate_encoder(encoder_t &encoder, bool expect_failure);
716
726 int probe_encoders();
727
728 // Several NTSC standard refresh rates are hardcoded here, because their
729 // true rate requires a denominator of 1001. ffmpeg's av_d2q() would assume it could
730 // reduce 29.97 to 2997/100 but this would be slightly wrong. We also include
731 // support for 23.976 film in case someone wants to stream a film at the perfect
732 // framerate.
739 inline AVRational framerateX100_to_rational(const int framerateX100) {
740 if (framerateX100 % 2997 == 0) {
741 // Multiples of NTSC 29.97 e.g. 59.94, 119.88
742 return AVRational {(framerateX100 / 2997) * 30000, 1001};
743 }
744 switch (framerateX100) {
745 case 2397: // the other weird NTSC framerate, assume these want 23.976 film
746 case 2398:
747 return AVRational {24000, 1001};
748 default:
749 // any other fractional rate can be reduced by ffmpeg. Max is set to 1 << 26 based on docs:
750 // "rational numbers with |num| <= 1<<26 && |den| <= 1<<26 can be recovered exactly from their double representation"
751 return av_d2q((double) framerateX100 / 100.0f, 1 << 26);
752 }
753 }
754
763 inline AVRational framerate_to_rational(const config_t &config) {
764 if (config.framerateX100 > 0) {
765 return framerateX100_to_rational(config.framerateX100);
766 }
767 return AVRational {config.framerate, 1};
768 }
769
777 inline std::chrono::nanoseconds capture_frame_interval(const config_t &config) {
778 const AVRational fps = framerate_to_rational(config);
779 return std::chrono::nanoseconds {(static_cast<int64_t>(fps.den) * 1'000'000'000LL) / fps.num};
780 }
781} // namespace video
FFmpeg software encode device used when no hardware frames are required.
Definition video.h:125
int init(int in_width, int in_height, AVFrame *in_frame, AVPixelFormat format, bool hardware)
Initialize FFmpeg software encoding for the requested codec.
Definition video.cpp:330
int convert(platf::img_t &img) override
Convert a captured image into the encoder input representation.
Definition video.cpp:224
void apply_colorspace() override
Apply the configured colorspace metadata to the active frame.
Definition video.cpp:317
int set_frame(AVFrame *in_frame, AVBufferRef *hw_frames_ctx) override
Attach frame resources used by the next conversion or encode operation.
Definition video.cpp:300
Declarations for common platform specific utilities.
mem_type_e
Enumerates supported mem type options.
Definition common.h:325
pix_fmt_e
Enumerates supported pix fmt options.
Definition common.h:338
void free_frame(AVFrame *frame)
Release an FFmpeg frame allocated by the capture or conversion backend.
Definition graphics.cpp:1537
Declarations for gamepad, keyboard, and mouse input handling.
bl::sources::severity_logger< int > error
Recoverable errors.
Definition logging.cpp:44
Handles process-wide communication.
Definition globals.h:34
Standalone NVENC encoder.
Definition nvenc_base.cpp:185
AVCodec-backed encode device and frame state.
Definition common.h:588
Captured frame buffer shared between capture and encode stages.
Definition common.h:524
Encoding configuration requested by a remote client.
Definition video.h:29
int encoderCscMode
Requested color range and SDR colorspace; HDR always uses BT.2020 and ST2084.
Definition video.h:37
int enableIntraRefresh
Intra refresh setting: 0 = disabled, 1 = enabled.
Definition video.h:41
int framerateX100
Optional NTSC-style framerate value, e.g. 59.94 as 5994.
Definition video.h:33
int videoFormat
Video codec format: 0 = H.264, 1 = HEVC, 2 = AV1.
Definition video.h:38
int width
Video width in pixels.
Definition video.h:30
int bitrate
Video bitrate in kilobits for the requested framerate.
Definition video.h:34
int numRefFrames
Maximum number of reference frames.
Definition video.h:36
int height
Video height in pixels.
Definition video.h:31
int slicesPerFrame
Number of slices per frame.
Definition video.h:35
int framerate
Requested framerate used in the per-frame bitrate budget.
Definition video.h:32
int dynamicRange
Encoding color depth: 0 = 8-bit, 1 = 10-bit.
Definition video.h:39
int chromaSamplingType
Chroma sampling type: 0 = 4:2:0, 1 = 4:4:4.
Definition video.h:40
Encoder session state shared by capture and encoding threads.
Definition video.h:424
virtual int convert(platf::img_t &img)=0
Convert a captured frame into the encoder's required input representation.
virtual void request_idr_frame()=0
Mark the frame as a request for an IDR frame.
virtual void request_normal_frame()=0
Mark the frame as a request for a normal inter frame.
virtual void invalidate_ref_frames(int64_t first_frame, int64_t last_frame)=0
Mark the frame range whose references must be invalidated.
AVPixelFormat avcodec_pix_fmt_8bit
FFmpeg 8-bit 4:2:0 software pixel format for this encoder.
Definition video.h:251
encoder_platform_formats_avcodec(const AVHWDeviceType &avcodec_base_dev_type, const AVHWDeviceType &avcodec_derived_dev_type, const AVPixelFormat &avcodec_dev_pix_fmt, const AVPixelFormat &avcodec_pix_fmt_8bit, const AVPixelFormat &avcodec_pix_fmt_10bit, const AVPixelFormat &avcodec_pix_fmt_yuv444_8bit, const AVPixelFormat &avcodec_pix_fmt_yuv444_10bit, const init_buffer_function_t &init_avcodec_hardware_input_buffer_function)
Construct AVCodec platform format mappings.
Definition video.h:223
AVPixelFormat avcodec_pix_fmt_10bit
FFmpeg 10-bit 4:2:0 software pixel format for this encoder.
Definition video.h:252
AVHWDeviceType avcodec_derived_dev_type
FFmpeg device type derived from the primary hardware context.
Definition video.h:249
AVPixelFormat avcodec_pix_fmt_yuv444_8bit
FFmpeg 8-bit 4:4:4 software pixel format for this encoder.
Definition video.h:253
std::function< util::Either< avcodec_buffer_t, int >(platf::avcodec_encode_device_t *)> init_buffer_function_t
Callback that prepares an FFmpeg hardware input buffer for the encode device.
Definition video.h:209
AVPixelFormat avcodec_pix_fmt_yuv444_10bit
FFmpeg 10-bit 4:4:4 software pixel format for this encoder.
Definition video.h:254
init_buffer_function_t init_avcodec_hardware_input_buffer
Backend hook that allocates or imports hardware frames for FFmpeg.
Definition video.h:256
AVPixelFormat avcodec_dev_pix_fmt
FFmpeg hardware-device pixel format for frames handed to the encoder.
Definition video.h:250
AVHWDeviceType avcodec_base_dev_type
FFmpeg device type used to create the primary hardware context.
Definition video.h:248
encoder_platform_formats_nvenc(const platf::mem_type_e &dev_type, const platf::pix_fmt_e &pix_fmt_8bit, const platf::pix_fmt_e &pix_fmt_10bit, const platf::pix_fmt_e &pix_fmt_yuv444_8bit, const platf::pix_fmt_e &pix_fmt_yuv444_10bit)
Construct NVENC platform format mappings.
Definition video.h:272
Pixel formats supported by one encoder backend.
Definition video.h:193
platf::mem_type_e dev_type
Platform memory type required by this encoder.
Definition video.h:195
platf::pix_fmt_e pix_fmt_10bit
10-bit 4:2:0 input format accepted by this encoder.
Definition video.h:197
platf::pix_fmt_e pix_fmt_yuv444_8bit
8-bit 4:4:4 input format accepted by this encoder.
Definition video.h:198
platf::pix_fmt_e pix_fmt_8bit
8-bit 4:2:0 input format accepted by this encoder.
Definition video.h:196
platf::pix_fmt_e pix_fmt_yuv444_10bit
10-bit 4:4:4 input format accepted by this encoder.
Definition video.h:199
Codec capabilities for AV1, HEVC, or H.264.
Definition video.h:362
std::bitset< MAX_FLAGS > capabilities
Capability flags supported by this codec on the encoder.
Definition video.h:371
std::vector< option_t > sdr_options
Options applied to SDR 4:2:0 streams.
Definition video.h:364
std::string name
Codec name passed to the encoder backend.
Definition video.h:370
std::vector< option_t > sdr444_options
Options applied to SDR 4:4:4 streams.
Definition video.h:366
std::vector< option_t > common_options
Options applied to every encode mode for this codec.
Definition video.h:363
std::bitset< MAX_FLAGS >::reference operator[](flag_e flag)
Return a mutable reference to a codec capability flag.
Definition video.h:389
std::vector< option_t > hdr_options
Options applied to HDR 4:2:0 streams.
Definition video.h:365
bool operator[](flag_e flag) const
Test whether a codec capability is enabled.
Definition video.h:379
std::vector< option_t > fallback_options
Options used when the preferred mode cannot be selected.
Definition video.h:368
std::vector< option_t > hdr444_options
Options applied to HDR 4:4:4 streams.
Definition video.h:367
std::variant< int, int *, std::optional< int > *, std::function< int()>, std::string, std::string *, std::function< const std::string(const config_t &)> > value
Literal, pointer, or callback that supplies the option value.
Definition video.h:343
option_t(option_t &&) noexcept=default
Defaulted move constructor for the generated type.
std::string name
Encoder command-line option name.
Definition video.h:342
Encoder name and feature flags advertised by Sunshine.
Definition video.h:290
codec_t av1
AV1 codec capability and option set.
Definition video.h:394
codec_t hevc
HEVC codec capability and option set.
Definition video.h:395
static std::string_view from_flag(flag_e flag)
Convert an encoder capability flag to its diagnostic string.
Definition video.h:312
const std::unique_ptr< const encoder_platform_formats_t > platform_formats
Platform-specific memory and pixel formats accepted by the encoder.
Definition video.h:357
const codec_t & codec_from_config(const config_t &config) const
Select the codec descriptor requested by a stream configuration.
Definition video.h:404
std::string_view name
Encoder name used in logs, configuration, and capability probes.
Definition video.h:291
flag_e
Capability flags that describe which stream modes an encoder supports.
Definition video.h:296
@ DYNAMIC_RANGE
HDR support.
Definition video.h:299
@ DYNAMIC_RANGE_YUV444
YUV 4:4:4 HDR support.
Definition video.h:301
@ VUI_PARAMETERS
AMD encoder with VAAPI doesn't add VUI parameters to SPS.
Definition video.h:302
@ PASSED
Indicates the encoder is supported.
Definition video.h:297
@ REF_FRAMES_RESTRICT
Set maximum reference frames.
Definition video.h:298
@ YUV444
YUV 4:4:4 support.
Definition video.h:300
@ MAX_FLAGS
Maximum number of flags.
Definition video.h:303
uint32_t flags
Encoder flags advertised to clients through GameStream capability responses.
Definition video.h:418
codec_t h264
H.264 codec capability and option set.
Definition video.h:396
bool enabled
Whether HDR mode should be enabled.
Definition video.h:672
SS_HDR_METADATA metadata
Display HDR metadata forwarded to the encoder and client.
Definition video.h:673
hdr_info_raw_t(bool enabled, const SS_HDR_METADATA &metadata)
Initialize HDR metadata with display metadata from the backend.
Definition video.h:668
hdr_info_raw_t(bool enabled)
Initialize HDR metadata with only the enabled state.
Definition video.h:659
uint8_t * data() override
Return writable access to the FFmpeg packet payload.
Definition video.h:571
size_t data_size() override
Return the FFmpeg packet payload length.
Definition video.h:580
AVPacket * av_packet
FFmpeg packet that owns encoded data and frame metadata.
Definition video.h:584
bool is_idr() override
Report whether the FFmpeg packet is marked as a key frame.
Definition video.h:553
int64_t frame_index() override
Return the FFmpeg packet PTS used as Sunshine's frame index.
Definition video.h:562
uint8_t * data() override
Return writable access to the generic packet payload.
Definition video.h:627
bool is_idr() override
Report whether the generic packet starts an IDR frame.
Definition video.h:609
std::vector< uint8_t > frame_data
Encoded frame bytes owned by this packet.
Definition video.h:640
int64_t frame_index() override
Return the stored frame index for this generic packet.
Definition video.h:618
int64_t index
Monotonic frame index assigned to this packet.
Definition video.h:641
packet_raw_generic(std::vector< uint8_t > &&frame_data, int64_t frame_index, bool idr)
Wrap generic encoded frame bytes in Sunshine packet metadata.
Definition video.h:598
bool idr
Whether the packet belongs to an IDR frame.
Definition video.h:642
size_t data_size() override
Return the generic packet payload length.
Definition video.h:636
replace_t(replace_t &&) noexcept=default
Defaulted move constructor for the generated type.
std::string_view _new
Byte sequence that replaces old before transmission.
Definition video.h:514
std::string_view old
Byte sequence to find in the encoded packet.
Definition video.h:513
Encoded packet wrapper used by the streaming pipeline.
Definition video.h:478
virtual size_t data_size()=0
Return the encoded payload length.
virtual bool is_idr()=0
Report whether this packet starts an IDR frame.
std::vector< replace_t > * replacements
Optional encoded-byte substitutions applied before packetization.
Definition video.h:530
void * channel_data
Platform or protocol state carried with this packet.
Definition video.h:531
virtual int64_t frame_index()=0
Return the frame index associated with this encoded packet.
bool after_ref_frame_invalidation
Whether the frame follows reference-frame invalidation.
Definition video.h:532
virtual uint8_t * data()=0
Return writable access to the encoded packet bytes.
std::optional< std::chrono::steady_clock::time_point > frame_timestamp
Capture timestamp associated with the frame.
Definition video.h:533
Declarations for thread-safe data structures.
std::shared_ptr< mail_raw_t > mail_t
Shared mailbox handle used by event and queue wrappers.
Definition thread_safe.h:753
uniq_ptr< T, Destroy< T *, void, function > > safe_ptr
Unique pointer using a compile-time C-style destroy function.
Definition utility.h:1591
#define KITTY_DEFAULT_CONSTR_MOVE(x)
Declare defaulted noexcept move construction and assignment for a type.
Definition utility.h:121
encoder_t vaapi
VA-API.
Definition video.cpp:1233
config_t resolve_dynamic_range(const encoder_t &encoder, config_t config)
Resolve a client-requested dynamic range against probed encoder capabilities.
Definition video.cpp:170
void capture(safe::mail_t mail, config_t config, void *channel_data)
Capture and encode video for a streaming session.
Definition video.cpp:2966
platf::mem_type_e map_base_dev_type(AVHWDeviceType type)
Map base dev type values.
Definition video.cpp:3696
bool validate_encoder(encoder_t &encoder, bool expect_failure)
Validate encoder before it is used.
Definition video.cpp:3068
encoder_t mediafoundation
Mediafoundation.
Definition video.cpp:1092
int active_hevc_mode
HEVC mode selected by the most recent encoder probe.
Definition video.cpp:1471
int active_av1_mode
AV1 mode selected by the most recent encoder probe.
Definition video.cpp:1472
std::array< bool, 3 > last_encoder_probe_supported_yuv444_for_codec
YUV444 support discovered for each probed codec.
Definition video.cpp:1474
encoder_t amdvce
Amdvce.
Definition video.cpp:977
int probe_encoders()
Probe encoders and select the preferred encoder. This is called once at startup and each time a strea...
Definition video.cpp:3266
encoder_t quicksync
Quicksync.
Definition video.cpp:863
bool last_encoder_probe_supported_ref_frames_invalidation
Whether the last probe found reference-frame invalidation support.
Definition video.cpp:1473
platf::pix_fmt_e map_pix_fmt(AVPixelFormat fmt)
Map pix fmt values.
Definition video.cpp:3722
encoder_t videotoolbox
Videotoolbox.
Definition video.cpp:1375
encoder_t software
Software.
Definition video.cpp:1156
util::safe_ptr< AVCodecContext, free_ctx > avcodec_ctx_t
Owning pointer for an FFmpeg codec context.
Definition video.h:104
AVRational framerateX100_to_rational(const int framerateX100)
Convert a framerate stored as hundredths of Hz to an FFmpeg rational.
Definition video.h:739
coder_e
Enumerates supported coder options for the AMF encoder.
Definition video.h:49
@ auto_
Select the coder based on the H.264 profile.
Definition video.h:50
std::chrono::nanoseconds capture_frame_interval(const config_t &config)
Capture frame interval for the requested framerate. Uses the exact fractional rate when the client pr...
Definition video.h:777
std::unique_ptr< packet_raw_t > packet_t
Owning pointer to an encoded packet abstraction.
Definition video.h:648
std::shared_ptr< safe::event_t< std::shared_ptr< platf::img_t > > > img_event_t
Shared event that transports captured images between capture and encode threads.
Definition video.h:120
util::safe_ptr< SwsContext, sws_freeContext > sws_t
Owning pointer for an FFmpeg software-scaling context.
Definition video.h:116
AVRational framerate_to_rational(const config_t &config)
Requested framerate as an exact rational. Uses the exact fractional rate when the client provided an ...
Definition video.h:763
util::safe_ptr< AVBufferRef, free_buffer > avcodec_buffer_t
Owning pointer for an FFmpeg buffer reference.
Definition video.h:112
util::safe_ptr< AVFrame, free_frame > avcodec_frame_t
Owning pointer for an FFmpeg frame.
Definition video.h:108
std::unique_ptr< hdr_info_raw_t > hdr_info_t
Owning pointer to optional HDR metadata for a captured display.
Definition video.h:679
Declarations for colorspace functions.