annotate libmpcodecs/ve_vfw.c @ 7202:b414c2e34b2e

removed buggy fd<0 check for disallowing dumpstream/cache
author arpi
date Sat, 31 Aug 2002 15:44:41 +0000
parents 1e47c2e7aa8e
children 1e84415320d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
1 #include <stdio.h>
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
2 #include <stdlib.h>
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
3 #include <string.h>
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
4
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
5 #include "../config.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
6 #ifdef USE_WIN32DLL
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
7
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
8 #include "../mp_msg.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
9
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
10 #include "codec-cfg.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
11 #include "stream.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
12 #include "demuxer.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
13 #include "stheader.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
14
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
15 #include "aviwrite.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
16
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
17 #include "img_format.h"
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
18 #include "mp_image.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
19 #include "vf.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
20
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6083
diff changeset
21 extern void mencoder_write_chunk(aviwrite_stream_t *s,int len,unsigned int flags);
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6083
diff changeset
22
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
23 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
24
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
25 #include "dll_init.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
26
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
27 static char *vfw_param_codec = NULL;
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
28
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
29 #include "cfgparser.h"
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
30
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
31 struct config vfwopts_conf[]={
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
32 {"codec", &vfw_param_codec, CONF_TYPE_STRING, 0, 0, 0, NULL},
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
33 {NULL, NULL, 0, 0, 0, 0, NULL}
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
34 };
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
35
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
36 struct vf_priv_s {
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
37 aviwrite_stream_t* mux;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
38 BITMAPINFOHEADER* bih;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
39 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
40
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
41 #define mux_v (vf->priv->mux)
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
42 #define vfw_bih (vf->priv->bih)
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
43
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
44 static int config(struct vf_instance_s* vf,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
45 int width, int height, int d_width, int d_height,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
46 unsigned int flags, unsigned int outfmt){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
47
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
48 vfw_bih->biWidth=width;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
49 vfw_bih->biHeight=height;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
50 vfw_bih->biSizeImage=width*height*((vfw_bih->biBitCount+7)/8);
5551
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
51
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
52 if(!vfw_start_encoder(vfw_bih, mux_v->bih)) return 0;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
53
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
54 // mux_v->bih->biWidth=width;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
55 // mux_v->bih->biHeight=height;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
56 // mux_v->bih->biSizeImage=width*height*((mux_v->bih->biBitCount+7)/8);
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
57
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
58 return 1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
59 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
60
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
61 static int control(struct vf_instance_s* vf, int request, void* data){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
62
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
63 return CONTROL_UNKNOWN;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
64 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
65
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
66 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
5565
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5551
diff changeset
67 if(fmt==IMGFMT_BGR24) return 3 | VFCAP_FLIPPED;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
68 return 0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
69 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
70
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
71 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
72 long flags=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
73 int ret;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
74 // flip_upside_down(vo_image_ptr,vo_image_ptr,3*vo_w,vo_h); // dirty hack
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
75 ret=vfw_encode_frame(mux_v->bih, mux_v->buffer, vfw_bih, mpi->planes[0], &flags, 10000);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
76 mencoder_write_chunk(mux_v,mux_v->bih->biSizeImage,flags);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
77 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
78
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
79 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
80
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
81 static int vf_open(vf_instance_t *vf, char* args){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
82 vf->config=config;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
83 vf->control=control;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
84 vf->query_format=query_format;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
85 vf->put_image=put_image;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
86 vf->priv=malloc(sizeof(struct vf_priv_s));
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
87 memset(vf->priv,0,sizeof(struct vf_priv_s));
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6083
diff changeset
88 vf->priv->mux=(aviwrite_stream_t*)args;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
89
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
90 vfw_bih=malloc(sizeof(BITMAPINFOHEADER));
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
91 vfw_bih->biSize=sizeof(BITMAPINFOHEADER);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
92 vfw_bih->biWidth=0; // FIXME ?
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
93 vfw_bih->biHeight=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
94 vfw_bih->biPlanes=1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
95 vfw_bih->biBitCount=24;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
96 vfw_bih->biCompression=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
97 // vfw_bih->biSizeImage=vo_w*vo_h*((vfw_bih->biBitCount+7)/8);
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
98
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
99 if (!vfw_param_codec)
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
100 {
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
101 printf("No VfW codec specified! It's required!\n");
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
102 return 0;
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
103 }
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
104 // mux_v->bih=vfw_open_encoder("divxc32.dll",vfw_bih,mmioFOURCC('D', 'I', 'V', '3'));
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
105 // mux_v->bih=vfw_open_encoder("AvidAVICodec.dll",vfw_bih, 0);
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
106 mux_v->bih = vfw_open_encoder(vfw_param_codec, vfw_bih, 0);
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
107 if(!mux_v->bih) return 0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
108
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
109 return 1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
110 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
111
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
112 vf_info_t ve_info_vfw = {
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
113 "Win32/VfW encoders",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
114 "vfw",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
115 "A'rpi",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
116 "for internal use by mencoder",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
117 vf_open
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
118 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
119
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
120 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
121 #endif