annotate libmpcodecs/ve_lavc.c @ 6714:be17a987e0a1

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