diff --git a/src/core/coreav.cpp b/src/core/coreav.cpp index 4186ead42..2b00dfc08 100644 --- a/src/core/coreav.cpp +++ b/src/core/coreav.cpp @@ -361,7 +361,7 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr vframe) } // This frame shares vframe's buffers, we don't call vpx_img_free but just delete it - ToxAVFrame frame = vframe->toToxAVFrame(); + ToxYUVFrame frame = vframe->toToxAVFrame(); if(frame.width == 0 || frame.height == 0) { diff --git a/src/video/videoframe.cpp b/src/video/videoframe.cpp index be9a0870f..5d370c5d2 100644 --- a/src/video/videoframe.cpp +++ b/src/video/videoframe.cpp @@ -185,7 +185,7 @@ QImage VideoFrame::toQImage(QSize frameSize) return toGenericObject(frameSize, AV_PIX_FMT_RGB24, false, converter, QImage {}); } -ToxAVFrame VideoFrame::toToxAVFrame(QSize frameSize) +ToxYUVFrame VideoFrame::toToxAVFrame(QSize frameSize) { if(frameSize.width() == 0 && frameSize.height() == 0) { @@ -193,9 +193,9 @@ ToxAVFrame VideoFrame::toToxAVFrame(QSize frameSize) } // Converter function (constructs ToxAVFrame out of AVFrame*) - const std::function converter = [&](AVFrame* const frame) + const std::function converter = [&](AVFrame* const frame) { - ToxAVFrame ret + ToxYUVFrame ret { static_cast(frameSize.width()), static_cast(frameSize.height()), @@ -205,7 +205,7 @@ ToxAVFrame VideoFrame::toToxAVFrame(QSize frameSize) return ret; }; - return toGenericObject(frameSize, AV_PIX_FMT_YUV420P, true, converter, ToxAVFrame {0, 0, nullptr, nullptr, nullptr}); + return toGenericObject(frameSize, AV_PIX_FMT_YUV420P, true, converter, ToxYUVFrame {0, 0, nullptr, nullptr, nullptr}); } AVFrame* VideoFrame::retrieveAVFrame(const QSize& dimensions, const int pixelFormat, const bool requireAligned) diff --git a/src/video/videoframe.h b/src/video/videoframe.h index d388cab52..34831f376 100644 --- a/src/video/videoframe.h +++ b/src/video/videoframe.h @@ -37,9 +37,18 @@ extern "C"{ #include /** - * @brief A simple structure to represent a ToxAV frame. + * @brief A simple structure to represent a ToxYUV video frame (corresponds to a frame encoded + * under format: AV_PIX_FMT_YUV420P [FFmpeg] or VPX_IMG_FMT_I420 [WebM]). + * + * This structure exists for convenience and code clarity when ferrying YUV420 frames from one + * source to another. The buffers pointed to by the struct should not be owned by the struct nor + * should they be freed from the struct, instead this struct functions only as a simple alias to a + * more complicated frame container like AVFrame. + * + * The creation of this structure was done to replace existing code which mis-used vpx_image + * structs when passing frame data to toxcore. */ -struct ToxAVFrame +struct ToxYUVFrame { public: const std::uint16_t width; @@ -217,7 +226,7 @@ public: * @return a ToxAVFrame structure that represents this VideoFrame, sharing it's buffers or an * empty structure if this VideoFrame is no longer valid. */ - ToxAVFrame toToxAVFrame(QSize frameSize = {0, 0}); + ToxYUVFrame toToxAVFrame(QSize frameSize = {0, 0}); /** * @brief Data alignment parameter used to populate AVFrame buffers.