1 /***************************************************************************
2 ADM_vidChroma.cpp - description
3 -------------------
4 begin : Wed Aug 28 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_videoFilterDynamic.h"
20
21 #include "ADM_vidChroma.h"
22
23
24 static FILTER_PARAM nullParam={0,{""}};
25
26
27
28 VF_DEFINE_FILTER ( ADMVideoChromaV,nullParam,
29 chromav,
30 QT_TR_NOOP ( "Chroma V" ),
31 1,
32 VF_COLORS,
33 QT_TR_NOOP ( "Keep chroma V only." ) );
34
35
36
printConf(void)37 char *ADMVideoChromaV::printConf( void )
38 {
39 ADM_FILTER_DECLARE_CONF(" chroma v only");
40
41 }
42
43 //_______________________________________________________________
44
ADMVideoChromaV(AVDMGenericVideoStream * in,CONFcouple * setup)45 ADMVideoChromaV::ADMVideoChromaV(
46 AVDMGenericVideoStream *in,CONFcouple *setup)
47 {
48 UNUSED_ARG(setup);
49
50 _in=in;
51 memcpy(&_info,_in->getInfo(),sizeof(_info));
52 _info.encoding=1;
53
54
55 }
~ADMVideoChromaV()56 ADMVideoChromaV::~ADMVideoChromaV()
57 {
58
59
60
61 }
62
63 //
64 // Remove y and v just keep U and expand it
65 //
getFrameNumberNoAlloc(uint32_t frame,uint32_t * len,ADMImage * data,uint32_t * flags)66 uint8_t ADMVideoChromaV::getFrameNumberNoAlloc(uint32_t frame,
67 uint32_t *len,
68 ADMImage *data,
69 uint32_t *flags)
70 {
71 uint32_t w,x;
72 uint32_t page;
73 if(frame>= _info.nb_frames) return 0;
74 if(!_in->getFrameNumberNoAlloc(frame, len,data,flags)) return 0;
75
76 page= _info.width*_info.height;
77 *len=(page*3)>>1;
78
79
80 // now expand u
81 uint8_t *y,*v,*y2;
82
83 y=YPLANE(data);
84 y2=y+_info.width;
85 v=VPLANE(data);
86 for(w= _info.height>>1;w>0;w--)
87 {
88 for(x= _info.width>>1;x>0;x--)
89 {
90 *y=*v;
91 *y2=*v;
92 *(y+1)=*v;
93 *(y2+1)=*v;
94 v++;
95 y+=2;
96 y2+=2;
97 }
98 y+=_info.width;
99 y2+=_info.width;
100 }
101
102 // Remove chroma u & v
103 memset(UPLANE(data),0x80,page>>2);
104 memset(VPLANE(data),0x80,page>>2);
105 }
106
107