~ubuntu-branches/ubuntu/hardy/avidemux/hardy

« back to all changes in this revision

Viewing changes to avidemux/ADM_videoFilter/ADM_vidSeparateField.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matvey Kozhev
  • Date: 2007-12-18 13:53:04 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218135304-cdqec2lg2bglyz15
Tags: 1:2.4~preview3-0.0ubuntu1
* Upload to Ubuntu. (LP: #163287, LP: #126572)
* debian/changelog: re-added Ubuntu releases.
* debian/control:
  - Require debhelper >= 5.0.51 (for dh_icons) and imagemagick.
  - Build-depend on libsdl1.2-dev instead of libsdl-dev.
  - Build against newer libx264-dev. (LP: #138854)
  - Removed libamrnb-dev, not in Ubuntu yet.
* debian/rules:
  - Install all icon sizes, using convert (upstream installs none).
  - Added missing calls to dh_installmenu, dh_installman, dh_icons and
    dh_desktop.
* debian/menu, debian/avidemux-qt.menu:
  - Corrected package and executable names.
* debian/avidemux-common.install: Install icons.
* debian/avidemux.common.manpages: Install man/avidemux.1.
* debian/links, debian/avidemux-cli.links, debian/avidemux-gtk.links:
  - Link manpages to avidemux.1.gz.
* debian/install, debian/avidemux-qt.install, debian/avidemux-gtk.desktop,
  debian/avidemux-qt.desktop: Install desktop files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          Separate Fields.cpp  -  description
 
3
                             -------------------
 
4
Convert a x*y * f fps video into -> x*(y/2)*fps/2 video
 
5
 
 
6
Same idea as for avisynth separatefield
 
7
 
 
8
 
 
9
    begin                : Thu Mar 21 2002
 
10
    copyright            : (C) 2002 by mean
 
11
    email                : fixounet@free.fr
 
12
 ***************************************************************************/
 
13
 
 
14
/***************************************************************************
 
15
 *                                                                         *
 
16
 *   This program is free software; you can redistribute it and/or modify  *
 
17
 *   it under the terms of the GNU General Public License as published by  *
 
18
 *   the Free Software Foundation; either version 2 of the License, or     *
 
19
 *   (at your option) any later version.                                   *
 
20
 *                                                                         *
 
21
 ***************************************************************************/
 
22
 
 
23
#include <stdio.h>
 
24
#include <stdlib.h>
 
25
#include <string.h>
 
26
#include <ADM_assert.h>
 
27
 
 
28
#include "config.h"
 
29
#include "fourcc.h"
 
30
#include "avio.hxx"
 
31
#include "config.h"
 
32
#include "avi_vars.h"
 
33
 
 
34
 
 
35
#include "ADM_toolkit/toolkit.hxx"
 
36
#include "ADM_editor/ADM_edit.hxx"
 
37
#include "ADM_video/ADM_genvideo.hxx"
 
38
#include "ADM_video/ADM_vidFieldUtil.h"
 
39
#include "ADM_vidSeparateField.h"
 
40
#include "ADM_filter/video_filters.h"
 
41
 
 
42
 
 
43
static FILTER_PARAM swapParam={0,{""}};
 
44
 
 
45
SCRIPT_CREATE(separatefield_script,AVDMVideoSeparateField,swapParam);
 
46
SCRIPT_CREATE(mergefield_script,AVDMVideoMergeField,swapParam);
 
47
SCRIPT_CREATE(stackfield_script,AVDMVideoStackField,swapParam);
 
48
SCRIPT_CREATE(unstackfield_script,AVDMVideoUnStackField,swapParam);
 
49
 
 
50
BUILD_CREATE(separatefield_create,AVDMVideoSeparateField);
 
51
BUILD_CREATE(mergefield_create,AVDMVideoMergeField);
 
52
BUILD_CREATE(stackfield_create,AVDMVideoStackField);
 
53
BUILD_CREATE(unstackfield_create,AVDMVideoUnStackField);
 
54
 
 
55
char *AVDMVideoSeparateField::printConf( void )
 
56
{
 
57
        static char buf[50];
 
58
 
 
59
        sprintf((char *)buf," Separate Fields");
 
60
        return buf;
 
61
}
 
62
 
 
63
//_______________________________________________________________
 
64
AVDMVideoSeparateField::AVDMVideoSeparateField(
 
65
                                                                        AVDMGenericVideoStream *in,CONFcouple *setup)
 
66
{
 
67
UNUSED_ARG(setup);
 
68
        _in=in;
 
69
        memcpy(&_info,_in->getInfo(),sizeof(_info));
 
70
        
 
71
 
 
72
        _info.height>>=1;
 
73
        _info.fps1000*=2;
 
74
        _info.nb_frames*=2;
 
75
        vidCache=new VideoCache(2,_in);
 
76
 
 
77
}
 
78
 
 
79
// ___ destructor_____________
 
80
AVDMVideoSeparateField::~AVDMVideoSeparateField()
 
81
{
 
82
        
 
83
        delete vidCache;
 
84
        vidCache=NULL;
 
85
}
 
86
 
 
87
//
 
88
//      Basically ask a uncompressed frame from editor and ask
 
89
//              GUI to decompress it .
 
90
//
 
91
 
 
92
uint8_t AVDMVideoSeparateField::getFrameNumberNoAlloc(uint32_t frame,
 
93
                                uint32_t *len,
 
94
                                ADMImage *data,
 
95
                                uint32_t *flags)
 
96
{
 
97
uint32_t ref;
 
98
ADMImage *ptr;
 
99
                if(frame>=_info.nb_frames) return 0;
 
100
                ref=frame>>1;
 
101
                
 
102
                ptr=vidCache->getImage(ref);
 
103
                if(!ptr) return 0;
 
104
 
 
105
                ADM_assert(ptr->data);
 
106
                ADM_assert(data->data);
 
107
                if(frame&1) // odd image
 
108
                         vidFieldKeepOdd(_info.width,_info.height,ptr->data,data->data);
 
109
                else
 
110
                         vidFieldKeepEven(_info.width,_info.height,ptr->data,data->data);
 
111
                data->copyInfo(ptr);    
 
112
                vidCache->unlockAll();
 
113
      return 1;
 
114
}
 
115
//------------------ and merge them ------------------
 
116
 
 
117
 
 
118
char *AVDMVideoMergeField::printConf( void )
 
119
{
 
120
        static char buf[50];
 
121
 
 
122
        sprintf((char *)buf," Merge fields");
 
123
        return buf;
 
124
}
 
125
 
 
126
//_______________________________________________________________
 
127
AVDMVideoMergeField::AVDMVideoMergeField(
 
128
                                                                        AVDMGenericVideoStream *in,CONFcouple *setup)
 
129
{
 
130
UNUSED_ARG(setup);
 
131
        _in=in;
 
132
        memcpy(&_info,_in->getInfo(),sizeof(_info));    
 
133
        vidCache=new VideoCache(4,_in);
 
134
        
 
135
 
 
136
        _info.height<<=1;
 
137
        _info.fps1000>>=1;
 
138
        _info.nb_frames>>=1;
 
139
 
 
140
 
 
141
}
 
142
 
 
143
// ___ destructor_____________
 
144
AVDMVideoMergeField::~AVDMVideoMergeField()
 
145
{
 
146
                delete vidCache;
 
147
                vidCache=NULL;
 
148
}
 
149
 
 
150
/**
 
151
        Interleave frame*2 and frame*2+1
 
152
*/
 
153
uint8_t AVDMVideoMergeField::getFrameNumberNoAlloc(uint32_t frame,
 
154
                                uint32_t *len,
 
155
                                ADMImage *data,
 
156
                                uint32_t *flags)
 
157
{
 
158
uint32_t ref,ref2;
 
159
ADMImage *ptr1,*ptr2;
 
160
                if(frame>=_info.nb_frames) return 0;
 
161
 
 
162
                ref=frame<<1;
 
163
                ref2=ref+1;
 
164
                ptr1=vidCache->getImage(ref);
 
165
                ptr2=vidCache->getImage(ref+1);
 
166
                
 
167
                if(!ptr1 || !ptr2)
 
168
                {
 
169
                        printf("Merge field : cannot read\n");
 
170
                        vidCache->unlockAll();
 
171
                        return 0;
 
172
                }
 
173
                 vidFieldMerge(_info.width,_info.height,ptr1->data,ptr2->data,data->data);
 
174
                 vidCache->unlockAll();
 
175
                
 
176
      return 1;
 
177
}
 
178
//_______________________Stack Fields_______________________
 
179
 
 
180
char *AVDMVideoStackField::printConf( void )
 
181
{
 
182
        static char buf[50];
 
183
 
 
184
        sprintf((char *)buf," Stack fields");
 
185
        return buf;
 
186
}
 
187
 
 
188
//_______________________________________________________________
 
189
AVDMVideoStackField::AVDMVideoStackField(       AVDMGenericVideoStream *in,CONFcouple *setup)
 
190
{
 
191
UNUSED_ARG(setup);
 
192
        _in=in;
 
193
        memcpy(&_info,_in->getInfo(),sizeof(_info));    
 
194
        _uncompressed=new ADMImage(_info.width,_info.height);   
 
195
 
 
196
}
 
197
 
 
198
// ___ destructor_____________
 
199
AVDMVideoStackField::AVDMVideoStackField()
 
200
{
 
201
                delete _uncompressed;
 
202
                _uncompressed=NULL;
 
203
}
 
204
 
 
205
/**
 
206
        Interleave frame*2 and frame*2+1
 
207
*/
 
208
uint8_t AVDMVideoStackField::getFrameNumberNoAlloc(uint32_t frame,
 
209
                                uint32_t *len,
 
210
                                ADMImage *data,
 
211
                                uint32_t *flags)
 
212
{
 
213
uint32_t ref,ref2;
 
214
ADMImage *ptr1,*ptr2;
 
215
                if(frame>=_info.nb_frames) return 0;
 
216
 
 
217
                 if(!_in->getFrameNumberNoAlloc(frame, len, _uncompressed, flags)) return 0;
 
218
                 
 
219
                  vidFielStack(_info.width ,_info.height,YPLANE(_uncompressed),YPLANE(data));
 
220
                data->copyInfo(_uncompressed);  
 
221
      return 1;
 
222
}
 
223
 
 
224
/****/
 
225
//_______________________Stack Fields_______________________
 
226
 
 
227
char *AVDMVideoUnStackField::printConf( void )
 
228
{
 
229
        static char buf[50];
 
230
 
 
231
        sprintf((char *)buf," UnStack fields");
 
232
        return buf;
 
233
}
 
234
 
 
235
//_______________________________________________________________
 
236
AVDMVideoUnStackField::AVDMVideoUnStackField(       AVDMGenericVideoStream *in,CONFcouple *setup)
 
237
{
 
238
UNUSED_ARG(setup);
 
239
        _in=in;
 
240
        memcpy(&_info,_in->getInfo(),sizeof(_info));    
 
241
        _uncompressed=new ADMImage(_info.width,_info.height);   
 
242
 
 
243
}
 
244
 
 
245
// ___ destructor_____________
 
246
AVDMVideoUnStackField::AVDMVideoUnStackField()
 
247
{
 
248
                delete _uncompressed;
 
249
                _uncompressed=NULL;
 
250
}
 
251
 
 
252
/**
 
253
        Interleave frame*2 and frame*2+1
 
254
*/
 
255
uint8_t AVDMVideoUnStackField::getFrameNumberNoAlloc(uint32_t frame,
 
256
                                uint32_t *len,
 
257
                                ADMImage *data,
 
258
                                uint32_t *flags)
 
259
{
 
260
uint32_t ref,ref2;
 
261
ADMImage *ptr1,*ptr2;
 
262
                if(frame>=_info.nb_frames) return 0;
 
263
 
 
264
                 if(!_in->getFrameNumberNoAlloc(frame, len, _uncompressed, flags)) return 0;
 
265
                 
 
266
                  vidFielUnStack(_info.width ,_info.height,YPLANE(_uncompressed),YPLANE(data));
 
267
                data->copyInfo(_uncompressed);  
 
268
      return 1;
 
269
}