aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/video4linux
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-12-11 09:34:20 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-16 06:27:20 -0500
commit35b23b522696118b5ec5b84ba6846ee96aa2743e (patch)
treebb2a8d64a2ebcde24bc97a36a69b49e5ea0e64e5 /Documentation/video4linux
parent0f4482940a75b52db931e1fff181c9d267e462d2 (diff)
V4L/DVB (13651): sh_mobile_ceu_camera: document the scaling and cropping algorithm
The sh_mobile_ceu_camera driver implements an advanced algorithm, combining scaling and cropping on the client and on the host. Due to its complexity the algorithm deserves separate documentation. create mode 100644 Documentation/video4linux/sh_mobile_ceu_camera.txt Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'Documentation/video4linux')
-rw-r--r--Documentation/video4linux/sh_mobile_ceu_camera.txt157
1 files changed, 157 insertions, 0 deletions
diff --git a/Documentation/video4linux/sh_mobile_ceu_camera.txt b/Documentation/video4linux/sh_mobile_ceu_camera.txt
new file mode 100644
index 000000000000..2ae16349a78d
--- /dev/null
+++ b/Documentation/video4linux/sh_mobile_ceu_camera.txt
@@ -0,0 +1,157 @@
1 Cropping and Scaling algorithm, used in the sh_mobile_ceu_camera driver
2 =======================================================================
3
4Terminology
5-----------
6
7sensor scales: horizontal and vertical scales, configured by the sensor driver
8host scales: -"- host driver
9combined scales: sensor_scale * host_scale
10
11
12Generic scaling / cropping scheme
13---------------------------------
14
15-1--
16|
17-2-- -\
18| --\
19| --\
20+-5-- -\ -- -3--
21| ---\
22| --- -4-- -\
23| -\
24| - -6--
25|
26| - -6'-
27| -/
28| --- -4'- -/
29| ---/
30+-5'- -/
31| -- -3'-
32| --/
33| --/
34-2'- -/
35|
36|
37-1'-
38
39Produced by user requests:
40
41S_CROP(left / top = (5) - (1), width / height = (5') - (5))
42S_FMT(width / height = (6') - (6))
43
44Here:
45
46(1) to (1') - whole max width or height
47(1) to (2) - sensor cropped left or top
48(2) to (2') - sensor cropped width or height
49(3) to (3') - sensor scale
50(3) to (4) - CEU cropped left or top
51(4) to (4') - CEU cropped width or height
52(5) to (5') - reverse sensor scale applied to CEU cropped width or height
53(2) to (5) - reverse sensor scale applied to CEU cropped left or top
54(6) to (6') - CEU scale - user window
55
56
57S_FMT
58-----
59
60Do not touch input rectangle - it is already optimal.
61
621. Calculate current sensor scales:
63
64 scale_s = ((3') - (3)) / ((2') - (2))
65
662. Calculate "effective" input crop (sensor subwindow) - CEU crop scaled back at
67current sensor scales onto input window - this is user S_CROP:
68
69 width_u = (5') - (5) = ((4') - (4)) * scale_s
70
713. Calculate new combined scales from "effective" input window to requested user
72window:
73
74 scale_comb = width_u / ((6') - (6))
75
764. Calculate sensor output window by applying combined scales to real input
77window:
78
79 width_s_out = ((2') - (2)) / scale_comb
80
815. Apply iterative sensor S_FMT for sensor output window.
82
83 subdev->video_ops->s_fmt(.width = width_s_out)
84
856. Retrieve sensor output window (g_fmt)
86
877. Calculate new sensor scales:
88
89 scale_s_new = ((3')_new - (3)_new) / ((2') - (2))
90
918. Calculate new CEU crop - apply sensor scales to previously calculated
92"effective" crop:
93
94 width_ceu = (4')_new - (4)_new = width_u / scale_s_new
95 left_ceu = (4)_new - (3)_new = ((5) - (2)) / scale_s_new
96
979. Use CEU cropping to crop to the new window:
98
99 ceu_crop(.width = width_ceu, .left = left_ceu)
100
10110. Use CEU scaling to scale to the requested user window:
102
103 scale_ceu = width_ceu / width
104
105
106S_CROP
107------
108
109If old scale applied to new crop is invalid produce nearest new scale possible
110
1111. Calculate current combined scales.
112
113 scale_comb = (((4') - (4)) / ((6') - (6))) * (((2') - (2)) / ((3') - (3)))
114
1152. Apply iterative sensor S_CROP for new input window.
116
1173. If old combined scales applied to new crop produce an impossible user window,
118adjust scales to produce nearest possible window.
119
120 width_u_out = ((5') - (5)) / scale_comb
121
122 if (width_u_out > max)
123 scale_comb = ((5') - (5)) / max;
124 else if (width_u_out < min)
125 scale_comb = ((5') - (5)) / min;
126
1274. Issue G_CROP to retrieve actual input window.
128
1295. Using actual input window and calculated combined scales calculate sensor
130target output window.
131
132 width_s_out = ((3') - (3)) = ((2') - (2)) / scale_comb
133
1346. Apply iterative S_FMT for new sensor target output window.
135
1367. Issue G_FMT to retrieve the actual sensor output window.
137
1388. Calculate sensor scales.
139
140 scale_s = ((3') - (3)) / ((2') - (2))
141
1429. Calculate sensor output subwindow to be cropped on CEU by applying sensor
143scales to the requested window.
144
145 width_ceu = ((5') - (5)) / scale_s
146
14710. Use CEU cropping for above calculated window.
148
14911. Calculate CEU scales from sensor scales from results of (10) and user window
150from (3)
151
152 scale_ceu = calc_scale(((5') - (5)), &width_u_out)
153
15412. Apply CEU scales.
155
156--
157Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>