annotate libmpcodecs/vd_vfw.c @ 7131:1943b619990c

Sipro audio now supported.
author diego
date Thu, 29 Aug 2002 01:56:09 +0000
parents e69615f1c309
children f8b147aab1a5
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 "vd_internal.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
11
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
12 #include "dll_init.h"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
13
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
14 static vd_info_t info_vfw = {
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
15 "Win32/VfW video codecs",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
16 "vfw",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
17 VFM_VFW,
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
18 "A'rpi",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
19 "based on http://avifile.sf.net",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
20 "win32 codecs"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
21 };
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
22
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
23 static vd_info_t info_vfwex = {
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
24 "Win32/VfWex video codecs",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
25 "vfwex",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
26 VFM_VFWEX,
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
27 "A'rpi",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
28 "based on http://avifile.sf.net",
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
29 "win32 codecs"
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
30 };
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
31
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
32 #define info info_vfw
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
33 LIBVD_EXTERN(vfw)
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
34 #undef info
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
35
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
36 #define info info_vfwex
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
37 LIBVD_EXTERN(vfwex)
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
38 #undef info
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
39
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
40 // to set/get/query special features/parameters
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
41 static int control(sh_video_t *sh,int cmd,void* arg,...){
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
42 switch(cmd){
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
43 case VDCTRL_QUERY_MAX_PP_LEVEL:
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
44 return 9;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
45 case VDCTRL_SET_PP_LEVEL:
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
46 vfw_set_postproc(sh,10*(*((int*)arg)));
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
47 return CONTROL_OK;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
48 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
49 return CONTROL_UNKNOWN;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
50 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
51
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
52 // init driver
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
53 static int init(sh_video_t *sh){
5153
7091d4c46685 fixed colorspace detection
arpi
parents: 5124
diff changeset
54 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
4968
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
55 if(!init_vfw_video_codec(sh,(sh->codec->driver==VFM_VFWEX))) return 0;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
56 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n");
5153
7091d4c46685 fixed colorspace detection
arpi
parents: 5124
diff changeset
57 return 1;
4968
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 // uninit driver
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
61 static void uninit(sh_video_t *sh){
5451
b716977c47d9 added vfw uninit
alex
parents: 5153
diff changeset
62 vfw_close_video_codec(sh, (sh->codec->driver==VFM_VFWEX));
4968
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
63 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
64
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
65 //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
66
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
67 // decode a frame
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
68 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
69 mp_image_t* mpi;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
70 int ret;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
71 if(len<=0) return NULL; // skipped frame
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
72
6105
b77b984120f9 iive is right - we shouldn't use IP buffering for vfw. it was changed
arpi
parents: 5769
diff changeset
73 mpi=mpcodecs_get_image(sh,
b77b984120f9 iive is right - we shouldn't use IP buffering for vfw. it was changed
arpi
parents: 5769
diff changeset
74 (sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_STATIC) ?
b77b984120f9 iive is right - we shouldn't use IP buffering for vfw. it was changed
arpi
parents: 5769
diff changeset
75 MP_IMGTYPE_STATIC : MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_WIDTH,
4968
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
76 sh->disp_w, sh->disp_h);
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
77 if(!mpi){ // temporary!
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
78 printf("couldn't allocate image for cinepak codec\n");
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
79 return NULL;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
80 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
81
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
82 // set buffer:
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
83 sh->our_out_buffer=mpi->planes[0];
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
84
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
85 // set stride: (trick discovered by Andreas Ackermann - thanx!)
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
86 sh->bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8);
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
87 sh->o_bih.biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8);
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
88
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
89 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
90 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%d\n",ret);
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
91 return NULL;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
92 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
93
5769
f28c734f20b3 export palette for rgb8/bgr8
arpi
parents: 5451
diff changeset
94 if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){
f28c734f20b3 export palette for rgb8/bgr8
arpi
parents: 5451
diff changeset
95 // export palette:
6232
f8e0eac1256c grayscaled palette support
arpi
parents: 6105
diff changeset
96 // FIXME: sh->o_bih is cutted down to 40 bytes!!!
f8e0eac1256c grayscaled palette support
arpi
parents: 6105
diff changeset
97 // if(sh->o_bih->biSize>40)
f8e0eac1256c grayscaled palette support
arpi
parents: 6105
diff changeset
98 // mpi->planes[1]=((unsigned char*)&sh->o_bih)+40;
f8e0eac1256c grayscaled palette support
arpi
parents: 6105
diff changeset
99 // else
f8e0eac1256c grayscaled palette support
arpi
parents: 6105
diff changeset
100 mpi->planes[1]=NULL;
5769
f28c734f20b3 export palette for rgb8/bgr8
arpi
parents: 5451
diff changeset
101 }
f28c734f20b3 export palette for rgb8/bgr8
arpi
parents: 5451
diff changeset
102
4968
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
103 return mpi;
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
104 }
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
105
236b06410b03 vfw, vfwex, odivx, divx4 added
arpi
parents:
diff changeset
106 #endif