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