Mercurial > mplayer.hg
annotate libmpcodecs/ve_xvid4.c @ 32115:38ffbeed52a0
Replace one more instance of sizeof(WAVEFORMATEX); fix compilation.
patch by Clment Bsch, ubitux gmail com
author | diego |
---|---|
date | Sun, 12 Sep 2010 15:14:47 +0000 |
parents | a735105a66b6 |
children | a86413775fbe |
rev | line source |
---|---|
26727 | 1 /* |
26883 | 2 * - XviD 1.x decoder module for mplayer/mencoder - |
11437 | 3 * |
26727 | 4 * Copyright(C) 2003 Marco Belli <elcabesa@inwind.it> |
5 * 2003-2004 Edouard Gomez <ed.gomez@free.fr> | |
11437 | 6 * |
26727 | 7 * This file is part of MPlayer. |
11437 | 8 * |
26727 | 9 * MPlayer is free software; you can redistribute it and/or modify |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
11437 | 13 * |
26727 | 14 * MPlayer is distributed in the hope that it will be useful, |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
11437 | 18 * |
26727 | 19 * You should have received a copy of the GNU General Public License along |
20 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
22 */ | |
11437 | 23 |
24 /***************************************************************************** | |
25 * Includes | |
26 ****************************************************************************/ | |
27 | |
28 #include <stdio.h> | |
29 #include <stdlib.h> | |
30 #include <string.h> | |
31 #include <errno.h> | |
32 #include <math.h> | |
33 #include <limits.h> | |
11920 | 34 #include <time.h> |
11437 | 35 |
17012 | 36 #include "config.h" |
37 #include "mp_msg.h" | |
32064
a735105a66b6
Move all MEncoder-related extern variable declarations to mencoder.h.
diego
parents:
32033
diff
changeset
|
38 #include "mencoder.h" |
11437 | 39 #include "codec-cfg.h" |
22600
3c2b4a866c6a
Add explicit location for headers from the stream/ directory.
diego
parents:
21660
diff
changeset
|
40 #include "stream/stream.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
41 #include "libmpdemux/demuxer.h" |
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
42 #include "libmpdemux/stheader.h" |
11437 | 43 |
22600
3c2b4a866c6a
Add explicit location for headers from the stream/ directory.
diego
parents:
21660
diff
changeset
|
44 #include "stream/stream.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
45 #include "libmpdemux/muxer.h" |
11437 | 46 |
47 #include "img_format.h" | |
48 #include "mp_image.h" | |
49 #include "vf.h" | |
50 | |
51 #include <xvid.h> | |
52 #include <stdio.h> | |
53 #include <stdarg.h> | |
54 #include <limits.h> | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
55 #include <assert.h> |
11437 | 56 |
57 #include "m_option.h" | |
26069
1318e956c092
FFmpeg now uses different (unified) #include paths.
diego
parents:
25962
diff
changeset
|
58 #include "libavutil/avutil.h" |
24295
de8e36aec5ff
Remove imported rational calculation code and use the original one from avutil.
iive
parents:
22601
diff
changeset
|
59 |
11437 | 60 #define FINE (!0) |
61 #define BAD (!FINE) | |
62 | |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
63 #define MAX_ZONES 64 |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
64 |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
65 // Profile flag definitions |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
66 #define PROFILE_ADAPTQUANT 0x00000001 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
67 #define PROFILE_BVOP 0x00000002 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
68 #define PROFILE_MPEGQUANT 0x00000004 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
69 #define PROFILE_INTERLACE 0x00000008 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
70 #define PROFILE_QPEL 0x00000010 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
71 #define PROFILE_GMC 0x00000020 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
72 #define PROFILE_4MV 0x00000040 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
73 #define PROFILE_DXN 0x00000080 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
74 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
75 // Reduce code duplication in profiles[] array |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
76 #define PROFILE_S (PROFILE_4MV) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
77 #define PROFILE_AS (PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_MPEGQUANT|PROFILE_INTERLACE|PROFILE_QPEL|PROFILE_GMC) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
78 |
24629
36c574ac1008
Define profiles_t as const to fix a warning. Prevent profiles[] from been exported.
iive
parents:
24295
diff
changeset
|
79 typedef const struct |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
80 { |
28186
79aef31ed618
XVID profile array should be const, so it is in rodata
reimar
parents:
26883
diff
changeset
|
81 const char *name; ///< profile name |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
82 int id; ///< mpeg-4 profile id; iso/iec 14496-2:2001 table G-1 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
83 int width; ///< profile width restriction |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
84 int height; ///< profile height restriction |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
85 int fps; ///< profile frame rate restriction |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
86 int max_objects; ///< ?????? |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
87 int total_vmv_buffer_sz; ///< macroblock memory; when BVOPS=false, vmv = 2*vcv; when BVOPS=true, vmv = 3*vcv |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
88 int max_vmv_buffer_sz; ///< max macroblocks per vop |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
89 int vcv_decoder_rate; ///< macroblocks decoded per second |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
90 int max_acpred_mbs; ///< percentage |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
91 int max_vbv_size; ///< max vbv size (bits) 16368 bits |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
92 int max_video_packet_length; ///< bits |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
93 int max_bitrate; ///< bits per second |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
94 int vbv_peakrate; ///< max bits over anyone second period; 0=don't care |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
95 int dxn_max_bframes; ///< dxn: max consecutive bframes |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
96 unsigned int flags; ///< flags for allowed options/dxn note the definitions for PROFILE_S and PROFILE_AS |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
97 } profile_t; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
98 |
26883 | 99 // Code taken from XviD VfW source for profile support |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
100 |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
101 /* default vbv_occupancy is (64/170)*vbv_buffer_size */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
102 |
28186
79aef31ed618
XVID profile array should be const, so it is in rodata
reimar
parents:
26883
diff
changeset
|
103 static const profile_t profiles[] = |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
104 { |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
105 /* name p@l w h fps obj Tvmv vmv vcv ac% vbv pkt bps vbv_peak dbf flags */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
106 /* unrestricted profile (default) */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
107 { "unrestricted", 0x00, 0, 0, 0, 0, 0, 0, 0, 100, 0*16368, -1, 0, 0, -1, 0xffffffff & ~PROFILE_DXN }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
108 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
109 { "sp0", 0x08, 176, 144, 15, 1, 198, 99, 1485, 100, 10*16368, 2048, 64000, 0, -1, PROFILE_S }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
110 /* simple@l0: max f_code=1, intra_dc_vlc_threshold=0 */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
111 /* if ac preidition is used, adaptive quantization must not be used */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
112 /* <=qcif must be used */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
113 { "sp1", 0x01, 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 2048, 64000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
114 { "sp2", 0x02, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 4096, 128000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
115 { "sp3", 0x03, 352, 288, 15, 4, 792, 396, 11880, 100, 40*16368, 8192, 384000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, |
31937
0b29d0c8c62d
Add new Simple Profile Levels to the Xvid encoder.
cehoyos
parents:
30955
diff
changeset
|
116 /* From ISO/IEC 14496-2:2004/FPDAM 2: New Levels for Simple Profile */ |
0b29d0c8c62d
Add new Simple Profile Levels to the Xvid encoder.
cehoyos
parents:
30955
diff
changeset
|
117 { "sp4a", 0x04, 640, 480, 30, 4, 2400, 1200, 36000, 100, 80*16368, 16384, 4000000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, |
0b29d0c8c62d
Add new Simple Profile Levels to the Xvid encoder.
cehoyos
parents:
30955
diff
changeset
|
118 { "sp5", 0x05, 720, 576, 30, 4, 3240, 1620, 40500, 100, 112*16368, 16384, 8000000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, |
0b29d0c8c62d
Add new Simple Profile Levels to the Xvid encoder.
cehoyos
parents:
30955
diff
changeset
|
119 /* From ISO/IEC 14496-2:2004/FPDAM 4: Simple profile level 6 */ |
0b29d0c8c62d
Add new Simple Profile Levels to the Xvid encoder.
cehoyos
parents:
30955
diff
changeset
|
120 { "sp6", 0x06, 1280, 720, 30, 4, 7200, 3600, 108000, 100, 248*16368, 16384,12000000, 0, -1, PROFILE_S|PROFILE_ADAPTQUANT }, |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
121 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
122 { "asp0", 0xf0, 176, 144, 30, 1, 297, 99, 2970, 100, 10*16368, 2048, 128000, 0, -1, PROFILE_AS }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
123 { "asp1", 0xf1, 176, 144, 30, 4, 297, 99, 2970, 100, 10*16368, 2048, 128000, 0, -1, PROFILE_AS }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
124 { "asp2", 0xf2, 352, 288, 15, 4, 1188, 396, 5940, 100, 40*16368, 4096, 384000, 0, -1, PROFILE_AS }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
125 { "asp3", 0xf3, 352, 288, 30, 4, 1188, 396, 11880, 100, 40*16368, 4096, 768000, 0, -1, PROFILE_AS }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
126 /* ISMA Profile 1, (ASP) @ L3b (CIF, 1.5 Mb/s) CIF(352x288), 30fps, 1.5Mbps max ??? */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
127 { "asp4", 0xf4, 352, 576, 30, 4, 2376, 792, 23760, 50, 80*16368, 8192, 3000000, 0, -1, PROFILE_AS }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
128 { "asp5", 0xf5, 720, 576, 30, 4, 4860, 1620, 48600, 25, 112*16368, 16384, 8000000, 0, -1, PROFILE_AS }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
129 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
130 // information provided by DivXNetworks, USA. |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
131 // "DivX Certified Profile Compatibility v1.1", February 2005 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
132 { "dxnhandheld", 0x00, 176, 144, 15, 1, 198, 99, 1485, 100, 32*8192, -1, 537600, 800000, 0, PROFILE_ADAPTQUANT|PROFILE_DXN }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
133 { "dxnportntsc", 0x00, 352, 240, 30, 1, 990, 330, 36000, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_DXN }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
134 { "dxnportpal", 0x00, 352, 288, 25, 1, 1188, 396, 36000, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_DXN }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
135 { "dxnhtntsc", 0x00, 720, 480, 30, 1, 4050, 1350, 40500, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE|PROFILE_DXN }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
136 { "dxnhtpal", 0x00, 720, 576, 25, 1, 4860, 1620, 40500, 100, 384*8192, -1, 4854000, 8000000, 1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE|PROFILE_DXN }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
137 { "dxnhdtv", 0x00, 1280, 720, 30, 1,10800, 3600, 108000, 100, 768*8192, -1, 9708400, 16000000, 2, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE|PROFILE_DXN }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
138 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
139 { NULL, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00000000 }, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
140 }; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
141 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
142 /** |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
143 * \brief return the pointer to a chosen profile |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
144 * \param str the profile name |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
145 * \return pointer of the appropriate profiles array entry or NULL for a mistyped profile name |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
146 */ |
28186
79aef31ed618
XVID profile array should be const, so it is in rodata
reimar
parents:
26883
diff
changeset
|
147 static const profile_t *profileFromName(const char *str) |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
148 { |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
149 profile_t *cur = profiles; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
150 while (cur->name && strcasecmp(cur->name, str)) cur++; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
151 if(!cur->name) return NULL; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
152 return cur; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
153 } |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
154 |
11437 | 155 /***************************************************************************** |
156 * Configuration options | |
157 ****************************************************************************/ | |
158 | |
159 static int xvidenc_bitrate = 0; | |
160 static int xvidenc_pass = 0; | |
161 static float xvidenc_quantizer = 0; | |
162 | |
163 static int xvidenc_packed = 0; | |
164 static int xvidenc_closed_gop = 1; | |
165 static int xvidenc_interlaced = 0; | |
166 static int xvidenc_quarterpel = 0; | |
167 static int xvidenc_gmc = 0; | |
15070
bde4030f9134
Better defaults encoding settings for XviD, intended to be a good tradeoff CPU/PSNR.
gpoirier
parents:
14878
diff
changeset
|
168 static int xvidenc_trellis = 1; |
11437 | 169 static int xvidenc_cartoon = 0; |
170 static int xvidenc_hqacpred = 1; | |
15070
bde4030f9134
Better defaults encoding settings for XviD, intended to be a good tradeoff CPU/PSNR.
gpoirier
parents:
14878
diff
changeset
|
171 static int xvidenc_chromame = 1; |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
172 static int xvidenc_chroma_opt = 0; |
15070
bde4030f9134
Better defaults encoding settings for XviD, intended to be a good tradeoff CPU/PSNR.
gpoirier
parents:
14878
diff
changeset
|
173 static int xvidenc_vhq = 1; |
bde4030f9134
Better defaults encoding settings for XviD, intended to be a good tradeoff CPU/PSNR.
gpoirier
parents:
14878
diff
changeset
|
174 static int xvidenc_bvhq = 1; |
11437 | 175 static int xvidenc_motion = 6; |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
176 static int xvidenc_turbo = 0; |
11437 | 177 static int xvidenc_stats = 0; |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
178 static int xvidenc_max_key_interval = 0; /* Let xvidcore set a 10s interval by default */ |
11437 | 179 static int xvidenc_frame_drop_ratio = 0; |
180 static int xvidenc_greyscale = 0; | |
15638
189da3c3116b
Add XviD's luminance masking (option name: lumi_mask)
gpoirier
parents:
15619
diff
changeset
|
181 static int xvidenc_luminance_masking = 0; |
11920 | 182 static int xvidenc_debug = 0; |
183 static int xvidenc_psnr = 0; | |
11437 | 184 |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
185 static int xvidenc_max_bframes = 2; |
17703 | 186 static int xvidenc_num_threads = 0; |
11437 | 187 static int xvidenc_bquant_ratio = 150; |
188 static int xvidenc_bquant_offset = 100; | |
189 static int xvidenc_bframe_threshold = 0; | |
190 | |
191 static int xvidenc_min_quant[3] = {2, 2, 2}; | |
192 static int xvidenc_max_quant[3] = {31, 31, 31}; | |
193 static char *xvidenc_intra_matrix_file = NULL; | |
194 static char *xvidenc_inter_matrix_file = NULL; | |
195 static char *xvidenc_quant_method = NULL; | |
196 | |
197 static int xvidenc_cbr_reaction_delay_factor = 0; | |
198 static int xvidenc_cbr_averaging_period = 0; | |
199 static int xvidenc_cbr_buffer = 0; | |
200 | |
201 static int xvidenc_vbr_keyframe_boost = 0; | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
202 static int xvidenc_vbr_overflow_control_strength = 5; |
11437 | 203 static int xvidenc_vbr_curve_compression_high = 0; |
204 static int xvidenc_vbr_curve_compression_low = 0; | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
205 static int xvidenc_vbr_max_overflow_improvement = 5; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
206 static int xvidenc_vbr_max_overflow_degradation = 5; |
11437 | 207 static int xvidenc_vbr_kfreduction = 0; |
11586 | 208 static int xvidenc_vbr_kfthreshold = 0; |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
209 static int xvidenc_vbr_container_frame_overhead = 24; /* mencoder uses AVI container */ |
11437 | 210 |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
211 // commandline profile option string - default to unrestricted |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
212 static char *xvidenc_profile = "unrestricted"; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
213 |
11437 | 214 static char *xvidenc_par = NULL; |
215 static int xvidenc_par_width = 0; | |
216 static int xvidenc_par_height = 0; | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
217 static float xvidenc_dar_aspect = 0.0f; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
218 static int xvidenc_autoaspect = 0; |
11437 | 219 |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
220 static char *xvidenc_zones = NULL; // zones string |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
221 |
30955
4e59a7aebadb
Mark encoder-related m_option_t struct arrays as const.
diego
parents:
30642
diff
changeset
|
222 const m_option_t xvidencopts_conf[] = |
11437 | 223 { |
224 /* Standard things mencoder should be able to treat directly */ | |
225 {"bitrate", &xvidenc_bitrate, CONF_TYPE_INT, 0, 0, 0, NULL}, | |
226 {"pass", &xvidenc_pass, CONF_TYPE_INT, CONF_RANGE, 1, 2, NULL}, | |
227 {"fixed_quant", &xvidenc_quantizer, CONF_TYPE_FLOAT, CONF_RANGE, 1, 31, NULL}, | |
228 | |
229 /* Features */ | |
230 {"quant_type", &xvidenc_quant_method, CONF_TYPE_STRING, 0, 0, 0, NULL}, | |
231 {"me_quality", &xvidenc_motion, CONF_TYPE_INT, CONF_RANGE, 0, 6, NULL}, | |
232 {"chroma_me", &xvidenc_chromame, CONF_TYPE_FLAG, 0, 0, 1, NULL}, | |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
233 {"nochroma_me", &xvidenc_chromame, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
234 {"chroma_opt", &xvidenc_chroma_opt, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
235 {"nochroma_opt", &xvidenc_chroma_opt, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11437 | 236 {"vhq", &xvidenc_vhq, CONF_TYPE_INT, CONF_RANGE, 0, 4, NULL}, |
13610 | 237 {"bvhq", &xvidenc_bvhq, CONF_TYPE_INT, CONF_RANGE, 0, 1, NULL}, |
11437 | 238 {"max_bframes", &xvidenc_max_bframes, CONF_TYPE_INT, CONF_RANGE, 0, 20, NULL}, |
17703 | 239 {"threads", &xvidenc_num_threads, CONF_TYPE_INT, 0, 0, 0, NULL}, |
11437 | 240 {"bquant_ratio", &xvidenc_bquant_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 200, NULL}, |
241 {"bquant_offset", &xvidenc_bquant_offset, CONF_TYPE_INT, CONF_RANGE, 0, 200, NULL}, | |
242 {"bf_threshold", &xvidenc_bframe_threshold, CONF_TYPE_INT, CONF_RANGE, -255, 255, NULL}, | |
243 {"qpel", &xvidenc_quarterpel, CONF_TYPE_FLAG, 0, 0, 1, NULL}, | |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
244 {"noqpel", &xvidenc_quarterpel, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11437 | 245 {"gmc", &xvidenc_gmc, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
246 {"nogmc", &xvidenc_gmc, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11437 | 247 {"trellis", &xvidenc_trellis, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
248 {"notrellis", &xvidenc_trellis, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11437 | 249 {"packed", &xvidenc_packed, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
250 {"nopacked", &xvidenc_packed, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11437 | 251 {"closed_gop", &xvidenc_closed_gop, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
252 {"noclosed_gop", &xvidenc_closed_gop, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11491 | 253 {"interlacing", &xvidenc_interlaced, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
254 {"nointerlacing", &xvidenc_interlaced, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11437 | 255 {"cartoon", &xvidenc_cartoon, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
256 {"nocartoon", &xvidenc_cartoon, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11437 | 257 {"hq_ac", &xvidenc_hqacpred, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
258 {"nohq_ac", &xvidenc_hqacpred, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11437 | 259 {"frame_drop_ratio", &xvidenc_frame_drop_ratio, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, |
260 {"max_key_interval", &xvidenc_max_key_interval, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, | |
20259
135e5919638f
Use American spelling of "gray" instead for British's "grey" for XviD option, while keeping backward compatibility
gpoirier
parents:
20017
diff
changeset
|
261 {"greyscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 0, 1, NULL}, /* kept for backward compatibility */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
262 {"grayscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
263 {"nogreyscale", &xvidenc_greyscale, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
15638
189da3c3116b
Add XviD's luminance masking (option name: lumi_mask)
gpoirier
parents:
15619
diff
changeset
|
264 {"lumi_mask", &xvidenc_luminance_masking, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
189da3c3116b
Add XviD's luminance masking (option name: lumi_mask)
gpoirier
parents:
15619
diff
changeset
|
265 {"nolumi_mask", &xvidenc_luminance_masking, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
266 {"turbo", &xvidenc_turbo, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
11920 | 267 {"debug", &xvidenc_debug, CONF_TYPE_INT , 0 ,0,-1,NULL}, |
11437 | 268 {"stats", &xvidenc_stats, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
11920 | 269 {"psnr", &xvidenc_psnr , CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
11437 | 270 |
271 | |
272 /* section [quantizer] */ | |
273 {"min_iquant", &xvidenc_min_quant[0], CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, | |
274 {"max_iquant", &xvidenc_max_quant[0], CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, | |
275 {"min_pquant", &xvidenc_min_quant[1], CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, | |
276 {"max_pquant", &xvidenc_max_quant[1], CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, | |
277 {"min_bquant", &xvidenc_min_quant[2], CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, | |
278 {"max_bquant", &xvidenc_max_quant[2], CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL}, | |
279 {"quant_intra_matrix", &xvidenc_intra_matrix_file, CONF_TYPE_STRING, 0, 0, 100, NULL}, | |
280 {"quant_inter_matrix", &xvidenc_inter_matrix_file, CONF_TYPE_STRING, 0, 0, 100, NULL}, | |
281 | |
282 /* section [cbr] */ | |
11491 | 283 {"rc_reaction_delay_factor", &xvidenc_cbr_reaction_delay_factor, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, |
284 {"rc_averaging_period", &xvidenc_cbr_averaging_period, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, | |
285 {"rc_buffer", &xvidenc_cbr_buffer, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, | |
11437 | 286 |
287 /* section [vbr] */ | |
288 {"keyframe_boost", &xvidenc_vbr_keyframe_boost, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, | |
289 {"curve_compression_high", &xvidenc_vbr_curve_compression_high, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, | |
290 {"curve_compression_low", &xvidenc_vbr_curve_compression_low, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, | |
291 {"overflow_control_strength", &xvidenc_vbr_overflow_control_strength, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, | |
292 {"max_overflow_improvement", &xvidenc_vbr_max_overflow_improvement, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, | |
293 {"max_overflow_degradation", &xvidenc_vbr_max_overflow_degradation, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, | |
294 {"kfreduction", &xvidenc_vbr_kfreduction, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, | |
11586 | 295 {"kfthreshold", &xvidenc_vbr_kfthreshold, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, |
11437 | 296 {"container_frame_overhead", &xvidenc_vbr_container_frame_overhead, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, |
297 | |
298 /* Section Aspect Ratio */ | |
299 {"par", &xvidenc_par, CONF_TYPE_STRING, 0, 0, 0, NULL}, | |
300 {"par_width", &xvidenc_par_width, CONF_TYPE_INT, CONF_RANGE, 0, 255, NULL}, | |
301 {"par_height", &xvidenc_par_height, CONF_TYPE_INT, CONF_RANGE, 0, 255, NULL}, | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
302 {"aspect", &xvidenc_dar_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.1, 9.99, NULL}, |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
303 {"autoaspect", &xvidenc_autoaspect, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
13853
5a786c7e4df4
have each XviD's option flag have its (no)counterpart
gpoirier
parents:
13675
diff
changeset
|
304 {"noautoaspect", &xvidenc_autoaspect, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
11437 | 305 |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
306 /* Section Zones */ |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
307 {"zones", &xvidenc_zones, CONF_TYPE_STRING, 0, 0, 0, NULL}, |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
308 |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
309 /* section profiles */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
310 {"profile", &xvidenc_profile, CONF_TYPE_STRING, 0, 0, 0, NULL}, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
311 |
11437 | 312 /* End of the config array */ |
313 {NULL, 0, 0, 0, 0, 0, NULL} | |
314 }; | |
315 | |
316 /***************************************************************************** | |
317 * Module private data | |
318 ****************************************************************************/ | |
319 | |
25607
9d0b189ce1b2
Fix illegal identifiers: Names starting with __ or _ and uppercase are reserved
diego
parents:
24735
diff
changeset
|
320 typedef struct xvid_mplayer_module_t |
11437 | 321 { |
322 /* Instance related global vars */ | |
323 void *instance; | |
324 xvid_gbl_init_t init; | |
325 xvid_enc_create_t create; | |
326 xvid_enc_frame_t frame; | |
327 xvid_plugin_single_t onepass; | |
328 xvid_plugin_2pass1_t pass1; | |
329 xvid_plugin_2pass2_t pass2; | |
330 | |
331 /* This data must survive local block scope, so here it is */ | |
332 xvid_enc_plugin_t plugins[7]; | |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
333 xvid_enc_zone_t zones[MAX_ZONES]; |
11437 | 334 |
335 /* MPEG4 stream buffer */ | |
336 muxer_stream_t *mux; | |
337 | |
338 /* Stats accumulators */ | |
339 int frames; | |
340 long long sse_y; | |
341 long long sse_u; | |
342 long long sse_v; | |
343 | |
344 /* Min & Max PSNR */ | |
345 int min_sse_y; | |
346 int min_sse_u; | |
347 int min_sse_v; | |
11920 | 348 int min_framenum; |
11437 | 349 int max_sse_y; |
350 int max_sse_u; | |
351 int max_sse_v; | |
11920 | 352 int max_framenum; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
353 |
11920 | 354 int pixels; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
355 |
13610 | 356 /* DAR/PAR and all that thingies */ |
357 int d_width; | |
358 int d_height; | |
359 FILE *fvstats; | |
11437 | 360 } xvid_mplayer_module_t; |
361 | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
362 static int dispatch_settings(xvid_mplayer_module_t *mod); |
11437 | 363 static int set_create_struct(xvid_mplayer_module_t *mod); |
364 static int set_frame_struct(xvid_mplayer_module_t *mod, mp_image_t *mpi); | |
13610 | 365 static void update_stats(xvid_mplayer_module_t *mod, xvid_enc_stats_t *stats); |
366 static void print_stats(xvid_mplayer_module_t *mod); | |
367 static void flush_internal_buffers(xvid_mplayer_module_t *mod); | |
368 static const char *par_string(int parcode); | |
11437 | 369 static const char *errorstring(int err); |
370 | |
371 /***************************************************************************** | |
372 * Video Filter API function definitions | |
373 ****************************************************************************/ | |
374 | |
375 /*============================================================================ | |
376 * config | |
377 *==========================================================================*/ | |
378 | |
379 static int | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29263
diff
changeset
|
380 config(struct vf_instance *vf, |
11437 | 381 int width, int height, int d_width, int d_height, |
382 unsigned int flags, unsigned int outfmt) | |
383 { | |
384 int err; | |
385 xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
386 |
11437 | 387 /* Complete the muxer initialization */ |
388 mod->mux->bih->biWidth = width; | |
389 mod->mux->bih->biHeight = height; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
390 mod->mux->bih->biSizeImage = |
13610 | 391 mod->mux->bih->biWidth * mod->mux->bih->biHeight * 3 / 2; |
12061 | 392 mod->mux->aspect = (float)d_width/d_height; |
11437 | 393 |
394 /* Message the FourCC type */ | |
395 mp_msg(MSGT_MENCODER, MSGL_INFO, | |
26883 | 396 "videocodec: XviD (%dx%d fourcc=%x [%.4s])\n", |
11437 | 397 width, height, mod->mux->bih->biCompression, |
398 (char *)&mod->mux->bih->biCompression); | |
399 | |
13610 | 400 /* Total number of pixels per frame required for PSNR */ |
401 mod->pixels = mod->mux->bih->biWidth*mod->mux->bih->biHeight; | |
402 | |
11437 | 403 /*-------------------------------------------------------------------- |
26883 | 404 * Dispatch all module settings to XviD structures |
11437 | 405 *------------------------------------------------------------------*/ |
406 | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
407 mod->d_width = d_width; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
408 mod->d_height = d_height; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
409 |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
410 if(dispatch_settings(mod) == BAD) |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
411 return BAD; |
11437 | 412 |
413 /*-------------------------------------------------------------------- | |
414 * Set remaining information in the xvid_enc_create_t structure | |
415 *------------------------------------------------------------------*/ | |
416 | |
417 if(set_create_struct(mod) == BAD) | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
418 return BAD; |
11437 | 419 |
420 /*-------------------------------------------------------------------- | |
421 * Encoder instance creation | |
422 *------------------------------------------------------------------*/ | |
423 | |
424 err = xvid_encore(NULL, XVID_ENC_CREATE, &mod->create, NULL); | |
425 | |
426 if(err<0) { | |
427 mp_msg(MSGT_MENCODER, MSGL_ERR, | |
428 "xvid: xvidcore returned a '%s' error\n", errorstring(err)); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
429 return BAD; |
11437 | 430 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
431 |
11437 | 432 /* Store the encoder instance into the private data */ |
433 mod->instance = mod->create.handle; | |
434 | |
17659 | 435 mod->mux->decoder_delay = mod->create.max_bframes ? 1 : 0; |
436 | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
437 return FINE; |
11437 | 438 } |
439 | |
440 /*============================================================================ | |
441 * uninit | |
442 *==========================================================================*/ | |
443 | |
444 static void | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29263
diff
changeset
|
445 uninit(struct vf_instance *vf) |
11437 | 446 { |
447 | |
448 xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; | |
449 | |
450 /* Destroy xvid instance */ | |
451 xvid_encore(mod->instance, XVID_ENC_DESTROY, NULL, NULL); | |
452 | |
13610 | 453 /* Display stats (if any) */ |
454 print_stats(mod); | |
11437 | 455 |
13610 | 456 /* Close PSNR file if ever opened */ |
457 if (mod->fvstats) { | |
458 fclose(mod->fvstats); | |
459 mod->fvstats = NULL; | |
11437 | 460 } |
461 | |
13610 | 462 /* Free allocated memory */ |
463 if(mod->frame.quant_intra_matrix) | |
464 free(mod->frame.quant_intra_matrix); | |
465 | |
466 if(mod->frame.quant_inter_matrix) | |
467 free(mod->frame.quant_inter_matrix); | |
468 | |
469 if(mod->mux->bih) | |
470 free(mod->mux->bih); | |
471 | |
472 free(vf->priv); | |
473 vf->priv=NULL; | |
11437 | 474 |
475 return; | |
476 } | |
477 | |
478 /*============================================================================ | |
479 * control | |
480 *==========================================================================*/ | |
481 | |
482 static int | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29263
diff
changeset
|
483 control(struct vf_instance *vf, int request, void* data) |
11437 | 484 { |
13610 | 485 xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; |
486 | |
487 switch(request){ | |
488 case VFCTRL_FLUSH_FRAMES: | |
489 if(mod)/*paranoid*/ | |
490 flush_internal_buffers(mod); | |
491 break; | |
492 } | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
493 return CONTROL_UNKNOWN; |
11437 | 494 } |
495 | |
496 /*============================================================================ | |
497 * query_format | |
498 *==========================================================================*/ | |
499 | |
500 static int | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29263
diff
changeset
|
501 query_format(struct vf_instance *vf, unsigned int fmt) |
11437 | 502 { |
503 switch(fmt){ | |
504 case IMGFMT_YV12: | |
505 case IMGFMT_IYUV: | |
506 case IMGFMT_I420: | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
507 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; |
11437 | 508 case IMGFMT_YUY2: |
509 case IMGFMT_UYVY: | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
510 return VFCAP_CSP_SUPPORTED; |
11437 | 511 } |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
512 return BAD; |
11437 | 513 } |
514 | |
515 /*============================================================================ | |
516 * put_image | |
517 *==========================================================================*/ | |
518 | |
519 static int | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
29263
diff
changeset
|
520 put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) |
11437 | 521 { |
522 int size; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
523 xvid_enc_stats_t stats; |
11437 | 524 xvid_mplayer_module_t *mod = (xvid_mplayer_module_t *)vf->priv; |
525 | |
526 /* Prepare the stats */ | |
527 memset(&stats,0,sizeof( xvid_enc_stats_t)); | |
528 stats.version = XVID_VERSION; | |
529 | |
530 /* ------------------------------------------------------------------- | |
531 * Set remaining information in the xvid_enc_frame_t structure | |
532 * NB: all the other struct members were initialized by | |
533 * dispatch_settings | |
534 * -----------------------------------------------------------------*/ | |
535 | |
536 if(set_frame_struct(mod, mpi) == BAD) | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
537 return BAD; |
11437 | 538 |
539 /* ------------------------------------------------------------------- | |
540 * Encode the frame | |
541 * ---------------------------------------------------------------- */ | |
542 | |
543 size = xvid_encore(mod->instance, XVID_ENC_ENCODE, &mod->frame, &stats); | |
544 | |
545 /* Analyse the returned value */ | |
546 if(size<0) { | |
547 mp_msg(MSGT_MENCODER, MSGL_ERR, | |
548 "xvid: xvidcore returned a '%s' error\n", errorstring(size)); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
549 return BAD; |
11437 | 550 } |
551 | |
552 /* If size is == 0, we're done with that frame */ | |
17659 | 553 if(size == 0) { |
554 ++mod->mux->encoder_delay; | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
555 return FINE; |
17659 | 556 } |
11437 | 557 |
13610 | 558 /* xvidcore returns stats about encoded frame in an asynchronous way |
559 * accumulate these stats */ | |
560 update_stats(mod, &stats); | |
11437 | 561 |
562 /* xvidcore outputed bitstream -- mux it */ | |
563 muxer_write_chunk(mod->mux, | |
564 size, | |
17487
fa17424b4c7b
change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents:
17012
diff
changeset
|
565 (mod->frame.out_flags & XVID_KEYFRAME)?0x10:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE); |
11437 | 566 |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
567 return FINE; |
11437 | 568 } |
569 | |
570 /*============================================================================ | |
571 * vf_open | |
572 *==========================================================================*/ | |
573 | |
574 static int | |
575 vf_open(vf_instance_t *vf, char* args) | |
576 { | |
577 xvid_mplayer_module_t *mod; | |
578 xvid_gbl_init_t xvid_gbl_init; | |
579 xvid_gbl_info_t xvid_gbl_info; | |
580 | |
581 /* Setting libmpcodec module API pointers */ | |
582 vf->config = config; | |
14878 | 583 vf->default_caps = VFCAP_CONSTANT; |
11437 | 584 vf->control = control; |
585 vf->uninit = uninit; | |
586 vf->query_format = query_format; | |
587 vf->put_image = put_image; | |
588 | |
589 /* Allocate the private part of the codec module */ | |
590 vf->priv = malloc(sizeof(xvid_mplayer_module_t)); | |
591 mod = (xvid_mplayer_module_t*)vf->priv; | |
592 | |
593 if(mod == NULL) { | |
594 mp_msg(MSGT_MENCODER,MSGL_ERR, | |
595 "xvid: memory allocation failure (private data)\n"); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
596 return BAD; |
11437 | 597 } |
598 | |
599 /* Initialize the module to zeros */ | |
600 memset(mod, 0, sizeof(xvid_mplayer_module_t)); | |
601 mod->min_sse_y = mod->min_sse_u = mod->min_sse_v = INT_MAX; | |
602 mod->max_sse_y = mod->max_sse_u = mod->max_sse_v = INT_MIN; | |
603 | |
604 /* Bind the Muxer */ | |
605 mod->mux = (muxer_stream_t*)args; | |
606 | |
607 /* Initialize muxer BITMAP header */ | |
14549
acf3241be19b
Initialized BITMAPINFOHEADER to 0 to avoid problems, esp. windows has problems
reimar
parents:
13853
diff
changeset
|
608 mod->mux->bih = calloc(1, sizeof(BITMAPINFOHEADER)); |
11437 | 609 |
610 if(mod->mux->bih == NULL) { | |
611 mp_msg(MSGT_MENCODER,MSGL_ERR, | |
612 "xvid: memory allocation failure (BITMAP header)\n"); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
613 return BAD; |
11437 | 614 } |
615 | |
616 mod->mux->bih->biSize = sizeof(BITMAPINFOHEADER); | |
617 mod->mux->bih->biWidth = 0; | |
618 mod->mux->bih->biHeight = 0; | |
619 mod->mux->bih->biPlanes = 1; | |
13610 | 620 mod->mux->bih->biBitCount = 12; |
11437 | 621 mod->mux->bih->biCompression = mmioFOURCC('X','V','I','D'); |
622 | |
26883 | 623 /* Retrieve information about the host XviD library */ |
11437 | 624 memset(&xvid_gbl_info, 0, sizeof(xvid_gbl_info_t)); |
625 xvid_gbl_info.version = XVID_VERSION; | |
626 | |
627 if (xvid_global(NULL, XVID_GBL_INFO, &xvid_gbl_info, NULL) < 0) { | |
13610 | 628 mp_msg(MSGT_MENCODER,MSGL_WARN, "xvid: could not get information about the library\n"); |
11437 | 629 } else { |
630 mp_msg(MSGT_MENCODER,MSGL_INFO, "xvid: using library version %d.%d.%d (build %s)\n", | |
631 XVID_VERSION_MAJOR(xvid_gbl_info.actual_version), | |
632 XVID_VERSION_MINOR(xvid_gbl_info.actual_version), | |
633 XVID_VERSION_PATCH(xvid_gbl_info.actual_version), | |
634 xvid_gbl_info.build); | |
635 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
636 |
11437 | 637 /* Initialize the xvid_gbl_init structure */ |
638 memset(&xvid_gbl_init, 0, sizeof(xvid_gbl_init_t)); | |
639 xvid_gbl_init.version = XVID_VERSION; | |
11920 | 640 xvid_gbl_init.debug = xvidenc_debug; |
11437 | 641 |
642 /* Initialize the xvidcore library */ | |
643 if (xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL) < 0) { | |
644 mp_msg(MSGT_MENCODER,MSGL_ERR, "xvid: initialisation failure\n"); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
645 return BAD; |
11437 | 646 } |
647 | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
648 return FINE; |
11437 | 649 } |
650 | |
651 /***************************************************************************** | |
652 * Helper functions | |
653 ****************************************************************************/ | |
654 | |
655 static void *read_matrix(unsigned char *filename); | |
656 | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
657 static int dispatch_settings(xvid_mplayer_module_t *mod) |
11437 | 658 { |
659 xvid_enc_create_t *create = &mod->create; | |
660 xvid_enc_frame_t *frame = &mod->frame; | |
661 xvid_plugin_single_t *onepass = &mod->onepass; | |
662 xvid_plugin_2pass2_t *pass2 = &mod->pass2; | |
24295
de8e36aec5ff
Remove imported rational calculation code and use the original one from avutil.
iive
parents:
22601
diff
changeset
|
663 AVRational ar; |
11437 | 664 |
665 const int motion_presets[7] = | |
666 { | |
667 0, | |
668 0, | |
669 0, | |
670 0, | |
671 XVID_ME_HALFPELREFINE16, | |
672 XVID_ME_HALFPELREFINE16 | XVID_ME_ADVANCEDDIAMOND16, | |
673 XVID_ME_HALFPELREFINE16 | XVID_ME_EXTSEARCH16 | | |
674 XVID_ME_HALFPELREFINE8 | XVID_ME_USESQUARES16 | |
675 }; | |
676 | |
16615 | 677 //profile is unrestricted as default |
28186
79aef31ed618
XVID profile array should be const, so it is in rodata
reimar
parents:
26883
diff
changeset
|
678 const profile_t *selected_profile = profileFromName("unrestricted"); |
16615 | 679 if(xvidenc_profile) |
680 selected_profile = profileFromName(xvidenc_profile); | |
681 if(!selected_profile) | |
682 { | |
683 mp_msg(MSGT_MENCODER,MSGL_ERR, | |
684 "xvid:[ERROR] \"%s\" is an invalid profile name\n", xvidenc_profile); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
685 return BAD; |
16615 | 686 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
687 |
11437 | 688 /* ------------------------------------------------------------------- |
689 * Dispatch all settings having an impact on the "create" structure | |
690 * This includes plugins as they are passed to encore through the | |
691 * create structure | |
692 * -----------------------------------------------------------------*/ | |
693 | |
694 /* ------------------------------------------------------------------- | |
695 * The create structure | |
696 * ---------------------------------------------------------------- */ | |
697 | |
698 create->global = 0; | |
699 | |
11920 | 700 if(xvidenc_psnr) |
701 xvidenc_stats = 1; | |
702 | |
11437 | 703 if(xvidenc_stats) |
704 create->global |= XVID_GLOBAL_EXTRASTATS_ENABLE; | |
705 | |
706 create->num_zones = 0; | |
707 create->zones = NULL; | |
708 create->num_plugins = 0; | |
709 create->plugins = NULL; | |
17703 | 710 create->num_threads = xvidenc_num_threads; |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
711 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
712 if( (selected_profile->flags & PROFILE_BVOP) && |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
713 /* dxn: prevent bframes usage if interlacing is selected */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
714 !((selected_profile->flags & PROFILE_DXN) && xvidenc_interlaced) ) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
715 { |
11437 | 716 create->max_bframes = xvidenc_max_bframes; |
717 create->bquant_ratio = xvidenc_bquant_ratio; | |
718 create->bquant_offset = xvidenc_bquant_offset; | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
719 if(xvidenc_packed) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
720 create->global |= XVID_GLOBAL_PACKED; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
721 if(xvidenc_closed_gop) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
722 create->global |= XVID_GLOBAL_CLOSED_GOP; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
723 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
724 /* dxn: restrict max bframes, require closed gop |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
725 and require packed b-frames */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
726 if(selected_profile->flags & PROFILE_DXN) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
727 { |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
728 if(create->max_bframes > selected_profile->dxn_max_bframes) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
729 create->max_bframes = selected_profile->dxn_max_bframes; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
730 create->global |= XVID_GLOBAL_CLOSED_GOP; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
731 create->global |= XVID_GLOBAL_PACKED; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
732 } |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
733 } |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
734 else |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
735 create->max_bframes = 0; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
736 |
16515
1218c5859ce8
10l: fully working DXN profile support require XviD 1.1.x. Earlier version will work but will lack VBV support
gpoirier
parents:
16481
diff
changeset
|
737 #if XVID_API >= XVID_MAKE_API(4,1) |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
738 /* dxn: always write divx5 userdata */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
739 if(selected_profile->flags & PROFILE_DXN) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
740 create->global |= XVID_GLOBAL_DIVX5_USERDATA; |
16515
1218c5859ce8
10l: fully working DXN profile support require XviD 1.1.x. Earlier version will work but will lack VBV support
gpoirier
parents:
16481
diff
changeset
|
741 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
742 |
11437 | 743 create->max_key_interval = xvidenc_max_key_interval; |
744 create->frame_drop_ratio = xvidenc_frame_drop_ratio; | |
745 create->min_quant[0] = xvidenc_min_quant[0]; | |
746 create->min_quant[1] = xvidenc_min_quant[1]; | |
747 create->min_quant[2] = xvidenc_min_quant[2]; | |
748 create->max_quant[0] = xvidenc_max_quant[0]; | |
749 create->max_quant[1] = xvidenc_max_quant[1]; | |
750 create->max_quant[2] = xvidenc_max_quant[2]; | |
751 | |
752 | |
753 /* ------------------------------------------------------------------- | |
754 * The single pass plugin | |
755 * ---------------------------------------------------------------- */ | |
756 | |
13675
d4cba4c4c54c
Bitrate setting option in ve_xvid4.c doesn't follow the rules described
rathann
parents:
13610
diff
changeset
|
757 if (xvidenc_bitrate > 16000) onepass->bitrate = xvidenc_bitrate; |
d4cba4c4c54c
Bitrate setting option in ve_xvid4.c doesn't follow the rules described
rathann
parents:
13610
diff
changeset
|
758 else onepass->bitrate = xvidenc_bitrate*1000; |
11437 | 759 onepass->reaction_delay_factor = xvidenc_cbr_reaction_delay_factor; |
760 onepass->averaging_period = xvidenc_cbr_averaging_period; | |
761 onepass->buffer = xvidenc_cbr_buffer; | |
762 | |
763 /* ------------------------------------------------------------------- | |
764 * The pass2 plugin | |
765 * ---------------------------------------------------------------- */ | |
766 | |
767 pass2->keyframe_boost = xvidenc_vbr_keyframe_boost; | |
768 pass2->overflow_control_strength = xvidenc_vbr_overflow_control_strength; | |
769 pass2->curve_compression_high = xvidenc_vbr_curve_compression_high; | |
770 pass2->curve_compression_low = xvidenc_vbr_curve_compression_low; | |
771 pass2->max_overflow_improvement = xvidenc_vbr_max_overflow_improvement; | |
772 pass2->max_overflow_degradation = xvidenc_vbr_max_overflow_degradation; | |
773 pass2->kfreduction = xvidenc_vbr_kfreduction; | |
11586 | 774 pass2->kfthreshold = xvidenc_vbr_kfthreshold; |
11437 | 775 pass2->container_frame_overhead = xvidenc_vbr_container_frame_overhead; |
776 | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
777 /* VBV */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
778 |
16515
1218c5859ce8
10l: fully working DXN profile support require XviD 1.1.x. Earlier version will work but will lack VBV support
gpoirier
parents:
16481
diff
changeset
|
779 #if XVID_API >= XVID_MAKE_API(4,1) |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
780 pass2->vbv_size = selected_profile->max_vbv_size; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
781 pass2->vbv_initial = (selected_profile->max_vbv_size*3)>>2; /* 75% */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
782 pass2->vbv_maxrate = selected_profile->max_bitrate; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
783 pass2->vbv_peakrate = selected_profile->vbv_peakrate*3; |
16515
1218c5859ce8
10l: fully working DXN profile support require XviD 1.1.x. Earlier version will work but will lack VBV support
gpoirier
parents:
16481
diff
changeset
|
784 #endif |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
785 // XXX: xvidcore currently provides a "peak bits over 3 seconds" constraint. |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
786 // according to the latest dxn literature, a 1 second constraint is now used |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
787 |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
788 create->profile = selected_profile->id; |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
789 |
11437 | 790 /* ------------------------------------------------------------------- |
791 * The frame structure | |
792 * ---------------------------------------------------------------- */ | |
793 frame->vol_flags = 0; | |
794 frame->vop_flags = 0; | |
795 frame->motion = 0; | |
796 | |
797 frame->vop_flags |= XVID_VOP_HALFPEL; | |
798 frame->motion |= motion_presets[xvidenc_motion]; | |
799 | |
800 if(xvidenc_stats) | |
801 frame->vol_flags |= XVID_VOL_EXTRASTATS; | |
802 | |
803 if(xvidenc_greyscale) | |
804 frame->vop_flags |= XVID_VOP_GREYSCALE; | |
805 | |
806 if(xvidenc_cartoon) { | |
807 frame->vop_flags |= XVID_VOP_CARTOON; | |
808 frame->motion |= XVID_ME_DETECT_STATIC_MOTION; | |
809 } | |
810 | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
811 // MPEG quantisation is only supported in ASP and unrestricted profiles |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
812 if((selected_profile->flags & PROFILE_MPEGQUANT) && |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
813 (xvidenc_quant_method != NULL) && |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
814 !strcasecmp(xvidenc_quant_method, "mpeg")) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
815 { |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
816 frame->vol_flags |= XVID_VOL_MPEGQUANT; |
11437 | 817 if(xvidenc_intra_matrix_file != NULL) { |
818 frame->quant_intra_matrix = (unsigned char*)read_matrix(xvidenc_intra_matrix_file); | |
819 if(frame->quant_intra_matrix != NULL) { | |
13610 | 820 mp_msg(MSGT_MENCODER, MSGL_INFO, "xvid: Loaded Intra matrix (switching to mpeg quantization type)\n"); |
11437 | 821 if(xvidenc_quant_method) free(xvidenc_quant_method); |
822 xvidenc_quant_method = strdup("mpeg"); | |
823 } | |
824 } | |
825 if(xvidenc_inter_matrix_file != NULL) { | |
826 frame->quant_inter_matrix = read_matrix(xvidenc_inter_matrix_file); | |
827 if(frame->quant_inter_matrix) { | |
13610 | 828 mp_msg(MSGT_MENCODER, MSGL_INFO, "\nxvid: Loaded Inter matrix (switching to mpeg quantization type)\n"); |
11437 | 829 if(xvidenc_quant_method) free(xvidenc_quant_method); |
830 xvidenc_quant_method = strdup("mpeg"); | |
831 } | |
832 } | |
833 } | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
834 if(xvidenc_quarterpel && (selected_profile->flags & PROFILE_QPEL)) { |
11437 | 835 frame->vol_flags |= XVID_VOL_QUARTERPEL; |
836 frame->motion |= XVID_ME_QUARTERPELREFINE16; | |
837 frame->motion |= XVID_ME_QUARTERPELREFINE8; | |
838 } | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
839 if(xvidenc_gmc && (selected_profile->flags & PROFILE_GMC)) { |
11437 | 840 frame->vol_flags |= XVID_VOL_GMC; |
841 frame->motion |= XVID_ME_GME_REFINE; | |
842 } | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
843 if(xvidenc_interlaced && (selected_profile->flags & PROFILE_INTERLACE)) { |
11437 | 844 frame->vol_flags |= XVID_VOL_INTERLACING; |
845 } | |
846 if(xvidenc_trellis) { | |
847 frame->vop_flags |= XVID_VOP_TRELLISQUANT; | |
848 } | |
849 if(xvidenc_hqacpred) { | |
850 frame->vop_flags |= XVID_VOP_HQACPRED; | |
851 } | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
852 if(xvidenc_chroma_opt) { |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
853 frame->vop_flags |= XVID_VOP_CHROMAOPT; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
854 } |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
855 if((xvidenc_motion > 4) && (selected_profile->flags & PROFILE_4MV)) { |
11437 | 856 frame->vop_flags |= XVID_VOP_INTER4V; |
857 } | |
858 if(xvidenc_chromame) { | |
859 frame->motion |= XVID_ME_CHROMA_PVOP; | |
860 frame->motion |= XVID_ME_CHROMA_BVOP; | |
861 } | |
862 if(xvidenc_vhq >= 1) { | |
863 frame->vop_flags |= XVID_VOP_MODEDECISION_RD; | |
864 } | |
865 if(xvidenc_vhq >= 2) { | |
866 frame->motion |= XVID_ME_HALFPELREFINE16_RD; | |
867 frame->motion |= XVID_ME_QUARTERPELREFINE16_RD; | |
868 } | |
869 if(xvidenc_vhq >= 3) { | |
870 frame->motion |= XVID_ME_HALFPELREFINE8_RD; | |
871 frame->motion |= XVID_ME_QUARTERPELREFINE8_RD; | |
872 frame->motion |= XVID_ME_CHECKPREDICTION_RD; | |
873 } | |
874 if(xvidenc_vhq >= 4) { | |
875 frame->motion |= XVID_ME_EXTSEARCH_RD; | |
876 } | |
13610 | 877 if(xvidenc_bvhq >= 1) { |
878 #if XVID_API >= XVID_MAKE_API(4,1) | |
879 frame->vop_flags |= XVID_VOP_RD_BVOP; | |
880 #endif | |
881 } | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
882 if(xvidenc_turbo) { |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
883 frame->motion |= XVID_ME_FASTREFINE16; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
884 frame->motion |= XVID_ME_FASTREFINE8; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
885 frame->motion |= XVID_ME_SKIP_DELTASEARCH; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
886 frame->motion |= XVID_ME_FAST_MODEINTERPOLATE; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
887 frame->motion |= XVID_ME_BFRAME_EARLYSTOP; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
888 } |
11437 | 889 |
890 /* motion level == 0 means no motion search which is equivalent to | |
891 * intra coding only */ | |
892 if(xvidenc_motion == 0) { | |
893 frame->type = XVID_TYPE_IVOP; | |
894 } else { | |
895 frame->type = XVID_TYPE_AUTO; | |
896 } | |
897 | |
898 frame->bframe_threshold = xvidenc_bframe_threshold; | |
899 | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
900 /* PAR related initialization */ |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
901 frame->par = XVID_PAR_11_VGA; /* Default */ |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
902 |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
903 if( !(selected_profile->flags & PROFILE_DXN) ) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
904 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
905 if(xvidenc_dar_aspect > 0) |
24295
de8e36aec5ff
Remove imported rational calculation code and use the original one from avutil.
iive
parents:
22601
diff
changeset
|
906 ar = av_d2q(xvidenc_dar_aspect * mod->mux->bih->biHeight / mod->mux->bih->biWidth, 255); |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
907 else if(xvidenc_autoaspect) |
24295
de8e36aec5ff
Remove imported rational calculation code and use the original one from avutil.
iive
parents:
22601
diff
changeset
|
908 ar = av_d2q((float)mod->d_width / mod->d_height * mod->mux->bih->biHeight / mod->mux->bih->biWidth, 255); |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
909 else ar.num = ar.den = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
910 |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
911 if(ar.den != 0) { |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
912 if(ar.num == 12 && ar.den == 11) |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
913 frame->par = XVID_PAR_43_PAL; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
914 else if(ar.num == 10 && ar.den == 11) |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
915 frame->par = XVID_PAR_43_NTSC; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
916 else if(ar.num == 16 && ar.den == 11) |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
917 frame->par = XVID_PAR_169_PAL; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
918 else if(ar.num == 40 && ar.den == 33) |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
919 frame->par = XVID_PAR_169_NTSC; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
920 else |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
921 { |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
922 frame->par = XVID_PAR_EXT; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
923 frame->par_width = ar.num; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
924 frame->par_height= ar.den; |
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
925 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
926 |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
927 } else if(xvidenc_par != NULL) { |
11437 | 928 if(strcasecmp(xvidenc_par, "pal43") == 0) |
929 frame->par = XVID_PAR_43_PAL; | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
930 else if(strcasecmp(xvidenc_par, "pal169") == 0) |
11437 | 931 frame->par = XVID_PAR_169_PAL; |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
932 else if(strcasecmp(xvidenc_par, "ntsc43") == 0) |
11437 | 933 frame->par = XVID_PAR_43_NTSC; |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
934 else if(strcasecmp(xvidenc_par, "ntsc169") == 0) |
11437 | 935 frame->par = XVID_PAR_169_NTSC; |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
936 else if(strcasecmp(xvidenc_par, "ext") == 0) |
11437 | 937 frame->par = XVID_PAR_EXT; |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
938 |
11437 | 939 if(frame->par == XVID_PAR_EXT) { |
940 if(xvidenc_par_width) | |
941 frame->par_width = xvidenc_par_width; | |
942 else | |
943 frame->par_width = 1; | |
944 | |
945 if(xvidenc_par_height) | |
946 frame->par_height = xvidenc_par_height; | |
947 else | |
948 frame->par_height = 1; | |
949 } | |
11912
8eb96d751dcd
new options - aspect,autoaspect,turbo,chroma_opt. patch by Nico <nsabbi@tiscali.it> and Edouard Gomez
iive
parents:
11586
diff
changeset
|
950 } |
13610 | 951 |
952 /* Display par information */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
953 mp_msg(MSGT_MENCODER, MSGL_INFO, "xvid: par=%d/%d (%s), displayed=%dx%d, sampled=%dx%d\n", |
13610 | 954 ar.num, ar.den, par_string(frame->par), |
955 mod->d_width, mod->d_height, mod->mux->bih->biWidth, mod->mux->bih->biHeight); | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
956 } |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
957 else |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
958 mp_msg(MSGT_MENCODER, MSGL_INFO, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
959 "xvid: par=0/0 (vga11) forced by choosing a DXN profile\n"); |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
960 return FINE; |
11437 | 961 } |
962 | |
963 static int set_create_struct(xvid_mplayer_module_t *mod) | |
964 { | |
965 int pass; | |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
966 int doZones = 0; |
11437 | 967 xvid_enc_create_t *create = &mod->create; |
968 | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
969 // profile is unrestricted as default |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
970 profile_t *selected_profile = profileFromName("unrestricted"); |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
971 if(xvidenc_profile) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
972 selected_profile = profileFromName(xvidenc_profile); |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
973 if(!selected_profile) |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
974 return BAD; |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
975 |
11437 | 976 /* Most of the structure is initialized by dispatch settings, only a |
977 * few things are missing */ | |
978 create->version = XVID_VERSION; | |
979 | |
980 /* Width and Height */ | |
981 create->width = mod->mux->bih->biWidth; | |
982 create->height = mod->mux->bih->biHeight; | |
983 | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
984 /* Check resolution of video to be coded is within profile width/height |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
985 restrictions */ |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
986 if( ((selected_profile->width != 0) && |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
987 (mod->mux->bih->biWidth > selected_profile->width)) || |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
988 ((selected_profile->height != 0) && |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
989 (mod->mux->bih->biHeight > selected_profile->height)) ) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
990 { |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
991 mp_msg(MSGT_MENCODER,MSGL_ERR, |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
992 "xvid:[ERROR] resolution must be <= %dx%d for the chosen profile\n", |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
993 selected_profile->width, selected_profile->height); |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
994 return BAD; |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
995 } |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
996 |
11437 | 997 /* FPS */ |
998 create->fincr = mod->mux->h.dwScale; | |
999 create->fbase = mod->mux->h.dwRate; | |
1000 | |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
1001 // Check frame rate is within profile restrictions |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
1002 if( ((float)mod->mux->h.dwRate/(float)mod->mux->h.dwScale > (float)selected_profile->fps) && |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
1003 (selected_profile->fps != 0)) |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
1004 { |
31938
93c67b51b171
Print a warning, but allow to encode to a non-supported frame rate with
cehoyos
parents:
31937
diff
changeset
|
1005 mp_msg(MSGT_MENCODER,MSGL_WARN, |
93c67b51b171
Print a warning, but allow to encode to a non-supported frame rate with
cehoyos
parents:
31937
diff
changeset
|
1006 "xvid:[WARNING] frame rate should be <= %d for the chosen profile\n", |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
1007 selected_profile->fps); |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
1008 } |
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
1009 |
11437 | 1010 /* Encodings zones */ |
1011 memset(mod->zones, 0, sizeof(mod->zones)); | |
1012 create->zones = mod->zones; | |
1013 create->num_zones = 0; | |
1014 | |
1015 /* Plugins */ | |
1016 memset(mod->plugins, 0, sizeof(mod->plugins)); | |
1017 create->plugins = mod->plugins; | |
1018 create->num_plugins = 0; | |
1019 | |
1020 /* ------------------------------------------------------------------- | |
1021 * Initialize and bind the right rate controller plugin | |
1022 * ---------------------------------------------------------------- */ | |
1023 | |
1024 /* First we try to sort out configuration conflicts */ | |
1025 if(xvidenc_quantizer != 0 && (xvidenc_bitrate || xvidenc_pass)) { | |
1026 mp_msg(MSGT_MENCODER, MSGL_ERR, | |
1027 "xvid: you can't mix Fixed Quantizer Rate Control" | |
1028 " with other Rate Control mechanisms\n"); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1029 return BAD; |
11437 | 1030 } |
1031 | |
1032 if(xvidenc_bitrate != 0 && xvidenc_pass == 1) { | |
13610 | 1033 mp_msg(MSGT_MENCODER, MSGL_WARN, |
11437 | 1034 "xvid: bitrate setting is ignored during first pass\n"); |
1035 } | |
1036 | |
1037 /* Sort out which sort of pass we are supposed to do | |
1038 * pass == 1<<0 CBR | |
1039 * pass == 1<<1 Two pass first pass | |
1040 * pass == 1<<2 Two pass second pass | |
1041 * pass == 1<<3 Constant quantizer | |
1042 */ | |
1043 #define MODE_CBR (1<<0) | |
1044 #define MODE_2PASS1 (1<<1) | |
1045 #define MODE_2PASS2 (1<<2) | |
1046 #define MODE_QUANT (1<<3) | |
1047 | |
1048 pass = 0; | |
1049 | |
1050 if(xvidenc_bitrate != 0 && xvidenc_pass == 0) | |
1051 pass |= MODE_CBR; | |
1052 | |
1053 if(xvidenc_pass == 1) | |
1054 pass |= MODE_2PASS1; | |
1055 | |
1056 if(xvidenc_bitrate != 0 && xvidenc_pass == 2) | |
1057 pass |= MODE_2PASS2; | |
1058 | |
1059 if(xvidenc_quantizer != 0 && xvidenc_pass == 0) | |
1060 pass |= MODE_QUANT; | |
1061 | |
1062 /* We must be in at least one RC mode */ | |
1063 if(pass == 0) { | |
1064 mp_msg(MSGT_MENCODER, MSGL_ERR, | |
1065 "xvid: you must specify one or a valid combination of " | |
25809 | 1066 "'bitrate', 'pass', 'fixed_quant' settings\n"); |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1067 return BAD; |
11437 | 1068 } |
1069 | |
1070 /* Sanity checking */ | |
1071 if(pass != MODE_CBR && pass != MODE_QUANT && | |
1072 pass != MODE_2PASS1 && pass != MODE_2PASS2) { | |
1073 mp_msg(MSGT_MENCODER, MSGL_ERR, | |
1074 "xvid: this code should not be reached - fill a bug " | |
1075 "report\n"); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1076 return BAD; |
11437 | 1077 } |
1078 | |
1079 /* This is a single pass encoding: either a CBR pass or a constant | |
1080 * quantizer pass */ | |
1081 if(pass == MODE_CBR || pass == MODE_QUANT) { | |
1082 xvid_plugin_single_t *onepass = &mod->onepass; | |
1083 | |
1084 /* There is not much left to initialize after dispatch settings */ | |
1085 onepass->version = XVID_VERSION; | |
13675
d4cba4c4c54c
Bitrate setting option in ve_xvid4.c doesn't follow the rules described
rathann
parents:
13610
diff
changeset
|
1086 if (xvidenc_bitrate > 16000) onepass->bitrate = xvidenc_bitrate; |
d4cba4c4c54c
Bitrate setting option in ve_xvid4.c doesn't follow the rules described
rathann
parents:
13610
diff
changeset
|
1087 else onepass->bitrate = xvidenc_bitrate*1000; |
11437 | 1088 |
1089 /* Quantizer mode uses the same plugin, we have only to define | |
1090 * a constant quantizer zone beginning at frame 0 */ | |
1091 if(pass == MODE_QUANT) { | |
24295
de8e36aec5ff
Remove imported rational calculation code and use the original one from avutil.
iive
parents:
22601
diff
changeset
|
1092 AVRational squant; |
de8e36aec5ff
Remove imported rational calculation code and use the original one from avutil.
iive
parents:
22601
diff
changeset
|
1093 squant = av_d2q(xvidenc_quantizer,128); |
11437 | 1094 |
1095 create->zones[create->num_zones].mode = XVID_ZONE_QUANT; | |
1096 create->zones[create->num_zones].frame = 0; | |
12806 | 1097 create->zones[create->num_zones].increment = squant.num; |
1098 create->zones[create->num_zones].base = squant.den; | |
11437 | 1099 create->num_zones++; |
1100 | |
1101 mp_msg(MSGT_MENCODER, MSGL_INFO, | |
1102 "xvid: Fixed Quant Rate Control -- quantizer=%d/%d=%2.2f\n", | |
11929 | 1103 squant.num, |
1104 squant.den, | |
1105 (float)(squant.num)/(float)(squant.den)); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
1106 |
11437 | 1107 } else { |
1108 mp_msg(MSGT_MENCODER, MSGL_INFO, | |
1109 "xvid: CBR Rate Control -- bitrate=%dkbit/s\n", | |
13675
d4cba4c4c54c
Bitrate setting option in ve_xvid4.c doesn't follow the rules described
rathann
parents:
13610
diff
changeset
|
1110 xvidenc_bitrate>16000?xvidenc_bitrate/1000:xvidenc_bitrate); |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1111 doZones = 1; |
11437 | 1112 } |
1113 | |
1114 create->plugins[create->num_plugins].func = xvid_plugin_single; | |
1115 create->plugins[create->num_plugins].param = onepass; | |
1116 create->num_plugins++; | |
1117 } | |
1118 | |
1119 /* This is the first pass of a Two pass process */ | |
1120 if(pass == MODE_2PASS1) { | |
1121 xvid_plugin_2pass1_t *pass1 = &mod->pass1; | |
1122 | |
1123 /* There is not much to initialize for this plugin */ | |
1124 pass1->version = XVID_VERSION; | |
16602 | 1125 pass1->filename = passtmpfile; |
11437 | 1126 |
1127 create->plugins[create->num_plugins].func = xvid_plugin_2pass1; | |
1128 create->plugins[create->num_plugins].param = pass1; | |
1129 create->num_plugins++; | |
1130 | |
1131 mp_msg(MSGT_MENCODER, MSGL_INFO, | |
1132 "xvid: 2Pass Rate Control -- 1st pass\n"); | |
1133 } | |
1134 | |
1135 /* This is the second pass of a Two pass process */ | |
1136 if(pass == MODE_2PASS2) { | |
1137 xvid_plugin_2pass2_t *pass2 = &mod->pass2; | |
1138 | |
1139 /* There is not much left to initialize after dispatch settings */ | |
1140 pass2->version = XVID_VERSION; | |
16602 | 1141 pass2->filename = passtmpfile; |
11437 | 1142 |
1143 /* Positive bitrate values are bitrates as usual but if the | |
1144 * value is negative it is considered as being a total size | |
1145 * to reach (in kilobytes) */ | |
1146 if(xvidenc_bitrate > 0) { | |
13675
d4cba4c4c54c
Bitrate setting option in ve_xvid4.c doesn't follow the rules described
rathann
parents:
13610
diff
changeset
|
1147 if(xvidenc_bitrate > 16000) pass2->bitrate = xvidenc_bitrate; |
d4cba4c4c54c
Bitrate setting option in ve_xvid4.c doesn't follow the rules described
rathann
parents:
13610
diff
changeset
|
1148 else pass2->bitrate = xvidenc_bitrate*1000; |
11437 | 1149 mp_msg(MSGT_MENCODER, MSGL_INFO, |
1150 "xvid: 2Pass Rate Control -- 2nd pass -- bitrate=%dkbit/s\n", | |
13675
d4cba4c4c54c
Bitrate setting option in ve_xvid4.c doesn't follow the rules described
rathann
parents:
13610
diff
changeset
|
1151 xvidenc_bitrate>16000?xvidenc_bitrate/1000:xvidenc_bitrate); |
11437 | 1152 } else { |
1153 pass2->bitrate = xvidenc_bitrate; | |
1154 mp_msg(MSGT_MENCODER, MSGL_INFO, | |
1155 "xvid: 2Pass Rate Control -- 2nd pass -- total size=%dkB\n", | |
1156 -xvidenc_bitrate); | |
1157 } | |
1158 | |
1159 create->plugins[create->num_plugins].func = xvid_plugin_2pass2; | |
1160 create->plugins[create->num_plugins].param = pass2; | |
1161 create->num_plugins++; | |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1162 doZones = 1; |
11437 | 1163 } |
15638
189da3c3116b
Add XviD's luminance masking (option name: lumi_mask)
gpoirier
parents:
15619
diff
changeset
|
1164 |
16481
beebfccc00f1
adds Simple, Advanced Simple and DivX profile support for XviD, Patch by Robert Swain < robert POUM swain AH gmail POUM com >
gpoirier
parents:
15664
diff
changeset
|
1165 if(xvidenc_luminance_masking && (selected_profile->flags & PROFILE_ADAPTQUANT)) { |
15638
189da3c3116b
Add XviD's luminance masking (option name: lumi_mask)
gpoirier
parents:
15619
diff
changeset
|
1166 create->plugins[create->num_plugins].func = xvid_plugin_lumimasking; |
189da3c3116b
Add XviD's luminance masking (option name: lumi_mask)
gpoirier
parents:
15619
diff
changeset
|
1167 create->plugins[create->num_plugins].param = NULL; |
189da3c3116b
Add XviD's luminance masking (option name: lumi_mask)
gpoirier
parents:
15619
diff
changeset
|
1168 create->num_plugins++; |
189da3c3116b
Add XviD's luminance masking (option name: lumi_mask)
gpoirier
parents:
15619
diff
changeset
|
1169 } |
189da3c3116b
Add XviD's luminance masking (option name: lumi_mask)
gpoirier
parents:
15619
diff
changeset
|
1170 |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1171 // parse zones |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1172 if (xvidenc_zones != NULL && doZones > 0) // do not apply zones in CQ, and first pass mode (xvid vfw doesn't allow them in those modes either) |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1173 { |
24735
4baa2dbe172c
Silence a gcc warning: "wrong type argument to increment".
zuxy
parents:
24629
diff
changeset
|
1174 char *p; |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1175 int i; |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1176 p = xvidenc_zones; |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1177 create->num_zones = 0; // set the number of zones back to zero, this overwrites the zone defined for CQ - desired because each zone has to be specified on the commandline even in cq mode |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1178 for(i = 0; p; i++) |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1179 { |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1180 int start; |
15664 | 1181 int q; |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1182 double value; |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1183 char mode; |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1184 int e = sscanf(p, "%d,%c,%lf", &start, &mode, &value); // start,mode(q = constant quant, w = weight),value |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1185 if(e != 3) |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1186 { |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1187 mp_msg(MSGT_MENCODER,MSGL_ERR, "error parsing zones\n"); |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1188 return BAD; |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1189 } |
15664 | 1190 q = (int)(value * 100); |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1191 if (mode == 'q') |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1192 { |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1193 if (q < 200 || q > 3100) // make sure that quantizer is in allowable range |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1194 { |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1195 mp_msg(MSGT_MENCODER, MSGL_ERR, "zone quantizer must be between 2 and 31\n"); |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1196 return BAD; |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1197 } |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1198 else |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1199 { |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1200 create->zones[create->num_zones].mode = XVID_ZONE_QUANT; |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1201 } |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1202 } |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1203 if (mode == 'w') |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1204 { |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1205 if (q < 1 || q > 200) |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1206 { |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1207 mp_msg(MSGT_MENCODER, MSGL_ERR, "zone weight must be between 1 and 200\n"); |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1208 return BAD; |
15619
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1209 } |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1210 else |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1211 { |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1212 create->zones[create->num_zones].mode = XVID_ZONE_WEIGHT; |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1213 } |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1214 } |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1215 create->zones[create->num_zones].frame = start; |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1216 create->zones[create->num_zones].increment = q; |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1217 create->zones[create->num_zones].base = 100; // increment is 100 times the actual value |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1218 create->num_zones++; |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1219 if (create->num_zones > MAX_ZONES) // show warning if we have too many zones |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1220 { |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1221 mp_msg(MSGT_MENCODER, MSGL_ERR, "too many zones, zones will be ignored\n"); |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1222 } |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1223 p = strchr(p, '/'); |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1224 if(p) p++; |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1225 } |
ccf2c61afacd
XviD zones support. Patch by Doom9: < feedback123 GROOVY doom9 STEADY org >
gpoirier
parents:
15070
diff
changeset
|
1226 } |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1227 return FINE; |
11437 | 1228 } |
1229 | |
1230 static int set_frame_struct(xvid_mplayer_module_t *mod, mp_image_t *mpi) | |
1231 { | |
1232 xvid_enc_frame_t *frame = &mod->frame; | |
1233 | |
1234 /* Most of the initialization is done during dispatch_settings */ | |
1235 frame->version = XVID_VERSION; | |
1236 | |
1237 /* Bind output buffer */ | |
1238 frame->bitstream = mod->mux->buffer; | |
1239 frame->length = -1; | |
1240 | |
1241 /* Frame format */ | |
1242 switch(mpi->imgfmt) { | |
1243 case IMGFMT_YV12: | |
1244 case IMGFMT_IYUV: | |
1245 case IMGFMT_I420: | |
1246 frame->input.csp = XVID_CSP_USER; | |
1247 break; | |
1248 case IMGFMT_YUY2: | |
1249 frame->input.csp = XVID_CSP_YUY2; | |
1250 break; | |
1251 case IMGFMT_UYVY: | |
1252 frame->input.csp = XVID_CSP_UYVY; | |
1253 break; | |
1254 default: | |
1255 mp_msg(MSGT_MENCODER, MSGL_ERR, | |
1256 "xvid: unsupported picture format (%s)!\n", | |
1257 vo_format_name(mpi->imgfmt)); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1258 return BAD; |
11437 | 1259 } |
1260 | |
1261 /* Bind source frame */ | |
1262 frame->input.plane[0] = mpi->planes[0]; | |
1263 frame->input.plane[1] = mpi->planes[1]; | |
1264 frame->input.plane[2] = mpi->planes[2]; | |
1265 frame->input.stride[0] = mpi->stride[0]; | |
1266 frame->input.stride[1] = mpi->stride[1]; | |
1267 frame->input.stride[2] = mpi->stride[2]; | |
1268 | |
1269 /* Force the right quantizer -- It is internally managed by RC | |
1270 * plugins */ | |
1271 frame->quant = 0; | |
1272 | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1273 return FINE; |
11437 | 1274 } |
1275 | |
13610 | 1276 static void |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
1277 flush_internal_buffers(xvid_mplayer_module_t *mod) |
13610 | 1278 { |
1279 int size; | |
1280 xvid_enc_frame_t *frame = &mod->frame; | |
1281 | |
1282 if (mod->instance == NULL) | |
25962 | 1283 return; /* encoder not initialized */ |
13610 | 1284 |
1285 /* Init a fake frame to force flushing */ | |
1286 frame->version = XVID_VERSION; | |
1287 frame->bitstream = mod->mux->buffer; | |
1288 frame->length = -1; | |
1289 frame->input.csp = XVID_CSP_NULL; | |
1290 frame->input.plane[0] = NULL; | |
1291 frame->input.plane[1] = NULL; | |
1292 frame->input.plane[2] = NULL; | |
1293 frame->input.stride[0] = 0; | |
1294 frame->input.stride[1] = 0; | |
1295 frame->input.stride[2] = 0; | |
1296 frame->quant = 0; | |
1297 | |
1298 /* Flush encoder buffers caused by bframes usage */ | |
1299 do { | |
1300 xvid_enc_stats_t stats; | |
1301 memset(&stats, 0, sizeof(xvid_enc_stats_t)); | |
1302 stats.version = XVID_VERSION; | |
1303 | |
1304 /* Encode internal buffer */ | |
1305 size = xvid_encore(mod->instance, XVID_ENC_ENCODE, &mod->frame, &stats); | |
1306 | |
1307 if (size>0) { | |
1308 /* Update stats */ | |
1309 update_stats(mod, &stats); | |
1310 | |
1311 /* xvidcore outputed bitstream -- mux it */ | |
1312 muxer_write_chunk(mod->mux, size, | |
17487
fa17424b4c7b
change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents:
17012
diff
changeset
|
1313 (mod->frame.out_flags & XVID_KEYFRAME)?0x10:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE); |
13610 | 1314 } |
1315 } while (size>0); | |
1316 } | |
1317 | |
1318 #define SSE2PSNR(sse, nbpixels) \ | |
1319 ((!(sse)) ? 99.99f : 48.131f - 10*(double)log10((double)(sse)/(double)((nbpixels)))) | |
1320 static void | |
1321 update_stats(xvid_mplayer_module_t *mod, xvid_enc_stats_t *stats) | |
1322 { | |
1323 if(xvidenc_stats && stats->type > 0) { | |
1324 mod->sse_y += stats->sse_y; | |
1325 mod->sse_u += stats->sse_u; | |
1326 mod->sse_v += stats->sse_v; | |
1327 | |
1328 if(mod->min_sse_y > stats->sse_y) { | |
1329 mod->min_sse_y = stats->sse_y; | |
1330 mod->min_sse_u = stats->sse_u; | |
1331 mod->min_sse_v = stats->sse_v; | |
1332 mod->min_framenum = mod->frames; | |
1333 } | |
1334 | |
1335 if(mod->max_sse_y < stats->sse_y) { | |
1336 mod->max_sse_y = stats->sse_y; | |
1337 mod->max_sse_u = stats->sse_u; | |
1338 mod->max_sse_v = stats->sse_v; | |
1339 mod->max_framenum = mod->frames; | |
1340 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
1341 |
13610 | 1342 if (xvidenc_psnr) { |
1343 if (!mod->fvstats) { | |
1344 char filename[20]; | |
1345 time_t today2; | |
1346 struct tm *today; | |
1347 today2 = time (NULL); | |
1348 today = localtime (&today2); | |
1349 sprintf (filename, "psnr_%02d%02d%02d.log", today->tm_hour, today->tm_min, today->tm_sec); | |
1350 mod->fvstats = fopen (filename,"w"); | |
1351 if (!mod->fvstats) { | |
1352 perror ("fopen"); | |
1353 /* Disable PSNR file output so we don't get here again */ | |
1354 xvidenc_psnr = 0; | |
1355 } | |
1356 } | |
1357 fprintf (mod->fvstats, "%6d, %2d, %6d, %2.2f, %2.2f, %2.2f, %2.2f %c\n", | |
1358 mod->frames, | |
1359 stats->quant, | |
1360 stats->length, | |
1361 SSE2PSNR (stats->sse_y, mod->pixels), | |
1362 SSE2PSNR (stats->sse_u, mod->pixels / 4), | |
1363 SSE2PSNR (stats->sse_v, mod->pixels / 4), | |
1364 SSE2PSNR (stats->sse_y + stats->sse_u + stats->sse_v,(double)mod->pixels * 1.5), | |
1365 stats->type==1?'I':stats->type==2?'P':stats->type==3?'B':stats->type?'S':'?' | |
1366 ); | |
1367 } | |
1368 mod->frames++; | |
1369 } | |
1370 } | |
1371 | |
1372 static void | |
1373 print_stats(xvid_mplayer_module_t *mod) | |
1374 { | |
1375 if (mod->frames) { | |
1376 mod->sse_y /= mod->frames; | |
1377 mod->sse_u /= mod->frames; | |
1378 mod->sse_v /= mod->frames; | |
1379 | |
1380 mp_msg(MSGT_MENCODER, MSGL_INFO, | |
1381 "The value 99.99dB is a special value and represents " | |
1382 "the upper range limit\n"); | |
1383 mp_msg(MSGT_MENCODER, MSGL_INFO, | |
20017
8e43776eeb49
make PSNR printing more consistent with other encoders
corey
parents:
19614
diff
changeset
|
1384 "xvid: Min PSNR Y:%.2f, Cb:%.2f, Cr:%.2f, All:%.2f in frame %d\n", |
13610 | 1385 SSE2PSNR(mod->max_sse_y, mod->pixels), |
1386 SSE2PSNR(mod->max_sse_u, mod->pixels/4), | |
1387 SSE2PSNR(mod->max_sse_v, mod->pixels/4), | |
20017
8e43776eeb49
make PSNR printing more consistent with other encoders
corey
parents:
19614
diff
changeset
|
1388 SSE2PSNR(mod->max_sse_y + mod->max_sse_u + mod->max_sse_v, mod->pixels*1.5), |
13610 | 1389 mod->max_framenum); |
1390 mp_msg(MSGT_MENCODER, MSGL_INFO, | |
20017
8e43776eeb49
make PSNR printing more consistent with other encoders
corey
parents:
19614
diff
changeset
|
1391 "xvid: Average PSNR Y:%.2f, Cb:%.2f, Cr:%.2f, All:%.2f for %d frames\n", |
13610 | 1392 SSE2PSNR(mod->sse_y, mod->pixels), |
1393 SSE2PSNR(mod->sse_u, mod->pixels/4), | |
1394 SSE2PSNR(mod->sse_v, mod->pixels/4), | |
20017
8e43776eeb49
make PSNR printing more consistent with other encoders
corey
parents:
19614
diff
changeset
|
1395 SSE2PSNR(mod->sse_y + mod->sse_u + mod->sse_v, mod->pixels*1.5), |
13610 | 1396 mod->frames); |
1397 mp_msg(MSGT_MENCODER, MSGL_INFO, | |
20017
8e43776eeb49
make PSNR printing more consistent with other encoders
corey
parents:
19614
diff
changeset
|
1398 "xvid: Max PSNR Y:%.2f, Cb:%.2f, Cr:%.2f, All:%.2f in frame %d\n", |
13610 | 1399 SSE2PSNR(mod->min_sse_y, mod->pixels), |
1400 SSE2PSNR(mod->min_sse_u, mod->pixels/4), | |
1401 SSE2PSNR(mod->min_sse_v, mod->pixels/4), | |
20017
8e43776eeb49
make PSNR printing more consistent with other encoders
corey
parents:
19614
diff
changeset
|
1402 SSE2PSNR(mod->min_sse_y + mod->min_sse_u + mod->min_sse_v, mod->pixels*1.5), |
13610 | 1403 mod->min_framenum); |
1404 } | |
1405 } | |
1406 #undef SSE2PSNR | |
1407 | |
11437 | 1408 static void *read_matrix(unsigned char *filename) |
1409 { | |
1410 int i; | |
1411 unsigned char *matrix; | |
1412 FILE *input; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
1413 |
11437 | 1414 /* Allocate matrix space */ |
1415 if((matrix = malloc(64*sizeof(unsigned char))) == NULL) | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1416 return NULL; |
11437 | 1417 |
1418 /* Open the matrix file */ | |
1419 if((input = fopen(filename, "rb")) == NULL) { | |
13610 | 1420 mp_msg(MSGT_MENCODER, MSGL_ERR, |
11437 | 1421 "xvid: Error opening the matrix file %s\n", |
1422 filename); | |
1423 free(matrix); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1424 return NULL; |
11437 | 1425 } |
1426 | |
1427 /* Read the matrix */ | |
1428 for(i=0; i<64; i++) { | |
1429 | |
1430 int value; | |
1431 | |
1432 /* If fscanf fails then get out of the loop */ | |
1433 if(fscanf(input, "%d", &value) != 1) { | |
13610 | 1434 mp_msg(MSGT_MENCODER, MSGL_ERR, |
11437 | 1435 "xvid: Error reading the matrix file %s\n", |
1436 filename); | |
1437 free(matrix); | |
1438 fclose(input); | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1439 return NULL; |
11437 | 1440 } |
1441 | |
1442 /* Clamp the value to safe range */ | |
1443 value = (value< 1)?1 :value; | |
1444 value = (value>255)?255:value; | |
1445 matrix[i] = value; | |
1446 } | |
1447 | |
1448 /* Fills the rest with 1 */ | |
1449 while(i<64) matrix[i++] = 1; | |
1450 | |
1451 /* We're done */ | |
1452 fclose(input); | |
1453 | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1454 return matrix; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28186
diff
changeset
|
1455 |
11437 | 1456 } |
1457 | |
13610 | 1458 |
1459 static const char * | |
1460 par_string(int parcode) | |
1461 { | |
1462 const char *par_string; | |
1463 switch (parcode) { | |
1464 case XVID_PAR_11_VGA: | |
1465 par_string = "vga11"; | |
1466 break; | |
1467 case XVID_PAR_43_PAL: | |
1468 par_string = "pal43"; | |
1469 break; | |
1470 case XVID_PAR_43_NTSC: | |
1471 par_string = "ntsc43"; | |
1472 break; | |
1473 case XVID_PAR_169_PAL: | |
1474 par_string = "pal169"; | |
1475 break; | |
1476 case XVID_PAR_169_NTSC: | |
1477 par_string = "ntsc69"; | |
1478 break; | |
1479 case XVID_PAR_EXT: | |
1480 par_string = "ext"; | |
1481 break; | |
1482 default: | |
1483 par_string = "unknown"; | |
1484 break; | |
1485 } | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1486 return par_string; |
13610 | 1487 } |
1488 | |
11437 | 1489 static const char *errorstring(int err) |
1490 { | |
13610 | 1491 const char *error; |
11437 | 1492 switch(err) { |
1493 case XVID_ERR_FAIL: | |
1494 error = "General fault"; | |
1495 break; | |
1496 case XVID_ERR_MEMORY: | |
1497 error = "Memory allocation error"; | |
1498 break; | |
1499 case XVID_ERR_FORMAT: | |
1500 error = "File format error"; | |
1501 break; | |
1502 case XVID_ERR_VERSION: | |
1503 error = "Structure version not supported"; | |
1504 break; | |
1505 case XVID_ERR_END: | |
1506 error = "End of stream reached"; | |
1507 break; | |
1508 default: | |
1509 error = "Unknown"; | |
1510 } | |
1511 | |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26727
diff
changeset
|
1512 return error; |
11437 | 1513 } |
1514 | |
1515 /***************************************************************************** | |
1516 * Module structure definition | |
1517 ****************************************************************************/ | |
1518 | |
32033 | 1519 const vf_info_t ve_info_xvid = { |
26883 | 1520 "XviD 1.0 encoder", |
11437 | 1521 "xvid", |
1522 "Marco Belli <elcabesa@inwind.it>, Edouard Gomez <ed.gomez@free.fr>", | |
1523 "No comment", | |
1524 vf_open | |
1525 }; | |
1526 | |
1527 | |
1528 /* Please do not change that tag comment. | |
1529 * arch-tag: 42ccc257-0548-4a3e-9617-2876c4e8ac88 mplayer xvid encoder module */ |