diff --git a/src/media/video/accel.cpp b/src/media/video/accel.cpp index f820387c4891ae2781c4fbf845c52e455dc36b01..c4de20993b2d95689591f69bc67919393fb13188 100644 --- a/src/media/video/accel.cpp +++ b/src/media/video/accel.cpp @@ -124,8 +124,12 @@ HardwareAccel::extractData(VideoFrame& input) auto outFrame = output->pointer(); outFrame->format = AV_PIX_FMT_YUV420P; - // call the acceleration's implementation extractData(input, *output); + + // move outFrame into inFrame so the caller receives extracted image data + // but we have to delete inFrame first + av_frame_unref(inFrame); + av_frame_move_ref(inFrame, outFrame); } catch (const std::runtime_error& e) { fail(false); RING_ERR("%s", e.what()); diff --git a/src/media/video/accel.h b/src/media/video/accel.h index 87f90a417d03679e0856f25750ce67a67a8bea5f..968cb4d9fb51c5a0536d07440489bf7d34ced369 100644 --- a/src/media/video/accel.h +++ b/src/media/video/accel.h @@ -53,8 +53,6 @@ class HardwareAccel { virtual bool check() = 0; virtual bool init() = 0; virtual int allocateBuffer(AVFrame* frame, int flags) = 0; - // The reference to the extracted frame should be moved to input - // as that's the frame returned to the MediaDecoder virtual void extractData(VideoFrame& input, VideoFrame& output) = 0; protected: diff --git a/src/media/video/v4l2/vaapi.cpp b/src/media/video/v4l2/vaapi.cpp index e936a56e6eba536ce7a3184a64e5deb21273c81a..ebe3b3d8802c701a3601f32782d3d405e701fc49 100644 --- a/src/media/video/v4l2/vaapi.cpp +++ b/src/media/video/v4l2/vaapi.cpp @@ -71,9 +71,6 @@ VaapiAccel::extractData(VideoFrame& input, VideoFrame& output) if (av_frame_copy_props(outFrame, inFrame) < 0 ) { av_frame_unref(outFrame); } - - av_frame_unref(inFrame); - av_frame_move_ref(inFrame, outFrame); } bool