| 1 |
#include "frame.h" |
| 2 |
#include "videodecoder.h" |
| 3 |
#include "videoencoder.h" |
| 4 |
#include "avm_fourcc.h" |
| 5 |
#include "avm_cpuinfo.h" |
| 6 |
#include "renderer.h" |
| 7 |
#include "utils.h" |
| 8 |
|
| 9 |
#include <unistd.h> |
| 10 |
#include <sys/time.h> //gettimeofday |
| 11 |
#include <stdlib.h> // labs |
| 12 |
#include <string.h> // memset |
| 13 |
|
| 14 |
AVM_BEGIN_NAMESPACE; |
| 15 |
|
| 16 |
IVideoDecoder::IVideoDecoder(const CodecInfo& info, const BITMAPINFOHEADER& format) |
| 17 |
:m_Info(info), m_pFormat(0), |
| 18 |
m_Dest(format.biWidth, format.biHeight, 24), |
| 19 |
//m_Dest(format), |
| 20 |
m_pImage(0) |
| 21 |
{ |
| 22 |
// m_Dest.biWidth = format.biWidth; |
| 23 |
// m_Dest.biHeight = format.biHeight; |
| 24 |
// m_Dest.SetBits(24); |
| 25 |
size_t bihs = (format.biSize < sizeof(BITMAPINFOHEADER)) ? |
| 26 |
sizeof(BITMAPINFOHEADER) : format.biSize; |
| 27 |
// some parsers are bit-reading data slightly behind the bounds |
| 28 |
bihs += 3; |
| 29 |
m_pFormat = (BITMAPINFOHEADER*) new char[bihs]; |
| 30 |
memset(m_pFormat, 0, bihs); |
| 31 |
memcpy(m_pFormat, &format, format.biSize); |
| 32 |
} |
| 33 |
|
| 34 |
IVideoDecoder::~IVideoDecoder() |
| 35 |
{ |
| 36 |
delete[] (char*) m_pFormat; |
| 37 |
if (m_pImage) |
| 38 |
m_pImage->Release(); |
| 39 |
} |
| 40 |
|
| 41 |
const BITMAPINFOHEADER& IVideoDecoder::GetDestFmt() const |
| 42 |
{ |
| 43 |
return (const BITMAPINFOHEADER&) m_Dest; |
| 44 |
} |
| 45 |
|
| 46 |
IVideoDecoder::CAPS IVideoDecoder::GetCapabilities() const |
| 47 |
{ |
| 48 |
return CAP_NONE; |
| 49 |
} |
| 50 |
|
| 51 |
const CodecInfo& IVideoDecoder::GetCodecInfo() const |
| 52 |
{ |
| 53 |
return m_Info; |
| 54 |
} |
| 55 |
|
| 56 |
IRtConfig* IVideoDecoder::GetRtConfig() |
| 57 |
{ |
| 58 |
return 0; |
| 59 |
} |
| 60 |
|
| 61 |
void IVideoDecoder::Flush() |
| 62 |
{ |
| 63 |
} |
| 64 |
|
| 65 |
int IVideoDecoder::Start() |
| 66 |
{ |
| 67 |
return 0; |
| 68 |
} |
| 69 |
|
| 70 |
int IVideoDecoder::Stop() |
| 71 |
{ |
| 72 |
return 0; |
| 73 |
} |
| 74 |
|
| 75 |
int IVideoDecoder::Restart() |
| 76 |
{ |
| 77 |
Stop(); |
| 78 |
return Start(); |
| 79 |
} |
| 80 |
|
| 81 |
int IVideoDecoder::SetDirection(int d) |
| 82 |
{ |
| 83 |
if (m_Dest.biHeight < 0) |
| 84 |
m_Dest.biHeight = -m_Dest.biHeight; |
| 85 |
if (!d) |
| 86 |
m_Dest.biHeight = -m_Dest.biHeight; |
| 87 |
|
| 88 |
return 0; |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Implementation for Encoder |
| 93 |
*/ |
| 94 |
|
| 95 |
IVideoEncoder::IVideoEncoder(const CodecInfo& info) |
| 96 |
:m_Info(info) |
| 97 |
{ |
| 98 |
} |
| 99 |
IVideoEncoder::~IVideoEncoder() |
| 100 |
{ |
| 101 |
} |
| 102 |
const CodecInfo& IVideoEncoder::GetCodecInfo() const |
| 103 |
{ |
| 104 |
return m_Info; |
| 105 |
} |
| 106 |
float IVideoEncoder::GetFps() const |
| 107 |
{ |
| 108 |
return -1.; |
| 109 |
} |
| 110 |
int IVideoEncoder::SetFps(float fps) |
| 111 |
{ |
| 112 |
return -1; |
| 113 |
} |
| 114 |
|
| 115 |
AVM_END_NAMESPACE; |