Revision 8ea9ce41 doc/optimization.txt

View differences:

doc/optimization.txt
1 1
optimization Tips (for libavcodec):
2 2

  
3 3
What to optimize:
4
if you plan to do non-x86 architecture specific optimiztions (SIMD normally) then
5
take a look in the i386/ directory, as most important functions are allready
6
optimized for MMX
4
If you plan to do non-x86 architecture specific optimiztions (SIMD normally)
5
then take a look in the i386/ directory, as most important functions are
6
already optimized for MMX.
7 7

  
8
if you want to do x86 optimizations then u can either try to finetune the stuff in the
9
i386 directory or find some other functions in the c source to optimize, but there
10
arent many left
8
If you want to do x86 optimizations then you can either try to finetune the
9
stuff in the i386 directory or find some other functions in the C source to
10
optimize, but there aren't many left.
11 11

  
12 12
Understanding these overoptimized functions:
13
as many functions, like the c ones tend to be a bit unreadable currently becouse
14
of optimizations it is difficult to understand them (and write arichtecture
15
specific versions, or optimize the c functions further) it is recommanded to look
16
at older CVS versions of the interresting files (just use CVSWEB at
17
http://www1.mplayerhq.hu/cgi-bin/cvsweb.cgi/ffmpeg/libavcodec/?cvsroot=FFmpeg)
18
or perhaps look into the other architecture specific versions in i386/, ppc/,
19
alpha/, ...; even if u dont understand the instructions exactly it could help
20
understanding the functions & how they can be optimized
21

  
22
NOTE:!!! if u still dont understand some function then ask at our mailing list!!!
13
As many functions, like the C ones tend to be a bit unreadable currently
14
because of optimizations it is difficult to understand them (and write
15
architecture specific versions, or optimize the C functions further) it is
16
recommended to look at older CVS versions of the interesting files (just use
17
ViewCVS at http://www1.mplayerhq.hu/cgi-bin/cvsweb.cgi/ffmpeg/?cvsroot=FFMpeg)
18
or perhaps look into the other architecture-specific versions in i386/, ppc/,
19
alpha/, ... Even if you don't understand the instructions exactly it could
20
help understanding the functions & how they can be optimized.
21

  
22
NOTE: If you still don't understand some function, ask at our mailing list!!!
23 23
(http://www1.mplayerhq.hu/mailman/listinfo/ffmpeg-devel)
24 24

  
25 25

  
26 26

  
27
wtf is that function good for ....:
28
the primary purpose of that list is to avoid wasting time to optimize functions
27
WTF is that function good for ....:
28
The primary purpose of that list is to avoid wasting time to optimize functions
29 29
which are rarely used
30 30

  
31 31
put(_no_rnd)_pixels{,_x2,_y2,_xy2}
32
    used in motion compensation (en/decoding)
32
    Used in motion compensation (en/decoding).
33 33

  
34 34
avg_pixels{,_x2,_y2,_xy2}
35
    used in motion compensation of B Frames
36
    these are less important then the put*pixels functions
35
    Used in motion compensation of B-frames.
36
    These are less important then the put*pixels functions.
37 37

  
38 38
avg_no_rnd_pixels*
39 39
    unused
40 40

  
41 41
pix_abs16x16{,_x2,_y2,_xy2}
42
    used in motion estimation (encoding) with SAD
42
    Used in motion estimation (encoding) with SAD.
43 43

  
44 44
pix_abs8x8{,_x2,_y2,_xy2}
45
    used in motion estimation (encoding) with SAD of MPEG4 4MV only
46
    these are less important then the pix_abs16x16* functions
45
    Used in motion estimation (encoding) with SAD of MPEG-4 4MV only.
46
    These are less important then the pix_abs16x16* functions.
47 47

  
48 48
put_mspel8_mc* / wmv2_mspel8*
49
    used only in WMV2
50
    it is not recommanded that u waste ur time with these, as WMV2 is a
51
    ugly and relativly useless codec
49
    Used only in WMV2.
50
    it is not recommended that you waste your time with these, as WMV2
51
    is an ugly and relatively useless codec.
52 52

  
53 53
mpeg4_qpel* / *qpel_mc*
54
    use in MPEG4 qpel Motion compensation (encoding & decoding)
55
    the qpel8 functions are used only for 4mv
56
    the avg_* functions are used only for b frames
57
    optimizing them should have a significant impact on qpel encoding & decoding
54
    Used in MPEG-4 qpel motion compensation (encoding & decoding).
55
    The qpel8 functions are used only for 4mv,
56
    the avg_* functions are used only for B-frames.
57
    Optimizing them should have a significant impact on qpel
58
    encoding & decoding.
58 59

  
59 60
qpel{8,16}_mc??_old_c / *pixels{8,16}_l4
60
    just used to workaround a bug in old libavcodec encoder
61
    dont optimze them
61
    Just used to work around a bug in an old libavcodec encoder version.
62
    Don't optimize them.
62 63

  
63 64
tpel_mc_func {put,avg}_tpel_pixels_tab
64
    used only for SVQ3, so only optimze them if u need fast SVQ3 decoding
65
    Used only for SVQ3, so only optimize them if you need fast SVQ3 decoding.
65 66

  
66 67
add_bytes/diff_bytes
67
    for huffyuv only, optimize if u want a faster ff-huffyuv codec
68
    For huffyuv only, optimize if you want a faster ffhuffyuv codec.
68 69

  
69 70
get_pixels / diff_pixels
70
    used for encoding, easy
71
    Used for encoding, easy.
71 72

  
72 73
clear_blocks
73
    easiest, to optimize
74
    easiest to optimize
74 75

  
75 76
gmc
76
    used for mpeg4 gmc
77
    optimizing this should have a significant effect on the gmc decoding speed but
78
    its very likely impossible to write in SIMD
77
    Used for MPEG-4 gmc.
78
    Optimizing this should have a significant effect on the gmc decoding
79
    speed but it's very likely impossible to write in SIMD.
79 80

  
80 81
gmc1
81
    used for chroma blocks in mpeg4 gmc with 1 warp point
82
    (there are 4 luma & 2 chroma blocks per macrobock, so
82
    Used for chroma blocks in MPEG-4 gmc with 1 warp point
83
    (there are 4 luma & 2 chroma blocks per macroblock, so
83 84
    only 1/3 of the gmc blocks use this, the other 2/3
84 85
    use the normal put_pixel* code, but only if there is
85
    just 1 warp point)
86
    Note: Divx5 gmc always uses just 1 warp point
86
    just 1 warp point).
87
    Note: DivX5 gmc always uses just 1 warp point.
87 88

  
88 89
pix_sum
89
    used for encoding
90
    Used for encoding.
90 91

  
91 92
hadamard8_diff / sse / sad == pix_norm1 / dct_sad / quant_psnr / rd / bit
92
    specific compare functions used in encoding, it depends upon the command line
93
    switches which of these are used
94
    dont waste ur time with dct_sad & quant_psnr they arent really usefull
93
    Specific compare functions used in encoding, it depends upon the
94
    command line switches which of these are used.
95
    Don't waste your time with dct_sad & quant_psnr, they aren't
96
    really useful.
95 97

  
96 98
put_pixels_clamped / add_pixels_clamped
97
    used for en/decoding in the IDCT, easy
98
    Note, some optimized IDCTs have the add/put clamped code included and then
99
    put_pixels_clamped / add_pixels_clamped will be unused
99
    Used for en/decoding in the IDCT, easy.
100
    Note, some optimized IDCTs have the add/put clamped code included and
101
    then put_pixels_clamped / add_pixels_clamped will be unused.
100 102

  
101 103
idct/fdct
102 104
    idct (encoding & decoding)
......
104 106
    difficult to optimize
105 107

  
106 108
dct_quantize_trellis
107
    used for encoding with trellis quantization
109
    Used for encoding with trellis quantization.
108 110
    difficult to optimize
109 111

  
110 112
dct_quantize
111
    used for encoding
113
    Used for encoding.
112 114

  
113 115
dct_unquantize_mpeg1
114
    used in mpeg1 en/decoding
116
    Used in MPEG-1 en/decoding.
115 117

  
116 118
dct_unquantize_mpeg2
117
    used in mpeg2 en/decoding
119
    Used in MPEG-2 en/decoding.
118 120

  
119 121
dct_unquantize_h263
120
    used in mpeg4/h263 en/decoding
122
    Used in MPEG-4/H.263 en/decoding.
121 123

  
122 124
FIXME remaining functions?
123
btw, most of these are in dsputil.c/.h some are in mpegvideo.c/.h
125
BTW, most of these functions are in dsputil.c/.h, some are in mpegvideo.c/.h.
124 126

  
125 127

  
126 128

  
127 129
Alignment:
128
some instructions on some architectures have strict alignment restrictions,
129
for example most SSE/SSE2 inctructios on X86
130
the minimum guranteed alignment is writen in the .h files
131
for example:
130
Some instructions on some architectures have strict alignment restrictions,
131
for example most SSE/SSE2 inctructios on x86.
132
The minimum guaranteed alignment is written in the .h files, for example:
132 133
    void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, UINT8 *pixels/*align 8*/, int line_size);
133 134

  
134 135

  
......
136 137
Links:
137 138
http://www.aggregate.org/MAGIC/
138 139

  
139
X86 specific:
140
x86-specific:
140 141
http://developer.intel.com/design/pentium4/manuals/248966.htm
141 142

  
142 143
The IA-32 Intel Architecture Software Developer's Manual, Volume 2:
......
152 153
official doc but quite ugly
153 154
http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
154 155

  
155
a bit old (note "+" is valid for input-output, even though the next says its not)
156
a bit old (note "+" is valid for input-output, even though the next disagrees)
156 157
http://www.cs.virginia.edu/~clc5q/gcc-inline-asm.pdf
157

  

Also available in: Unified diff