Mercurial > mplayer.hg
annotate libmpcodecs/ve_lavc.c @ 6659:715d93d492c3
interlacing support - Klaus Stengel <ks1@inter-ject.de>
author | arpi |
---|---|
date | Sat, 06 Jul 2002 15:20:34 +0000 |
parents | b2f659932839 |
children | d6adae1af0e3 |
rev | line source |
---|---|
5550 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 | |
5 #include "../config.h" | |
6 | |
7 #ifdef USE_LIBAVCODEC | |
8 | |
9 #include "../mp_msg.h" | |
10 #include "../help_mp.h" | |
11 | |
12 #include "codec-cfg.h" | |
13 #include "stream.h" | |
14 #include "demuxer.h" | |
15 #include "stheader.h" | |
16 | |
17 #include "aviwrite.h" | |
18 | |
5607 | 19 #include "img_format.h" |
20 #include "mp_image.h" | |
5550 | 21 #include "vf.h" |
22 | |
23 #include "divx4_vbr.h" | |
24 | |
25 extern int pass; | |
26 extern char* passtmpfile; | |
27 | |
28 //===========================================================================// | |
29 | |
30 #ifdef USE_LIBAVCODEC_SO | |
31 #include <libffmpeg/avcodec.h> | |
32 #else | |
33 #include "libavcodec/avcodec.h" | |
34 #endif | |
35 | |
5778 | 36 #if LIBAVCODEC_BUILD < 4601 |
37 #error your version of libavcodec is too old, get a newer one, and dont send a bugreport, THIS IS NO BUG | |
38 #endif | |
39 | |
5550 | 40 extern int avcodec_inited; |
41 | |
42 /* video options */ | |
43 static char *lavc_param_vcodec = NULL; | |
44 static int lavc_param_vbitrate = -1; | |
45 static int lavc_param_vrate_tolerance = 1024*8; | |
46 static int lavc_param_vhq = 0; /* default is realtime encoding */ | |
47 static int lavc_param_v4mv = 0; | |
5556 | 48 static int lavc_param_vme = 4; |
5550 | 49 static int lavc_param_vqscale = 0; |
50 static int lavc_param_vqmin = 3; | |
51 static int lavc_param_vqmax = 15; | |
52 static int lavc_param_vqdiff = 3; | |
53 static float lavc_param_vqcompress = 0.5; | |
54 static float lavc_param_vqblur = 0.5; | |
5778 | 55 static float lavc_param_vb_qfactor = 2.0; |
6228
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
56 static float lavc_param_vb_qoffset = 0.0; |
5657
ee2efbf3dc9d
Preliminary support for lavcs b-frame encoding, disabled by default.
atmos4
parents:
5646
diff
changeset
|
57 static int lavc_param_vmax_b_frames = 0; |
5550 | 58 static int lavc_param_keyint = -1; |
5778 | 59 static int lavc_param_vpass = 0; |
60 static int lavc_param_vrc_strategy = 2; | |
61 static int lavc_param_vb_strategy = 0; | |
6255
140e94c4c89b
single coefficient elimination disabled by default
michael
parents:
6228
diff
changeset
|
62 static int lavc_param_luma_elim_threshold = 0; |
140e94c4c89b
single coefficient elimination disabled by default
michael
parents:
6228
diff
changeset
|
63 static int lavc_param_chroma_elim_threshold = 0; |
6228
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
64 static int lavc_param_packet_size= 0; |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
65 static int lavc_param_strict= 0; |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
66 static int lavc_param_data_partitioning= 0; |
6461 | 67 static int lavc_param_gray=0; |
5550 | 68 |
69 #include "cfgparser.h" | |
70 | |
71 #ifdef USE_LIBAVCODEC | |
72 struct config lavcopts_conf[]={ | |
73 {"vcodec", &lavc_param_vcodec, CONF_TYPE_STRING, 0, 0, 0, NULL}, | |
74 {"vbitrate", &lavc_param_vbitrate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL}, | |
75 {"vratetol", &lavc_param_vrate_tolerance, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL}, | |
76 {"vhq", &lavc_param_vhq, CONF_TYPE_FLAG, 0, 0, 1, NULL}, | |
77 {"v4mv", &lavc_param_v4mv, CONF_TYPE_FLAG, 0, 0, 1, NULL}, | |
78 {"vme", &lavc_param_vme, CONF_TYPE_INT, CONF_RANGE, 0, 5, NULL}, | |
79 {"vqscale", &lavc_param_vqscale, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, | |
80 {"vqmin", &lavc_param_vqmin, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, | |
81 {"vqmax", &lavc_param_vqmax, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, | |
82 {"vqdiff", &lavc_param_vqdiff, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, | |
83 {"vqcomp", &lavc_param_vqcompress, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL}, | |
84 {"vqblur", &lavc_param_vqblur, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL}, | |
5778 | 85 {"vb_qfactor", &lavc_param_vb_qfactor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 31.0, NULL}, |
5657
ee2efbf3dc9d
Preliminary support for lavcs b-frame encoding, disabled by default.
atmos4
parents:
5646
diff
changeset
|
86 {"vmax_b_frames", &lavc_param_vmax_b_frames, CONF_TYPE_INT, CONF_RANGE, 0, FF_MAX_B_FRAMES, NULL}, |
5778 | 87 {"vpass", &lavc_param_vpass, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL}, |
88 {"vrc_strategy", &lavc_param_vrc_strategy, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL}, | |
89 {"vb_strategy", &lavc_param_vb_strategy, CONF_TYPE_INT, CONF_RANGE, 0, 1, NULL}, | |
6228
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
90 #ifdef CODEC_FLAG_PART |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
91 {"vb_qoffset", &lavc_param_vb_qoffset, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 31.0, NULL}, |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
92 {"vlelim", &lavc_param_luma_elim_threshold, CONF_TYPE_INT, CONF_RANGE, 0, 99, NULL}, |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
93 {"vcelim", &lavc_param_chroma_elim_threshold, CONF_TYPE_INT, CONF_RANGE, 0, 99, NULL}, |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
94 {"vpsize", &lavc_param_packet_size, CONF_TYPE_INT, CONF_RANGE, 0, 100000000, NULL}, |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
95 {"vstrict", &lavc_param_strict, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
96 {"vdpart", &lavc_param_data_partitioning, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART, NULL}, |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
97 #endif |
5550 | 98 {"keyint", &lavc_param_keyint, CONF_TYPE_INT, 0, 0, 0, NULL}, |
6461 | 99 #if LIBAVCODEC_BUILD >= 4614 |
100 {"gray", &lavc_param_gray, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART, NULL}, | |
101 #endif | |
5550 | 102 {NULL, NULL, 0, 0, 0, 0, NULL} |
103 }; | |
104 #endif | |
105 | |
106 struct vf_priv_s { | |
107 aviwrite_stream_t* mux; | |
108 AVCodecContext context; | |
109 AVCodec *codec; | |
110 }; | |
111 | |
112 #define mux_v (vf->priv->mux) | |
113 #define lavc_venc_context (vf->priv->context) | |
114 | |
115 static int config(struct vf_instance_s* vf, | |
116 int width, int height, int d_width, int d_height, | |
117 unsigned int flags, unsigned int outfmt){ | |
118 | |
119 mux_v->bih->biWidth=width; | |
120 mux_v->bih->biHeight=height; | |
121 mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8); | |
122 | |
123 memset(&lavc_venc_context, 0, sizeof(lavc_venc_context)); | |
124 | |
125 printf("videocodec: libavcodec (%dx%d fourcc=%x [%.4s])\n", | |
126 mux_v->bih->biWidth, mux_v->bih->biHeight, mux_v->bih->biCompression, | |
127 (char *)&mux_v->bih->biCompression); | |
128 | |
129 lavc_venc_context.width = width; | |
130 lavc_venc_context.height = height; | |
5677
a21cab74cde8
bitrate>16000 means bits not kbits - noticed by George Hawkins <george_hawkins@yahoo.com>
arpi
parents:
5657
diff
changeset
|
131 if (lavc_param_vbitrate > 16000) /* != -1 */ |
a21cab74cde8
bitrate>16000 means bits not kbits - noticed by George Hawkins <george_hawkins@yahoo.com>
arpi
parents:
5657
diff
changeset
|
132 lavc_venc_context.bit_rate = lavc_param_vbitrate; |
a21cab74cde8
bitrate>16000 means bits not kbits - noticed by George Hawkins <george_hawkins@yahoo.com>
arpi
parents:
5657
diff
changeset
|
133 else if (lavc_param_vbitrate >= 0) /* != -1 */ |
5550 | 134 lavc_venc_context.bit_rate = lavc_param_vbitrate*1000; |
135 else | |
136 lavc_venc_context.bit_rate = 800000; /* default */ | |
137 lavc_venc_context.bit_rate_tolerance= lavc_param_vrate_tolerance*1000; | |
138 lavc_venc_context.frame_rate = (float)mux_v->h.dwRate/mux_v->h.dwScale * FRAME_RATE_BASE; | |
139 lavc_venc_context.qmin= lavc_param_vqmin; | |
140 lavc_venc_context.qmax= lavc_param_vqmax; | |
141 lavc_venc_context.max_qdiff= lavc_param_vqdiff; | |
142 lavc_venc_context.qcompress= lavc_param_vqcompress; | |
143 lavc_venc_context.qblur= lavc_param_vqblur; | |
5657
ee2efbf3dc9d
Preliminary support for lavcs b-frame encoding, disabled by default.
atmos4
parents:
5646
diff
changeset
|
144 lavc_venc_context.max_b_frames= lavc_param_vmax_b_frames; |
5778 | 145 lavc_venc_context.b_quant_factor= lavc_param_vb_qfactor; |
146 lavc_venc_context.rc_strategy= lavc_param_vrc_strategy; | |
147 lavc_venc_context.b_frame_strategy= lavc_param_vb_strategy; | |
6228
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
148 |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
149 #ifdef CODEC_FLAG_PART |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
150 lavc_venc_context.b_quant_offset= lavc_param_vb_qoffset; |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
151 lavc_venc_context.luma_elim_threshold= lavc_param_luma_elim_threshold; |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
152 lavc_venc_context.chroma_elim_threshold= lavc_param_chroma_elim_threshold; |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
153 lavc_venc_context.rtp_payload_size= lavc_param_packet_size; |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
154 if(lavc_param_packet_size )lavc_venc_context.rtp_mode=1; |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
155 lavc_venc_context.strict_std_compliance= lavc_param_strict; |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
156 #endif |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
157 |
5550 | 158 /* keyframe interval */ |
159 if (lavc_param_keyint >= 0) /* != -1 */ | |
160 lavc_venc_context.gop_size = lavc_param_keyint; | |
161 else | |
162 lavc_venc_context.gop_size = 250; /* default */ | |
163 | |
164 if (lavc_param_vhq) | |
165 { | |
166 printf("High quality encoding selected (non real time)!\n"); | |
167 lavc_venc_context.flags = CODEC_FLAG_HQ; | |
168 } | |
169 else | |
170 lavc_venc_context.flags = 0; | |
171 | |
5781
62e9e0c0bd6a
hq mode in first pass should work (as bad, ehh as well as LQ)
michael
parents:
5778
diff
changeset
|
172 /* 4mv is currently buggy with B frames */ |
62e9e0c0bd6a
hq mode in first pass should work (as bad, ehh as well as LQ)
michael
parents:
5778
diff
changeset
|
173 if (lavc_param_vmax_b_frames > 0 && lavc_param_v4mv) { |
62e9e0c0bd6a
hq mode in first pass should work (as bad, ehh as well as LQ)
michael
parents:
5778
diff
changeset
|
174 printf("4MV with B-Frames not yet supported -> 4MV disabled\n"); |
62e9e0c0bd6a
hq mode in first pass should work (as bad, ehh as well as LQ)
michael
parents:
5778
diff
changeset
|
175 lavc_param_v4mv = 0; |
62e9e0c0bd6a
hq mode in first pass should work (as bad, ehh as well as LQ)
michael
parents:
5778
diff
changeset
|
176 } |
62e9e0c0bd6a
hq mode in first pass should work (as bad, ehh as well as LQ)
michael
parents:
5778
diff
changeset
|
177 |
5550 | 178 lavc_venc_context.flags|= lavc_param_v4mv ? CODEC_FLAG_4MV : 0; |
6228
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
179 #ifdef CODEC_FLAG_PART |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
180 lavc_venc_context.flags|= lavc_param_data_partitioning; |
ea6b20e70ac5
new options to support Michael's libavcodec patch, #ifdefed
arpi
parents:
5977
diff
changeset
|
181 #endif |
6461 | 182 #if LIBAVCODEC_BUILD >= 4614 |
183 if(lavc_param_gray) lavc_venc_context.flags|= CODEC_FLAG_GRAY; | |
184 #endif | |
185 | |
5550 | 186 |
5778 | 187 /* lavc internal 2pass bitrate control */ |
188 if(lavc_param_vpass==1) | |
189 lavc_venc_context.flags|= CODEC_FLAG_PASS1; | |
190 else if(lavc_param_vpass==2) | |
191 lavc_venc_context.flags|= CODEC_FLAG_PASS2; | |
192 | |
5624 | 193 #ifdef ME_ZERO |
194 // workaround Juanjo's stupid incompatible change: | |
5550 | 195 motion_estimation_method = lavc_param_vme; |
5624 | 196 #else |
197 lavc_venc_context.me_method = ME_ZERO+lavc_param_vme; | |
198 #endif | |
5550 | 199 |
200 /* fixed qscale :p */ | |
201 if (lavc_param_vqscale) | |
202 { | |
203 printf("Using constant qscale = %d (VBR)\n", lavc_param_vqscale); | |
204 lavc_venc_context.flags |= CODEC_FLAG_QSCALE; | |
205 lavc_venc_context.quality = lavc_param_vqscale; | |
206 } | |
207 | |
208 switch(pass){ | |
209 case 1: | |
210 if (VbrControl_init_2pass_vbr_analysis(passtmpfile, 5) == -1){ | |
211 mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s\n", passtmpfile); | |
212 pass=0; | |
5781
62e9e0c0bd6a
hq mode in first pass should work (as bad, ehh as well as LQ)
michael
parents:
5778
diff
changeset
|
213 } |
5550 | 214 break; |
215 case 2: | |
216 if (VbrControl_init_2pass_vbr_encoding(passtmpfile, | |
217 lavc_venc_context.bit_rate, | |
218 (float)mux_v->h.dwRate/mux_v->h.dwScale, | |
219 100, /* crispness */ | |
220 5) == -1){ | |
221 mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s\n", passtmpfile); | |
222 pass=0; | |
5632 | 223 } else |
224 lavc_venc_context.flags|=CODEC_FLAG_QSCALE|CODEC_FLAG_TYPE; // VBR | |
5550 | 225 break; |
226 } | |
227 | |
228 if (avcodec_open(&lavc_venc_context, vf->priv->codec) != 0) { | |
229 mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec); | |
230 return 0; | |
231 } | |
232 | |
233 if (lavc_venc_context.codec->encode == NULL) { | |
234 mp_msg(MSGT_MENCODER,MSGL_ERR,"avcodec init failed (ctx->codec->encode == NULL)!\n"); | |
235 return 0; | |
236 } | |
237 | |
238 return 1; | |
239 } | |
240 | |
241 static int control(struct vf_instance_s* vf, int request, void* data){ | |
242 | |
243 return CONTROL_UNKNOWN; | |
244 } | |
245 | |
246 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | |
247 switch(fmt){ | |
248 case IMGFMT_YV12: | |
249 case IMGFMT_IYUV: | |
250 case IMGFMT_I420: | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5556
diff
changeset
|
251 return VFCAP_CSP_SUPPORTED | VFCAP_ACCEPT_STRIDE; |
5550 | 252 } |
253 return 0; | |
254 } | |
255 | |
256 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
257 int out_size; | |
258 AVPicture lavc_venc_picture; | |
259 | |
260 lavc_venc_picture.data[0]=mpi->planes[0]; | |
261 lavc_venc_picture.data[1]=mpi->planes[1]; | |
262 lavc_venc_picture.data[2]=mpi->planes[2]; | |
263 lavc_venc_picture.linesize[0]=mpi->stride[0]; | |
264 lavc_venc_picture.linesize[1]=mpi->stride[1]; | |
265 lavc_venc_picture.linesize[2]=mpi->stride[2]; | |
266 | |
267 if(pass==2){ // handle 2-pass: | |
268 lavc_venc_context.flags|=CODEC_FLAG_QSCALE; // enable VBR | |
269 lavc_venc_context.quality=VbrControl_get_quant(); | |
270 lavc_venc_context.key_frame=VbrControl_get_intra(); | |
271 lavc_venc_context.gop_size=0x3fffffff; | |
272 out_size = avcodec_encode_video(&lavc_venc_context, mux_v->buffer, mux_v->buffer_size, | |
273 &lavc_venc_picture); | |
274 VbrControl_update_2pass_vbr_encoding(lavc_venc_context.mv_bits, | |
275 lavc_venc_context.i_tex_bits+lavc_venc_context.p_tex_bits, | |
276 8*out_size); | |
277 } else { | |
278 out_size = avcodec_encode_video(&lavc_venc_context, mux_v->buffer, mux_v->buffer_size, | |
279 &lavc_venc_picture); | |
280 | |
281 if(pass==1){ | |
282 VbrControl_update_2pass_vbr_analysis(lavc_venc_context.key_frame, | |
283 lavc_venc_context.mv_bits, | |
284 lavc_venc_context.i_tex_bits+lavc_venc_context.p_tex_bits, | |
285 8*out_size, lavc_venc_context.quality); | |
286 } | |
287 | |
288 } | |
289 | |
290 mencoder_write_chunk(mux_v,out_size,lavc_venc_context.key_frame?0x10:0); | |
291 } | |
292 | |
5551 | 293 static void uninit(struct vf_instance_s* vf){ |
294 avcodec_close(&lavc_venc_context); | |
295 } | |
296 | |
5550 | 297 //===========================================================================// |
298 | |
299 static int vf_open(vf_instance_t *vf, char* args){ | |
5551 | 300 vf->uninit=uninit; |
5550 | 301 vf->config=config; |
302 vf->control=control; | |
303 vf->query_format=query_format; | |
304 vf->put_image=put_image; | |
305 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
306 memset(vf->priv,0,sizeof(struct vf_priv_s)); | |
307 vf->priv->mux=args; | |
308 | |
5977
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
309 /* XXX: hack: some of the MJPEG decoder DLL's needs exported huffman |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
310 table, so we define a zero-table, also lavc mjpeg encoder is putting |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
311 huffman tables into the stream, so no problem */ |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
312 if (lavc_param_vcodec && !strcasecmp(lavc_param_vcodec, "mjpeg")) |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
313 { |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
314 mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)+28); |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
315 memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)+28); |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
316 mux_v->bih->biSize=sizeof(BITMAPINFOHEADER)+28; |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
317 } |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
318 else |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
319 { |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
320 mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)); |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
321 memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)); |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
322 mux_v->bih->biSize=sizeof(BITMAPINFOHEADER); |
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
323 } |
5550 | 324 mux_v->bih->biWidth=0; |
325 mux_v->bih->biHeight=0; | |
326 mux_v->bih->biPlanes=1; | |
327 mux_v->bih->biBitCount=24; | |
328 if (!lavc_param_vcodec) | |
329 { | |
5977
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
330 printf("No libavcodec codec specified! It's required!\n"); |
5550 | 331 return 0; |
332 } | |
333 | |
334 if (!strcasecmp(lavc_param_vcodec, "mpeg1") || !strcasecmp(lavc_param_vcodec, "mpeg1video")) | |
335 mux_v->bih->biCompression = mmioFOURCC('m', 'p', 'g', '1'); | |
336 else if (!strcasecmp(lavc_param_vcodec, "h263") || !strcasecmp(lavc_param_vcodec, "h263p")) | |
337 mux_v->bih->biCompression = mmioFOURCC('h', '2', '6', '3'); | |
338 else if (!strcasecmp(lavc_param_vcodec, "rv10")) | |
339 mux_v->bih->biCompression = mmioFOURCC('R', 'V', '1', '0'); | |
340 else if (!strcasecmp(lavc_param_vcodec, "mjpeg")) | |
341 mux_v->bih->biCompression = mmioFOURCC('M', 'J', 'P', 'G'); | |
342 else if (!strcasecmp(lavc_param_vcodec, "mpeg4")) | |
343 mux_v->bih->biCompression = mmioFOURCC('D', 'I', 'V', 'X'); | |
344 else if (!strcasecmp(lavc_param_vcodec, "msmpeg4")) | |
345 mux_v->bih->biCompression = mmioFOURCC('d', 'i', 'v', '3'); | |
5972 | 346 else if (!strcasecmp(lavc_param_vcodec, "msmpeg4v2")) |
347 mux_v->bih->biCompression = mmioFOURCC('M', 'P', '4', '2'); | |
6461 | 348 else if (!strcasecmp(lavc_param_vcodec, "wmv1")) |
349 mux_v->bih->biCompression = mmioFOURCC('W', 'M', 'V', '1'); | |
5550 | 350 else |
351 mux_v->bih->biCompression = mmioFOURCC(lavc_param_vcodec[0], | |
352 lavc_param_vcodec[1], lavc_param_vcodec[2], lavc_param_vcodec[3]); /* FIXME!!! */ | |
353 | |
354 if (!avcodec_inited){ | |
355 avcodec_init(); | |
356 avcodec_register_all(); | |
357 avcodec_inited=1; | |
358 } | |
359 | |
360 vf->priv->codec = (AVCodec *)avcodec_find_encoder_by_name(lavc_param_vcodec); | |
361 if (!vf->priv->codec) { | |
362 mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_MissingLAVCcodec, lavc_param_vcodec); | |
363 return 0; | |
364 } | |
365 | |
366 return 1; | |
367 } | |
368 | |
369 vf_info_t ve_info_lavc = { | |
370 "libavcodec encoder", | |
371 "lavc", | |
5977
e8f6f477aad0
a hack to make ffmjpeg created files viewable with windows dlls too
alex
parents:
5972
diff
changeset
|
372 "A'rpi and Alex", |
5550 | 373 "for internal use by mencoder", |
374 vf_open | |
375 }; | |
376 | |
377 //===========================================================================// | |
378 #endif |