You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
4.9KB

  1. optimization Tips (for libavcodec):
  2. What to optimize:
  3. if u plan to do non-x86 architecture specific optimiztions (SIMD normally) then
  4. take a look in the i386/ directory, as most important functions are allready
  5. optimized for MMX
  6. if u want to do x86 optimizations then u can either try to finetune the stuff in the
  7. i386 directory or find some other functions in the c source to optimize, but there
  8. arent many left
  9. Understanding these overoptimized functions:
  10. as many functions, like the c ones tend to be a bit unreadable currently becouse
  11. of optimizations it is difficult to understand them (and write arichtecture
  12. specific versions, or optimize the c functions further) it is recommanded to look
  13. at older CVS versions of the interresting files (just use CVSWEB at
  14. (http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ffmpeg/ffmpeg/libavcodec/))
  15. or perhaps look into the other architecture specific versions in i386/, ppc/,
  16. alpha/, ...; even if u dont understand the instructions exactly it could help
  17. understanding the functions & how they can be optimized
  18. NOTE:!!! if u still dont understand some function then ask at our mailing list!!!
  19. (http://lists.sourceforge.net/lists/listinfo/ffmpeg-devel)
  20. wtf is that function good for ....:
  21. the primary purpose of that list is to avoid wasting time to optimize functions
  22. which are rarely used
  23. put(_no_rnd)_pixels{,_x2,_y2,_xy2}
  24. used in motion compensation (en/decoding)
  25. avg_pixels{,_x2,_y2,_xy2}
  26. used in motion compensation of B Frames
  27. these are less important then the put*pixels functions
  28. avg_no_rnd_pixels*
  29. unused
  30. pix_abs16x16{,_x2,_y2,_xy2}
  31. used in motion estimation (encoding) with SAD
  32. pix_abs8x8{,_x2,_y2,_xy2}
  33. used in motion estimation (encoding) with SAD of MPEG4 4MV only
  34. these are less important then the pix_abs16x16* functions
  35. put_mspel8_mc* / wmv2_mspel8*
  36. used only in WMV2
  37. it is not recommanded that u waste ur time with these, as WMV2 is a
  38. ugly and relativly useless codec
  39. mpeg4_qpel* / *qpel_mc*
  40. use in MPEG4 qpel Motion compensation (encoding & decoding)
  41. the qpel8 functions are used only for 4mv
  42. the avg_* functions are used only for b frames
  43. optimizing them should have a significant impact on qpel encoding & decoding
  44. qpel{8,16}_mc??_old_c / *pixels{8,16}_l4
  45. just used to workaround a bug in old libavcodec encoder
  46. dont optimze them
  47. add_bytes/diff_bytes
  48. for huffyuv only, optimize if u want a faster ff-huffyuv codec
  49. get_pixels / diff_pixels
  50. used for encoding, easy
  51. clear_blocks
  52. easiest, to optimize
  53. gmc
  54. used for mpeg4 gmc
  55. optimizing this should have a significant effect on the gmc decoding speed but
  56. its very likely impossible to write in SIMD
  57. gmc1
  58. used for chroma blocks in mpeg4 gmc with 1 warp point
  59. (there are 4 luma & 2 chroma blocks per macrobock, so
  60. only 1/3 of the gmc blocks use this, the other 2/3
  61. use the normal put_pixel* code, but only if there is
  62. just 1 warp point)
  63. Note: Divx5 gmc always uses just 1 warp point
  64. pix_sum
  65. used for encoding
  66. hadamard8_diff / sse / sad == pix_norm1 / dct_sad / quant_psnr / rd / bit
  67. specific compare functions used in encoding, it depends upon the command line
  68. switches which of these are used
  69. dont waste ur time with dct_sad & quant_psnr they arent really usefull
  70. put_pixels_clamped / add_pixels_clamped
  71. used for en/decoding in the IDCT, easy
  72. Note, some optimized IDCTs have the add/put clamped code included and then
  73. put_pixels_clamped / add_pixels_clamped will be unused
  74. idct/fdct
  75. idct (encoding & decoding)
  76. fdct (encoding)
  77. difficult to optimize
  78. dct_quantize_trellis
  79. used for encoding with trellis quantization
  80. difficult to optimize
  81. dct_quantize
  82. used for encoding
  83. dct_unquantize_mpeg1
  84. used in mpeg1 en/decoding
  85. dct_unquantize_mpeg2
  86. used in mpeg2 en/decoding
  87. dct_unquantize_h263
  88. used in mpeg4/h263 en/decoding
  89. FIXME remaining functions?
  90. btw, most of these are in dsputil.c/.h some are in mpegvideo.c/.h
  91. Alignment:
  92. some instructions on some architectures have strict alignment restrictions,
  93. for example most SSE/SSE2 inctructios on X86
  94. the minimum guranteed alignment is writen in the .h files
  95. for example:
  96. void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, UINT8 *pixels/*align 8*/, int line_size);
  97. Links:
  98. http://www.aggregate.org/MAGIC/
  99. X86 specific:
  100. http://developer.intel.com/design/pentium4/manuals/248966.htm
  101. The IA-32 Intel Architecture Software Developer's Manual, Volume 2:
  102. Instruction Set Reference
  103. http://developer.intel.com/design/pentium4/manuals/245471.htm
  104. http://www.agner.org/assem/
  105. AMD Athlon Processor x86 Code Optimization Guide:
  106. http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/22007.pdf
  107. GCC asm links:
  108. official doc but quite ugly
  109. http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
  110. a bit old (note "+" is valid for input-output, even though the next says its not)
  111. http://www.cs.virginia.edu/~clc5q/gcc-inline-asm.pdf