5550
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <string.h>
|
|
4
|
|
5 #include "../config.h"
|
|
6 #ifdef USE_WIN32DLL
|
|
7
|
|
8 #include "../mp_msg.h"
|
|
9
|
|
10 #include "codec-cfg.h"
|
|
11 #include "stream.h"
|
|
12 #include "demuxer.h"
|
|
13 #include "stheader.h"
|
|
14
|
|
15 #include "aviwrite.h"
|
|
16
|
|
17 #include "../libvo/img_format.h"
|
|
18 #include "../mp_image.h"
|
|
19 #include "vf.h"
|
|
20
|
|
21 //===========================================================================//
|
|
22
|
|
23 #include "dll_init.h"
|
|
24
|
|
25 struct vf_priv_s {
|
|
26 aviwrite_stream_t* mux;
|
|
27 BITMAPINFOHEADER* bih;
|
|
28 };
|
|
29
|
|
30 #define mux_v (vf->priv->mux)
|
|
31 #define vfw_bih (vf->priv->bih)
|
|
32
|
|
33 static int config(struct vf_instance_s* vf,
|
|
34 int width, int height, int d_width, int d_height,
|
|
35 unsigned int flags, unsigned int outfmt){
|
|
36
|
|
37 vfw_bih->biWidth=width;
|
|
38 vfw_bih->biHeight=height;
|
|
39 vfw_bih->biSizeImage=width*height*((vfw_bih->biBitCount+7)/8);
|
5551
|
40
|
|
41 if(!vfw_start_encoder(vfw_bih, mux_v->bih)) return 0;
|
|
42
|
|
43 // mux_v->bih->biWidth=width;
|
|
44 // mux_v->bih->biHeight=height;
|
|
45 // mux_v->bih->biSizeImage=width*height*((mux_v->bih->biBitCount+7)/8);
|
5550
|
46
|
|
47 return 1;
|
|
48 }
|
|
49
|
|
50 static int control(struct vf_instance_s* vf, int request, void* data){
|
|
51
|
|
52 return CONTROL_UNKNOWN;
|
|
53 }
|
|
54
|
|
55 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
|
|
56 if(fmt==IMGFMT_BGR24) return 1;
|
|
57 return 0;
|
|
58 }
|
|
59
|
|
60 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
|
61 long flags=0;
|
|
62 int ret;
|
|
63 // flip_upside_down(vo_image_ptr,vo_image_ptr,3*vo_w,vo_h); // dirty hack
|
|
64 ret=vfw_encode_frame(mux_v->bih, mux_v->buffer, vfw_bih, mpi->planes[0], &flags, 10000);
|
|
65 mencoder_write_chunk(mux_v,mux_v->bih->biSizeImage,flags);
|
|
66 }
|
|
67
|
|
68 //===========================================================================//
|
|
69
|
|
70 static int vf_open(vf_instance_t *vf, char* args){
|
|
71 vf->config=config;
|
|
72 vf->control=control;
|
|
73 vf->query_format=query_format;
|
|
74 vf->put_image=put_image;
|
|
75 vf->priv=malloc(sizeof(struct vf_priv_s));
|
|
76 memset(vf->priv,0,sizeof(struct vf_priv_s));
|
|
77 vf->priv->mux=args;
|
|
78
|
|
79 vfw_bih=malloc(sizeof(BITMAPINFOHEADER));
|
|
80 vfw_bih->biSize=sizeof(BITMAPINFOHEADER);
|
|
81 vfw_bih->biWidth=0; // FIXME ?
|
|
82 vfw_bih->biHeight=0;
|
|
83 vfw_bih->biPlanes=1;
|
|
84 vfw_bih->biBitCount=24;
|
|
85 vfw_bih->biCompression=0;
|
|
86 // vfw_bih->biSizeImage=vo_w*vo_h*((vfw_bih->biBitCount+7)/8);
|
|
87 // mux_v->bih=vfw_open_encoder("divxc32.dll",vfw_bih,mmioFOURCC('D', 'I', 'V', '3'));
|
|
88 mux_v->bih=vfw_open_encoder("AvidAVICodec.dll",vfw_bih, 0);
|
|
89 if(!mux_v->bih) return 0;
|
|
90
|
|
91 return 1;
|
|
92 }
|
|
93
|
|
94 vf_info_t ve_info_vfw = {
|
|
95 "Win32/VfW encoders",
|
|
96 "vfw",
|
|
97 "A'rpi",
|
|
98 "for internal use by mencoder",
|
|
99 vf_open
|
|
100 };
|
|
101
|
|
102 //===========================================================================//
|
|
103 #endif
|