2010-01-30 16:57:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2010-02-21 12:48:56 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#if HAVE_MALLOC_H
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
2002-11-26 22:55:32 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "mp_msg.h"
|
|
|
|
|
|
|
|
#include "vd_internal.h"
|
|
|
|
|
|
|
|
#include "loader/dmo/DMO_VideoDecoder.h"
|
|
|
|
|
2008-04-24 05:43:56 +00:00
|
|
|
static const vd_info_t info = {
|
2002-11-26 22:55:32 +00:00
|
|
|
"DMO video codecs",
|
|
|
|
"dmo",
|
|
|
|
"A'rpi",
|
|
|
|
"based on http://avifile.sf.net",
|
|
|
|
"win32 codecs"
|
|
|
|
};
|
|
|
|
|
|
|
|
LIBVD_EXTERN(dmo)
|
|
|
|
|
2010-02-18 23:11:27 +00:00
|
|
|
struct context {
|
|
|
|
void *decoder;
|
|
|
|
uint8_t *buffer;
|
|
|
|
int stride;
|
|
|
|
};
|
|
|
|
|
2002-11-26 22:55:32 +00:00
|
|
|
// to set/get/query special features/parameters
|
|
|
|
static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
|
|
return CONTROL_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// init driver
|
|
|
|
static int init(sh_video_t *sh){
|
2010-03-03 21:32:31 +00:00
|
|
|
unsigned int out_fmt=sh->codec->outfmt[0];
|
2010-02-18 23:11:27 +00:00
|
|
|
struct context *ctx;
|
|
|
|
void *decoder;
|
|
|
|
if(!(decoder=DMO_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll);
|
|
|
|
mp_tmsg(MSGT_DECVIDEO,MSGL_HINT,"You need to upgrade/install the binary codecs package.\nGo to http://www.mplayerhq.hu/dload.html\n");
|
2002-11-26 22:55:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-02-18 22:28:55 +00:00
|
|
|
if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,out_fmt)) return 0;
|
2010-03-03 21:32:31 +00:00
|
|
|
// mpcodecs_config_vo can change the format
|
|
|
|
out_fmt=sh->codec->outfmt[sh->outfmtidx];
|
2010-02-18 23:11:27 +00:00
|
|
|
sh->context = ctx = calloc(1, sizeof(*ctx));
|
|
|
|
ctx->decoder = decoder;
|
2002-11-26 22:55:32 +00:00
|
|
|
switch(out_fmt){
|
|
|
|
case IMGFMT_YUY2:
|
|
|
|
case IMGFMT_UYVY:
|
2010-02-18 23:11:27 +00:00
|
|
|
DMO_VideoDecoder_SetDestFmt(ctx->decoder,16,out_fmt);break; // packed YUV
|
2002-11-26 22:55:32 +00:00
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_IYUV:
|
2010-02-18 23:11:27 +00:00
|
|
|
DMO_VideoDecoder_SetDestFmt(ctx->decoder,12,out_fmt);break; // planar YUV
|
2002-11-26 22:55:32 +00:00
|
|
|
case IMGFMT_YVU9:
|
2010-02-18 23:11:27 +00:00
|
|
|
DMO_VideoDecoder_SetDestFmt(ctx->decoder,9,out_fmt);break;
|
|
|
|
case IMGFMT_RGB24:
|
|
|
|
case IMGFMT_BGR24:
|
|
|
|
if (sh->disp_w & 3)
|
|
|
|
{
|
|
|
|
ctx->stride = ((sh->disp_w * 3) + 3) & ~3;
|
2010-04-20 04:33:00 +00:00
|
|
|
ctx->buffer = av_malloc(ctx->stride * sh->disp_h);
|
2010-02-18 23:11:27 +00:00
|
|
|
}
|
2002-11-26 22:55:32 +00:00
|
|
|
default:
|
2010-02-18 23:11:27 +00:00
|
|
|
DMO_VideoDecoder_SetDestFmt(ctx->decoder,out_fmt&255,0); // RGB/BGR
|
2002-11-26 22:55:32 +00:00
|
|
|
}
|
2010-02-18 23:11:27 +00:00
|
|
|
DMO_VideoDecoder_StartInternal(ctx->decoder);
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMO video codec init OK.\n");
|
2002-11-26 22:55:32 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// uninit driver
|
|
|
|
static void uninit(sh_video_t *sh){
|
2010-02-18 23:11:27 +00:00
|
|
|
struct context *ctx = sh->context;
|
|
|
|
DMO_VideoDecoder_Destroy(ctx->decoder);
|
2010-04-20 04:33:00 +00:00
|
|
|
av_free(ctx->buffer);
|
2010-02-18 23:11:27 +00:00
|
|
|
free(ctx);
|
|
|
|
sh->context = NULL;
|
2002-11-26 22:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
|
|
|
|
|
|
|
|
// decode a frame
|
|
|
|
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
2010-02-18 23:11:27 +00:00
|
|
|
struct context *ctx = sh->context;
|
|
|
|
uint8_t *buffer = ctx->buffer;
|
|
|
|
int type = ctx->buffer ? MP_IMGTYPE_EXPORT : MP_IMGTYPE_TEMP;
|
2002-11-26 22:55:32 +00:00
|
|
|
mp_image_t* mpi;
|
|
|
|
if(len<=0) return NULL; // skipped frame
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-26 22:55:32 +00:00
|
|
|
if(flags&3){
|
|
|
|
// framedrop:
|
2010-02-18 23:11:27 +00:00
|
|
|
DMO_VideoDecoder_DecodeInternal(ctx->decoder, data, len, 0, 0);
|
2002-11-26 22:55:32 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2010-02-18 23:11:27 +00:00
|
|
|
mpi=mpcodecs_get_image(sh, type, MP_IMGFLAG_COMMON_PLANE,
|
2002-11-26 22:55:32 +00:00
|
|
|
sh->disp_w, sh->disp_h);
|
2010-02-18 23:11:27 +00:00
|
|
|
if (buffer) {
|
|
|
|
mpi->planes[0] = buffer;
|
|
|
|
mpi->stride[0] = ctx->stride;
|
|
|
|
} else {
|
|
|
|
buffer = mpi->planes[0];
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-11-26 22:55:32 +00:00
|
|
|
if(!mpi){ // temporary!
|
2009-07-06 22:15:02 +00:00
|
|
|
mp_tmsg(MSGT_DECVIDEO,MSGL_WARN,"[VD_DMO] Couldn't allocate image for cinepak codec.\n");
|
2002-11-26 22:55:32 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-02-18 23:11:27 +00:00
|
|
|
DMO_VideoDecoder_DecodeInternal(ctx->decoder, data, len, 1, buffer);
|
2002-11-26 22:55:32 +00:00
|
|
|
|
|
|
|
return mpi;
|
|
|
|
}
|