X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fpbo_frame_allocator.cpp;h=d7204f283927426b18e6c831174dd101c8dd5d6a;hb=8850f9468d6a1727e7be302d2a9b4360f69210cc;hp=70675b1a630dfbdf1c30730f5134e9f014820c41;hpb=f4dc4d6d393026a5507be1f04a9149f6b8c2322c;p=nageru diff --git a/nageru/pbo_frame_allocator.cpp b/nageru/pbo_frame_allocator.cpp index 70675b1..d7204f2 100644 --- a/nageru/pbo_frame_allocator.cpp +++ b/nageru/pbo_frame_allocator.cpp @@ -10,7 +10,7 @@ #include "flags.h" #include "mjpeg_encoder.h" #include "v210_converter.h" -#include "va_display_with_cleanup.h" +#include "shared/va_display.h" using namespace std; @@ -236,7 +236,7 @@ void PBOFrameAllocator::destroy_frame(Frame *frame) check_error(); glDeleteBuffers(1, &pbo); check_error(); - switch (pixel_format) { + switch (ud->pixel_format) { case bmusb::PixelFormat_10BitYCbCr: glDeleteTextures(2, ud->tex_v210); check_error(); @@ -328,8 +328,8 @@ bmusb::FrameAllocator::Frame PBOFrameAllocator::create_frame(size_t width, size_ mjpeg_encoder->should_encode_mjpeg_for_card(card_index)) { if (mjpeg_encoder->using_vaapi()) { VADisplay va_dpy = mjpeg_encoder->va_dpy->va_dpy; - MJPEGEncoder::VAResources resources = mjpeg_encoder->get_va_resources(width, height); - MJPEGEncoder::ReleaseVAResources release(mjpeg_encoder, resources); + VAResourcePool::VAResources resources = mjpeg_encoder->get_va_pool()->get_va_resources(width, height, VA_FOURCC_UYVY); // Only used by DeckLinkCapture, so always 4:2:2. + ReleaseVAResources release(mjpeg_encoder->get_va_pool(), resources); if (resources.image.pitches[0] == stride) { userdata->va_resources = move(resources); @@ -393,8 +393,8 @@ void PBOFrameAllocator::release_frame(Frame frame) { // In case we never got to upload the frame to MJPEGEncoder. Userdata *userdata = (Userdata *)frame.userdata; - MJPEGEncoder::VAResources resources __attribute__((unused)) = move(userdata->va_resources); - MJPEGEncoder::ReleaseVAResources release = move(userdata->va_resources_release); + VAResourcePool::VAResources resources __attribute__((unused)) = move(userdata->va_resources); + ReleaseVAResources release = move(userdata->va_resources_release); if (frame.data_copy != nullptr && userdata->data_copy_current_src == Userdata::FROM_VA_API) { VADisplay va_dpy = mjpeg_encoder->va_dpy->va_dpy; @@ -437,7 +437,15 @@ void PBOFrameAllocator::reconfigure(bmusb::PixelFormat pixel_format, return; } - size_t old_num_queued_frames = this->num_queued_frames; + lock_guard lock(freelist_mutex); + lingering_generations[generation] = LingeringGeneration{ move(userdata), this->num_queued_frames }; + ++generation; + + while (!freelist.empty()) { + Frame frame = freelist.front(); + freelist.pop(); + destroy_frame(&frame); + } this->pixel_format = pixel_format; this->frame_size = frame_size; @@ -450,16 +458,6 @@ void PBOFrameAllocator::reconfigure(bmusb::PixelFormat pixel_format, this->permissions = permissions; this->map_bits = map_bits; - lock_guard lock(freelist_mutex); - lingering_generations[generation] = LingeringGeneration{ move(userdata), old_num_queued_frames }; - ++generation; - - while (!freelist.empty()) { - Frame frame = freelist.front(); - freelist.pop(); - destroy_frame(&frame); - } - userdata.reset(new Userdata[num_queued_frames]); for (size_t i = 0; i < num_queued_frames; ++i) { init_frame(i, frame_size, width, height, permissions, map_bits, generation);