Mercurial > mplayer.hg
comparison libmpcodecs/ve_divx4.c @ 10252:d275152390ee
I've found some time to implement the encoding support for the new
DivX API. Now it's possible to play and encode movies with the
latest DivX release.
One thing that doesn't work is the new Video Buffer Verifier (VBV)
multipass encoding. The encoder segfaults. Maybe it just isn't
supported with the standard profile of the released binary encoder.
Andreas Hess <jaska@gmx.net>
author | arpi |
---|---|
date | Fri, 06 Jun 2003 19:57:37 +0000 |
parents | 32be26de0d7c |
children | 57bdcdb061d7 |
comparison
equal
deleted
inserted
replaced
10251:95dc2037fb27 | 10252:d275152390ee |
---|---|
1 #define HAVE_XVID_VBR | |
2 #include <stdio.h> | 1 #include <stdio.h> |
3 #include <stdlib.h> | 2 #include <stdlib.h> |
4 #include <string.h> | 3 #include <string.h> |
5 | 4 |
6 #include "../config.h" | 5 #include "../config.h" |
35 <GomGom> that the vbr lib does not "know" | 34 <GomGom> that the vbr lib does not "know" |
36 */ | 35 */ |
37 | 36 |
38 //===========================================================================// | 37 //===========================================================================// |
39 | 38 |
40 #include "divx4_vbr.h" | |
41 #ifdef HAVE_XVID_VBR | |
42 #include "xvid_vbr.h" | |
43 #endif | |
44 | |
45 static int pass; | 39 static int pass; |
46 extern char* passtmpfile; | 40 extern char* passtmpfile; |
47 | 41 |
48 #ifdef ENCORE_XVID | 42 #ifdef ENCORE_XVID |
49 #include <divx4.h> | 43 #include <divx4.h> |
53 | 47 |
54 #ifndef ENCORE_MAJOR_VERSION | 48 #ifndef ENCORE_MAJOR_VERSION |
55 #define ENCORE_MAJOR_VERSION 4000 | 49 #define ENCORE_MAJOR_VERSION 4000 |
56 #endif | 50 #endif |
57 | 51 |
52 #if ENCORE_MAJOR_VERSION < 5200 | |
53 #include "divx4_vbr.h" | |
54 #define HAVE_XVID_VBR | |
55 #ifdef HAVE_XVID_VBR | |
56 #include "xvid_vbr.h" | |
57 #endif | |
58 #endif | |
59 | |
60 #if ENCORE_MAJOR_VERSION >= 5200 | |
61 SETTINGS divx4_param; | |
62 #else | |
58 ENC_PARAM divx4_param; | 63 ENC_PARAM divx4_param; |
64 #endif | |
59 int divx4_crispness; | 65 int divx4_crispness; |
60 #ifdef HAVE_XVID_VBR | 66 #ifdef HAVE_XVID_VBR |
61 static int vbrpass = -1; | 67 static int vbrpass = -1; |
62 static int vbrdebug = 0; | 68 static int vbrdebug = 0; |
63 #endif | 69 #endif |
65 #include "cfgparser.h" | 71 #include "cfgparser.h" |
66 | 72 |
67 struct config divx4opts_conf[]={ | 73 struct config divx4opts_conf[]={ |
68 {"pass", &pass, CONF_TYPE_INT, CONF_RANGE,0,2, NULL}, | 74 {"pass", &pass, CONF_TYPE_INT, CONF_RANGE,0,2, NULL}, |
69 {"br", &divx4_param.bitrate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL}, | 75 {"br", &divx4_param.bitrate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL}, |
76 #if ENCORE_MAJOR_VERSION < 5200 | |
70 {"rc_period", &divx4_param.rc_period, CONF_TYPE_INT, 0,0,0, NULL}, | 77 {"rc_period", &divx4_param.rc_period, CONF_TYPE_INT, 0,0,0, NULL}, |
71 {"rc_reaction_period", &divx4_param.rc_reaction_period, CONF_TYPE_INT, 0,0,0, NULL}, | 78 {"rc_reaction_period", &divx4_param.rc_reaction_period, CONF_TYPE_INT, 0,0,0, NULL}, |
72 {"rc_reaction_ratio", &divx4_param.rc_reaction_ratio, CONF_TYPE_INT, 0,0,0, NULL}, | 79 {"rc_reaction_ratio", &divx4_param.rc_reaction_ratio, CONF_TYPE_INT, 0,0,0, NULL}, |
73 {"min_quant", &divx4_param.min_quantizer, CONF_TYPE_INT, CONF_RANGE,0,32, NULL}, | 80 {"min_quant", &divx4_param.min_quantizer, CONF_TYPE_INT, CONF_RANGE,0,32, NULL}, |
74 {"max_quant", &divx4_param.max_quantizer, CONF_TYPE_INT, CONF_RANGE,0,32, NULL}, | 81 {"max_quant", &divx4_param.max_quantizer, CONF_TYPE_INT, CONF_RANGE,0,32, NULL}, |
82 #endif | |
75 {"key", &divx4_param.max_key_interval, CONF_TYPE_INT, CONF_MIN,0,0, NULL}, | 83 {"key", &divx4_param.max_key_interval, CONF_TYPE_INT, CONF_MIN,0,0, NULL}, |
76 {"deinterlace", &divx4_param.deinterlace, CONF_TYPE_FLAG, 0,0,1, NULL}, | 84 {"deinterlace", &divx4_param.deinterlace, CONF_TYPE_FLAG, 0,0,1, NULL}, |
77 {"q", &divx4_param.quality, CONF_TYPE_INT, CONF_RANGE, 1, 5, NULL}, | 85 {"q", &divx4_param.quality, CONF_TYPE_INT, CONF_RANGE, 1, 5, NULL}, |
78 {"crispness", &divx4_crispness, CONF_TYPE_INT, CONF_RANGE,0,100, NULL}, | 86 {"crispness", &divx4_crispness, CONF_TYPE_INT, CONF_RANGE,0,100, NULL}, |
79 #if ENCORE_MAJOR_VERSION >= 5010 | 87 #if ENCORE_MAJOR_VERSION >= 5010 |
88 #if ENCORE_MAJOR_VERSION >= 5200 | |
89 /* rate control modes: | |
90 0 (VBV 1-pass) | |
91 1 (1-pass constant quality) | |
92 2 (VBV multipass 1st-pass) | |
93 3 (VBV multipass nth-pass) | |
94 4 (original 1-pass) | |
95 5 (original 1st pass) | |
96 6 (original 2nd pass) | |
97 7 (1-pass constant frame size) | |
98 */ | |
99 {"vbr", &divx4_param.vbr_mode, CONF_TYPE_INT, CONF_RANGE,0,7, NULL}, | |
100 {"bidirect", &divx4_param.use_bidirect, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
101 {"key_frame_threshold", &divx4_param.key_frame_threshold, CONF_TYPE_INT, CONF_RANGE,1,100, NULL}, | |
102 /* default values from the DivX Help Guide: | |
103 bitrate size occupancy | |
104 128000 262144 196608 (Handheld) | |
105 768000 1048576 786432 (Portable) | |
106 4000000 3145728 2359296 (Home Theatre) | |
107 8000000 6291456 4718592 (High Definition) | |
108 Do not mess with these values unless you are absolutely sure of what you are doing! | |
109 */ | |
110 {"vbv_bitrate", &divx4_param.vbv_bitrate, CONF_TYPE_INT, 0,0,0, NULL}, | |
111 {"vbv_size", &divx4_param.vbv_size, CONF_TYPE_INT, 0,0,0, NULL}, | |
112 {"vbv_occupancy", &divx4_param.vbv_occupancy, CONF_TYPE_INT, 0,0,0, NULL}, | |
113 {"complexity", &divx4_param.complexity_modulation, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL}, | |
114 {"readlog", &divx4_param.log_file_read, CONF_TYPE_STRING, 0,0,1, NULL}, | |
115 {"writelog", &divx4_param.log_file_write, CONF_TYPE_STRING, 0,0,1, NULL}, | |
116 {"mv_file", &divx4_param.mv_file, CONF_TYPE_STRING, 0,0,1, NULL}, | |
117 {"data_partitioning", &divx4_param.data_partitioning, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
118 {"qpel", &divx4_param.quarter_pel, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
119 {"gmc", &divx4_param.use_gmc, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
120 {"pv", &divx4_param.psychovisual, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
121 {"pv_strength_frame", &divx4_param.pv_strength_frame, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL}, | |
122 {"pv_strength_MB", &divx4_param.pv_strength_MB, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL}, | |
123 {"interlace_mode", &divx4_param.interlace_mode, CONF_TYPE_INT, CONF_RANGE,0,3, NULL}, | |
124 {"crop", &divx4_param.enable_crop, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
125 {"resize", &divx4_param.enable_resize, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
126 {"width", &divx4_param.resize_width, CONF_TYPE_INT, 0,0,0, NULL}, | |
127 {"height", &divx4_param.resize_height, CONF_TYPE_INT, 0,0,0, NULL}, | |
128 {"left", &divx4_param.crop_left, CONF_TYPE_INT, 0,0,0, NULL}, | |
129 {"right", &divx4_param.crop_right, CONF_TYPE_INT, 0,0,0, NULL}, | |
130 {"top", &divx4_param.crop_top, CONF_TYPE_INT, 0,0,0, NULL}, | |
131 {"bottom", &divx4_param.crop_bottom, CONF_TYPE_INT, 0,0,0, NULL}, | |
132 {"resize_mode", &divx4_param.resize_mode, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
133 {"temporal", &divx4_param.temporal_enable, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
134 {"spatial", &divx4_param.spatial_passes, CONF_TYPE_INT, CONF_RANGE,0,3, NULL}, | |
135 {"temporal_level", &divx4_param.temporal_level, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL}, | |
136 {"spatial_level", &divx4_param.spatial_level, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL}, | |
137 #else | |
80 {"bidirect", &divx4_param.extensions.use_bidirect, CONF_TYPE_FLAG, 0,0,1, NULL}, | 138 {"bidirect", &divx4_param.extensions.use_bidirect, CONF_TYPE_FLAG, 0,0,1, NULL}, |
81 {"obmc", &divx4_param.extensions.obmc, CONF_TYPE_FLAG, 0,0,1, NULL}, | 139 {"obmc", &divx4_param.extensions.obmc, CONF_TYPE_FLAG, 0,0,1, NULL}, |
82 {"data_partitioning", &divx4_param.extensions.data_partitioning, CONF_TYPE_FLAG, 0,0,1, NULL}, | 140 {"data_partitioning", &divx4_param.extensions.data_partitioning, CONF_TYPE_FLAG, 0,0,1, NULL}, |
141 // {"mpeg2", &divx4_param.extensions.mpeg2_quant, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
83 {"qpel", &divx4_param.extensions.quarter_pel, CONF_TYPE_FLAG, 0,0,1, NULL}, | 142 {"qpel", &divx4_param.extensions.quarter_pel, CONF_TYPE_FLAG, 0,0,1, NULL}, |
84 {"intra_frame_threshold", &divx4_param.extensions.intra_frame_threshold, CONF_TYPE_INT, CONF_RANGE,1,100, NULL}, | 143 {"intra_frame_threshold", &divx4_param.extensions.intra_frame_threshold, CONF_TYPE_INT, CONF_RANGE,1,100, NULL}, |
85 {"psychovisual", &divx4_param.extensions.psychovisual, CONF_TYPE_FLAG, 0,0,1, NULL}, | 144 {"psychovisual", &divx4_param.extensions.psychovisual, CONF_TYPE_FLAG, 0,0,1, NULL}, |
145 {"pv", &divx4_param.extensions.psychovisual, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
146 {"pv_strength_frame", &divx4_param.extensions.pv_strength_frame, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL}, | |
147 {"pv_strength_MB", &divx4_param.extensions.pv_strength_MB, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL}, | |
86 {"testing_param", &divx4_param.extensions.testing_param, CONF_TYPE_FLAG, 0,0,1, NULL}, | 148 {"testing_param", &divx4_param.extensions.testing_param, CONF_TYPE_FLAG, 0,0,1, NULL}, |
87 {"gmc", &divx4_param.extensions.use_gmc, CONF_TYPE_FLAG, 0,0,1, NULL}, | 149 {"gmc", &divx4_param.extensions.use_gmc, CONF_TYPE_FLAG, 0,0,1, NULL}, |
88 {"interlace_mode", &divx4_param.extensions.interlace_mode, CONF_TYPE_INT, CONF_RANGE,0,2, NULL}, | 150 {"interlace_mode", &divx4_param.extensions.interlace_mode, CONF_TYPE_INT, CONF_RANGE,0,2, NULL}, |
151 {"crop", &divx4_param.extensions.enable_crop, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
152 {"resize", &divx4_param.extensions.enable_resize, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
153 {"width", &divx4_param.extensions.resize_width, CONF_TYPE_INT, 0,0,0, NULL}, | |
154 {"height", &divx4_param.extensions.resize_height, CONF_TYPE_INT, 0,0,0, NULL}, | |
155 {"left", &divx4_param.extensions.crop_left, CONF_TYPE_INT, 0,0,0, NULL}, | |
156 {"right", &divx4_param.extensions.crop_right, CONF_TYPE_INT, 0,0,0, NULL}, | |
157 {"top", &divx4_param.extensions.crop_top, CONF_TYPE_INT, 0,0,0, NULL}, | |
158 {"bottom", &divx4_param.extensions.crop_bottom, CONF_TYPE_INT, 0,0,0, NULL}, | |
159 {"resize_mode", &divx4_param.extensions.resize_mode, CONF_TYPE_FLAG, 0,0,1, NULL}, | |
89 {"temporal", &divx4_param.extensions.temporal_enable, CONF_TYPE_FLAG, 0,0,1, NULL}, | 160 {"temporal", &divx4_param.extensions.temporal_enable, CONF_TYPE_FLAG, 0,0,1, NULL}, |
90 {"spatial", &divx4_param.extensions.spatial_passes, CONF_TYPE_INT, 0,0,1, NULL}, | 161 {"spatial", &divx4_param.extensions.spatial_passes, CONF_TYPE_INT, CONF_RANGE,0,3, NULL}, |
162 {"temporal_level", &divx4_param.extensions.temporal_level, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL}, | |
163 {"spatial_level", &divx4_param.extensions.spatial_level, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL}, | |
91 {"mv_file", &divx4_param.extensions.mv_file, CONF_TYPE_STRING, 0,0,1, NULL}, | 164 {"mv_file", &divx4_param.extensions.mv_file, CONF_TYPE_STRING, 0,0,1, NULL}, |
165 #endif | |
92 #endif | 166 #endif |
93 #ifdef HAVE_XVID_VBR | 167 #ifdef HAVE_XVID_VBR |
94 {"vbrpass", &vbrpass, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL}, | 168 {"vbrpass", &vbrpass, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL}, |
95 {"vbrdebug", &vbrdebug, CONF_TYPE_INT, CONF_RANGE, 0, 1, NULL}, | 169 {"vbrdebug", &vbrdebug, CONF_TYPE_INT, CONF_RANGE, 0, 1, NULL}, |
96 #endif | 170 #endif |
112 | 186 |
113 static int config(struct vf_instance_s* vf, | 187 static int config(struct vf_instance_s* vf, |
114 int width, int height, int d_width, int d_height, | 188 int width, int height, int d_width, int d_height, |
115 unsigned int flags, unsigned int outfmt){ | 189 unsigned int flags, unsigned int outfmt){ |
116 | 190 |
191 #if ENCORE_MAJOR_VERSION >= 5200 | |
192 DivXBitmapInfoHeader format; | |
193 char profile = (char) encore(0, ENC_OPT_PROFILE, 0, 0); | |
194 | |
195 mp_msg(MSGT_MENCODER, MSGL_INFO, "encoder binary profile: %c\n", profile); | |
196 | |
197 if((pass <= 1 && (divx4_param.vbr_mode == RCMODE_VBV_MULTIPASS_NTH || | |
198 divx4_param.vbr_mode == RCMODE_502_2PASS_2ND)) || | |
199 (pass == 2 && (divx4_param.vbr_mode == RCMODE_VBV_1PASS || | |
200 divx4_param.vbr_mode == RCMODE_1PASS_CONSTANT_Q || | |
201 divx4_param.vbr_mode == RCMODE_VBV_MULTIPASS_1ST || | |
202 divx4_param.vbr_mode == RCMODE_502_1PASS || | |
203 divx4_param.vbr_mode == RCMODE_502_2PASS_1ST || | |
204 divx4_param.vbr_mode == RCMODE_IMAGE_COMPRESS))) { | |
205 mp_msg(MSGT_MENCODER, MSGL_ERR, "pass (%i) and rate control mode (%i) doesn't match, please consult encore2.h\n", | |
206 pass, divx4_param.vbr_mode); | |
207 abort(); | |
208 } | |
209 #endif | |
210 | |
117 mux_v->bih->biWidth=width; | 211 mux_v->bih->biWidth=width; |
118 mux_v->bih->biHeight=height; | 212 mux_v->bih->biHeight=height; |
119 | 213 mux_v->bih->biSizeImage=width*height*3; |
214 | |
215 if(!divx4_param.bitrate) divx4_param.bitrate=800000; | |
216 else if(divx4_param.bitrate<=16000) divx4_param.bitrate*=1000; | |
217 if(!divx4_param.quality) divx4_param.quality=5; // the quality of compression ( 1 - fastest, 5 - best ) | |
218 | |
219 #if ENCORE_MAJOR_VERSION >= 5200 | |
220 format.biSize=sizeof(DivXBitmapInfoHeader); | |
221 format.biWidth=width; | |
222 format.biHeight=height; | |
223 format.biSizeImage=mux_v->bih->biSizeImage; | |
224 if(divx4_param.vbv_bitrate > 0) { | |
225 divx4_param.vbv_bitrate = ((divx4_param.vbv_bitrate - 1) / 400 + 1) * 400; | |
226 divx4_param.vbv_size = ((divx4_param.vbv_size - 1) / 16384 + 1) * 16384; | |
227 divx4_param.vbv_occupancy = ((divx4_param.vbv_occupancy - 1) / 64 + 1) * 64; | |
228 } | |
229 #else | |
120 divx4_param.x_dim=width; | 230 divx4_param.x_dim=width; |
121 divx4_param.y_dim=height; | 231 divx4_param.y_dim=height; |
122 divx4_param.framerate=(float)mux_v->h.dwRate/mux_v->h.dwScale; | 232 divx4_param.framerate=(float)mux_v->h.dwRate/mux_v->h.dwScale; |
123 mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*3; | |
124 | |
125 if(!divx4_param.bitrate) divx4_param.bitrate=800000; | |
126 else if(divx4_param.bitrate<=16000) divx4_param.bitrate*=1000; | |
127 if(!divx4_param.quality) divx4_param.quality=5; // the quality of compression ( 1 - fastest, 5 - best ) | |
128 | |
129 // set some usefull defaults: | 233 // set some usefull defaults: |
130 if(!divx4_param.min_quantizer) divx4_param.min_quantizer=2; | 234 if(!divx4_param.min_quantizer) divx4_param.min_quantizer=2; |
131 if(!divx4_param.max_quantizer) divx4_param.max_quantizer=31; | 235 if(!divx4_param.max_quantizer) divx4_param.max_quantizer=31; |
132 if(!divx4_param.rc_period) divx4_param.rc_period=2000; | 236 if(!divx4_param.rc_period) divx4_param.rc_period=2000; |
133 if(!divx4_param.rc_reaction_period) divx4_param.rc_reaction_period=10; | 237 if(!divx4_param.rc_reaction_period) divx4_param.rc_reaction_period=10; |
134 if(!divx4_param.rc_reaction_ratio) divx4_param.rc_reaction_ratio=20; | 238 if(!divx4_param.rc_reaction_ratio) divx4_param.rc_reaction_ratio=20; |
239 #endif | |
135 | 240 |
136 #ifdef HAVE_XVID_VBR | 241 #ifdef HAVE_XVID_VBR |
137 if (vbrpass >= 0) { | 242 if (vbrpass >= 0) { |
138 vbrSetDefaults(&vf->priv->vbr_state); | 243 vbrSetDefaults(&vf->priv->vbr_state); |
139 vf->priv->vbr_state.desired_bitrate = divx4_param.bitrate; | 244 vf->priv->vbr_state.desired_bitrate = divx4_param.bitrate; |
157 if (vf->priv->vbr_state.mode != VBR_MODE_2PASS_2) | 262 if (vf->priv->vbr_state.mode != VBR_MODE_2PASS_2) |
158 divx4_param.min_quantizer = divx4_param.max_quantizer = vbrGetQuant(&vf->priv->vbr_state); | 263 divx4_param.min_quantizer = divx4_param.max_quantizer = vbrGetQuant(&vf->priv->vbr_state); |
159 } | 264 } |
160 #endif | 265 #endif |
161 | 266 |
267 #if ENCORE_MAJOR_VERSION >= 5200 | |
268 switch(outfmt){ | |
269 case IMGFMT_YV12: { | |
270 format.biCompression=mmioFOURCC('Y','V','1','2'); | |
271 break; | |
272 } | |
273 case IMGFMT_IYUV: { | |
274 format.biCompression=mmioFOURCC('I','Y','U','V'); | |
275 break; | |
276 } | |
277 case IMGFMT_I420: { | |
278 format.biCompression=mmioFOURCC('I','4','2','0'); | |
279 break; | |
280 } | |
281 case IMGFMT_YUY2: { | |
282 format.biCompression=mmioFOURCC('Y','U','Y','2'); | |
283 break; | |
284 } | |
285 case IMGFMT_V422: { | |
286 format.biCompression=mmioFOURCC('V','4','2','2'); | |
287 break; | |
288 } | |
289 case IMGFMT_UYVY: { | |
290 format.biCompression=mmioFOURCC('U','Y','V','Y'); | |
291 break; | |
292 } | |
293 case IMGFMT_YVYU: { | |
294 format.biCompression=mmioFOURCC('Y','V','Y','U'); | |
295 break; | |
296 } | |
297 case IMGFMT_BGR24: { | |
298 format.biCompression=0; | |
299 format.biBitCount=24; | |
300 break; | |
301 } | |
302 case IMGFMT_BGR32: { | |
303 format.biCompression=0; | |
304 format.biBitCount=32; | |
305 break; | |
306 } | |
307 default: | |
308 mp_msg(MSGT_MENCODER,MSGL_ERR,"divx4: unsupported picture format (%s)!\n", | |
309 vo_format_name(outfmt)); | |
310 return 0; | |
311 } | |
312 | |
313 encore(&vf->priv->enc_handle, ENC_OPT_INIT, &format, &divx4_param); | |
314 #else | |
162 divx4_param.handle=NULL; | 315 divx4_param.handle=NULL; |
163 encore(NULL,ENC_OPT_INIT,&divx4_param,NULL); | 316 encore(NULL,ENC_OPT_INIT,&divx4_param,NULL); |
164 vf->priv->enc_handle=divx4_param.handle; | 317 vf->priv->enc_handle=divx4_param.handle; |
165 switch(outfmt){ | 318 switch(outfmt){ |
166 case IMGFMT_YV12: vf->priv->enc_frame.colorspace=ENC_CSP_YV12; break; | 319 case IMGFMT_YV12: vf->priv->enc_frame.colorspace=ENC_CSP_YV12; break; |
193 mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s\n", passtmpfile); | 346 mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s\n", passtmpfile); |
194 pass=0; | 347 pass=0; |
195 } | 348 } |
196 break; | 349 break; |
197 } | 350 } |
351 #endif | |
198 | 352 |
199 return 1; | 353 return 1; |
200 } | 354 } |
201 | 355 |
202 #ifdef HAVE_XVID_VBR | 356 #ifdef HAVE_XVID_VBR |
203 static void uninit(struct vf_instance_s* vf){ | 357 static void uninit(struct vf_instance_s* vf){ |
204 if (vbrpass >= 0 && vbrFinish(&vf->priv->vbr_state) == -1) | 358 if (vbrpass >= 0 && vbrFinish(&vf->priv->vbr_state) == -1) |
205 abort(); | 359 abort(); |
360 } | |
361 #else | |
362 static void uninit(struct vf_instance_s* vf){ | |
363 encore(vf->priv->enc_handle, ENC_OPT_RELEASE, 0, 0); | |
364 vf->priv->enc_handle = NULL; | |
206 } | 365 } |
207 #endif | 366 #endif |
208 | 367 |
209 static int control(struct vf_instance_s* vf, int request, void* data){ | 368 static int control(struct vf_instance_s* vf, int request, void* data){ |
210 | 369 |
230 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ | 389 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
231 ENC_RESULT enc_result; | 390 ENC_RESULT enc_result; |
232 vf->priv->enc_frame.image=mpi->planes[0]; | 391 vf->priv->enc_frame.image=mpi->planes[0]; |
233 vf->priv->enc_frame.bitstream=mux_v->buffer; | 392 vf->priv->enc_frame.bitstream=mux_v->buffer; |
234 vf->priv->enc_frame.length=mux_v->buffer_size; | 393 vf->priv->enc_frame.length=mux_v->buffer_size; |
394 #if ENCORE_MAJOR_VERSION >= 5200 | |
395 vf->priv->enc_frame.produce_empty_frame = 0; | |
396 encore(vf->priv->enc_handle, ENC_OPT_ENCODE, &vf->priv->enc_frame, &enc_result); | |
397 if(enc_result.cType == 'I') | |
398 muxer_write_chunk(mux_v,vf->priv->enc_frame.length,0x10); | |
399 else | |
400 muxer_write_chunk(mux_v,vf->priv->enc_frame.length,0); | |
401 #else | |
235 vf->priv->enc_frame.mvs=NULL; | 402 vf->priv->enc_frame.mvs=NULL; |
236 #ifdef HAVE_XVID_VBR | 403 #ifdef HAVE_XVID_VBR |
237 if (vbrpass >= 0) { | 404 if (vbrpass >= 0) { |
238 int quant = vbrGetQuant(&vf->priv->vbr_state); | 405 int quant = vbrGetQuant(&vf->priv->vbr_state); |
239 int intra = vbrGetIntra(&vf->priv->vbr_state); | 406 int intra = vbrGetIntra(&vf->priv->vbr_state); |
275 enc_result.total_bits, | 442 enc_result.total_bits, |
276 enc_result.quantizer); | 443 enc_result.quantizer); |
277 } | 444 } |
278 } | 445 } |
279 muxer_write_chunk(mux_v,vf->priv->enc_frame.length,enc_result.is_key_frame?0x10:0); | 446 muxer_write_chunk(mux_v,vf->priv->enc_frame.length,enc_result.is_key_frame?0x10:0); |
447 #endif | |
280 return 1; | 448 return 1; |
281 } | 449 } |
282 | 450 |
283 //===========================================================================// | 451 //===========================================================================// |
284 | 452 |
285 static int vf_open(vf_instance_t *vf, char* args){ | 453 static int vf_open(vf_instance_t *vf, char* args){ |
286 vf->config=config; | 454 vf->config=config; |
287 vf->control=control; | 455 vf->control=control; |
288 vf->query_format=query_format; | 456 vf->query_format=query_format; |
289 vf->put_image=put_image; | 457 vf->put_image=put_image; |
290 #ifdef HAVE_XVID_VBR | 458 //#ifdef HAVE_XVID_VBR |
291 vf->uninit = uninit; | 459 vf->uninit = uninit; |
292 #endif | 460 //#endif |
293 vf->priv=malloc(sizeof(struct vf_priv_s)); | 461 vf->priv=malloc(sizeof(struct vf_priv_s)); |
294 memset(vf->priv,0,sizeof(struct vf_priv_s)); | 462 memset(vf->priv,0,sizeof(struct vf_priv_s)); |
295 vf->priv->mux=(muxer_stream_t*)args; | 463 vf->priv->mux=(muxer_stream_t*)args; |
296 | 464 |
297 mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)); | 465 mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)); |