⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 Video4Linux_test.rar 接視訊的範例程式
💻
字号:
Colour ConVerT: conversion routines from YUV to RGB colour space and backVersion: 0.3 (24-10-2004) (C) 2001-2002 Nemosoft Unv.  nemosoft@smcc.demon.nlThis code is covered by the GPL; please see the file COPYING orhttp://www.gnu.org/ for more details.This package contains a number of colour conversion routines; these areoften needed in image processing, compression, video conferencing, etc.There are 3 variants of the code available:  ccvt_c1.c	Simple, yet readable C code  ccvt_c2.c	More optimized, but slightly obfuscated C code  ccvt_mmx.S	Hand-crafted assembly code for x86 processorsTo use this code in your program, run the ./configure script (or pack itwith your own program and include it in your own ./configure), run 'make'and link in the resulting libccvt.a into your program. The script tries tobe smart and compile assembly routines when available for your platform(most notably: x86 processors with MMX).The functions have a strict naming convention and take the same amount ofparameters; for example:   void ccvt_420p_bgr32(int width, int height, void *src, void *dst);'width' and 'height' are in pixels; the src and dst pointers are inputand output respectively. Any YUV planar formats are assumed to becontiguous, i.e. the U and V data follow the Y data immediately in onememory block.Width and Height must be a multiple of 2.Showing & benchmarkingIf you run	$ make bench	$ make showthis will build a total of 6 programs, 3 benchmarking and 3 verificationtools (in case MMX is not available, you will end up with only 4 programs).The verification tool is a small Qt program that runs one of the 3 variantsof the conversion code and shows the result. Any errors can thus be seenimmediately.The benchmarking tool runs the conversion routine a number of times andmeasures the time, in clock-ticks; though not exactly accurate, it gives agood indication of the time spent in the program; also, it's independant ofthe load on the system.Here are some averaged results:bench_c1	360bench_c2	206bench_mmx	160I was a little disappointed at the relatively low speed-up of the MMXroutine... I had expected it to be 3 times faster than bench_c1, with anaverage number of clock-ticks of 125... In the MMX routines 4 pixels areprocessed at a time, so that should increase throughput quite a bit, minussome overhead to get the data in and out of the MMX registers.So, I did some testing as to see what takes most time, and found the resultsquite interesting. I compiled the MMX assembly with various sections turnedon or off, ran the benchmark a few times and averaged the numbers. Thesection numbers are in the assembly source code.The times are in ticks for 500 iterations of the ccvt_420p_bgr32() function,on a Celeron 400. You will note that the numbers don't always add uplinearily; this is due to the various caching and branch-predictionmechanism used in the processor.No sections (just the loop overhead)			5 Section A1: load & prepare UV values			40 Section A2: multiply UV values with factors		38  Section A1 & A2					74 Section B1: load gray values and add UV values		47 Section B2: store 2 * 8 bytes from MMX to memory	67 (!)  Section B1 & B2					88All sections						170What was most surprising was when just section B2 was compiled in: thefunction then comprises of only a tight loop where data is transfered fromMMX to memory; this takes a relatively long time, and appearantly memoryaccess is the bottleneck here. However, if you add up the times of SectionA1 & A2, Section B1 & B2 and the overhead, you get close to the total time.Still, it seems that transfering to memory is a costly operation (I estimatethat the two 'movq' instructions from section B2 take up 25% of the totalexecution time!) Unfortunately there is not much we can do about that.However, once data is in an MMX register it is processed very fast. Adding,doing logical operations and even multiplication perform very quickly. Inaddition it has these 'saturated' functions, which prevent range overflow ofdata and saves costly compare and assign operators.Or maybe my assembly programming just sucks :)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -