Use actual fps hint for mediacodec init
This commit is contained in:
@@ -388,8 +388,14 @@ void decoder::push_nals(std::span<uint8_t> data, int64_t timestamp, uint32_t fla
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder::decoder(VkDevice device, VkPhysicalDevice physical_device, const xrt::drivers::wivrn::to_headset::video_stream_description::item & description, std::weak_ptr<scenes::stream> weak_scene, shard_accumulator * accumulator) :
|
decoder::decoder(
|
||||||
description(description), device(device), weak_scene(weak_scene), accumulator(accumulator)
|
VkDevice device,
|
||||||
|
VkPhysicalDevice physical_device,
|
||||||
|
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
||||||
|
float fps,
|
||||||
|
std::weak_ptr<scenes::stream> weak_scene,
|
||||||
|
shard_accumulator * accumulator) :
|
||||||
|
description(description), fps(fps), device(device), weak_scene(weak_scene), accumulator(accumulator)
|
||||||
{
|
{
|
||||||
AImageReader * ir;
|
AImageReader * ir;
|
||||||
check(AImageReader_newWithUsage(description.width, description.height, AIMAGE_FORMAT_PRIVATE, AHARDWAREBUFFER_USAGE_CPU_READ_NEVER | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE, 5 /* maxImages */, &ir),
|
check(AImageReader_newWithUsage(description.width, description.height, AIMAGE_FORMAT_PRIVATE, AHARDWAREBUFFER_USAGE_CPU_READ_NEVER | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE, 5 /* maxImages */, &ir),
|
||||||
@@ -496,7 +502,7 @@ void decoder::push_data(std::span<uint8_t> data, uint64_t frame_index, bool part
|
|||||||
// latency mode
|
// latency mode
|
||||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_WIDTH, description.width);
|
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_WIDTH, description.width);
|
||||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_HEIGHT, description.height);
|
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_HEIGHT, description.height);
|
||||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_OPERATING_RATE, 72);
|
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_OPERATING_RATE, std::ceil(fps));
|
||||||
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_PRIORITY, 0);
|
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_PRIORITY, 0);
|
||||||
// AMediaFormat_setBuffer(format.get(), AMEDIAFORMAT_KEY_CSD_0, csd.data(), csd.size());
|
// AMediaFormat_setBuffer(format.get(), AMEDIAFORMAT_KEY_CSD_0, csd.data(), csd.size());
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
xrt::drivers::wivrn::to_headset::video_stream_description::item description;
|
xrt::drivers::wivrn::to_headset::video_stream_description::item description;
|
||||||
|
float fps;
|
||||||
|
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
|
|
||||||
@@ -128,7 +129,13 @@ private:
|
|||||||
std::shared_ptr<mapped_hardware_buffer> map_hardware_buffer(AImage *);
|
std::shared_ptr<mapped_hardware_buffer> map_hardware_buffer(AImage *);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
decoder(VkDevice device, VkPhysicalDevice physical_device, const xrt::drivers::wivrn::to_headset::video_stream_description::item & description, std::weak_ptr<scenes::stream> scene, shard_accumulator * accumulator);
|
decoder(
|
||||||
|
VkDevice device,
|
||||||
|
VkPhysicalDevice physical_device,
|
||||||
|
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
||||||
|
float fps,
|
||||||
|
std::weak_ptr<scenes::stream> scene,
|
||||||
|
shard_accumulator * accumulator);
|
||||||
|
|
||||||
decoder(const decoder &) = delete;
|
decoder(const decoder &) = delete;
|
||||||
decoder(decoder &&) = delete;
|
decoder(decoder &&) = delete;
|
||||||
|
|||||||
@@ -68,7 +68,13 @@ decoder::blit_handle::~blit_handle()
|
|||||||
self->free_images.push_back(image_index);
|
self->free_images.push_back(image_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder::decoder(VkDevice device, VkPhysicalDevice physical_device, const xrt::drivers::wivrn::to_headset::video_stream_description::item & description, std::weak_ptr<scenes::stream> scene, shard_accumulator * accumulator) :
|
decoder::decoder(
|
||||||
|
VkDevice device,
|
||||||
|
VkPhysicalDevice physical_device,
|
||||||
|
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
||||||
|
float fps,
|
||||||
|
std::weak_ptr<scenes::stream> scene,
|
||||||
|
shard_accumulator * accumulator) :
|
||||||
device(device), description(description), codec(nullptr, free_codec_context), sws(nullptr, sws_freeContext), weak_scene(scene), accumulator(accumulator)
|
device(device), description(description), codec(nullptr, free_codec_context), sws(nullptr, sws_freeContext), weak_scene(scene), accumulator(accumulator)
|
||||||
{
|
{
|
||||||
free_images.resize(image_count);
|
free_images.resize(image_count);
|
||||||
|
|||||||
@@ -84,7 +84,13 @@ private:
|
|||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
decoder(VkDevice device, VkPhysicalDevice physical_device, const xrt::drivers::wivrn::to_headset::video_stream_description::item & description, std::weak_ptr<scenes::stream> scene, shard_accumulator * accumulator);
|
decoder(
|
||||||
|
VkDevice device,
|
||||||
|
VkPhysicalDevice physical_device,
|
||||||
|
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
||||||
|
float fps,
|
||||||
|
std::weak_ptr<scenes::stream> scene,
|
||||||
|
shard_accumulator * accumulator);
|
||||||
|
|
||||||
void push_data(std::span<uint8_t> data, uint64_t frame_index, bool partial);
|
void push_data(std::span<uint8_t> data, uint64_t frame_index, bool partial);
|
||||||
|
|
||||||
|
|||||||
@@ -82,9 +82,10 @@ public:
|
|||||||
VkDevice device,
|
VkDevice device,
|
||||||
VkPhysicalDevice physical_device,
|
VkPhysicalDevice physical_device,
|
||||||
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
|
||||||
|
float fps,
|
||||||
std::weak_ptr<scenes::stream> scene,
|
std::weak_ptr<scenes::stream> scene,
|
||||||
uint8_t stream_index) :
|
uint8_t stream_index) :
|
||||||
decoder(std::make_shared<decoder_impl>(device, physical_device, description, scene, this)),
|
decoder(std::make_shared<decoder_impl>(device, physical_device, description, fps, scene, this)),
|
||||||
current(stream_index),
|
current(stream_index),
|
||||||
next(stream_index),
|
next(stream_index),
|
||||||
weak_scene(scene)
|
weak_scene(scene)
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
|
|||||||
spdlog::info("Creating decoder size {}x{} offset {},{}", item.width, item.height, item.offset_x, item.offset_y);
|
spdlog::info("Creating decoder size {}x{} offset {},{}", item.width, item.height, item.offset_x, item.offset_y);
|
||||||
|
|
||||||
accumulator_images dec;
|
accumulator_images dec;
|
||||||
dec.decoder = std::make_unique<shard_accumulator>(device, physical_device, item, shared_from_this(), stream_index);
|
dec.decoder = std::make_unique<shard_accumulator>(device, physical_device, item, description.fps, shared_from_this(), stream_index);
|
||||||
dec.decoder->set_blit_targets(blit_targets, VK_FORMAT_A8B8G8R8_SRGB_PACK32);
|
dec.decoder->set_blit_targets(blit_targets, VK_FORMAT_A8B8G8R8_SRGB_PACK32);
|
||||||
|
|
||||||
decoders.push_back(std::move(dec));
|
decoders.push_back(std::move(dec));
|
||||||
|
|||||||
Reference in New Issue
Block a user