annotate libmpcodecs/ve_vfw.c @ 6674:f8551f89dd48

MEncoder vobsub ripping support, currently not compatible with windows vobsub, some bugs to be fixed. However it already works with mplayer, so it's a start.
author atmos4
date Mon, 08 Jul 2002 21:44:51 +0000
parents 6aa4fc282fc7
children 1e47c2e7aa8e
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
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
21 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
22
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
23 #include "dll_init.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
24
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
25 static char *vfw_param_codec = NULL;
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
26
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
27 #include "cfgparser.h"
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
28
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
29 struct config vfwopts_conf[]={
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
30 {"codec", &vfw_param_codec, CONF_TYPE_STRING, 0, 0, 0, NULL},
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
31 {NULL, NULL, 0, 0, 0, 0, NULL}
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
32 };
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
33
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
34 struct vf_priv_s {
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
35 aviwrite_stream_t* mux;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
36 BITMAPINFOHEADER* bih;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
37 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
38
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
39 #define mux_v (vf->priv->mux)
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
40 #define vfw_bih (vf->priv->bih)
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
41
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
42 static int config(struct vf_instance_s* vf,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
43 int width, int height, int d_width, int d_height,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
44 unsigned int flags, unsigned int outfmt){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
45
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
46 vfw_bih->biWidth=width;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
47 vfw_bih->biHeight=height;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
48 vfw_bih->biSizeImage=width*height*((vfw_bih->biBitCount+7)/8);
5551
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
49
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
50 if(!vfw_start_encoder(vfw_bih, mux_v->bih)) return 0;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
51
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
52 // mux_v->bih->biWidth=width;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
53 // mux_v->bih->biHeight=height;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
54 // mux_v->bih->biSizeImage=width*height*((mux_v->bih->biBitCount+7)/8);
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
55
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
56 return 1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
57 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
58
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
59 static int control(struct vf_instance_s* vf, int request, void* data){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
60
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
61 return CONTROL_UNKNOWN;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
62 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
63
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
64 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
65 if(fmt==IMGFMT_BGR24) return 3 | VFCAP_FLIPPED;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
66 return 0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
67 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
68
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
69 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
70 long flags=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
71 int ret;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
72 // flip_upside_down(vo_image_ptr,vo_image_ptr,3*vo_w,vo_h); // dirty hack
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
73 ret=vfw_encode_frame(mux_v->bih, mux_v->buffer, vfw_bih, mpi->planes[0], &flags, 10000);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
74 mencoder_write_chunk(mux_v,mux_v->bih->biSizeImage,flags);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
75 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
76
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
77 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
78
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
79 static int vf_open(vf_instance_t *vf, char* args){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
80 vf->config=config;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
81 vf->control=control;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
82 vf->query_format=query_format;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
83 vf->put_image=put_image;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
84 vf->priv=malloc(sizeof(struct vf_priv_s));
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
85 memset(vf->priv,0,sizeof(struct vf_priv_s));
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
86 vf->priv->mux=args;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
87
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
88 vfw_bih=malloc(sizeof(BITMAPINFOHEADER));
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
89 vfw_bih->biSize=sizeof(BITMAPINFOHEADER);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
90 vfw_bih->biWidth=0; // FIXME ?
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
91 vfw_bih->biHeight=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
92 vfw_bih->biPlanes=1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
93 vfw_bih->biBitCount=24;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
94 vfw_bih->biCompression=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
95 // vfw_bih->biSizeImage=vo_w*vo_h*((vfw_bih->biBitCount+7)/8);
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
96
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
97 if (!vfw_param_codec)
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
98 {
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
99 printf("No VfW codec specified! It's required!\n");
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
100 return 0;
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
101 }
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
102 // 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
103 // mux_v->bih=vfw_open_encoder("AvidAVICodec.dll",vfw_bih, 0);
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
104 mux_v->bih = vfw_open_encoder(vfw_param_codec, vfw_bih, 0);
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
105 if(!mux_v->bih) return 0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
106
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
107 return 1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
108 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
109
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
110 vf_info_t ve_info_vfw = {
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
111 "Win32/VfW encoders",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
112 "vfw",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
113 "A'rpi",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
114 "for internal use by mencoder",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
115 vf_open
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
116 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
117
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
118 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
119 #endif