ffmpeg provider almost works now
Originally committed to SVN as r953.
This commit is contained in:
parent
4f1f9ccdf0
commit
d7a6ca1d76
4 changed files with 64 additions and 31 deletions
|
@ -39,9 +39,9 @@
|
||||||
#include "video_frame.h"
|
#include "video_frame.h"
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
/////////
|
||||||
// Constructor
|
// Reset
|
||||||
AegiVideoFrame::AegiVideoFrame() {
|
void AegiVideoFrame::Reset() {
|
||||||
for (int i=0;i<4;i++) {
|
for (int i=0;i<4;i++) {
|
||||||
data[i] = NULL;
|
data[i] = NULL;
|
||||||
pitch[i] = 0;
|
pitch[i] = 0;
|
||||||
|
@ -56,14 +56,21 @@ AegiVideoFrame::AegiVideoFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////
|
||||||
|
// Constructor
|
||||||
|
AegiVideoFrame::AegiVideoFrame() {
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Create default
|
// Create default
|
||||||
AegiVideoFrame::AegiVideoFrame(int width,int height,VideoFrameFormat fmt) {
|
AegiVideoFrame::AegiVideoFrame(int width,int height,VideoFrameFormat fmt) {
|
||||||
AegiVideoFrame();
|
Reset();
|
||||||
format = fmt;
|
format = fmt;
|
||||||
w = width;
|
w = width;
|
||||||
h = height;
|
h = height;
|
||||||
pitch[0] = w;
|
pitch[0] = w * GetBpp();
|
||||||
|
|
||||||
Allocate();
|
Allocate();
|
||||||
for (int i=0;i<4;i++) {
|
for (int i=0;i<4;i++) {
|
||||||
|
@ -80,14 +87,16 @@ AegiVideoFrame::AegiVideoFrame(int width,int height,VideoFrameFormat fmt) {
|
||||||
void AegiVideoFrame::Allocate() {
|
void AegiVideoFrame::Allocate() {
|
||||||
// Get size
|
// Get size
|
||||||
int height = h;
|
int height = h;
|
||||||
unsigned int size = pitch[0]*height;
|
unsigned int size;
|
||||||
if (format == FORMAT_YV12) size = size * 3 / 2;
|
if (format == FORMAT_YV12) size = pitch[0] * height * 3 / 2;
|
||||||
else size = size * GetBpp();
|
else size = pitch[0] * height;
|
||||||
|
|
||||||
// Reallocate, if necessary
|
// Reallocate, if necessary
|
||||||
if (memSize != size) {
|
if (memSize != size) {
|
||||||
if (cppAlloc) delete[] data[0];
|
if (data[0]) {
|
||||||
else free(data[0]);
|
if (cppAlloc) delete[] data[0];
|
||||||
|
else free(data[0]);
|
||||||
|
}
|
||||||
data[0] = new unsigned char[size];
|
data[0] = new unsigned char[size];
|
||||||
for (int i=1;i<4;i++) data[i] = NULL;
|
for (int i=1;i<4;i++) data[i] = NULL;
|
||||||
memSize = size;
|
memSize = size;
|
||||||
|
|
|
@ -52,6 +52,7 @@ enum VideoFrameFormat {
|
||||||
class AegiVideoFrame {
|
class AegiVideoFrame {
|
||||||
private:
|
private:
|
||||||
unsigned int memSize;
|
unsigned int memSize;
|
||||||
|
void Reset();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned char *data[4]; // Pointers to the data planes. Interleaved formats only use data[0]
|
unsigned char *data[4]; // Pointers to the data planes. Interleaved formats only use data[0]
|
||||||
|
|
|
@ -300,19 +300,13 @@ const AegiVideoFrame LAVCVideoProvider::DoGetFrame(int n) {
|
||||||
// Return stored frame
|
// Return stored frame
|
||||||
n = MID(0,n,GetFrameCount()-1);
|
n = MID(0,n,GetFrameCount()-1);
|
||||||
if (n == frameNumber) {
|
if (n == frameNumber) {
|
||||||
if (!validFrame) {
|
if (!validFrame) validFrame = true;
|
||||||
//curFrame = AVFrameToWX(frame, n);
|
return curFrame;
|
||||||
validFrame = true;
|
|
||||||
}
|
|
||||||
//return curFrame;
|
|
||||||
AegiVideoFrame dummy;
|
|
||||||
return dummy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Following frame, just get it
|
// Following frame, just get it
|
||||||
if (n == frameNumber+1) {
|
if (n == frameNumber+1) {
|
||||||
GetNextFrame();
|
GetNextFrame();
|
||||||
//wxLogMessage(wxString::Format(_T("%i"),lastDecodeTime));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needs to seek
|
// Needs to seek
|
||||||
|
@ -380,21 +374,50 @@ const AegiVideoFrame LAVCVideoProvider::DoGetFrame(int n) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bitmap
|
// Get frame
|
||||||
//wxBitmap bmp;
|
AegiVideoFrame final;
|
||||||
//if (frame) bmp = AVFrameToWX(frame, n);
|
if (frame) {
|
||||||
//else bmp = wxBitmap(GetWidth(),GetHeight());
|
// Set AegiVideoFrame
|
||||||
|
PixelFormat format = codecContext->pix_fmt;
|
||||||
|
unsigned int size = avpicture_get_size(format,codecContext->width,codecContext->height);
|
||||||
|
final.w = codecContext->width;
|
||||||
|
final.h = codecContext->height;
|
||||||
|
final.flipped = false;
|
||||||
|
final.invertChannels = false;
|
||||||
|
|
||||||
//// Set current frame
|
// Set format
|
||||||
//validFrame = true;
|
switch (format) {
|
||||||
//curFrame = bmp;
|
case PIX_FMT_BGR24: final.invertChannels = true;
|
||||||
//frameNumber = n;
|
case PIX_FMT_RGB24: final.format = FORMAT_RGB24; break;
|
||||||
|
case PIX_FMT_BGR32: final.invertChannels = true;
|
||||||
|
case PIX_FMT_RGB32: final.format = FORMAT_RGB32; break;
|
||||||
|
case PIX_FMT_YUYV422: final.format = FORMAT_YUY2; break;
|
||||||
|
case PIX_FMT_YUV420P: final.format = FORMAT_YV12; break;
|
||||||
|
}
|
||||||
|
|
||||||
//// Return
|
// Allocate
|
||||||
//return curFrame;
|
final.pitch[0] = final.w * final.GetBpp();
|
||||||
|
final.Allocate();
|
||||||
|
|
||||||
AegiVideoFrame dummy;
|
// Copy data
|
||||||
return dummy;
|
if (final.format == FORMAT_YV12) {
|
||||||
|
memcpy(final.data[0],frame->data[0],final.w * final.h);
|
||||||
|
memcpy(final.data[1],frame->data[1],final.w * final.h / 4);
|
||||||
|
memcpy(final.data[2],frame->data[2],final.w * final.h / 4);
|
||||||
|
}
|
||||||
|
else memcpy(final.data[0],frame->data[0],size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No frame available
|
||||||
|
else final = AegiVideoFrame(GetWidth(),GetHeight());
|
||||||
|
|
||||||
|
// Set current frame
|
||||||
|
validFrame = true;
|
||||||
|
curFrame = final;
|
||||||
|
frameNumber = n;
|
||||||
|
|
||||||
|
// Return
|
||||||
|
return final;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ private:
|
||||||
__int64 lastDecodeTime;
|
__int64 lastDecodeTime;
|
||||||
int frameNumber;
|
int frameNumber;
|
||||||
int length;
|
int length;
|
||||||
wxBitmap curFrame;
|
AegiVideoFrame curFrame;
|
||||||
bool validFrame;
|
bool validFrame;
|
||||||
|
|
||||||
uint8_t *buffer1;
|
uint8_t *buffer1;
|
||||||
|
|
Loading…
Reference in a new issue