Format chore
This commit is contained in:
@@ -4,9 +4,9 @@
|
|||||||
#include "godot_cpp/classes/rd_texture_view.hpp"
|
#include "godot_cpp/classes/rd_texture_view.hpp"
|
||||||
#include "godot_cpp/classes/rendering_device.hpp"
|
#include "godot_cpp/classes/rendering_device.hpp"
|
||||||
#include "godot_cpp/classes/rendering_server.hpp"
|
#include "godot_cpp/classes/rendering_server.hpp"
|
||||||
#include "godot_cpp/variant/utility_functions.hpp"
|
|
||||||
#include "godot_cpp/variant/color.hpp"
|
#include "godot_cpp/variant/color.hpp"
|
||||||
#include "godot_cpp/variant/rect2.hpp"
|
#include "godot_cpp/variant/rect2.hpp"
|
||||||
|
#include "godot_cpp/variant/utility_functions.hpp"
|
||||||
|
|
||||||
#include "vaapi_decoder.h"
|
#include "vaapi_decoder.h"
|
||||||
#include "vk_image_import.h"
|
#include "vk_image_import.h"
|
||||||
@@ -30,7 +30,6 @@ enum HWMode { HW_NONE,
|
|||||||
static HWMode active_hw_mode = HW_NONE;
|
static HWMode active_hw_mode = HW_NONE;
|
||||||
|
|
||||||
void GDVAPIVideoStream::_bind_methods() {
|
void GDVAPIVideoStream::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("begin", "source"), &GDVAPIVideoStream::begin);
|
ClassDB::bind_method(D_METHOD("begin", "source"), &GDVAPIVideoStream::begin);
|
||||||
ClassDB::bind_method(D_METHOD("get_texture"), &GDVAPIVideoStream::get_texture);
|
ClassDB::bind_method(D_METHOD("get_texture"), &GDVAPIVideoStream::get_texture);
|
||||||
ClassDB::bind_method(D_METHOD("get_desired_width"), &GDVAPIVideoStream::get_desired_width);
|
ClassDB::bind_method(D_METHOD("get_desired_width"), &GDVAPIVideoStream::get_desired_width);
|
||||||
@@ -73,7 +72,6 @@ void GDVAPIVideoStream::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("get_stream_height"), &GDVAPIVideoStream::get_stream_height);
|
ClassDB::bind_method(D_METHOD("get_stream_height"), &GDVAPIVideoStream::get_stream_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static enum AVPixelFormat get_hw_format(AVCodecContext *ctx, const enum AVPixelFormat *formats) {
|
static enum AVPixelFormat get_hw_format(AVCodecContext *ctx, const enum AVPixelFormat *formats) {
|
||||||
for (const enum AVPixelFormat *p = formats; *p != -1; p++) {
|
for (const enum AVPixelFormat *p = formats; *p != -1; p++) {
|
||||||
if (active_hw_mode == HW_VULKAN && *p == AV_PIX_FMT_VULKAN)
|
if (active_hw_mode == HW_VULKAN && *p == AV_PIX_FMT_VULKAN)
|
||||||
@@ -105,8 +103,7 @@ void GDVAPIVideoStream::_process(double delta) {
|
|||||||
}
|
}
|
||||||
wall_base = std::chrono::steady_clock::now();
|
wall_base = std::chrono::steady_clock::now();
|
||||||
String uri = stream_source;
|
String uri = stream_source;
|
||||||
if (uri.ends_with(".sdp") || uri.ends_with(".mp4")
|
if (uri.ends_with(".sdp") || uri.ends_with(".mp4") || uri.ends_with(".mov") || uri.begins_with("/"))
|
||||||
|| uri.ends_with(".mov") || uri.begins_with("/"))
|
|
||||||
worker_src = uri.utf8().get_data();
|
worker_src = uri.utf8().get_data();
|
||||||
else {
|
else {
|
||||||
const char *sdp = "/tmp/gdvapi_live.sdp";
|
const char *sdp = "/tmp/gdvapi_live.sdp";
|
||||||
@@ -114,7 +111,10 @@ void GDVAPIVideoStream::_process(double delta) {
|
|||||||
if (uri.begins_with("udp://")) {
|
if (uri.begins_with("udp://")) {
|
||||||
String rest = uri.substr(6);
|
String rest = uri.substr(6);
|
||||||
int c = rest.find(":");
|
int c = rest.find(":");
|
||||||
if (c > 0) { host = rest.substr(0, c); port = rest.substr(c + 1); }
|
if (c > 0) {
|
||||||
|
host = rest.substr(0, c);
|
||||||
|
port = rest.substr(c + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FILE *f = fopen(sdp, "w");
|
FILE *f = fopen(sdp, "w");
|
||||||
if (f) {
|
if (f) {
|
||||||
@@ -299,9 +299,7 @@ void GDVAPIVideoStream::consume_ready() {
|
|||||||
if (rf.pts_sec > 0.0) {
|
if (rf.pts_sec > 0.0) {
|
||||||
if (pts_base < 0.0) {
|
if (pts_base < 0.0) {
|
||||||
pts_base = rf.pts_sec;
|
pts_base = rf.pts_sec;
|
||||||
wall_base = std::chrono::steady_clock::now()
|
wall_base = std::chrono::steady_clock::now() - std::chrono::duration_cast<std::chrono::steady_clock::duration>(std::chrono::duration<double>(rf.pts_sec));
|
||||||
- std::chrono::duration_cast<std::chrono::steady_clock::duration>(
|
|
||||||
std::chrono::duration<double>(rf.pts_sec));
|
|
||||||
elapsed = 0.0;
|
elapsed = 0.0;
|
||||||
}
|
}
|
||||||
const double stream_pos = rf.pts_sec - pts_base;
|
const double stream_pos = rf.pts_sec - pts_base;
|
||||||
@@ -402,7 +400,8 @@ void GDVAPIVideoStream::consume_ready() {
|
|||||||
}
|
}
|
||||||
draw_idx = w;
|
draw_idx = w;
|
||||||
present_wall_sec = std::chrono::duration<double>(
|
present_wall_sec = std::chrono::duration<double>(
|
||||||
std::chrono::steady_clock::now() - wall_base).count();
|
std::chrono::steady_clock::now() - wall_base)
|
||||||
|
.count();
|
||||||
if (!have_presentable) {
|
if (!have_presentable) {
|
||||||
have_presentable = true;
|
have_presentable = true;
|
||||||
}
|
}
|
||||||
@@ -447,7 +446,6 @@ void GDVAPIVideoStream::cleanup() {
|
|||||||
stream_eof = true;
|
stream_eof = true;
|
||||||
|
|
||||||
godot_texture.unref();
|
godot_texture.unref();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDVAPIVideoStream::set_desired_width(const int v) {
|
void GDVAPIVideoStream::set_desired_width(const int v) {
|
||||||
@@ -462,7 +460,6 @@ void GDVAPIVideoStream::set_desired_height(const int v) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int GDVAPIVideoStream::get_desired_width() const {
|
int GDVAPIVideoStream::get_desired_width() const {
|
||||||
return desiredWidth;
|
return desiredWidth;
|
||||||
}
|
}
|
||||||
@@ -521,8 +518,6 @@ bool GDVAPIVideoStream::get_vpp_half_res() const {
|
|||||||
return decoder_opts.vpp_div == 2;
|
return decoder_opts.vpp_div == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GDVAPIVideoStream::_ready() {
|
void GDVAPIVideoStream::_ready() {
|
||||||
UtilityFunctions::print("_ready called");
|
UtilityFunctions::print("_ready called");
|
||||||
|
|
||||||
|
|||||||
@@ -93,21 +93,28 @@ public:
|
|||||||
void begin(const Variant &source);
|
void begin(const Variant &source);
|
||||||
Ref<Texture2DRD> get_texture() const { return draw_tex[draw_idx]; }
|
Ref<Texture2DRD> get_texture() const { return draw_tex[draw_idx]; }
|
||||||
|
|
||||||
void set_reorder_buffer_ms(const int v); int get_reorder_buffer_ms() const;
|
void set_reorder_buffer_ms(const int v);
|
||||||
void set_demux_fifo_bytes(const int v); int get_demux_fifo_bytes() const;
|
int get_reorder_buffer_ms() const;
|
||||||
void set_socket_buffer_bytes(const int v);int get_socket_buffer_bytes() const;
|
void set_demux_fifo_bytes(const int v);
|
||||||
void set_reorder_queue_size(const int v); int get_reorder_queue_size() const;
|
int get_demux_fifo_bytes() const;
|
||||||
void set_io_timeout_ms(const int v); int get_io_timeout_ms() const;
|
void set_socket_buffer_bytes(const int v);
|
||||||
void set_queue_depth(const int v); int get_queue_depth() const;
|
int get_socket_buffer_bytes() const;
|
||||||
void set_frame_latency_ms(const int v); int get_frame_latency_ms() const;
|
void set_reorder_queue_size(const int v);
|
||||||
void set_vpp_half_res(const bool v); bool get_vpp_half_res() const;
|
int get_reorder_queue_size() const;
|
||||||
|
void set_io_timeout_ms(const int v);
|
||||||
|
int get_io_timeout_ms() const;
|
||||||
|
void set_queue_depth(const int v);
|
||||||
|
int get_queue_depth() const;
|
||||||
|
void set_frame_latency_ms(const int v);
|
||||||
|
int get_frame_latency_ms() const;
|
||||||
|
void set_vpp_half_res(const bool v);
|
||||||
|
bool get_vpp_half_res() const;
|
||||||
|
|
||||||
int get_frame_count() const { return present_count; }
|
int get_frame_count() const { return present_count; }
|
||||||
bool has_frame() const { return have_presentable; }
|
bool has_frame() const { return have_presentable; }
|
||||||
int get_stream_width() const { return pending_w; }
|
int get_stream_width() const { return pending_w; }
|
||||||
int get_stream_height() const { return pending_h; }
|
int get_stream_height() const { return pending_h; }
|
||||||
|
|
||||||
|
|
||||||
void _process(double delta) override;
|
void _process(double delta) override;
|
||||||
|
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
@@ -120,4 +127,4 @@ public:
|
|||||||
int get_desired_height() const;
|
int get_desired_height() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} //namespace godot
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ void initialize_gdextension_types(ModuleInitializationLevel p_level) {
|
|||||||
GDREGISTER_RUNTIME_CLASS(GDVAPIVideoStream);
|
GDREGISTER_RUNTIME_CLASS(GDVAPIVideoStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void uninitialize_gdextension_types(ModuleInitializationLevel p_level) {
|
void uninitialize_gdextension_types(ModuleInitializationLevel p_level) {
|
||||||
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE)
|
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -234,7 +234,6 @@ bool VAAPIDecoder::next_frame(AVFrame *&out_frame) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void fill_dma_out(const VADRMPRIMESurfaceDescriptor &desc, DecodedFrame &out) {
|
static void fill_dma_out(const VADRMPRIMESurfaceDescriptor &desc, DecodedFrame &out) {
|
||||||
out.width = desc.width;
|
out.width = desc.width;
|
||||||
out.height = desc.height;
|
out.height = desc.height;
|
||||||
@@ -275,8 +274,10 @@ bool VAAPIDecoder::vpp_init() {
|
|||||||
int vpp_div = vpp_div_ > 0 ? vpp_div_ : 1;
|
int vpp_div = vpp_div_ > 0 ? vpp_div_ : 1;
|
||||||
vpp_out_w = video_width / vpp_div;
|
vpp_out_w = video_width / vpp_div;
|
||||||
vpp_out_h = video_height / vpp_div;
|
vpp_out_h = video_height / vpp_div;
|
||||||
if (vpp_out_w < 1) vpp_out_w = 1;
|
if (vpp_out_w < 1)
|
||||||
if (vpp_out_h < 1) vpp_out_h = 1;
|
vpp_out_w = 1;
|
||||||
|
if (vpp_out_h < 1)
|
||||||
|
vpp_out_h = 1;
|
||||||
st = vaCreateContext(dpy, vpp_config, vpp_out_w, vpp_out_h,
|
st = vaCreateContext(dpy, vpp_config, vpp_out_w, vpp_out_h,
|
||||||
VA_PROGRESSIVE, 0, 0, &vpp_ctx);
|
VA_PROGRESSIVE, 0, 0, &vpp_ctx);
|
||||||
if (st != VA_STATUS_SUCCESS) {
|
if (st != VA_STATUS_SUCCESS) {
|
||||||
@@ -415,8 +416,14 @@ void VAAPIDecoder::close() {
|
|||||||
rgba_pool[i] = VA_INVALID_ID;
|
rgba_pool[i] = VA_INVALID_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vpp_ctx != VA_INVALID_ID) { vaDestroyContext(dpy, vpp_ctx); vpp_ctx = VA_INVALID_ID; }
|
if (vpp_ctx != VA_INVALID_ID) {
|
||||||
if (vpp_config != VA_INVALID_ID) { vaDestroyConfig(dpy, vpp_config); vpp_config = VA_INVALID_ID; }
|
vaDestroyContext(dpy, vpp_ctx);
|
||||||
|
vpp_ctx = VA_INVALID_ID;
|
||||||
|
}
|
||||||
|
if (vpp_config != VA_INVALID_ID) {
|
||||||
|
vaDestroyConfig(dpy, vpp_config);
|
||||||
|
vpp_config = VA_INVALID_ID;
|
||||||
|
}
|
||||||
vpp_ready = false;
|
vpp_ready = false;
|
||||||
}
|
}
|
||||||
if (frame) {
|
if (frame) {
|
||||||
@@ -439,4 +446,4 @@ void VAAPIDecoder::close() {
|
|||||||
eof = false;
|
eof = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} //namespace gdvapi
|
||||||
|
|||||||
@@ -87,4 +87,4 @@ private:
|
|||||||
int vpp_div_ = 1; // VPP output downscale from DecoderOptions
|
int vpp_div_ = 1; // VPP output downscale from DecoderOptions
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} //namespace gdvapi
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ VkFormat fourcc_to_format(uint32_t fourcc, uint32_t pitch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} //namespace
|
||||||
|
|
||||||
VkImage import_dma_buf_image(VkDevice device, const DmaBufSurface &surf,
|
VkImage import_dma_buf_image(VkDevice device, const DmaBufSurface &surf,
|
||||||
VkDeviceMemory *out_memory) {
|
VkDeviceMemory *out_memory) {
|
||||||
@@ -223,4 +223,4 @@ void destroy_imported_image(VkDevice device, VkImage image, VkDeviceMemory mem)
|
|||||||
free_memory(device, mem, nullptr);
|
free_memory(device, mem, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} //namespace gdvapi
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ VkImage import_dma_buf_image(VkDevice device, const DmaBufSurface &surf,
|
|||||||
|
|
||||||
void destroy_imported_image(VkDevice device, VkImage image, VkDeviceMemory mem);
|
void destroy_imported_image(VkDevice device, VkImage image, VkDeviceMemory mem);
|
||||||
|
|
||||||
}
|
} //namespace gdvapi
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ static VkResult call_original(VkPhysicalDevice pd, const VkDeviceCreateInfo *ci,
|
|||||||
return fn(pd, ci, alloc, dev);
|
return fn(pd, ci, alloc, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool device_has_extension(VkPhysicalDevice dev, const char *name) {
|
static bool device_has_extension(VkPhysicalDevice dev, const char *name) {
|
||||||
if (!s_enumerate_ext)
|
if (!s_enumerate_ext)
|
||||||
return false;
|
return false;
|
||||||
@@ -77,7 +76,7 @@ static bool device_has_extension(VkPhysicalDevice dev, const char *name) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} //namespace
|
||||||
|
|
||||||
namespace gdvapi {
|
namespace gdvapi {
|
||||||
|
|
||||||
@@ -93,13 +92,13 @@ VKAPI_ATTR VkResult VKAPI_CALL hooked_vk_create_device(
|
|||||||
const VkDeviceCreateInfo *p_create_info,
|
const VkDeviceCreateInfo *p_create_info,
|
||||||
const VkAllocationCallbacks *p_allocator,
|
const VkAllocationCallbacks *p_allocator,
|
||||||
VkDevice *p_device) {
|
VkDevice *p_device) {
|
||||||
|
|
||||||
if (!s_trampoline || !p_create_info)
|
if (!s_trampoline || !p_create_info)
|
||||||
return VK_ERROR_INITIALIZATION_FAILED;
|
return VK_ERROR_INITIALIZATION_FAILED;
|
||||||
|
|
||||||
std::vector<const char *> missing;
|
std::vector<const char *> missing;
|
||||||
uint32_t existing_count = p_create_info->enabledExtensionCount
|
uint32_t existing_count = p_create_info->enabledExtensionCount
|
||||||
? p_create_info->enabledExtensionCount : 0;
|
? p_create_info->enabledExtensionCount
|
||||||
|
: 0;
|
||||||
const char *const *existing = p_create_info->ppEnabledExtensionNames;
|
const char *const *existing = p_create_info->ppEnabledExtensionNames;
|
||||||
|
|
||||||
for (const char *name : kExtNames) {
|
for (const char *name : kExtNames) {
|
||||||
@@ -190,4 +189,4 @@ bool install_vk_create_device_hook() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} //namespace gdvapi
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ bool install_vk_create_device_hook();
|
|||||||
|
|
||||||
bool device_supports_external_extensions(VkPhysicalDevice physical_device);
|
bool device_supports_external_extensions(VkPhysicalDevice physical_device);
|
||||||
|
|
||||||
}
|
} //namespace gdvapi
|
||||||
|
|||||||
Reference in New Issue
Block a user