lib/ffmpeg/Frame: add more wrapper methods

This commit is contained in:
Max Kellermann 2019-03-18 10:29:26 +01:00
parent 4722175049
commit 42a05bc904

View File

@ -20,6 +20,8 @@
#ifndef MPD_FFMPEG_FRAME_HXX
#define MPD_FFMPEG_FRAME_HXX
#include "Error.hxx"
extern "C" {
#include <libavutil/frame.h>
}
@ -47,6 +49,30 @@ public:
AVFrame &operator*() noexcept {
return *frame;
}
AVFrame *operator->() noexcept {
return frame;
}
AVFrame *get() noexcept {
return frame;
}
void GetBuffer() {
int err = av_frame_get_buffer(frame, 0);
if (err < 0)
throw MakeFfmpegError(err, "av_frame_get_buffer() failed");
}
void MakeWritable() {
int err = av_frame_make_writable(frame);
if (err < 0)
throw MakeFfmpegError(err, "av_frame_make_writable() failed");
}
void *GetData(unsigned plane) noexcept {
return frame->data[plane];
}
};
} // namespace Ffmpeg