comparison libmpcodecs/vd_vfwex.c @ 7175:f8b147aab1a5

vfwex separated from vfw, to work with new vfm system and dlopen
author arpi
date Fri, 30 Aug 2002 20:47:18 +0000
parents
children 42222161de9b
comparison
equal deleted inserted replaced
7174:7672615cc811 7175:f8b147aab1a5
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include "config.h"
5 #ifdef USE_WIN32DLL
6
7 #include "mp_msg.h"
8 #include "help_mp.h"
9
10 #include "vd_internal.h"
11
12 #include "dll_init.h"
13
14 static vd_info_t info_vfwex = {
15 "Win32/VfWex video codecs",
16 "vfwex",
17 VFM_VFWEX,
18 "A'rpi",
19 "based on http://avifile.sf.net",
20 "win32 codecs"
21 };
22
23 LIBVD_EXTERN(vfwex)
24
25 // to set/get/query special features/parameters
26 static int control(sh_video_t *sh,int cmd,void* arg,...){
27 switch(cmd){
28 case VDCTRL_QUERY_MAX_PP_LEVEL:
29 return 9;
30 case VDCTRL_SET_PP_LEVEL:
31 vfw_set_postproc(sh,10*(*((int*)arg)));
32 return CONTROL_OK;
33 }
34 return CONTROL_UNKNOWN;
35 }
36
37 // init driver
38 static int init(sh_video_t *sh){
39 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
40 if(!init_vfw_video_codec(sh,1)) return 0;
41 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n");
42 return 1;
43 }
44
45 // uninit driver
46 static void uninit(sh_video_t *sh){
47 vfw_close_video_codec(sh, 1);
48 }
49
50 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
51
52 // decode a frame
53 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
54 mp_image_t* mpi;
55 int ret;
56 if(len<=0) return NULL; // skipped frame
57
58 mpi=mpcodecs_get_image(sh,
59 (sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_STATIC) ?
60 MP_IMGTYPE_STATIC : MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_WIDTH,
61 sh->disp_w, sh->disp_h);
62 if(!mpi){ // temporary!
63 printf("couldn't allocate image for cinepak codec\n");
64 return NULL;
65 }
66
67 // set buffer:
68 sh->our_out_buffer=mpi->planes[0];
69
70 // set stride: (trick discovered by Andreas Ackermann - thanx!)
71 sh->bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8);
72 sh->o_bih.biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8);
73
74 if((ret=vfw_decode_video(sh,data,len,flags&3,1))){
75 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%d\n",ret);
76 return NULL;
77 }
78
79 if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){
80 // export palette:
81 // FIXME: sh->o_bih is cutted down to 40 bytes!!!
82 // if(sh->o_bih->biSize>40)
83 // mpi->planes[1]=((unsigned char*)&sh->o_bih)+40;
84 // else
85 mpi->planes[1]=NULL;
86 }
87
88 return mpi;
89 }
90
91 #endif