Use actual fps hint for mediacodec init

This commit is contained in:
Patrick Nicolas
2022-11-15 11:55:22 +01:00
parent df376d473f
commit 8a1388f102
6 changed files with 34 additions and 8 deletions
@@ -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) :
description(description), device(device), weak_scene(weak_scene), 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> weak_scene,
shard_accumulator * accumulator) :
description(description), fps(fps), device(device), weak_scene(weak_scene), accumulator(accumulator)
{
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),
@@ -496,7 +502,7 @@ void decoder::push_data(std::span<uint8_t> data, uint64_t frame_index, bool part
// latency mode
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_WIDTH, description.width);
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_setBuffer(format.get(), AMEDIAFORMAT_KEY_CSD_0, csd.data(), csd.size());
+8 -1
View File
@@ -92,6 +92,7 @@ public:
private:
xrt::drivers::wivrn::to_headset::video_stream_description::item description;
float fps;
VkDevice device;
@@ -128,7 +129,13 @@ private:
std::shared_ptr<mapped_hardware_buffer> map_hardware_buffer(AImage *);
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(decoder &&) = delete;
+7 -1
View File
@@ -68,7 +68,13 @@ decoder::blit_handle::~blit_handle()
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)
{
free_images.resize(image_count);
+7 -1
View File
@@ -84,7 +84,13 @@ private:
std::mutex mutex;
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);
+2 -1
View File
@@ -82,9 +82,10 @@ public:
VkDevice device,
VkPhysicalDevice physical_device,
const xrt::drivers::wivrn::to_headset::video_stream_description::item & description,
float fps,
std::weak_ptr<scenes::stream> scene,
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),
next(stream_index),
weak_scene(scene)
+1 -1
View File
@@ -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);
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);
decoders.push_back(std::move(dec));