annotate libmpcodecs/vd_vfw.c @ 4968:236b06410b03

vfw, vfwex, odivx, divx4 added
author arpi
date Thu, 07 Mar 2002 00:44:58 +0000
parents
children eb57973314ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4968
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
1 #include <stdio.h>
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
2 #include <stdlib.h>
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
3
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
4 #include "config.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
5 #ifdef USE_WIN32DLL
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
6
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
7 #include "mp_msg.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
8 #include "help_mp.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
9
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
10 #include "codec-cfg.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
11 #include "../libvo/img_format.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
12
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
13 #include "stream.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
14 #include "demuxer.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
15 #include "stheader.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
16
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
17 #include "vd.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
18 #include "vd_internal.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
19
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
20 #include "dll_init.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
21
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
22 static vd_info_t info_vfw = {
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
23 "Win32/VfW video codecs",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
24 "vfw",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
25 VFM_VFW,
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
26 "A'rpi",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
27 "based on http://avifile.sf.net",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
28 "win32 codecs"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
29 };
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
30
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
31 static vd_info_t info_vfwex = {
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
32 "Win32/VfWex video codecs",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
33 "vfwex",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
34 VFM_VFWEX,
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
35 "A'rpi",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
36 "based on http://avifile.sf.net",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
37 "win32 codecs"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
38 };
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
39
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
40 #define info info_vfw
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
41 LIBVD_EXTERN(vfw)
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
42 #undef info
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
43
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
44 #define info info_vfwex
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
45 LIBVD_EXTERN(vfwex)
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
46 #undef info
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
47
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
48 // to set/get/query special features/parameters
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
49 static int control(sh_video_t *sh,int cmd,void* arg,...){
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
50 switch(cmd){
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
51 case VDCTRL_QUERY_MAX_PP_LEVEL:
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
52 return 9;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
53 case VDCTRL_SET_PP_LEVEL:
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
54 vfw_set_postproc(sh,10*(*((int*)arg)));
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
55 return CONTROL_OK;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
56 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
57 return CONTROL_UNKNOWN;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
58 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
59
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
60 // init driver
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
61 static int init(sh_video_t *sh){
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
62 unsigned int out_fmt;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
63 if(!init_vfw_video_codec(sh,(sh->codec->driver==VFM_VFWEX))) return 0;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
64 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n");
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
65 mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2);
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
66 // out_fmt=sh->codec->outfmt[sh->outfmtidx];
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
67 return 1;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
68 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
69
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
70 // uninit driver
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
71 static void uninit(sh_video_t *sh){
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
72
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
73 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
74
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
75 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
76
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
77 // decode a frame
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
78 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
79 mp_image_t* mpi;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
80 int ret;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
81 if(len<=0) return NULL; // skipped frame
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
82
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
83 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_IP, MP_IMGFLAG_ACCEPT_WIDTH,
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
84 sh->disp_w, sh->disp_h);
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
85 if(!mpi){ // temporary!
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
86 printf("couldn't allocate image for cinepak codec\n");
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
87 return NULL;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
88 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
89
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
90 // set buffer:
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
91 sh->our_out_buffer=mpi->planes[0];
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
92
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
93 // set stride: (trick discovered by Andreas Ackermann - thanx!)
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
94 sh->bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8);
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
95 sh->o_bih.biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8);
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
96
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
97 if((ret=vfw_decode_video(sh,data,len,flags&3,(sh->codec->driver==VFM_VFWEX) ))){
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
98 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%d\n",ret);
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
99 return NULL;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
100 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
101
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
102 return mpi;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
103 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
104
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
105 #endif