1 /***************************************************************************
2 ADM_vidAddBorder.cpp - description
3 -------------------
4 begin : Sun Aug 11 2002
5 copyright : (C) 2002 by mean
6 email : fixounet@free.fr
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include "ADM_default.h"
19 #include "ADM_coreVideoFilter.h"
20 #include "DIA_coreToolkit.h"
21 #include "ADM_vidBlackBorder.h"
22 #include "DIA_factory.h"
23 #include "blackenBorder_desc.cpp"
24
25 /**
26 \fn getConfiguration
27 \brief Return current setting as a string
28 */
getConfiguration(void)29 const char *blackenBorders::getConfiguration(void)
30 {
31 static char conf[100];
32 conf[0]=0;
33 snprintf(conf,100,"blacken Borders : Left:%" PRIu32" Right:%" PRIu32" Top:%" PRIu32" Bottom:%" PRIu32"\n",
34 param.left,param.right,param.top,param.bottom);
35 return conf;
36 }
37 /**
38 \fn ctor
39 */
blackenBorders(ADM_coreVideoFilter * in,CONFcouple * setup)40 blackenBorders::blackenBorders( ADM_coreVideoFilter *in,CONFcouple *setup) : ADM_coreVideoFilter(in,setup)
41 {
42 if(!setup || !ADM_paramLoad(setup,blackenBorder_param,¶m))
43 {
44 // Default value
45 param.left=0;
46 param.right=0;
47 param.top=0;
48 param.bottom=0;
49 param.rubber_is_hidden=false;
50 }
51 }
52 /**
53 \fn dtor
54 */
~blackenBorders()55 blackenBorders::~blackenBorders()
56 {
57
58 }
59
60 /**
61 \fn getCoupledConf
62 \brief Return our current configuration as couple name=value
63 */
getCoupledConf(CONFcouple ** couples)64 bool blackenBorders::getCoupledConf(CONFcouple **couples)
65 {
66 return ADM_paramSave(couples, blackenBorder_param,¶m);
67 }
68
setCoupledConf(CONFcouple * couples)69 void blackenBorders::setCoupledConf(CONFcouple *couples)
70 {
71 ADM_paramLoad(couples, blackenBorder_param, ¶m);
72 }
73
74 #define Y_BLACK 16
75 #define UV_BLACK 128
blackenHz(int w,int nbLine,uint8_t * ptr[3],int strides[3])76 static bool blackenHz(int w,int nbLine,uint8_t *ptr[3],int strides[3])
77 {
78 // y
79 uint8_t *p=ptr[0];
80 uint32_t s=strides[0];
81 for(int y=0;y<nbLine;y++)
82 {
83 memset(p,Y_BLACK,w);
84 p+=s;
85 }
86 p=ptr[1];
87 s=strides[1];
88 nbLine/=2;
89 w/=2;
90 for(int y=0;y<nbLine;y++)
91 {
92 memset(p,UV_BLACK,w);
93 p+=s;
94 }
95 p=ptr[2];
96 s=strides[2];
97 for(int y=0;y<nbLine;y++)
98 {
99 memset(p,UV_BLACK,w);
100 p+=s;
101 }
102 return true;
103 }
104
105 /**
106 \fn getNextFrame
107 */
getNextFrame(uint32_t * fn,ADMImage * image)108 bool blackenBorders::getNextFrame(uint32_t *fn,ADMImage *image)
109 {
110 if(!previousFilter->getNextFrame(fn,image))
111 {
112 ADM_info("[blackenBorder] Cannot get previous image\n");
113 return false;
114 }
115
116
117 // Top...
118 uint8_t *ptr[3];
119 int stride[3];
120 image->GetPitches(stride);
121 image->GetWritePlanes(ptr);
122 // top
123 blackenHz(image->_width,param.top,ptr,stride);
124 // Left
125 blackenHz(param.left,image->_height,ptr,stride);
126 // Right
127 uint32_t pWidth=previousFilter->getInfo()->width-param.right;
128 ptr[0]+=pWidth;
129 ptr[1]+=(pWidth)/2;
130 ptr[2]+=(pWidth)/2;
131 blackenHz(param.right,image->_height,ptr,stride);
132 // Bottom
133 image->GetPitches(stride);
134 image->GetWritePlanes(ptr);
135 uint32_t offsetLine=previousFilter->getInfo()->height-param.bottom;
136 ptr[0]+=offsetLine*stride[0];
137 ptr[1]+=(offsetLine/2)*stride[1];
138 ptr[2]+=(offsetLine/2)*stride[2];
139 blackenHz(image->_width,param.bottom,ptr,stride);
140 return true;
141 }
142
143 /**
144 \fn configure
145 */
146 extern bool DIA_getBlackenParams( blackenBorder *param,ADM_coreVideoFilter *in);
configure(void)147 bool blackenBorders::configure(void)
148 {
149
150 bool r=DIA_getBlackenParams( ¶m,previousFilter);
151 if(!r) return false;
152 // sanity check, todo
153 return true;
154
155 }
156 // EOF
157
158
159