mirror of
https://github.com/odrling/Aegisub
synced 2025-04-11 22:56:02 +02:00
LAVCVideoProvider overlay support
Originally committed to SVN as r363.
This commit is contained in:
parent
c8352441e8
commit
635cfb2fa5
@ -63,6 +63,7 @@ LAVCVideoProvider::LAVCVideoProvider(wxString filename, wxString subfilename) {
|
|||||||
vidStream = -1;
|
vidStream = -1;
|
||||||
zoom = 1.0;
|
zoom = 1.0;
|
||||||
validFrame = false;
|
validFrame = false;
|
||||||
|
overlay = NULL;
|
||||||
|
|
||||||
// Load
|
// Load
|
||||||
LoadVideo(filename);
|
LoadVideo(filename);
|
||||||
@ -76,6 +77,16 @@ LAVCVideoProvider::~LAVCVideoProvider() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
// Attach overlay
|
||||||
|
void LAVCVideoProvider::AttachOverlay(SubtitleProvider::Overlay *_overlay)
|
||||||
|
{
|
||||||
|
overlay = _overlay;
|
||||||
|
if (overlay)
|
||||||
|
overlay->SetParams(display_w, display_h);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
// Load video
|
// Load video
|
||||||
void LAVCVideoProvider::LoadVideo(wxString filename) {
|
void LAVCVideoProvider::LoadVideo(wxString filename) {
|
||||||
@ -219,7 +230,7 @@ bool LAVCVideoProvider::GetNextFrame() {
|
|||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Convert AVFrame to wxBitmap
|
// Convert AVFrame to wxBitmap
|
||||||
wxBitmap LAVCVideoProvider::AVFrameToWX(AVFrame *source) {
|
wxBitmap LAVCVideoProvider::AVFrameToWX(AVFrame *source, int n) {
|
||||||
// Get sizes
|
// Get sizes
|
||||||
int w = codecContext->width;
|
int w = codecContext->width;
|
||||||
int h = codecContext->height;
|
int h = codecContext->height;
|
||||||
@ -271,15 +282,14 @@ wxBitmap LAVCVideoProvider::AVFrameToWX(AVFrame *source) {
|
|||||||
img_convert((AVPicture*) frameRGB, format, (AVPicture*) resized, codecContext->pix_fmt, w, h);
|
img_convert((AVPicture*) frameRGB, format, (AVPicture*) resized, codecContext->pix_fmt, w, h);
|
||||||
|
|
||||||
// Convert to wxBitmap
|
// Convert to wxBitmap
|
||||||
#ifdef __WINDOWS__
|
|
||||||
wxBitmap bmp((const char*) frameRGB->data[0],w,h,32);
|
|
||||||
#else
|
|
||||||
wxImage img(w, h, false);
|
wxImage img(w, h, false);
|
||||||
unsigned char *data = (unsigned char *)malloc(w * h * 3);
|
unsigned char *data = (unsigned char *)malloc(w * h * 3);
|
||||||
memcpy(data, frameRGB->data[0], w * h * 3);
|
memcpy(data, frameRGB->data[0], w * h * 3);
|
||||||
img.SetData(data);
|
img.SetData(data);
|
||||||
|
if (overlay)
|
||||||
|
overlay->Render(img, n);
|
||||||
|
|
||||||
wxBitmap bmp(img);
|
wxBitmap bmp(img);
|
||||||
#endif
|
|
||||||
|
|
||||||
av_free(frameRGB);
|
av_free(frameRGB);
|
||||||
if (resized != source)
|
if (resized != source)
|
||||||
@ -301,7 +311,7 @@ wxBitmap LAVCVideoProvider::GetFrame(int n) {
|
|||||||
n = MID(0,n,GetFrameCount()-1);
|
n = MID(0,n,GetFrameCount()-1);
|
||||||
if (n == frameNumber) {
|
if (n == frameNumber) {
|
||||||
if (!validFrame) {
|
if (!validFrame) {
|
||||||
curFrame = AVFrameToWX(frame);
|
curFrame = AVFrameToWX(frame, n);
|
||||||
validFrame = true;
|
validFrame = true;
|
||||||
}
|
}
|
||||||
return curFrame;
|
return curFrame;
|
||||||
@ -380,7 +390,7 @@ wxBitmap LAVCVideoProvider::GetFrame(int n) {
|
|||||||
|
|
||||||
// Bitmap
|
// Bitmap
|
||||||
wxBitmap bmp;
|
wxBitmap bmp;
|
||||||
if (frame) bmp = AVFrameToWX(frame);
|
if (frame) bmp = AVFrameToWX(frame, n);
|
||||||
else bmp = wxBitmap(GetWidth(),GetHeight());
|
else bmp = wxBitmap(GetWidth(),GetHeight());
|
||||||
|
|
||||||
// Set current frame
|
// Set current frame
|
||||||
|
@ -93,7 +93,11 @@ private:
|
|||||||
bool GetNextFrame();
|
bool GetNextFrame();
|
||||||
void LoadVideo(wxString filename);
|
void LoadVideo(wxString filename);
|
||||||
void Close();
|
void Close();
|
||||||
wxBitmap AVFrameToWX(AVFrame *frame);
|
wxBitmap AVFrameToWX(AVFrame *frame, int n);
|
||||||
|
|
||||||
|
SubtitleProvider::Overlay *overlay;
|
||||||
|
protected:
|
||||||
|
virtual void AttachOverlay(SubtitleProvider::Overlay *_overlay);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LAVCVideoProvider(wxString filename, wxString subfilename);
|
LAVCVideoProvider(wxString filename, wxString subfilename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user