1
/***************************************************************************
2
Swap Fields.cpp - description
4
Swap each line (shift up for odd, down for even)
7
begin : Thu Mar 21 2002
8
copyright : (C) 2002 by mean
9
email : fixounet@free.fr
10
***************************************************************************/
12
/***************************************************************************
14
* This program is free software; you can redistribute it and/or modify *
15
* it under the terms of the GNU General Public License as published by *
16
* the Free Software Foundation; either version 2 of the License, or *
17
* (at your option) any later version. *
19
***************************************************************************/
24
#include <ADM_assert.h>
34
#include "ADM_toolkit/toolkit.hxx"
35
#include "ADM_editor/ADM_edit.hxx"
36
#include "ADM_video/ADM_genvideo.hxx"
37
#include "ADM_video/ADM_vidFieldUtil.h"
38
#include "ADM_vidSwapFields.h"
39
//static void decimate(uint8_t *src,uint8_t *target, uint32_t linessrc, uint32_t width);
40
#include "ADM_filter/video_filters.h"
43
static FILTER_PARAM swapParam={0,{""}};
47
BUILD_CREATE(swapfield_create,AVDMVideoSwapField);
48
BUILD_CREATE(keepeven_create,AVDMVideoKeepEven);
49
BUILD_CREATE(keepodd_create,AVDMVideoKeepOdd);
51
SCRIPT_CREATE(swapfield_script,AVDMVideoSwapField,swapParam);
52
SCRIPT_CREATE(keepeven_script,AVDMVideoKeepEven,swapParam);
53
SCRIPT_CREATE(keepodd_script,AVDMVideoKeepOdd,swapParam);
55
char *AVDMVideoSwapField::printConf( void )
59
sprintf((char *)buf," Swap fields");
62
char *AVDMVideoKeepEven::printConf( void )
66
sprintf((char *)buf," Keep Even Fields");
68
}char *AVDMVideoKeepOdd::printConf( void )
72
sprintf((char *)buf," Keep Odd Fields");
75
//_______________________________________________________________
76
AVDMVideoSwapField::AVDMVideoSwapField(
77
AVDMGenericVideoStream *in,CONFcouple *setup)
81
memcpy(&_info,_in->getInfo(),sizeof(_info));
82
_uncompressed=new ADMImage(_info.width,_info.height);
86
//_______________________________________________________________
87
AVDMVideoKeepOdd::AVDMVideoKeepOdd(
88
AVDMGenericVideoStream *in,CONFcouple *setup)
92
memcpy(&_info,_in->getInfo(),sizeof(_info));
93
_uncompressed=new ADMImage(_info.width,_info.height);
97
// ___ destructor_____________
98
AVDMVideoSwapField::~AVDMVideoSwapField()
100
delete _uncompressed;
104
// ___ destructor_____________
105
AVDMVideoKeepOdd::~AVDMVideoKeepOdd()
107
delete _uncompressed;
113
// Basically ask a uncompressed frame from editor and ask
114
// GUI to decompress it .
117
uint8_t AVDMVideoSwapField::getFrameNumberNoAlloc(uint32_t frame,
122
//static Image in,out;
123
if(frame>=_info.nb_frames) return 0;
126
// read uncompressed frame
127
if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0;
129
uint32_t w=_info.width;
130
uint32_t h=_info.height;
135
memcpy(UPLANE(data),UPLANE(_uncompressed),page>>2);
136
memcpy(VPLANE(data),VPLANE(_uncompressed),page>>2);
138
uint8_t *odd,*even,*target,*target2;
140
even=YPLANE(_uncompressed);
143
target2=YPLANE(data)+w;
149
memcpy(target,odd,w);
150
memcpy(target2,even,w);
156
data->copyInfo(_uncompressed);
161
uint8_t AVDMVideoKeepOdd::getFrameNumberNoAlloc(uint32_t frame,
166
//static Image in,out;
167
if(frame>= _info.nb_frames) return 0;
168
if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0;
171
uint32_t w=_info.width;
172
uint32_t h=_info.height;
174
vidFieldKeepOdd( w, h, YPLANE(_uncompressed),YPLANE(data));
175
data->copyInfo(_uncompressed);
180
uint8_t AVDMVideoKeepEven::getFrameNumberNoAlloc(uint32_t frame,
185
//static Image in,out;
186
if(frame>=_info.nb_frames) return 0;
189
// read uncompressed frame
190
if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0;
192
uint32_t w=_info.width;
193
uint32_t h=_info.height;
196
data->copyInfo(_uncompressed);
197
vidFieldKeepEven( w, h, YPLANE(_uncompressed),YPLANE(data));