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