annotate libmpcodecs/ve_xvid.c @ 9278:caea8ed36b48

The reason why mplayer crashes (in some cases) when using x11 output and -wid (>0) parameter is this: Mplayer by default creates a colormap using DirectColor visual. If the window given to mplayer uses TrueColor visual there will be an error when mplayer sets the colormap for the window. This patch modifies mplayer to use TrueColor visual if the window given to mplayer uses TrueColor. Another solution is to make sure that the window given to mplayer is created using DirectColor visual if it is supported by the display. Jouni Tulkki <jitulkki@cc.hut.fi>
author arpi
date Tue, 04 Feb 2003 18:31:44 +0000
parents c671e9adbe22
children 4563dfa92a5b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
1 #include <stdio.h>
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
2 #include <stdlib.h>
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
3 #include <string.h>
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
4 #include <errno.h>
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
5
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
6 #include "../config.h"
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
7 #include "../mp_msg.h"
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
8
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
9 #ifdef HAVE_XVID
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
10
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
11 #include "codec-cfg.h"
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
12 #include "stream.h"
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
13 #include "demuxer.h"
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
14 #include "stheader.h"
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
15
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8561
diff changeset
16 #include "muxer.h"
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
17
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
18 #include "img_format.h"
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
19 #include "mp_image.h"
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
20 #include "vf.h"
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
21
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
22 #include <xvid.h>
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
23 #include "xvid_vbr.h"
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
24
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
25 #include "cfgparser.h"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
26
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
27
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
28 #ifdef XVID_API_UNSTABLE
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
29 #warning *******************************************************************
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
30 #warning ** **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
31 #warning ** Y O U '' R E U S I N G U N S T A B L E S O F T W A R E **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
32 #warning ** **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
33 #warning ** Streams produced by this version aren''nt probably compatible **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
34 #warning ** with anything else, even the xvid decoder itself. There are **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
35 #warning ** bugs, this code could crash, could blow up your PC or the **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
36 #warning ** whole building ! **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
37 #warning ** If you want stable code and compatible streams, use stable **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
38 #warning ** XViD releases (currently 0.9.x). **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
39 #warning ** **
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
40 #warning *******************************************************************
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
41 #endif
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
42
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
43 /**********************************************************************/
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
44 /* motion estimation quality presets */
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
45 static int const motion_presets[7] = {
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
46 #ifdef XVID_API_UNSTABLE
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
47 0,
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
48 PMV_QUICKSTOP16,
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
49 0,
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
50 0,
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
51 PMV_HALFPELREFINE16 | PMV_HALFPELDIAMOND8,
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
52 PMV_HALFPELREFINE16 | PMV_HALFPELDIAMOND8 | PMV_ADVANCEDDIAMOND16,
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
53 PMV_HALFPELREFINE16 | PMV_EXTSEARCH16 | PMV_HALFPELREFINE8 | PMV_HALFPELDIAMOND8 | PMV_USESQUARES16
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
54 #else
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
55 0,
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
56 PMV_QUICKSTOP16,
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
57 PMV_EARLYSTOP16,
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
58 PMV_EARLYSTOP16 | PMV_EARLYSTOP8,
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
59 PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | PMV_HALFPELDIAMOND8,
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
60 PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | PMV_HALFPELDIAMOND8 | PMV_ADVANCEDDIAMOND16,
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
61 PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EXTSEARCH16 | PMV_EARLYSTOP8 | PMV_HALFPELREFINE8 |
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
62 PMV_HALFPELDIAMOND8 | PMV_USESQUARES16
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
63
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
64 #endif
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
65 };
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
66
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
67 extern char* passtmpfile;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
68
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
69 static int xvidenc_pass = 0;
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
70 static int xvidenc_quality = 4;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
71 static int xvidenc_4mv = 0;
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
72 static int xvidenc_bitrate = -1;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
73 static int xvidenc_rc_reaction_delay_factor = -1;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
74 static int xvidenc_rc_averaging_period = -1;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
75 static int xvidenc_rc_buffer = -1;
8247
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
76 static char* xvidenc_quant_range = "2-31/2-31";
8221
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
77 static int xvidenc_min_key_interval = -1;
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
78 static int xvidenc_max_key_interval = -1;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
79 static int xvidenc_mpeg_quant = 0;
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
80 static int xvidenc_mod_quant = 0;
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
81 static int xvidenc_lumi_mask = 0;
8221
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
82 static int xvidenc_keyframe_boost = -1;
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
83 static int xvidenc_kfthreshold = -1;
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
84 static int xvidenc_kfreduction = -1;
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
85 static int xvidenc_fixed_quant = 0;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
86 static int xvidenc_debug = 0;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
87 static int xvidenc_hintedme = 0;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
88 static char* xvidenc_hintfile = "xvid_hint_me.dat";
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
89 #ifdef XVID_API_UNSTABLE
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
90 static int xvidenc_qpel = 0;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
91 static int xvidenc_max_bframes = 0;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
92 static int xvidenc_bquant_ratio = 125;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
93 static int xvidenc_bquant_offset = 60;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
94 static int xvidenc_gmc = 0;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
95 static int xvidenc_me_colour = 0;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
96 static int xvidenc_reduced = 0;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
97 #endif
7458
e5dacf3e6a04 Use string selection to choose mode
kmkaplan
parents: 7456
diff changeset
98
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
99 struct config xvidencopts_conf[] = {
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
100 { "pass", &xvidenc_pass, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
101 { "me_quality", &xvidenc_quality, CONF_TYPE_INT, CONF_RANGE, 0,
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
102 sizeof(motion_presets) / sizeof(motion_presets[0]) - 1, NULL},
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
103 { "4mv", &xvidenc_4mv, CONF_TYPE_FLAG, 0, 0, 1, NULL},
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
104 { "bitrate", &xvidenc_bitrate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL},
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
105 { "rc_reaction_delay_factor", &xvidenc_rc_reaction_delay_factor, CONF_TYPE_INT, 0, 0, 0, NULL},
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
106 { "rc_averaging_period", &xvidenc_rc_averaging_period, CONF_TYPE_INT, 0, 0, 0, NULL},
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
107 { "rc_buffer", &xvidenc_rc_buffer, CONF_TYPE_INT, 0, 0, 0, NULL},
8247
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
108 { "quant_range", &xvidenc_quant_range, CONF_TYPE_STRING, 0, 0, 0, NULL},
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
109 { "min_key_interval", &xvidenc_min_key_interval, CONF_TYPE_INT, 0, 0, 0, NULL}, /* for XVID_MODE_2PASS_2 */
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
110 { "max_key_interval", &xvidenc_max_key_interval, CONF_TYPE_INT, 0, 0, 0, NULL},
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
111 { "mpeg_quant", &xvidenc_mpeg_quant, CONF_TYPE_FLAG, 0, 0, 1, NULL},
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
112 { "mod_quant", &xvidenc_mod_quant, CONF_TYPE_FLAG, 0, 0, 1, NULL},
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
113 { "lumi_mask", &xvidenc_lumi_mask, CONF_TYPE_FLAG, 0, 0, 1, NULL},
8193
83d3125cb382 A bit more sane range.
rguyom
parents: 8192
diff changeset
114 { "keyframe_boost", &xvidenc_keyframe_boost, CONF_TYPE_INT, CONF_RANGE, 0, 1000, NULL}, /* for XVID_MODE_2PASS_2 */
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
115 { "kfthreshold", &xvidenc_kfthreshold, CONF_TYPE_INT, 0, 0, 0, NULL}, /* for XVID_MODE_2PASS_2 */
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
116 { "kfreduction", &xvidenc_kfreduction, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, /* for XVID_MODE_2PASS_2 */
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
117 { "fixed_quant", &xvidenc_fixed_quant, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, /* for XVID_MODE_FIXED_QUANT */
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
118 { "debug", &xvidenc_debug, CONF_TYPE_FLAG, 0, 0, 1, NULL},
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
119 { "hintedme", &xvidenc_hintedme, CONF_TYPE_FLAG, 0, 0, 1, NULL},
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
120 { "hintfile", &xvidenc_hintfile, CONF_TYPE_STRING, 0, 0, 0, NULL},
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
121 #ifdef XVID_API_UNSTABLE
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
122 { "qpel", &xvidenc_qpel, CONF_TYPE_FLAG, 0, 0, 1, NULL},
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
123 { "max_bframes", &xvidenc_max_bframes, CONF_TYPE_INT, CONF_RANGE, 0, 4, NULL},
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
124 { "bquant_ratio", &xvidenc_bquant_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 1000, NULL},
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
125 { "bquant_offset", &xvidenc_bquant_offset, CONF_TYPE_INT, CONF_RANGE, -1000, 1000, NULL},
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
126 { "reduced", &xvidenc_reduced, CONF_TYPE_FLAG, 0, 0, 1, NULL},
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
127 { "gmc", &xvidenc_gmc, CONF_TYPE_FLAG, 0, 0, 1, NULL},
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
128 { "me_colour", &xvidenc_me_colour, CONF_TYPE_FLAG, 0, 0, 1, NULL},
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
129 #endif
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
130 { NULL, NULL, 0, 0, 0, 0, NULL}
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
131 };
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
132
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
133 struct vf_priv_s {
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8561
diff changeset
134 muxer_stream_t* mux;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
135 XVID_ENC_FRAME enc_frame;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
136 void* enc_handle;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
137 vbr_control_t vbr_state;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
138 FILE *hintfile;
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
139 void *hintstream;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
140 };
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
141
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
142 static int
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
143 config(struct vf_instance_s* vf,
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
144 int width, int height, int d_width, int d_height,
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
145 unsigned int flags, unsigned int outfmt)
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
146 {
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
147 XVID_ENC_PARAM enc_param;
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
148 struct vf_priv_s *fp = vf->priv;
8247
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
149 unsigned int min_iq, max_iq, min_pq, max_pq;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
150
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
151 fp->mux->bih->biWidth = width;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
152 fp->mux->bih->biHeight = height;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
153 fp->mux->bih->biSizeImage = fp->mux->bih->biWidth * fp->mux->bih->biHeight * 3;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
154 mp_msg(MSGT_MENCODER,MSGL_INFO,"videocodec: XViD (%dx%d fourcc=%x [%.4s])\n",
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
155 width, height, fp->mux->bih->biCompression, (char *)&fp->mux->bih->biCompression);
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
156
8247
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
157 // {min,max}_{i,p}quantizer parsing & validation
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
158 if (sscanf (xvidenc_quant_range, "%u-%u/%u-%u", &min_iq, &max_iq, &min_pq, &max_pq) < 4) {
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
159 mp_msg (MSGT_MENCODER, MSGL_ERR,
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
160 "xvid: ERROR: cannot parse \"quant_range=%s\"\n", xvidenc_quant_range);
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
161 return 0;
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
162 }
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
163 if (min_iq < 1 || min_iq > 31 || max_iq < 1 || max_iq > 31 || min_iq > max_iq ||
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
164 min_pq < 1 || min_pq > 31 || max_pq < 1 || max_pq > 31 || min_pq > max_pq) {
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
165 mp_msg (MSGT_MENCODER, MSGL_ERR,
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
166 "xvid: ERROR: {min,max} {I,P} quantizer must be in [1,31] and min must be <= max.\n");
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
167 mp_msg (MSGT_MENCODER, MSGL_ERR,
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
168 "xvid: ERROR: cannot use \"quant_range=%s\"\n", xvidenc_quant_range);
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
169 return -1;
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
170 }
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
171
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
172 #ifdef XVID_API_UNSTABLE
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
173 mp_msg (MSGT_MENCODER, MSGL_WARN,
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
174 "\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
175 "*******************************************************************\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
176 "** **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
177 "** Y O U ' R E U S I N G U N S T A B L E S O F T W A R E **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
178 "** **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
179 "** Streams produced by this version aren'nt probably compatible **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
180 "** with anything else, even the xvid decoder itself. There are **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
181 "** bugs, this code could crash, could blow up your PC or the **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
182 "** whole building ! **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
183 "** If you want stable code and compatible streams, use stable **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
184 "** XViD releases (currently 0.9.x). **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
185 "** **\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
186 "*******************************************************************\n"
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
187 "\n");
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
188 #endif
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
189
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
190 // initialize XViD core parameters
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
191 // ===============================
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
192 memset(&enc_param, 0, sizeof(enc_param));
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
193 enc_param.width = width;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
194 enc_param.height = height;
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
195 enc_param.fincr = fp->mux->h.dwScale;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
196 enc_param.fbase = fp->mux->h.dwRate;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
197 if (xvidenc_bitrate > 16000)
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
198 enc_param.rc_bitrate = xvidenc_bitrate;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
199 else if (xvidenc_bitrate > 0)
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
200 enc_param.rc_bitrate = xvidenc_bitrate * 1000;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
201 else
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
202 enc_param.rc_bitrate = -1;
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
203 #ifdef XVID_API_UNSTABLE
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
204 if (xvidenc_max_bframes >= 1 && xvidenc_pass >= 1) {
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
205 mp_msg(MSGT_MENCODER,MSGL_WARN, "xvid: cannot use bframes with 2-pass, disabling bframes\n");
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
206 xvidenc_max_bframes = 0;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
207 }
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
208 enc_param.max_bframes = xvidenc_max_bframes;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
209 enc_param.bquant_ratio = xvidenc_bquant_ratio;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
210 enc_param.bquant_offset = xvidenc_bquant_offset;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
211 if (xvidenc_reduced)
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
212 enc_param.global |= XVID_GLOBAL_REDUCED;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
213 #endif
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
214 enc_param.rc_reaction_delay_factor = xvidenc_rc_reaction_delay_factor;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
215 enc_param.rc_averaging_period = xvidenc_rc_averaging_period;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
216 enc_param.rc_buffer = xvidenc_rc_buffer;
8247
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
217 enc_param.min_quantizer = min_iq;
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
218 enc_param.max_quantizer = max_iq;
8221
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
219 if( xvidenc_max_key_interval <= 0 )
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
220 xvidenc_max_key_interval = 10 * enc_param.fbase / enc_param.fincr;
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
221 enc_param.max_key_interval = xvidenc_max_key_interval;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
222 switch (xvid_encore(NULL, XVID_ENC_CREATE, &enc_param, NULL)) {
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
223 case XVID_ERR_FAIL:
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
224 mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: encoder creation failed\n");
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
225 return 0;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
226 case XVID_ERR_MEMORY:
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
227 mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: encoder creation failed, out of memory\n");
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
228 return 0;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
229 case XVID_ERR_FORMAT:
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
230 mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: encoder creation failed, bad format\n");
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
231 return 0;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
232 }
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
233 fp->enc_handle = enc_param.handle;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
234
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
235 // initialize XViD per-frame static parameters
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
236 // ===========================================
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
237 fp->enc_frame.motion = motion_presets[xvidenc_quality];
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
238 fp->enc_frame.general = XVID_HALFPEL | (xvidenc_mpeg_quant ? XVID_MPEGQUANT : XVID_H263QUANT);
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
239 if (xvidenc_4mv)
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
240 fp->enc_frame.general |= XVID_INTER4V;
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
241 if (xvidenc_lumi_mask)
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
242 fp->enc_frame.general |= XVID_LUMIMASKING;
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
243 #ifdef XVID_API_UNSTABLE
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
244 if (xvidenc_qpel) {
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
245 fp->enc_frame.general |= XVID_QUARTERPEL;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
246 fp->enc_frame.motion |= PMV_QUARTERPELREFINE16 | PMV_QUARTERPELREFINE8;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
247 }
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
248 if (xvidenc_gmc)
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
249 fp->enc_frame.general |= XVID_GMC;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
250 if (xvidenc_me_colour)
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
251 fp->enc_frame.general |= XVID_ME_COLOUR;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
252 if(xvidenc_reduced)
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
253 fp->enc_frame.general |= XVID_REDUCED;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
254 #endif
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
255
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
256 switch (outfmt) {
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
257 case IMGFMT_YV12:
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
258 fp->enc_frame.colorspace = XVID_CSP_YV12;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
259 break;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
260 case IMGFMT_IYUV: case IMGFMT_I420:
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
261 fp->enc_frame.colorspace = XVID_CSP_I420;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
262 break;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
263 case IMGFMT_YUY2:
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
264 fp->enc_frame.colorspace = XVID_CSP_YUY2;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
265 break;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
266 case IMGFMT_UYVY:
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
267 fp->enc_frame.colorspace = XVID_CSP_UYVY;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
268 break;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
269 case IMGFMT_RGB24: case IMGFMT_BGR24:
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
270 fp->enc_frame.colorspace = XVID_CSP_RGB24;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
271 break;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
272 default:
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
273 mp_msg(MSGT_MENCODER,MSGL_ERR,"xvid: unsupported picture format (%s)!\n",
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
274 vo_format_name(outfmt));
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
275 return 0;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
276 }
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
277 fp->enc_frame.quant_intra_matrix = 0;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
278 fp->enc_frame.quant_inter_matrix = 0;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
279
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
280 // hinted ME
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
281 fp->hintstream = NULL;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
282 fp->hintfile = NULL;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
283 if (xvidenc_hintedme && (xvidenc_pass == 1 || xvidenc_pass == 2)) {
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
284 fp->hintstream = malloc( 100000 ); // this is what the vfw code in XViD CVS allocates
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
285 if (fp->hintstream == NULL)
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
286 mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: cannot allocate memory for hinted ME\n");
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
287 else {
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
288 fp->hintfile = fopen(xvidenc_hintfile, xvidenc_pass == 1 ? "w" : "r");
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
289 if (fp->hintfile == NULL) {
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
290 mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: %s: %s\n", strerror(errno), xvidenc_hintfile);
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
291 free(fp->hintstream);
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
292 }
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
293 }
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
294 if (fp->hintstream == NULL || fp->hintfile == NULL)
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
295 xvidenc_hintedme = 0;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
296 }
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
297
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
298 // initialize VBR engine
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
299 // =====================
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
300 vbrSetDefaults(&fp->vbr_state);
8221
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
301 if (xvidenc_min_key_interval < 0)
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
302 xvidenc_min_key_interval = fp->vbr_state.min_key_interval;
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
303
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
304 // pass
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
305 if (xvidenc_pass == 0) {
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
306 if (xvidenc_fixed_quant >= 1) {
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
307 fp->vbr_state.mode = VBR_MODE_FIXED_QUANT;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
308 fp->vbr_state.fixed_quant = xvidenc_fixed_quant;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
309 } else
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
310 fp->vbr_state.mode = VBR_MODE_1PASS;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
311 }
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
312 else if (xvidenc_pass == 1)
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
313 fp->vbr_state.mode = VBR_MODE_2PASS_1;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
314 else if (xvidenc_pass == 2)
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
315 fp->vbr_state.mode = VBR_MODE_2PASS_2;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
316 else
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
317 return -1;
8221
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
318
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
319 // misc
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
320 fp->vbr_state.fps = (double)enc_param.fbase / enc_param.fincr;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
321 fp->vbr_state.filename = passtmpfile;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
322 fp->vbr_state.desired_bitrate = enc_param.rc_bitrate;
8247
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
323 fp->vbr_state.min_iquant = min_iq;
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
324 fp->vbr_state.max_iquant = max_iq;
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
325 fp->vbr_state.min_pquant = min_pq;
91edcb091dc6 Instead of min_quantizer, max_quantizer, min_iquantizer, etc... use a
rguyom
parents: 8221
diff changeset
326 fp->vbr_state.max_pquant = max_pq;
8221
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
327 if (xvidenc_keyframe_boost >= 0)
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
328 fp->vbr_state.keyframe_boost = xvidenc_keyframe_boost;
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
329 if (xvidenc_kfthreshold >= 0)
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
330 fp->vbr_state.kftreshold = xvidenc_kfthreshold;
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
331 if (xvidenc_kfreduction >= 0)
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
332 fp->vbr_state.kfreduction = xvidenc_kfreduction;
8221
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
333 if (xvidenc_min_key_interval >= 0)
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
334 fp->vbr_state.min_key_interval = xvidenc_min_key_interval;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
335 fp->vbr_state.max_key_interval = enc_param.max_key_interval;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
336 fp->vbr_state.debug = xvidenc_debug;
8221
8ea6ba1e6c0b Implements [min|max]_[i|p]quantizer.
rguyom
parents: 8193
diff changeset
337
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
338 vbrInit(&fp->vbr_state);
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
339
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
340 return 1;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
341 }
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
342
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
343 static void
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
344 uninit(struct vf_instance_s* vf)
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
345 {
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
346 struct vf_priv_s *fp = vf->priv;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
347
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
348 if (fp->hintfile)
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
349 fclose(fp->hintfile);
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
350 if (fp->hintstream)
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
351 free(fp->hintstream);
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
352 vbrFinish(&fp->vbr_state);
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
353 }
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
354
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
355 static int
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
356 control(struct vf_instance_s* vf, int request, void* data)
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
357 {
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
358 return CONTROL_UNKNOWN;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
359 }
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
360
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
361 static int
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
362 query_format(struct vf_instance_s* vf, unsigned int fmt)
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
363 {
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
364 switch(fmt){
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
365 case IMGFMT_YV12: case IMGFMT_IYUV: case IMGFMT_I420:
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
366 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
367 case IMGFMT_YUY2: case IMGFMT_UYVY:
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
368 return VFCAP_CSP_SUPPORTED;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
369 case IMGFMT_RGB24: case IMGFMT_BGR24:
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
370 return VFCAP_CSP_SUPPORTED | VFCAP_FLIPPED;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
371 }
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
372 return 0;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
373 }
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
374
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
375 static int
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
376 put_image(struct vf_instance_s* vf, mp_image_t *mpi)
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
377 {
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
378 XVID_ENC_STATS enc_stats;
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
379 struct vf_priv_s *fp = vf->priv;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
380
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
381 fp->enc_frame.bitstream = fp->mux->buffer;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
382 fp->enc_frame.length = -1 /* fp->mux->buffer_size */;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
383 fp->enc_frame.image = mpi->planes[0];
8561
36da960c94e3 API change in dev-api-3 branch.
rguyom
parents: 8491
diff changeset
384 #ifdef XVID_API_UNSTABLE
36da960c94e3 API change in dev-api-3 branch.
rguyom
parents: 8491
diff changeset
385 fp->enc_frame.stride = mpi->stride[0];
36da960c94e3 API change in dev-api-3 branch.
rguyom
parents: 8491
diff changeset
386 #endif
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
387
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
388 // get quantizers & I/P decision from the VBR engine
8491
ce25d80dd6c3 Use the XVID_API_UNSTABLE macro instead of a home-made one.
rguyom
parents: 8462
diff changeset
389 #ifdef XVID_API_UNSTABLE
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
390 if (xvidenc_max_bframes >= 1) {
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
391 if (!xvidenc_fixed_quant) {
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
392 // hack, the internal VBR engine isn't fixed-quant aware
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
393 fp->enc_frame.quant = xvidenc_fixed_quant;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
394 fp->enc_frame.intra = -1;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
395 fp->enc_frame.bquant = (xvidenc_fixed_quant * xvidenc_bquant_ratio + xvidenc_bquant_offset) / 100;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
396 } else
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
397 // use the internal VBR engine since the external one isn't bframe aware
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
398 fp->enc_frame.quant = fp->enc_frame.intra = fp->enc_frame.bquant = -1;
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
399 } else {
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
400 fp->enc_frame.quant = vbrGetQuant(&fp->vbr_state);
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
401 fp->enc_frame.intra = vbrGetIntra(&fp->vbr_state);
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
402 }
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
403 #else
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
404 fp->enc_frame.quant = vbrGetQuant(&fp->vbr_state);
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
405 fp->enc_frame.intra = vbrGetIntra(&fp->vbr_state);
8462
800d77666843 Support the latest development code from XViD dev-api-3 CVS
rguyom
parents: 8247
diff changeset
406 #endif
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
407
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
408 // modulated quantizer type
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
409 if (xvidenc_mod_quant && xvidenc_pass == 2) {
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
410 fp->enc_frame.general |= (fp->enc_frame.quant < 4) ? XVID_MPEGQUANT : XVID_H263QUANT;
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
411 fp->enc_frame.general &= (fp->enc_frame.quant < 4) ? ~XVID_H263QUANT : ~XVID_MPEGQUANT;
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
412 }
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
413
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
414 // hinted ME, 1st part
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
415 if (xvidenc_hintedme && xvidenc_pass == 1) {
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
416 fp->enc_frame.hint.hintstream = fp->hintstream;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
417 fp->enc_frame.hint.rawhints = 0;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
418 fp->enc_frame.general |= XVID_HINTEDME_GET;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
419 }
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
420 else if (xvidenc_hintedme && xvidenc_pass == 2) {
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
421 size_t read;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
422 int blocksize;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
423 fp->enc_frame.general &= ~XVID_HINTEDME_SET;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
424 read = fread(&blocksize, sizeof(blocksize), 1, fp->hintfile);
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
425 if (read == 1) {
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
426 read = fread(fp->hintstream, (size_t)blocksize, 1, fp->hintfile);
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
427 if (read == 1) {
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
428 fp->enc_frame.hint.hintstream = fp->hintstream;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
429 fp->enc_frame.hint.hintlength = 0;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
430 fp->enc_frame.hint.rawhints = 0;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
431 fp->enc_frame.general |= XVID_HINTEDME_SET;
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
432 }
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
433 else
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
434 perror("xvid: hint file read block failure");
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
435 }
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
436 else
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
437 perror("xvid: hint file read failure");
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
438 }
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
439
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
440 // encode frame
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
441 switch (xvid_encore(fp->enc_handle, XVID_ENC_ENCODE, &fp->enc_frame, &enc_stats)) {
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
442 case XVID_ERR_OK:
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
443 break;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
444 case XVID_ERR_MEMORY:
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
445 mp_msg(MSGT_MENCODER, MSGL_ERR, "xvid: out of memory\n");
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
446 break;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
447 case XVID_ERR_FORMAT:
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
448 mp_msg(MSGT_MENCODER, MSGL_ERR, "xvid: bad format\n");
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
449 break;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
450 default:
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
451 mp_msg(MSGT_MENCODER, MSGL_ERR, "xvid: failure\n");
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
452 break;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
453 }
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
454
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
455 // write output
9014
c671e9adbe22 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
456 muxer_write_chunk(fp->mux, fp->enc_frame.length, fp->enc_frame.intra==1 ? 0x10 : 0);
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
457
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
458 // update the VBR engine
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
459 vbrUpdate(&fp->vbr_state, enc_stats.quant, fp->enc_frame.intra,
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
460 enc_stats.hlength, fp->enc_frame.length, enc_stats.kblks, enc_stats.mblks, enc_stats.ublks);
8192
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
461
126223903808 - added modulated quatization
rguyom
parents: 8123
diff changeset
462 // hinted ME, 2nd part
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
463 if (fp->enc_frame.general & XVID_HINTEDME_GET) {
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
464 size_t wrote = fwrite(&fp->enc_frame.hint.hintlength, sizeof(fp->enc_frame.hint.hintlength), 1, fp->hintfile);
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
465 if (wrote == 1) {
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
466 wrote = fwrite(fp->enc_frame.hint.hintstream, fp->enc_frame.hint.hintlength, 1, fp->hintfile);
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
467 if (wrote != 1)
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
468 perror("xvid: hint write block failure");
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
469 }
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
470 else
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
471 perror("xvid: hint write failure");
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
472 }
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
473 return 1;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
474 }
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
475
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
476 //===========================================================================//
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
477
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
478 static int
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
479 vf_open(vf_instance_t *vf, char* args)
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
480 {
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
481 XVID_INIT_PARAM params = { 0, 0, 0};
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
482 vf->config = config;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
483 vf->control = control;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
484 vf->uninit = uninit;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
485 vf->query_format = query_format;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
486 vf->put_image = put_image;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
487 vf->priv = malloc(sizeof(struct vf_priv_s));
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
488 memset(vf->priv, 0, sizeof(struct vf_priv_s));
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8561
diff changeset
489 vf->priv->mux = (muxer_stream_t*)args;
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
490
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
491 vf->priv->mux->bih = malloc(sizeof(BITMAPINFOHEADER));
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
492 vf->priv->mux->bih->biSize = sizeof(BITMAPINFOHEADER);
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
493 vf->priv->mux->bih->biWidth = 0;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
494 vf->priv->mux->bih->biHeight = 0;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
495 vf->priv->mux->bih->biPlanes = 1;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
496 vf->priv->mux->bih->biBitCount = 24;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
497 vf->priv->mux->bih->biCompression = mmioFOURCC('X','V','I','D');
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
498
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
499 if (xvid_init(NULL, 0, &params, NULL) != XVID_ERR_OK) {
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
500 mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: initialisation failure\n");
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
501 abort();
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
502 }
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
503 if (params.api_version != API_VERSION) {
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
504 mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: XviD library API version mismatch\n"
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
505 "\texpected %d.%d, got %d.%d, you should recompile MPlayer.\n",
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
506 API_VERSION >> 16, API_VERSION & 0xff,
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
507 params.api_version >> 16, params.api_version & 0xff);
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
508 abort();
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
509 }
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
510
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
511 return 1;
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
512 }
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
513
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
514 vf_info_t ve_info_xvid = {
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
515 "XviD encoder",
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
516 "xvid",
8078
26a2ae540b04 bugfixes :
rguyom
parents: 7458
diff changeset
517 "Kim Minh Kaplan & Rémi Guyomarch",
7456
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
518 "for internal use by mencoder",
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
519 vf_open
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
520 };
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
521
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
522 //===========================================================================//
dacc262f41ba Support for XviD encoding
kmkaplan
parents:
diff changeset
523 #endif