1 /***************************************************************************
2 ADM_vidDeinterlace.cpp - description
3 -------------------
4 Strongly inspired by Donal Graft deinterlacer
5 Could be using some MMX
6 Should be faster than the original due to YV12 colorspace
7
8 20-Aug-2002 : Ported also the MMX part
9
10 begin : Sat Apr 20 2002
11 copyright : (C) 2002 by mean
12 email : fixounet@free.fr
13 ***************************************************************************/
14
15 /***************************************************************************
16 * *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
21 * *
22 ***************************************************************************/
23 #include "ADM_default.h"
24 #include "ADM_videoFilterDynamic.h"
25
26 #include"ADM_vidDeinterlace.h"
27
28 #include "DIA_factory.h"
29
30 static FILTER_PARAM deintParam={2,{"motion_trigger","blend_trigger"}};
31
32 //********** Register chunk ************
33
34 VF_DEFINE_FILTER(ADMVideoDeinterlace,deintParam,
35 deinterlace,
36 QT_TR_NOOP("Deinterlace"),
37 1,
38 VF_INTERLACING,
39 QT_TR_NOOP("Mask interlacing artifacts. Port of Smart deinterlace."));
40 //********** Register chunk ************
41
42 //_______________________________________________________________
43
44
~ADMVideoDeinterlace()45 ADMVideoDeinterlace::~ADMVideoDeinterlace()
46 {
47
48 delete _uncompressed;
49 _uncompressed=NULL;
50 }
ADMVideoDeinterlace(AVDMGenericVideoStream * in,CONFcouple * couples)51 ADMVideoDeinterlace::ADMVideoDeinterlace( AVDMGenericVideoStream *in,CONFcouple *couples)
52 :ADMVideoFields(in,couples)
53 {
54
55 _uncompressed=new ADMImage(_info.width,_info.height);
56 }
57
58 //
59 // Basically ask a uncompressed frame from editor and ask
60 // GUI to decompress it .
61 //
62
getFrameNumberNoAlloc(uint32_t frame,uint32_t * len,ADMImage * data,uint32_t * flags)63 uint8_t ADMVideoDeinterlace::getFrameNumberNoAlloc(uint32_t frame,
64 uint32_t *len,
65 ADMImage *data,
66 uint32_t *flags)
67 {
68 //uint8_t *dst,*dstu,*dstv,*srcu,*srcv;
69 uint32_t uvlen;
70
71 if(frame>=_info.nb_frames) return 0;
72
73
74 // read uncompressed frame
75 if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0;
76
77 uvlen= _info.width*_info.height;
78 *len= (uvlen*3)>>1;
79
80 // No interleaving detected
81 if(!hasMotion(_uncompressed))
82 {
83 data->duplicate(_uncompressed);
84
85 }
86 else
87 {
88 //printf("Blending\n");
89 doBlend(_uncompressed,data);
90 memcpy(UPLANE(data),UPLANE(_uncompressed),uvlen>>2);
91 memcpy(VPLANE(data),VPLANE(_uncompressed),uvlen>>2);
92 data->copyInfo(_uncompressed);
93 }
94 return 1;
95 }
96
97
98
printConf(void)99 char *ADMVideoDeinterlace::printConf(void)
100 {
101 return (char *)"Deinterlace";;
102 }
103
104
105
106
107