annotate libmpcodecs/vd_vfwex.c @ 7176:42222161de9b

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