change commented out code that will never be executed again
[sparrow.git] / play_core.h
blob9222816ddb62825066622a0273190e573ce6ae15
1 #include "sparrow.h"
2 #include "gstsparrow.h"
3 #include <string.h>
4 #include <math.h>
6 #define DEBUG_PLAY 0
7 #define OLD_FRAMES 4
10 typedef struct sparrow_play_s{
11 guint8 lut_hi[256];
12 guint8 lut_lo[256];
13 guint8 *image_row;
14 guint jpeg_index;
15 GstBuffer *old_frames[OLD_FRAMES];
16 int old_frames_head;
17 int old_frames_tail;
18 } sparrow_play_t;
21 #define SUBPIXEL(x) static inline guint8 one_subpixel_##x \
22 (sparrow_play_t *player, guint8 inpix, guint8 jpegpix, guint8 oldpix)
25 SUBPIXEL(gamma_clamp){
26 /*clamp in pseudo gamma space*/
27 int gj = player->lut_hi[jpegpix];
28 int gi = player->lut_hi[inpix];
29 int diff = gj - gi;
30 if (diff < 0)
31 return 0;
32 return player->lut_lo[diff];
36 SUBPIXEL(clamp){
37 /*clamp */
38 int diff = jpegpix - inpix;
39 if (diff < 0)
40 return 0;
41 return diff;
44 SUBPIXEL(full_mirror){
45 /*full mirror -SEGFAULTS */
46 int diff = jpegpix - inpix;
47 if (diff < 0)
48 return -diff; /*or -diff /2 */
49 return diff;
52 SUBPIXEL(sum){
53 guint sum = jpegpix + inpix;
54 return sum >> 1;
57 SUBPIXEL(gamma_avg){
58 int sum = player->lut_hi[jpegpix] + player->lut_hi[255 - inpix];
59 return player->lut_lo[sum >> 1];
62 SUBPIXEL(simple){
63 int sum = jpegpix + ((oldpix - inpix) >> 1);
64 if (sum < 0)
65 return 0;
66 if (sum > 200)
67 return 200 + sum / 2;
68 return sum;
71 SUBPIXEL(gentle_clamp){
72 /* gentle clamp */
73 int error = MAX(inpix - oldpix, 0) >> 1;
74 int diff = jpegpix - error;
75 if (diff < 0)
76 return 0;
77 return diff;
80 SUBPIXEL(zebra){
81 int error = MAX(inpix - oldpix, 0) >> 1;
82 int diff = jpegpix - error - (inpix >> 1);
83 if (diff < 0)
84 return 0;
85 if (diff > 255)
86 return 255;
87 return diff;
90 SUBPIXEL(inverse_clamp){
91 /* gentle clamp */
92 int error = MAX(oldpix - inpix, 0);
93 int diff = jpegpix + error;
94 if (diff < 0)
95 return 0;
96 if (diff > 255)
97 return 255;
98 return diff;
101 SUBPIXEL(gamma_oldpix){
102 /*clamp in pseudo gamma space*/
103 int jpeg_gamma = player->lut_lo[jpegpix];
104 int in_gamma = player->lut_lo[inpix];
105 int old_gamma = player->lut_lo[oldpix];
106 int error = (in_gamma - old_gamma) >> 1;
107 int diff = jpeg_gamma - error;
108 if (diff < 0)
109 return 0;
110 return player->lut_hi[diff];
114 SUBPIXEL(gamma_clamp_oldpix_gentle){
115 /*clamp in pseudo gamma space*/
116 int jpeg_gamma = player->lut_hi[jpegpix];
117 int in_gamma = player->lut_hi[inpix];
118 int old_gamma = player->lut_hi[oldpix];
119 int error = MAX(in_gamma - old_gamma, 0) >> 1;
120 int diff = jpeg_gamma - error;
121 if (diff < 0)
122 return 0;
123 return player->lut_lo[diff];
126 SUBPIXEL(gamma_clamp_oldpix){
127 /*clamp in pseudo gamma space*/
128 int jpeg_gamma = player->lut_hi[jpegpix];
129 int in_gamma = player->lut_hi[inpix];
130 int old_gamma = player->lut_hi[oldpix];
131 int error = MAX(in_gamma - old_gamma, 0);
132 int diff = jpeg_gamma - error;
133 if (diff < 0)
134 return 0;
135 return player->lut_lo[diff];
140 SUBPIXEL(mess){
141 /*something */
142 int target = 2 * jpegpix - oldpix;
143 int diff = (target - inpix -inpix) >> 1;
144 if (diff < 0)
145 return 0;
146 if (diff > 255)
147 return 255;
148 return diff;