mirror of https://github.com/mpv-player/mpv
mplayer integration
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3064 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
e5ebb2673d
commit
4a7c3f22ec
|
@ -75,13 +75,13 @@ DS_AudioDecoder * DS_AudioDecoder_Create(const CodecInfo * info, const WAVEFORMA
|
|||
/*try*/
|
||||
{
|
||||
ALLOCATOR_PROPERTIES props, props1;
|
||||
this->m_pDS_Filter = DS_Filter_Create((const char*)info->dll, &info->guid, &this->m_sOurType, &this->m_sDestType);
|
||||
this->m_pDS_Filter = DS_FilterCreate((const char*)info->dll, info->guid, &this->m_sOurType, &this->m_sDestType);
|
||||
if( !this->m_pDS_Filter ) {
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DS_Filter_Start(this->m_pDS_Filter);
|
||||
this->m_pDS_Filter->Start(this->m_pDS_Filter);
|
||||
|
||||
props.cBuffers=1;
|
||||
props.cbBuffer=this->m_sOurType.lSampleSize;
|
||||
|
@ -130,8 +130,8 @@ int DS_AudioDecoder_Convert(DS_AudioDecoder *this, const void* in_data, uint_t i
|
|||
int result;
|
||||
|
||||
// this->m_pOurOutput->SetFramePointer(out_data+written);
|
||||
COutputPin_SetFramePointer(this->m_pDS_Filter->m_pOurOutput,&frame_pointer);
|
||||
COutputPin_SetFrameSizePointer(this->m_pDS_Filter->m_pOurOutput,(long*)&frame_size);
|
||||
this->m_pDS_Filter->m_pOurOutput->SetFramePointer(this->m_pDS_Filter->m_pOurOutput,&frame_pointer);
|
||||
this->m_pDS_Filter->m_pOurOutput->SetFrameSizePointer(this->m_pDS_Filter->m_pOurOutput,(long*)&frame_size);
|
||||
this->m_pDS_Filter->m_pAll->vt->GetBuffer(this->m_pDS_Filter->m_pAll, &sample, 0, 0, 0);
|
||||
if (!sample)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "audiodecoder.h"
|
||||
#include "except.h"
|
||||
#else
|
||||
#include "../libwin32.h"
|
||||
#include "libwin32.h"
|
||||
#endif
|
||||
#include "DS_Filter.h"
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * f
|
|||
this->m_iLastQuality = -1;
|
||||
this->m_iMaxAuto = maxauto;
|
||||
|
||||
Setup_LDT_Keeper();
|
||||
|
||||
//memset(&m_obh, 0, sizeof(m_obh));
|
||||
//m_obh.biSize = sizeof(m_obh);
|
||||
/*try*/
|
||||
|
@ -140,7 +142,7 @@ DS_VideoDecoder * DS_VideoDecoder_Create(CodecInfo * info, BITMAPINFOHEADER * f
|
|||
* ((this->iv.m_obh.biBitCount + 7) / 8);
|
||||
|
||||
|
||||
this->m_pDS_Filter = DS_Filter_Create((const char*)info->dll, &info->guid, &this->m_sOurType, &this->m_sDestType);
|
||||
this->m_pDS_Filter = DS_FilterCreate((const char*)info->dll, info->guid, &this->m_sOurType, &this->m_sDestType);
|
||||
|
||||
if (!flip)
|
||||
{
|
||||
|
@ -230,7 +232,7 @@ void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this)
|
|||
ALLOCATOR_PROPERTIES props, props1;
|
||||
Debug printf("DS_VideoDecoder_StartInternal\n");
|
||||
//cout << "DSSTART" << endl;
|
||||
DS_Filter_Start(this->m_pDS_Filter);
|
||||
this->m_pDS_Filter->Start(this->m_pDS_Filter);
|
||||
|
||||
props.cBuffers = 1;
|
||||
props.cbBuffer = this->m_sDestType.lSampleSize;
|
||||
|
@ -245,17 +247,17 @@ void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this)
|
|||
|
||||
void DS_VideoDecoder_StopInternal(DS_VideoDecoder *this)
|
||||
{
|
||||
DS_Filter_Stop(this->m_pDS_Filter);
|
||||
this->m_pDS_Filter->Stop(this->m_pDS_Filter);
|
||||
//??? why was this here ??? m_pOurOutput->SetFramePointer(0);
|
||||
}
|
||||
|
||||
int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int size, int is_keyframe, CImage* pImage)
|
||||
int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int size, int is_keyframe, char* pImage)
|
||||
{
|
||||
IMediaSample* sample = 0;
|
||||
char* ptr;
|
||||
int result;
|
||||
|
||||
Debug printf("DS_VideoDecoder_DecodeInternal(%p,%p,%d,%d,%p)\n",this,src,size,is_keyframe,pImage->ptr);
|
||||
Debug printf("DS_VideoDecoder_DecodeInternal(%p,%p,%d,%d,%p)\n",this,src,size,is_keyframe,pImage);
|
||||
|
||||
this->m_pDS_Filter->m_pAll->vt->GetBuffer(this->m_pDS_Filter->m_pAll, &sample, 0, 0, 0);
|
||||
|
||||
|
@ -268,12 +270,7 @@ int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int s
|
|||
//cout << "DECODE " << (void*) pImage << " d: " << (void*) pImage->Data() << endl;
|
||||
if (pImage)
|
||||
{
|
||||
if (!(pImage->ptr))
|
||||
{
|
||||
Debug printf("no m_outFrame??\n");
|
||||
}
|
||||
else
|
||||
COutputPin_SetPointer2(this->m_pDS_Filter->m_pOurOutput,(char*)pImage->ptr);
|
||||
this->m_pDS_Filter->m_pOurOutput->SetPointer2(this->m_pDS_Filter->m_pOurOutput,pImage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -390,7 +387,7 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp)
|
|||
*/
|
||||
// BitmapInfo temp = m_obh;
|
||||
|
||||
if (bits != 0)
|
||||
if (!csp) // RGB
|
||||
{
|
||||
int ok = true;
|
||||
|
||||
|
@ -438,10 +435,8 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp)
|
|||
}
|
||||
}
|
||||
//.biSizeImage=abs(temp.biWidth*temp.biHeight*((temp.biBitCount+7)/8));
|
||||
}
|
||||
|
||||
if (csp != 0)
|
||||
{
|
||||
} else
|
||||
{ // YUV
|
||||
int ok = true;
|
||||
switch (csp)
|
||||
{
|
||||
|
@ -466,19 +461,6 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp)
|
|||
}
|
||||
|
||||
if (ok) {
|
||||
int bits=0;
|
||||
switch(csp){
|
||||
case fccYUV:
|
||||
bits=24;break;
|
||||
case fccYUY2:
|
||||
case fccUYVY:
|
||||
case fccYVYU:
|
||||
bits=16;break;
|
||||
case fccYV12:
|
||||
case fccIYUV:
|
||||
case fccI420:
|
||||
bits=12;break;
|
||||
}
|
||||
if (csp != 0 && csp != 3 && this->iv.m_obh.biHeight > 0)
|
||||
this->iv.m_obh.biHeight *= -1; // YUV formats uses should have height < 0
|
||||
this->iv.m_obh.biSize = sizeof(BITMAPINFOHEADER);
|
||||
|
@ -561,7 +543,7 @@ int DS_VideoDecoder_SetDestFmt(DS_VideoDecoder *this, int bits, fourcc_t csp)
|
|||
|
||||
this->m_pDS_Filter->m_pInputPin->vt->Disconnect(this->m_pDS_Filter->m_pInputPin);
|
||||
this->m_pDS_Filter->m_pOutputPin->vt->Disconnect(this->m_pDS_Filter->m_pOutputPin);
|
||||
COutputPin_SetNewFormat(this->m_pDS_Filter->m_pOurOutput,&this->m_sDestType);
|
||||
this->m_pDS_Filter->m_pOurOutput->SetNewFormat(this->m_pDS_Filter->m_pOurOutput,&this->m_sDestType);
|
||||
result = this->m_pDS_Filter->m_pInputPin->vt->ReceiveConnection(this->m_pDS_Filter->m_pInputPin,
|
||||
this->m_pDS_Filter->m_pOurInput,
|
||||
&this->m_sOurType);
|
||||
|
@ -811,5 +793,64 @@ HRESULT DS_VideoDecoder_SetValue(DS_VideoDecoder *this, const char* name, int va
|
|||
return 0;
|
||||
}
|
||||
/*
|
||||
vim: tabstop=8
|
||||
vim: vi* sux.
|
||||
*/
|
||||
|
||||
int DS_SetAttr_DivX(char* attribute, int value){
|
||||
int result, status, newkey, count;
|
||||
if(strcmp(attribute, "Quality")==0){
|
||||
char* keyname="SOFTWARE\\Microsoft\\Scrunch";
|
||||
result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status);
|
||||
if(result!=0)
|
||||
{
|
||||
printf("VideoDecoder::SetExtAttr: registry failure\n");
|
||||
return -1;
|
||||
}
|
||||
result=RegSetValueExA(newkey, "Current Post Process Mode", 0, REG_DWORD, &value, 4);
|
||||
if(result!=0)
|
||||
{
|
||||
printf("VideoDecoder::SetExtAttr: error writing value\n");
|
||||
return -1;
|
||||
}
|
||||
value=-1;
|
||||
result=RegSetValueExA(newkey, "Force Post Process Mode", 0, REG_DWORD, &value, 4);
|
||||
if(result!=0)
|
||||
{
|
||||
printf("VideoDecoder::SetExtAttr: error writing value\n");
|
||||
return -1;
|
||||
}
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(
|
||||
(strcmp(attribute, "Saturation")==0) ||
|
||||
(strcmp(attribute, "Hue")==0) ||
|
||||
(strcmp(attribute, "Contrast")==0) ||
|
||||
(strcmp(attribute, "Brightness")==0)
|
||||
)
|
||||
{
|
||||
char* keyname="SOFTWARE\\Microsoft\\Scrunch\\Video";
|
||||
result=RegCreateKeyExA(HKEY_CURRENT_USER, keyname, 0, 0, 0, 0, 0, &newkey, &status);
|
||||
if(result!=0)
|
||||
{
|
||||
printf("VideoDecoder::SetExtAttr: registry failure\n");
|
||||
return -1;
|
||||
}
|
||||
result=RegSetValueExA(newkey, attribute, 0, REG_DWORD, &value, 4);
|
||||
if(result!=0)
|
||||
{
|
||||
printf("VideoDecoder::SetExtAttr: error writing value\n");
|
||||
return -1;
|
||||
}
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Unknown attribute!\n");
|
||||
return -200;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#ifndef NOAVIFILE_HEADERS
|
||||
#include "videodecoder.h"
|
||||
#else
|
||||
#include "../libwin32.h"
|
||||
#include "libwin32.h"
|
||||
#endif
|
||||
#include "DS_Filter.h"
|
||||
|
||||
|
@ -36,7 +36,7 @@ void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this);
|
|||
|
||||
void DS_VideoDecoder_StopInternal(DS_VideoDecoder *this);
|
||||
|
||||
int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int size, int is_keyframe, CImage* pImage);
|
||||
int DS_VideoDecoder_DecodeInternal(DS_VideoDecoder *this, const void* src, int size, int is_keyframe, char* pImage);
|
||||
|
||||
/*
|
||||
* bits == 0 - leave unchanged
|
||||
|
|
|
@ -3,20 +3,20 @@ LIBNAME = libDS_Filter.a
|
|||
|
||||
include ../../config.mak
|
||||
|
||||
# DS_AudioDec.cpp
|
||||
SRCS = DS_AudioDec.cpp DS_AudioDecoder.cpp DS_VideoDec.cpp DS_Filter.cpp DS_VideoDecoder.cpp allocator.cpp cmediasample.cpp guids.cpp inputpin.cpp outputpin.cpp
|
||||
OBJS = $(SRCS:.cpp=.o)
|
||||
# DS_AudioDec.c
|
||||
SRCS = DS_AudioDecoder.c DS_Filter.c DS_VideoDecoder.c allocator.c cmediasample.c guids.c inputpin.c outputpin.c
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
# OBJS = DS_AudioDec.o DS_VideoDec.o DS_Filter.o allocator.o cmediasample.o guids.o inputpin.o outputpin.o
|
||||
|
||||
INCLUDE = -I. -I.. $(EXTRA_INC) -DNOAVIFILE_HEADERS
|
||||
CFLAGS = $(OPTFLAGS) $(INCLUDE) -fexceptions
|
||||
CFLAGS = $(OPTFLAGS) $(INCLUDE)
|
||||
|
||||
.SUFFIXES: .cpp .o
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
# .PHONY: all clean
|
||||
|
||||
.cpp.o:
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
$(LIBNAME): $(OBJS)
|
||||
|
|
|
@ -1,72 +1,161 @@
|
|||
#ifndef __LIBWIN32_H
|
||||
#define __LIBWIN32_H
|
||||
|
||||
#define VFW_E_INVALIDMEDIATYPE 0x80040200
|
||||
#define VFW_E_INVALIDSUBTYPE 0x80040201
|
||||
#define VFW_E_ALREADY_CONNECTED 0x80040204
|
||||
#define VFW_E_FILTER_ACTIVE 0x80040205
|
||||
#define VFW_E_NO_ACCEPTABLE_TYPES 0x80040207
|
||||
#define VFW_E_NOT_CONNECTED 0x80040209
|
||||
#define VFW_E_NO_ALLOCATOR 0x8004020A
|
||||
#define VFW_E_NOT_RUNNING 0x80040226
|
||||
#define VFW_E_TYPE_NOT_ACCEPTED 0x8004022A
|
||||
#define VFW_E_SAMPLE_REJECTED 0x8004022B
|
||||
#ifndef NOAVIFILE_HEADERS
|
||||
#error this header file should not be used without -DNOAVIFILE_HEADERS
|
||||
#endif
|
||||
|
||||
// this file is only included when NOAVIFILE_HEADERS are defined
|
||||
// serves mainly for mplayer
|
||||
|
||||
#define VFW_E_NOT_RUNNING 0x80040226
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifndef NOAVIFILE_HEADERS
|
||||
#include <audiodecoder.h>
|
||||
#include <audioencoder.h>
|
||||
#include <videodecoder.h>
|
||||
#include <videoencoder.h>
|
||||
#include <except.h>
|
||||
#include <fourcc.h>
|
||||
|
||||
#else
|
||||
// code for mplayer team
|
||||
|
||||
//#define FATAL(a) // you don't need exception - if you want - just fill more code
|
||||
#define FATAL(X...) FatalError(__MODULE__,__FILE__,__LINE__,X)
|
||||
#include <wine/mmreg.h>
|
||||
#include <wine/winreg.h>
|
||||
#include <wine/vfw.h>
|
||||
#include <com.h>
|
||||
#include <stdarg.h>
|
||||
//#include <string>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "wine/mmreg.h"
|
||||
#include "wine/winreg.h"
|
||||
#include "wine/vfw.h"
|
||||
#include "com.h"
|
||||
|
||||
typedef unsigned int uint_t; // use as generic type -
|
||||
typedef uint32_t fourcc_t;
|
||||
|
||||
typedef unsigned int fourcc_t;
|
||||
|
||||
struct FatalError
|
||||
/*
|
||||
typedef struct _FatalError
|
||||
{
|
||||
FatalError(const char* mod, const char* f, int l, const char* desc,...)
|
||||
{
|
||||
printf("FATAL: module: %s source: %s line %d ", mod, f, l);
|
||||
va_list va;
|
||||
va_start(va, desc);
|
||||
vprintf(desc, va);
|
||||
va_end(va);
|
||||
}
|
||||
FatalError();
|
||||
void PrintAll() {}
|
||||
};
|
||||
}FatalError;
|
||||
*/
|
||||
|
||||
struct CodecInfo
|
||||
typedef struct _CodecInfo
|
||||
{
|
||||
// std::string dll;
|
||||
char* dll;
|
||||
GUID guid;
|
||||
};
|
||||
GUID* guid;
|
||||
}CodecInfo;
|
||||
|
||||
struct CImage { // public your_libvo_mem
|
||||
|
||||
typedef struct _CImage // public your_libvo_mem
|
||||
{
|
||||
char* ptr;
|
||||
char* Data() { return ptr; } // pointer to memory block
|
||||
/* if you support such surface: */
|
||||
static bool Supported(fourcc_t csp, int bits) { return true; }
|
||||
|
||||
/*char* (*Data)();
|
||||
{
|
||||
return 0;
|
||||
// pointer to memory block
|
||||
}*/
|
||||
/*int (*Supported)(fourcc_t csp, int bits);
|
||||
{
|
||||
return true;
|
||||
// if you support such surface
|
||||
}*/
|
||||
}CImage;
|
||||
|
||||
|
||||
#if 0
|
||||
struct BitmapInfo : public BITMAPINFOHEADER
|
||||
{
|
||||
void SetBits(int b) { return; /*fixme*/ }
|
||||
void SetSpace(int b) { return; /*fixme*/ }
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct _IAudioDecoder
|
||||
{
|
||||
WAVEFORMATEX in_fmt;
|
||||
CodecInfo record;
|
||||
/*(*IAudioDecoder)( CodecInfo * r, const WAVEFORMATEX* w);
|
||||
{
|
||||
memcpy(&this->record,r,sizeof(CodecInfo));
|
||||
in_fmt = *w;
|
||||
}*/
|
||||
}IAudioDecoder;
|
||||
|
||||
/*
|
||||
struct IAudioEncoder
|
||||
{
|
||||
IAudioEncoder(const CodecInfo&, WAVEFORMATEX*) {}
|
||||
// you do not need this one...
|
||||
};
|
||||
*/
|
||||
|
||||
enum CAPS
|
||||
{
|
||||
CAP_NONE = 0,
|
||||
CAP_YUY2 = 1,
|
||||
CAP_YV12 = 2,
|
||||
CAP_IYUV = 4,
|
||||
CAP_UYVY = 8,
|
||||
CAP_YVYU = 16,
|
||||
CAP_I420 = 32,
|
||||
};
|
||||
enum DecodingMode
|
||||
{
|
||||
DIRECT = 0,
|
||||
REALTIME,
|
||||
REALTIME_QUALITY_AUTO,
|
||||
};
|
||||
enum DecodingState
|
||||
{
|
||||
STOP = 0,
|
||||
START,
|
||||
};
|
||||
|
||||
typedef struct _BitmapInfo
|
||||
{
|
||||
long biSize;
|
||||
long biWidth;
|
||||
long biHeight;
|
||||
short biPlanes;
|
||||
short biBitCount;
|
||||
long biCompression;
|
||||
long biSizeImage;
|
||||
long biXPelsPerMeter;
|
||||
long biYPelsPerMeter;
|
||||
long biClrUsed;
|
||||
long biClrImportant;
|
||||
int colors[3];
|
||||
} BitmapInfo;
|
||||
|
||||
typedef struct _IVideoDecoder
|
||||
{
|
||||
int VBUFSIZE;
|
||||
int QMARKHI;
|
||||
int QMARKLO;
|
||||
int DMARKHI;
|
||||
int DMARKLO;
|
||||
|
||||
/*
|
||||
IVideoDecoder(CodecInfo& info, const BITMAPINFOHEADER& format) : record(info)
|
||||
{
|
||||
// implement init part
|
||||
}
|
||||
virtual ~IVideoDecoder();
|
||||
void Stop()
|
||||
{
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
*/
|
||||
const CodecInfo record;
|
||||
int m_Mode; // should we do precaching (or even change Quality on the fly)
|
||||
int m_State;
|
||||
int m_iDecpos;
|
||||
int m_iPlaypos;
|
||||
float m_fQuality; // quality for the progress bar 0..1(best)
|
||||
int m_bCapable16b;
|
||||
|
||||
BITMAPINFOHEADER* m_bh; // format of input data (might be larger - e.g. huffyuv)
|
||||
BitmapInfo m_decoder; // format of decoder output
|
||||
BitmapInfo m_obh; // format of returned frames
|
||||
}IVideoDecoder;
|
||||
|
||||
/*
|
||||
struct IRtConfig
|
||||
{
|
||||
};
|
||||
*/
|
||||
|
||||
// might be minimalized to contain just those which are needed by DS_VideoDecoder
|
||||
|
||||
|
@ -167,160 +256,4 @@ struct CImage { // public your_libvo_mem
|
|||
#define fccUYVY mmioFOURCC('U', 'Y', 'V', 'Y')/* Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
#define fccYVYU mmioFOURCC('Y', 'V', 'Y', 'U')/* Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
|
||||
|
||||
struct BitmapInfo : public BITMAPINFOHEADER
|
||||
{
|
||||
int colors[3];
|
||||
|
||||
void SetBitFields16(){
|
||||
biSize=sizeof(BITMAPINFOHEADER)+12;
|
||||
biCompression=3;//BI_BITFIELDS
|
||||
biBitCount=16;
|
||||
biSizeImage=abs((int)(2*biWidth*biHeight));
|
||||
colors[0]=0xF800;
|
||||
colors[1]=0x07E0;
|
||||
colors[2]=0x001F;
|
||||
}
|
||||
void SetBitFields15(){
|
||||
biSize=sizeof(BITMAPINFOHEADER)+12;
|
||||
biCompression=3;//BI_BITFIELDS
|
||||
biBitCount=16;
|
||||
biSizeImage=abs((int)(2*biWidth*biHeight));
|
||||
colors[0]=0x7C00;
|
||||
colors[1]=0x03E0;
|
||||
colors[2]=0x001F;
|
||||
}
|
||||
void SetRGB(){
|
||||
biSize = sizeof(BITMAPINFOHEADER);
|
||||
biCompression = 0; //BI_RGB
|
||||
//biHeight = labs(biHeight);
|
||||
biSizeImage = labs(biWidth * biHeight) * ((biBitCount + 7) / 8);
|
||||
}
|
||||
void SetBits(int bits) {
|
||||
switch (bits){
|
||||
case 15: SetBitFields15();break;
|
||||
case 16: SetBitFields16();break;
|
||||
default: biBitCount = bits; SetRGB();break;
|
||||
}
|
||||
}
|
||||
void SetSpace(int csp,int bits) {
|
||||
biSize = sizeof(BITMAPINFOHEADER);
|
||||
biCompression=csp;
|
||||
biBitCount=bits;
|
||||
biSizeImage=labs(biBitCount*biWidth*biHeight)>>3;
|
||||
}
|
||||
void SetSpace(int csp) {
|
||||
int bits=0;
|
||||
switch(csp){
|
||||
case fccYUV:
|
||||
bits=24;break;
|
||||
case fccYUY2:
|
||||
case fccUYVY:
|
||||
case fccYVYU:
|
||||
bits=16;break;
|
||||
case fccYV12:
|
||||
case fccIYUV:
|
||||
case fccI420:
|
||||
bits=12;break;
|
||||
}
|
||||
if (csp != 0 && csp != 3 && biHeight > 0)
|
||||
biHeight *= -1; // YUV formats uses should have height < 0
|
||||
SetSpace(csp,bits);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct IAudioDecoder
|
||||
{
|
||||
WAVEFORMATEX in_fmt;
|
||||
const CodecInfo& record;
|
||||
IAudioDecoder(const CodecInfo& r, const WAVEFORMATEX* w) : record(r)
|
||||
{
|
||||
in_fmt = *w;
|
||||
}
|
||||
};
|
||||
|
||||
struct IAudioEncoder
|
||||
{
|
||||
IAudioEncoder(const CodecInfo&, WAVEFORMATEX*) {}
|
||||
// you do not need this one...
|
||||
};
|
||||
|
||||
struct IVideoDecoder
|
||||
{
|
||||
int VBUFSIZE;
|
||||
int QMARKHI;
|
||||
int QMARKLO;
|
||||
int DMARKHI;
|
||||
int DMARKLO;
|
||||
|
||||
enum CAPS
|
||||
{
|
||||
CAP_NONE = 0,
|
||||
CAP_YUY2 = 1,
|
||||
CAP_YV12 = 2,
|
||||
CAP_IYUV = 4,
|
||||
CAP_UYVY = 8,
|
||||
CAP_YVYU = 16,
|
||||
CAP_I420 = 32,
|
||||
};
|
||||
enum DecodingMode
|
||||
{
|
||||
DIRECT = 0,
|
||||
REALTIME,
|
||||
REALTIME_QUALITY_AUTO,
|
||||
};
|
||||
enum DecodingState
|
||||
{
|
||||
STOP = 0,
|
||||
START,
|
||||
};
|
||||
IVideoDecoder(const CodecInfo& info, const BITMAPINFOHEADER& format) : record(info)
|
||||
{
|
||||
// implement init part
|
||||
unsigned bihs = (format.biSize < (int) sizeof(BITMAPINFOHEADER)) ?
|
||||
sizeof(BITMAPINFOHEADER) : format.biSize;
|
||||
m_bh = (BITMAPINFOHEADER*) new char[bihs];
|
||||
memcpy(m_bh, &format, bihs);
|
||||
m_State = STOP;
|
||||
//m_pFrame = 0;
|
||||
m_Mode = DIRECT;
|
||||
m_iDecpos = 0;
|
||||
m_iPlaypos = -1;
|
||||
m_fQuality = 0.0f;
|
||||
m_bCapable16b = true;
|
||||
|
||||
}
|
||||
virtual ~IVideoDecoder(){};
|
||||
// use this one
|
||||
int Decode(void* src, size_t size, int is_keyframe, CImage* pImage)
|
||||
{ return DecodeInternal(src, size, is_keyframe, pImage); }
|
||||
void Stop(){ StopInternal(); m_State = STOP;}
|
||||
void Start(){StartInternal(); m_State = START;}
|
||||
protected:
|
||||
virtual int DecodeInternal(void* src, size_t size, int is_keyframe, CImage* pImage) = 0;
|
||||
virtual void StartInternal()=0;
|
||||
virtual void StopInternal()=0;
|
||||
|
||||
const CodecInfo& record;
|
||||
DecodingMode m_Mode; // should we do precaching (or even change Quality on the fly)
|
||||
DecodingState m_State;
|
||||
int m_iDecpos;
|
||||
int m_iPlaypos;
|
||||
float m_fQuality; // quality for the progress bar 0..1(best)
|
||||
bool m_bCapable16b;
|
||||
|
||||
BITMAPINFOHEADER* m_bh; // format of input data (might be larger - e.g. huffyuv)
|
||||
BitmapInfo m_decoder; // format of decoder output
|
||||
BitmapInfo m_obh; // format of returned frames
|
||||
};
|
||||
|
||||
struct IRtConfig
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue