]> git.sesse.net Git - kdenlive/blob - src/v4l/dec_grey.c
28cfbfd79c671334fe24a15958f521fa50115ee8
[kdenlive] / src / v4l / dec_grey.c
1 /* fswebcam - Small and simple webcam for *nix                */
2 /*============================================================*/
3 /* Copyright (C)2005-2010 Philip Heron <phil@sanslogic.co.uk> */
4 /*                                                            */
5 /* This program is distributed under the terms of the GNU     */
6 /* General Public License, version 2. You may use, modify,    */
7 /* and redistribute it under the terms of this license. A     */
8 /* copy should be included with this source.                  */
9
10 #ifdef HAVE_CONFIG_H
11 #include "config.h"
12 #endif
13
14 #include <stdint.h>
15
16 #include "src.h"
17
18 int fswc_add_image_y16(src_t *src, avgbmp_t *abitmap)
19 {
20         uint16_t *bitmap = (uint16_t *) src->img;
21         uint32_t i = src->width * src->height;
22         
23         if(src->length < i) return(-1);
24         
25         while(i-- > 0)
26         {
27                 *(abitmap++) += *bitmap >> 8;
28                 *(abitmap++) += *bitmap >> 8;
29                 *(abitmap++) += *(bitmap++) >> 8;
30         }
31         
32         return(0);
33 }
34
35 int fswc_add_image_grey(src_t *src, avgbmp_t *abitmap)
36 {
37         uint8_t *bitmap = (uint8_t *) src->img;
38         uint32_t i = src->width * src->height;
39         
40         if(src->length < i) return(-1);
41         
42         while(i-- > 0)
43         {
44                 *(abitmap++) += *bitmap;
45                 *(abitmap++) += *bitmap;
46                 *(abitmap++) += *(bitmap++);
47         }
48         
49         return(0);
50 }
51