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

« back to all changes in this revision

Viewing changes to avidemux/ADM_library/ADM_image.h

  • 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
 
// C++ Interface: %{MODULE}
3
 
//
4
 
// Description: 
5
 
//
6
 
//
7
 
// Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR}
8
 
//
9
 
// Copyright: See COPYING file that comes with this distribution
10
 
//
11
 
//
12
 
//      This is the base time for image exchanged between codec/filters/...
13
 
//
14
 
//      We (optionnally) can carry extra informations
15
 
//              - aspect ratio
16
 
//              - frame type
17
 
//              - quantizer for each macroblock (16x16 pixels)
18
 
//      For the latter 3 infos are used
19
 
//              quant which leads to the int8 quant array
20
 
//              qstride = stride of array. Usually width+15)/16. 0 MEANS NOT USABLE
21
 
//              qsize = size of the array (needed to be able to copy it)
22
 
//
23
 
#ifndef ADM_IMAGE
24
 
#define ADM_IMAGE
25
 
#include "ADM_assert.h"
26
 
#include "ADM_colorspace/ADM_rgb.h"
27
 
 
28
 
typedef enum ADM_ASPECT
29
 
{
30
 
        ADM_ASPECT_4_3=1,
31
 
        ADM_ASPECT_16_9,
32
 
        ADM_ASPECT_1_1
33
 
};
34
 
// Avisynth compatibility layer
35
 
 
36
 
//#define vi.num_frames _info.nb_frames
37
 
//#define vi.IsYV12()   1
38
 
#define GetReadPtr GetWritePtr
39
 
#define GetRowSize GetPitch
40
 
 
41
 
typedef enum ADM_PLANE
42
 
{
43
 
        PLANAR_Y=1,
44
 
        PLANAR_U=2,
45
 
        PLANAR_V=3
46
 
        
47
 
};
48
 
class ADMImage
49
 
{
50
 
public:
51
 
        
52
 
        uint8_t         *data;          /// Pointer to actual image data
53
 
        uint32_t        _width;         /// Width of image
54
 
        uint32_t        _height;        /// Height of image
55
 
        uint32_t        _qStride;       /// Stride of Q infos, usually about width/8 <- ***if 0 means no quant usable***
56
 
        uint8_t         *quant;         /// Byte representing quantize used for this block
57
 
        uint32_t        _Qp;            /// Average quantizer for this image, Default=2
58
 
        uint32_t        _qSize;         /// Size of the *quant bitfield
59
 
        ADM_ASPECT      _aspect;        /// Aspect ratio
60
 
        uint32_t        flags;          /// Flags for this image (AVI_KEY_FRAME/AVI_B_FRAME)
61
 
 
62
 
// This 3 fields are only used to convery container (reference to other datas)
63
 
// Between codec & editor
64
 
        uint8_t         _isRef;         /// If True means the datas are just a link to data we don't own!
65
 
        ADM_colorspace  _colorspace;    /// Colorspace we are moving, default is YV12
66
 
        uint8_t         _noPicture;     /// No picture to display
67
 
 
68
 
// End of section dedicated to codec/editor transfer
69
 
 
70
 
        void            commonInit(uint32_t w,uint32_t h); /// sub constructor
71
 
        
72
 
        uint32_t        GetPitch(ADM_PLANE plane)
73
 
                                {
74
 
                                        switch(plane)
75
 
                                        {
76
 
                                                case PLANAR_Y:return _width;break;
77
 
                                                case PLANAR_U:
78
 
                                                case PLANAR_V:return _width>>1;break;
79
 
                                                default: ADM_assert(0);
80
 
                                        }
81
 
                                };
82
 
        uint8_t         *GetWritePtr(ADM_PLANE plane)
83
 
                        {       
84
 
                                uint32_t plan=_width*_height;
85
 
                                switch(plane)
86
 
                                        {
87
 
                                                case PLANAR_Y:return data;break;
88
 
                                                case PLANAR_U:return data+plan;break;
89
 
                                                case PLANAR_V:return data+((plan*5)>>2);break;
90
 
                                                default: ADM_assert(0);
91
 
                                        }
92
 
                        };
93
 
   
94
 
        uint32_t GetHeight(ADM_PLANE plane)
95
 
                                {
96
 
                                        switch(plane)
97
 
                                        {
98
 
                                                case PLANAR_Y:return _height;break;
99
 
                                                case PLANAR_U:
100
 
                                                case PLANAR_V:return _height>>1;break;
101
 
                                                default: ADM_assert(0);
102
 
                                        }
103
 
                                };
104
 
        uint8_t duplicateMacro(ADMImage *src,uint32_t swap);       /// copy an image to ourself, including info
105
 
public:
106
 
 
107
 
        uint8_t         *_planes[3];     /// In case of linked data store y/u/v pointers
108
 
        uint32_t        _planeStride[3]; /// Same story
109
 
 
110
 
                ADMImage(uint32_t width, uint32_t height);
111
 
                ADMImage(uint32_t width, uint32_t height,uint32_t dummy); /// To create linked datas image        
112
 
 
113
 
                
114
 
                ~ADMImage();
115
 
        uint8_t getWidthHeight(uint32_t *w,uint32_t *h)
116
 
                    {
117
 
                          *w=_width;
118
 
                          *h=_height;
119
 
                          return 1;
120
 
                    }
121
 
        uint8_t duplicate(ADMImage *src);       /// copy an image to ourself, including info
122
 
        uint8_t duplicateSwapUV(ADMImage *src); /// copy an image to ourself, including info
123
 
        uint8_t duplicateFull(ADMImage *src);   /// copy an image to ourself, including info
124
 
        uint8_t copyInfo(ADMImage *src);        /// copy all the flags, not the data themselves
125
 
        uint8_t copyQuantInfo(ADMImage *src);   /// copy quant table if any
126
 
        uint8_t isRef(void) { return _isRef;};
127
 
        uint8_t setLinkInfos(uint8_t *y,        /// To fill in infos for linked image
128
 
                        uint8_t *u,uint8_t *v,uint32_t stridey,
129
 
                        uint32_t strideu, uint32_t stridev);
130
 
        uint8_t merge(ADMImage *src1,ADMImage *src2);
131
 
        uint8_t substract(ADMImage *src1,ADMImage *src2);
132
 
        uint8_t blacken(void);
133
 
        uint8_t copyTo(ADMImage *target, uint32_t x, uint32_t y);
134
 
        uint8_t pack(uint8_t invertChroma);     /// Transfer data from planes to regular packed space
135
 
static uint32_t lumaDiff(ADMImage *src1,ADMImage *src2,uint32_t noise);
136
 
};
137
 
void drawString(ADMImage *dst, int x, int y, const char *s) ;
138
 
#define YPLANE(x) (x->data)
139
 
#define UPLANE(x) (x->data+(x->_width*x->_height))
140
 
#define VPLANE(x) (x->data+(5*(x->_width*x->_height)>>2))
141
 
 
142
 
//
143
 
//  Simple image resizer
144
 
//
145
 
 
146
 
 
147
 
class ADMImageResizer
148
 
{
149
 
private:
150
 
        void    *_context;
151
 
        uint32_t orgWidth,orgHeight;
152
 
        uint32_t destWidth,destHeight;
153
 
public:
154
 
                ADMImageResizer(uint32_t ow,uint32_t oh, uint32_t dw, uint32_t dh);
155
 
                ~ADMImageResizer();
156
 
       uint8_t  resize(ADMImage *src,ADMImage *dest);
157
 
};
158
 
 
159
 
 
160
 
 
161
 
 
162
 
// Misc utilities
163
 
 
164
 
uint8_t BitBlit(uint8_t *dst, uint32_t pitchDest,uint8_t *src,uint32_t pitchSrc,uint32_t width, uint32_t height);
165
 
 
166
 
#endif