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

« back to all changes in this revision

Viewing changes to avidemux/ADM_videoFilter/ADM_vidSwapFields.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
                          Swap Fields.cpp  -  description
 
3
                             -------------------
 
4
Swap each line  (shift up for odd, down for even)
 
5
 
 
6
 
 
7
    begin                : Thu Mar 21 2002
 
8
    copyright            : (C) 2002 by mean
 
9
    email                : fixounet@free.fr
 
10
 ***************************************************************************/
 
11
 
 
12
/***************************************************************************
 
13
 *                                                                         *
 
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.                                   *
 
18
 *                                                                         *
 
19
 ***************************************************************************/
 
20
 
 
21
#include <stdio.h>
 
22
#include <stdlib.h>
 
23
#include <string.h>
 
24
#include <ADM_assert.h>
 
25
 
 
26
#include "config.h"
 
27
#include "fourcc.h"
 
28
#include "avio.hxx"
 
29
#include "config.h"
 
30
#include "avi_vars.h"
 
31
#ifdef HAVE_ENCODER
 
32
 
 
33
 
 
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"
 
41
 
 
42
 
 
43
static FILTER_PARAM swapParam={0,{""}};
 
44
 
 
45
 
 
46
 
 
47
BUILD_CREATE(swapfield_create,AVDMVideoSwapField);
 
48
BUILD_CREATE(keepeven_create,AVDMVideoKeepEven);
 
49
BUILD_CREATE(keepodd_create,AVDMVideoKeepOdd);
 
50
 
 
51
SCRIPT_CREATE(swapfield_script,AVDMVideoSwapField,swapParam);
 
52
SCRIPT_CREATE(keepeven_script,AVDMVideoKeepEven,swapParam);
 
53
SCRIPT_CREATE(keepodd_script,AVDMVideoKeepOdd,swapParam);
 
54
 
 
55
char *AVDMVideoSwapField::printConf( void )
 
56
{
 
57
        static char buf[50];
 
58
 
 
59
        sprintf((char *)buf," Swap fields");
 
60
        return buf;
 
61
}
 
62
char *AVDMVideoKeepEven::printConf( void )
 
63
{
 
64
        static char buf[50];
 
65
 
 
66
        sprintf((char *)buf," Keep Even Fields");
 
67
        return buf;
 
68
}char *AVDMVideoKeepOdd::printConf( void )
 
69
{
 
70
        static char buf[50];
 
71
 
 
72
        sprintf((char *)buf," Keep Odd Fields");
 
73
        return buf;
 
74
}
 
75
//_______________________________________________________________
 
76
AVDMVideoSwapField::AVDMVideoSwapField(
 
77
                                                                        AVDMGenericVideoStream *in,CONFcouple *setup)
 
78
{
 
79
UNUSED_ARG(setup);
 
80
        _in=in;
 
81
        memcpy(&_info,_in->getInfo(),sizeof(_info));
 
82
        _uncompressed=new ADMImage(_info.width,_info.height);
 
83
 
 
84
 
 
85
}
 
86
//_______________________________________________________________
 
87
AVDMVideoKeepOdd::AVDMVideoKeepOdd(
 
88
                                                                        AVDMGenericVideoStream *in,CONFcouple *setup)
 
89
{
 
90
UNUSED_ARG(setup);
 
91
        _in=in;
 
92
        memcpy(&_info,_in->getInfo(),sizeof(_info));
 
93
        _uncompressed=new ADMImage(_info.width,_info.height);
 
94
        _info.height>>=1;
 
95
 
 
96
}
 
97
// ___ destructor_____________
 
98
AVDMVideoSwapField::~AVDMVideoSwapField()
 
99
{
 
100
        delete  _uncompressed;
 
101
        _uncompressed=NULL;
 
102
 
 
103
}
 
104
// ___ destructor_____________
 
105
AVDMVideoKeepOdd::~AVDMVideoKeepOdd()
 
106
{
 
107
        delete _uncompressed;
 
108
        _uncompressed=NULL;
 
109
 
 
110
}
 
111
 
 
112
//
 
113
//      Basically ask a uncompressed frame from editor and ask
 
114
//              GUI to decompress it .
 
115
//
 
116
 
 
117
uint8_t AVDMVideoSwapField::getFrameNumberNoAlloc(uint32_t frame,
 
118
                                uint32_t *len,
 
119
                                ADMImage *data,
 
120
                                uint32_t *flags)
 
121
{
 
122
//static Image in,out;
 
123
                        if(frame>=_info.nb_frames) return 0;
 
124
 
 
125
 
 
126
                        // read uncompressed frame
 
127
                if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0;
 
128
 
 
129
                uint32_t w=_info.width;
 
130
                uint32_t h=_info.height;
 
131
                uint32_t page=w*h;
 
132
                uint32_t stride;
 
133
 
 
134
                // copy u & v
 
135
                memcpy(UPLANE(data),UPLANE(_uncompressed),page>>2);
 
136
                memcpy(VPLANE(data),VPLANE(_uncompressed),page>>2);
 
137
                
 
138
                uint8_t *odd,*even,*target,*target2;
 
139
 
 
140
                even=YPLANE(_uncompressed);
 
141
                odd=even+w;
 
142
                target=YPLANE(data);
 
143
                target2=YPLANE(data)+w;
 
144
                stride=2*w;
 
145
 
 
146
                h>>=1;
 
147
                for(;h--;h>0)
 
148
                {
 
149
                        memcpy(target,odd,w);
 
150
                        memcpy(target2,even,w);
 
151
                        target+=stride;
 
152
                        target2+=stride;
 
153
                        odd+=stride;
 
154
                        even+=stride;
 
155
                }
 
156
                data->copyInfo(_uncompressed);
 
157
 
 
158
      return 1;
 
159
}
 
160
 
 
161
uint8_t AVDMVideoKeepOdd::getFrameNumberNoAlloc(uint32_t frame,
 
162
                                uint32_t *len,
 
163
                                ADMImage *data,
 
164
                                uint32_t *flags)
 
165
{
 
166
//static Image in,out;
 
167
                if(frame>= _info.nb_frames) return 0;
 
168
                        if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0;
 
169
 
 
170
 
 
171
                uint32_t w=_info.width;
 
172
                uint32_t h=_info.height;
 
173
 
 
174
                vidFieldKeepOdd(  w,  h, YPLANE(_uncompressed),YPLANE(data));
 
175
                data->copyInfo(_uncompressed);
 
176
 
 
177
      return 1;
 
178
}
 
179
 
 
180
uint8_t AVDMVideoKeepEven::getFrameNumberNoAlloc(uint32_t frame,
 
181
                                uint32_t *len,
 
182
                                ADMImage *data,
 
183
                                uint32_t *flags)
 
184
{
 
185
//static Image in,out;
 
186
                        if(frame>=_info.nb_frames) return 0;
 
187
 
 
188
 
 
189
                        // read uncompressed frame
 
190
                if(!_in->getFrameNumberNoAlloc(frame, len,_uncompressed,flags)) return 0;
 
191
 
 
192
                uint32_t w=_info.width;
 
193
                uint32_t h=_info.height;
 
194
 
 
195
 
 
196
                data->copyInfo(_uncompressed);
 
197
                vidFieldKeepEven(  w,  h, YPLANE(_uncompressed),YPLANE(data));
 
198
      return 1;
 
199
}
 
200
 
 
201
#endif