annotate libmpcodecs/ve_divx4.c @ 18987:1f08622dd297

Fix window size bug when starting with -fs and returning to windowed mode
author reimar
date Mon, 10 Jul 2006 10:22:29 +0000
parents a1807995e2ab
children
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
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15212
diff changeset
5 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15212
diff changeset
6 #include "mp_msg.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
7
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
8 #include "codec-cfg.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
9 #include "stream.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
10 #include "demuxer.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
11 #include "stheader.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
12
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8032
diff changeset
13 #include "muxer.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
14
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5551
diff changeset
15 #include "img_format.h"
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5551
diff changeset
16 #include "mp_image.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
17 #include "vf.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
18
7332
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
19 /* About XviD VBR Library, Edouard Gomez (GomGom) said:
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
20 <GomGom> header bytes == frame header bytes :-)
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
21 <GomGom> total bytes = frame bytes == texture + header
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
22 <GomGom> quant = quant returned by xvidcore
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
23 <GomGom> it's possible that xvid lowers or increases the passed quant because of lumimasking
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
24 <GomGom> kblks = blocks coded as intra blocks
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
25 <GomGom> mblks = blocks coded as predicted blocks
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
26 <GomGom> ublks = skipped blocks
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
27 <GomGom> at the moemnt le vbr lib uses total bytes, and quant
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
28 <GomGom> so it's easy to use it with divx5 (wo bframes)
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
29 <klOUg> bframes breaks what assumptions?
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
30 <GomGom> quant estimation for next frame
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
31 <GomGom> because of the bframe quant multiplier given to divx5
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
32 <GomGom> that the vbr lib does not "know"
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
33 */
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
34
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
35 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
36
8032
136e7e515764 removed -pass nonsense from mencoder! it's now a suboption to -divx4opts
rfelker
parents: 7368
diff changeset
37 static int pass;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
38 extern char* passtmpfile;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
39
9300
32be26de0d7c cleanup detection of various divx4 versions/alternatives
arpi
parents: 9014
diff changeset
40 #ifdef ENCORE_XVID
32be26de0d7c cleanup detection of various divx4 versions/alternatives
arpi
parents: 9014
diff changeset
41 #include <divx4.h>
32be26de0d7c cleanup detection of various divx4 versions/alternatives
arpi
parents: 9014
diff changeset
42 #else
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
43 #include <encore2.h>
9300
32be26de0d7c cleanup detection of various divx4 versions/alternatives
arpi
parents: 9014
diff changeset
44 #endif
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
45
5854
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
46 #ifndef ENCORE_MAJOR_VERSION
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
47 #define ENCORE_MAJOR_VERSION 4000
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
48 #endif
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
49
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
50 #if ENCORE_MAJOR_VERSION < 5200
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
51 #include "divx4_vbr.h"
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
52 #define HAVE_XVID_VBR
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
53 #ifdef HAVE_XVID_VBR
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
54 #include "xvid_vbr.h"
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
55 #endif
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
56 #endif
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
57
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
58 #if ENCORE_MAJOR_VERSION >= 5200
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
59 SETTINGS divx4_param;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
60 #else
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
61 ENC_PARAM divx4_param;
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
62 #endif
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
63 int divx4_crispness;
7332
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
64 #ifdef HAVE_XVID_VBR
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
65 static int vbrpass = -1;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
66 static int vbrdebug = 0;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
67 #endif
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
68
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 10252
diff changeset
69 #include "m_option.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
70
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 10252
diff changeset
71 m_option_t divx4opts_conf[]={
8032
136e7e515764 removed -pass nonsense from mencoder! it's now a suboption to -divx4opts
rfelker
parents: 7368
diff changeset
72 {"pass", &pass, CONF_TYPE_INT, CONF_RANGE,0,2, NULL},
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
73 {"br", &divx4_param.bitrate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL},
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
74 #if ENCORE_MAJOR_VERSION < 5200
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
75 {"rc_period", &divx4_param.rc_period, CONF_TYPE_INT, 0,0,0, NULL},
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
76 {"rc_reaction_period", &divx4_param.rc_reaction_period, CONF_TYPE_INT, 0,0,0, NULL},
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
77 {"rc_reaction_ratio", &divx4_param.rc_reaction_ratio, CONF_TYPE_INT, 0,0,0, NULL},
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
78 {"min_quant", &divx4_param.min_quantizer, CONF_TYPE_INT, CONF_RANGE,0,32, NULL},
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
79 {"max_quant", &divx4_param.max_quantizer, CONF_TYPE_INT, CONF_RANGE,0,32, NULL},
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
80 #endif
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
81 {"key", &divx4_param.max_key_interval, CONF_TYPE_INT, CONF_MIN,0,0, NULL},
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
82 {"deinterlace", &divx4_param.deinterlace, CONF_TYPE_FLAG, 0,0,1, NULL},
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
83 {"q", &divx4_param.quality, CONF_TYPE_INT, CONF_RANGE, 1, 5, NULL},
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
84 {"crispness", &divx4_crispness, CONF_TYPE_INT, CONF_RANGE,0,100, NULL},
5854
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
85 #if ENCORE_MAJOR_VERSION >= 5010
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
86 #if ENCORE_MAJOR_VERSION >= 5200
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
87 /* rate control modes:
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
88 0 (VBV 1-pass)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
89 1 (1-pass constant quality)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
90 2 (VBV multipass 1st-pass)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
91 3 (VBV multipass nth-pass)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
92 4 (original 1-pass)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
93 5 (original 1st pass)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
94 6 (original 2nd pass)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
95 7 (1-pass constant frame size)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
96 */
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
97 {"vbr", &divx4_param.vbr_mode, CONF_TYPE_INT, CONF_RANGE,0,7, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
98 {"bidirect", &divx4_param.use_bidirect, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
99 {"key_frame_threshold", &divx4_param.key_frame_threshold, CONF_TYPE_INT, CONF_RANGE,1,100, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
100 /* default values from the DivX Help Guide:
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
101 bitrate size occupancy
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
102 128000 262144 196608 (Handheld)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
103 768000 1048576 786432 (Portable)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
104 4000000 3145728 2359296 (Home Theatre)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
105 8000000 6291456 4718592 (High Definition)
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
106 Do not mess with these values unless you are absolutely sure of what you are doing!
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
107 */
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
108 {"vbv_bitrate", &divx4_param.vbv_bitrate, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
109 {"vbv_size", &divx4_param.vbv_size, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
110 {"vbv_occupancy", &divx4_param.vbv_occupancy, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
111 {"complexity", &divx4_param.complexity_modulation, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
112 {"readlog", &divx4_param.log_file_read, CONF_TYPE_STRING, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
113 {"writelog", &divx4_param.log_file_write, CONF_TYPE_STRING, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
114 {"mv_file", &divx4_param.mv_file, CONF_TYPE_STRING, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
115 {"data_partitioning", &divx4_param.data_partitioning, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
116 {"qpel", &divx4_param.quarter_pel, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
117 {"gmc", &divx4_param.use_gmc, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
118 {"pv", &divx4_param.psychovisual, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
119 {"pv_strength_frame", &divx4_param.pv_strength_frame, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
120 {"pv_strength_MB", &divx4_param.pv_strength_MB, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
121 {"interlace_mode", &divx4_param.interlace_mode, CONF_TYPE_INT, CONF_RANGE,0,3, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
122 {"crop", &divx4_param.enable_crop, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
123 {"resize", &divx4_param.enable_resize, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
124 {"width", &divx4_param.resize_width, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
125 {"height", &divx4_param.resize_height, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
126 {"left", &divx4_param.crop_left, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
127 {"right", &divx4_param.crop_right, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
128 {"top", &divx4_param.crop_top, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
129 {"bottom", &divx4_param.crop_bottom, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
130 {"resize_mode", &divx4_param.resize_mode, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
131 {"temporal", &divx4_param.temporal_enable, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
132 {"spatial", &divx4_param.spatial_passes, CONF_TYPE_INT, CONF_RANGE,0,3, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
133 {"temporal_level", &divx4_param.temporal_level, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
134 {"spatial_level", &divx4_param.spatial_level, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
135 #else
5854
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
136 {"bidirect", &divx4_param.extensions.use_bidirect, CONF_TYPE_FLAG, 0,0,1, NULL},
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
137 {"obmc", &divx4_param.extensions.obmc, CONF_TYPE_FLAG, 0,0,1, NULL},
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
138 {"data_partitioning", &divx4_param.extensions.data_partitioning, CONF_TYPE_FLAG, 0,0,1, NULL},
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
139 // {"mpeg2", &divx4_param.extensions.mpeg2_quant, CONF_TYPE_FLAG, 0,0,1, NULL},
5854
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
140 {"qpel", &divx4_param.extensions.quarter_pel, CONF_TYPE_FLAG, 0,0,1, NULL},
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
141 {"intra_frame_threshold", &divx4_param.extensions.intra_frame_threshold, CONF_TYPE_INT, CONF_RANGE,1,100, NULL},
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
142 {"psychovisual", &divx4_param.extensions.psychovisual, CONF_TYPE_FLAG, 0,0,1, NULL},
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
143 {"pv", &divx4_param.extensions.psychovisual, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
144 {"pv_strength_frame", &divx4_param.extensions.pv_strength_frame, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
145 {"pv_strength_MB", &divx4_param.extensions.pv_strength_MB, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL},
5854
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
146 {"testing_param", &divx4_param.extensions.testing_param, CONF_TYPE_FLAG, 0,0,1, NULL},
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
147 {"gmc", &divx4_param.extensions.use_gmc, CONF_TYPE_FLAG, 0,0,1, NULL},
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
148 {"interlace_mode", &divx4_param.extensions.interlace_mode, CONF_TYPE_INT, CONF_RANGE,0,2, NULL},
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
149 {"crop", &divx4_param.extensions.enable_crop, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
150 {"resize", &divx4_param.extensions.enable_resize, CONF_TYPE_FLAG, 0,0,1, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
151 {"width", &divx4_param.extensions.resize_width, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
152 {"height", &divx4_param.extensions.resize_height, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
153 {"left", &divx4_param.extensions.crop_left, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
154 {"right", &divx4_param.extensions.crop_right, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
155 {"top", &divx4_param.extensions.crop_top, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
156 {"bottom", &divx4_param.extensions.crop_bottom, CONF_TYPE_INT, 0,0,0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
157 {"resize_mode", &divx4_param.extensions.resize_mode, CONF_TYPE_FLAG, 0,0,1, NULL},
5854
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
158 {"temporal", &divx4_param.extensions.temporal_enable, CONF_TYPE_FLAG, 0,0,1, NULL},
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
159 {"spatial", &divx4_param.extensions.spatial_passes, CONF_TYPE_INT, CONF_RANGE,0,3, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
160 {"temporal_level", &divx4_param.extensions.temporal_level, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL},
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
161 {"spatial_level", &divx4_param.extensions.spatial_level, CONF_TYPE_FLOAT, CONF_RANGE,0.0,1.0, NULL},
5854
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
162 {"mv_file", &divx4_param.extensions.mv_file, CONF_TYPE_STRING, 0,0,1, NULL},
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
163 #endif
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
164 #endif
7332
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
165 #ifdef HAVE_XVID_VBR
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
166 {"vbrpass", &vbrpass, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
167 {"vbrdebug", &vbrdebug, CONF_TYPE_INT, CONF_RANGE, 0, 1, NULL},
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
168 #endif
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
169 {"help", "TODO: divx4opts help!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
170 {NULL, NULL, 0, 0, 0, 0, NULL}
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
171 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
172
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
173 struct vf_priv_s {
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8032
diff changeset
174 muxer_stream_t* mux;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
175 ENC_RESULT enc_result;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
176 ENC_FRAME enc_frame;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
177 void* enc_handle;
7332
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
178 #ifdef HAVE_XVID_VBR
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
179 vbr_control_t vbr_state;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
180 #endif
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
181 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
182
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
183 #define mux_v (vf->priv->mux)
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
184
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
185 static int config(struct vf_instance_s* vf,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
186 int width, int height, int d_width, int d_height,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
187 unsigned int flags, unsigned int outfmt){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
188
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
189 #if ENCORE_MAJOR_VERSION >= 5200
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
190 DivXBitmapInfoHeader format;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
191 char profile = (char) encore(0, ENC_OPT_PROFILE, 0, 0);
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
192
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
193 mp_msg(MSGT_MENCODER, MSGL_INFO, "encoder binary profile: %c\n", profile);
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
194
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
195 if((pass <= 1 && (divx4_param.vbr_mode == RCMODE_VBV_MULTIPASS_NTH ||
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
196 divx4_param.vbr_mode == RCMODE_502_2PASS_2ND)) ||
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
197 (pass == 2 && (divx4_param.vbr_mode == RCMODE_VBV_1PASS ||
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
198 divx4_param.vbr_mode == RCMODE_1PASS_CONSTANT_Q ||
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
199 divx4_param.vbr_mode == RCMODE_VBV_MULTIPASS_1ST ||
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
200 divx4_param.vbr_mode == RCMODE_502_1PASS ||
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
201 divx4_param.vbr_mode == RCMODE_502_2PASS_1ST ||
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
202 divx4_param.vbr_mode == RCMODE_IMAGE_COMPRESS))) {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
203 mp_msg(MSGT_MENCODER, MSGL_ERR, "pass (%i) and rate control mode (%i) doesn't match, please consult encore2.h\n",
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
204 pass, divx4_param.vbr_mode);
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
205 abort();
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
206 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
207 #endif
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
208
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
209 mux_v->bih->biWidth=width;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
210 mux_v->bih->biHeight=height;
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
211 mux_v->bih->biSizeImage=width*height*3;
12061
656a1b45b309 Use aspect from encoder for AVI vprp header
ranma
parents: 10594
diff changeset
212 mux_v->aspect = (float)d_width/d_height;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
213
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
214 if(!divx4_param.bitrate) divx4_param.bitrate=800000;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
215 else if(divx4_param.bitrate<=16000) divx4_param.bitrate*=1000;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
216 if(!divx4_param.quality) divx4_param.quality=5; // the quality of compression ( 1 - fastest, 5 - best )
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
217
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
218 #if ENCORE_MAJOR_VERSION >= 5200
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
219 format.biSize=sizeof(DivXBitmapInfoHeader);
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
220 format.biWidth=width;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
221 format.biHeight=height;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
222 format.biSizeImage=mux_v->bih->biSizeImage;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
223 if(divx4_param.vbv_bitrate > 0) {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
224 divx4_param.vbv_bitrate = ((divx4_param.vbv_bitrate - 1) / 400 + 1) * 400;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
225 divx4_param.vbv_size = ((divx4_param.vbv_size - 1) / 16384 + 1) * 16384;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
226 divx4_param.vbv_occupancy = ((divx4_param.vbv_occupancy - 1) / 64 + 1) * 64;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
227 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
228 #else
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
229 divx4_param.x_dim=width;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
230 divx4_param.y_dim=height;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
231 divx4_param.framerate=(float)mux_v->h.dwRate/mux_v->h.dwScale;
5551
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
232 // set some usefull defaults:
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
233 if(!divx4_param.min_quantizer) divx4_param.min_quantizer=2;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
234 if(!divx4_param.max_quantizer) divx4_param.max_quantizer=31;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
235 if(!divx4_param.rc_period) divx4_param.rc_period=2000;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
236 if(!divx4_param.rc_reaction_period) divx4_param.rc_reaction_period=10;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
237 if(!divx4_param.rc_reaction_ratio) divx4_param.rc_reaction_ratio=20;
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
238 #endif
5551
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
239
7332
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
240 #ifdef HAVE_XVID_VBR
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
241 if (vbrpass >= 0) {
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
242 vbrSetDefaults(&vf->priv->vbr_state);
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
243 vf->priv->vbr_state.desired_bitrate = divx4_param.bitrate;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
244 switch (vbrpass) {
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
245 case 0:
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
246 vf->priv->vbr_state.mode = VBR_MODE_1PASS;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
247 break;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
248 case 1:
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
249 vf->priv->vbr_state.mode = VBR_MODE_2PASS_1;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
250 break;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
251 case 2:
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
252 vf->priv->vbr_state.mode = VBR_MODE_2PASS_2;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
253 break;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
254 default:
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
255 abort();
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
256 }
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
257 vf->priv->vbr_state.debug = vbrdebug;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
258 if (vbrInit(&vf->priv->vbr_state) == -1)
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
259 abort();
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
260 /* XXX - kludge to workaround some DivX encoder limitations */
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
261 if (vf->priv->vbr_state.mode != VBR_MODE_2PASS_2)
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
262 divx4_param.min_quantizer = divx4_param.max_quantizer = vbrGetQuant(&vf->priv->vbr_state);
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
263 }
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
264 #endif
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
265
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
266 #if ENCORE_MAJOR_VERSION >= 5200
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
267 switch(outfmt){
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
268 case IMGFMT_YV12: {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
269 format.biCompression=mmioFOURCC('Y','V','1','2');
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
270 break;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
271 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
272 case IMGFMT_IYUV: {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
273 format.biCompression=mmioFOURCC('I','Y','U','V');
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
274 break;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
275 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
276 case IMGFMT_I420: {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
277 format.biCompression=mmioFOURCC('I','4','2','0');
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
278 break;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
279 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
280 case IMGFMT_YUY2: {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
281 format.biCompression=mmioFOURCC('Y','U','Y','2');
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
282 break;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
283 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
284 case IMGFMT_V422: {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
285 format.biCompression=mmioFOURCC('V','4','2','2');
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
286 break;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
287 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
288 case IMGFMT_UYVY: {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
289 format.biCompression=mmioFOURCC('U','Y','V','Y');
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
290 break;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
291 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
292 case IMGFMT_YVYU: {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
293 format.biCompression=mmioFOURCC('Y','V','Y','U');
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
294 break;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
295 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
296 case IMGFMT_BGR24: {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
297 format.biCompression=0;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
298 format.biBitCount=24;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
299 break;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
300 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
301 case IMGFMT_BGR32: {
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
302 format.biCompression=0;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
303 format.biBitCount=32;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
304 break;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
305 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
306 default:
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
307 mp_msg(MSGT_MENCODER,MSGL_ERR,"divx4: unsupported picture format (%s)!\n",
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
308 vo_format_name(outfmt));
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
309 return 0;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
310 }
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
311
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
312 encore(&vf->priv->enc_handle, ENC_OPT_INIT, &format, &divx4_param);
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
313 #else
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
314 divx4_param.handle=NULL;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
315 encore(NULL,ENC_OPT_INIT,&divx4_param,NULL);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
316 vf->priv->enc_handle=divx4_param.handle;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
317 switch(outfmt){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
318 case IMGFMT_YV12: vf->priv->enc_frame.colorspace=ENC_CSP_YV12; break;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
319 case IMGFMT_IYUV:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
320 case IMGFMT_I420: vf->priv->enc_frame.colorspace=ENC_CSP_I420; break;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
321 case IMGFMT_YUY2: vf->priv->enc_frame.colorspace=ENC_CSP_YUY2; break;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
322 case IMGFMT_UYVY: vf->priv->enc_frame.colorspace=ENC_CSP_UYVY; break;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
323 case IMGFMT_RGB24:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
324 case IMGFMT_BGR24:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
325 vf->priv->enc_frame.colorspace=ENC_CSP_RGB24; break;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
326 default:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
327 mp_msg(MSGT_MENCODER,MSGL_ERR,"divx4: unsupported picture format (%s)!\n",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
328 vo_format_name(outfmt));
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
329 return 0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
330 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
331
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
332 switch(pass){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
333 case 1:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
334 if (VbrControl_init_2pass_vbr_analysis(passtmpfile, divx4_param.quality) == -1){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
335 mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s\n", passtmpfile);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
336 pass=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
337 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
338 break;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
339 case 2:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
340 if (VbrControl_init_2pass_vbr_encoding(passtmpfile,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
341 divx4_param.bitrate,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
342 divx4_param.framerate,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
343 divx4_crispness,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
344 divx4_param.quality) == -1){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
345 mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s\n", passtmpfile);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
346 pass=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
347 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
348 break;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
349 }
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
350 #endif
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
351
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
352 return 1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
353 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
354
7332
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
355 #ifdef HAVE_XVID_VBR
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
356 static void uninit(struct vf_instance_s* vf){
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
357 if (vbrpass >= 0 && vbrFinish(&vf->priv->vbr_state) == -1)
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
358 abort();
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
359 }
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
360 #else
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
361 static void uninit(struct vf_instance_s* vf){
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
362 encore(vf->priv->enc_handle, ENC_OPT_RELEASE, 0, 0);
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
363 vf->priv->enc_handle = NULL;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
364 }
7332
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
365 #endif
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
366
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
367 static int control(struct vf_instance_s* vf, int request, void* data){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
368
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
369 return CONTROL_UNKNOWN;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
370 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
371
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
372 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
373 switch(fmt){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
374 case IMGFMT_YV12:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
375 case IMGFMT_IYUV:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
376 case IMGFMT_I420:
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 14878
diff changeset
377 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; // no conversion
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
378 case IMGFMT_YUY2:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
379 case IMGFMT_UYVY:
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 14878
diff changeset
380 return VFCAP_CSP_SUPPORTED; // conversion
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
381 case IMGFMT_RGB24:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
382 case IMGFMT_BGR24:
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 14878
diff changeset
383 return VFCAP_CSP_SUPPORTED | VFCAP_FLIPPED; // conversion+flipped
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
384 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
385 return 0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
386 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
387
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17487
diff changeset
388 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
389 ENC_RESULT enc_result;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
390 vf->priv->enc_frame.image=mpi->planes[0];
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
391 vf->priv->enc_frame.bitstream=mux_v->buffer;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
392 vf->priv->enc_frame.length=mux_v->buffer_size;
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
393 #if ENCORE_MAJOR_VERSION >= 5200
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
394 vf->priv->enc_frame.produce_empty_frame = 0;
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
395 encore(vf->priv->enc_handle, ENC_OPT_ENCODE, &vf->priv->enc_frame, &enc_result);
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
396 if(enc_result.cType == 'I')
17487
fa17424b4c7b change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents: 17012
diff changeset
397 muxer_write_chunk(mux_v,vf->priv->enc_frame.length,0x10, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
398 else
17487
fa17424b4c7b change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents: 17012
diff changeset
399 muxer_write_chunk(mux_v,vf->priv->enc_frame.length,0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
400 #else
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
401 vf->priv->enc_frame.mvs=NULL;
7332
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
402 #ifdef HAVE_XVID_VBR
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
403 if (vbrpass >= 0) {
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
404 int quant = vbrGetQuant(&vf->priv->vbr_state);
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
405 int intra = vbrGetIntra(&vf->priv->vbr_state);
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
406 vf->priv->enc_frame.quant = quant ? quant : 1;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
407 vf->priv->enc_frame.intra = intra;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
408 /* XXX - kludge to workaround some DivX encoder limitations:
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
409 only pass 2 needs to call encore with VBR, and then it does
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
410 not report quantizer and intra*/
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
411 if (vf->priv->vbr_state.mode != VBR_MODE_2PASS_2)
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
412 encore(vf->priv->enc_handle, ENC_OPT_ENCODE, &vf->priv->enc_frame, &enc_result);
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
413 else {
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
414 encore(vf->priv->enc_handle, ENC_OPT_ENCODE_VBR, &vf->priv->enc_frame, &enc_result);
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
415 enc_result.quantizer = quant;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
416 if (intra >= 0)
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
417 enc_result.is_key_frame = intra;
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
418 }
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
419 if (vbrUpdate(&vf->priv->vbr_state, enc_result.quantizer, enc_result.is_key_frame,
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
420 (enc_result.total_bits - enc_result.texture_bits) / 8, enc_result.total_bits / 8,
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
421 0, 0, 0) == -1)
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
422 abort();
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
423 }
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
424 else
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
425 #endif
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
426 if(pass==2){ // handle 2-pass:
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
427 vf->priv->enc_frame.quant = VbrControl_get_quant();
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
428 vf->priv->enc_frame.intra = VbrControl_get_intra();
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
429 encore(vf->priv->enc_handle,ENC_OPT_ENCODE_VBR,&vf->priv->enc_frame,&enc_result);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
430 VbrControl_update_2pass_vbr_encoding(enc_result.motion_bits,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
431 enc_result.texture_bits,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
432 enc_result.total_bits);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
433 } else {
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
434 vf->priv->enc_frame.quant=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
435 vf->priv->enc_frame.intra=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
436 encore(vf->priv->enc_handle,ENC_OPT_ENCODE,&vf->priv->enc_frame,&enc_result);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
437 if(pass==1){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
438 VbrControl_update_2pass_vbr_analysis(enc_result.is_key_frame,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
439 enc_result.motion_bits,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
440 enc_result.texture_bits,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
441 enc_result.total_bits,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
442 enc_result.quantizer);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
443 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
444 }
17487
fa17424b4c7b change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents: 17012
diff changeset
445 muxer_write_chunk(mux_v,vf->priv->enc_frame.length,enc_result.is_key_frame?0x10:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
446 #endif
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7332
diff changeset
447 return 1;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
448 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
449
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
450 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
451
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
452 static int vf_open(vf_instance_t *vf, char* args){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
453 vf->config=config;
14878
5723c4b2a2ea fixes for encoding of multiple files
henry
parents: 14549
diff changeset
454 vf->default_caps=VFCAP_CONSTANT;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
455 vf->control=control;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
456 vf->query_format=query_format;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
457 vf->put_image=put_image;
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
458 //#ifdef HAVE_XVID_VBR
7332
dd32b0c95c95 Code to XviD VBR Library from transcode.
kmkaplan
parents: 7127
diff changeset
459 vf->uninit = uninit;
10252
d275152390ee I've found some time to implement the encoding support for the new
arpi
parents: 9300
diff changeset
460 //#endif
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
461 vf->priv=malloc(sizeof(struct vf_priv_s));
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
462 memset(vf->priv,0,sizeof(struct vf_priv_s));
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8032
diff changeset
463 vf->priv->mux=(muxer_stream_t*)args;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
464
14549
acf3241be19b Initialized BITMAPINFOHEADER to 0 to avoid problems, esp. windows has problems
reimar
parents: 12061
diff changeset
465 mux_v->bih=calloc(1, sizeof(BITMAPINFOHEADER));
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
466 mux_v->bih->biSize=sizeof(BITMAPINFOHEADER);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
467 mux_v->bih->biWidth=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
468 mux_v->bih->biHeight=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
469 mux_v->bih->biPlanes=1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
470 mux_v->bih->biBitCount=24;
5854
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
471 #if ENCORE_MAJOR_VERSION >= 5010
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
472 mux_v->bih->biCompression=mmioFOURCC('D','X','5','0');
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
473 #else
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
474 mux_v->bih->biCompression=mmioFOURCC('d','i','v','x');
5854
3a961eaf45b9 divx5.1 features added
arpi
parents: 5706
diff changeset
475 #endif
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
476
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
477 return 1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
478 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
479
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
480 vf_info_t ve_info_divx4 = {
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
481 "divx4 encoder",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
482 "divx4",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
483 "A'rpi",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
484 "for internal use by mencoder",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
485 vf_open
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
486 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
487
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
488 //===========================================================================//