Imported Debian version 2.4.3~trusty1
[deb_ffmpeg.git] / ffmpeg / libavfilter / libmpcodecs / mp_image.h
CommitLineData
2ba45a60
DM
1/*
2 * This file is part of MPlayer.
3 *
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#ifndef MPLAYER_MP_IMAGE_H
20#define MPLAYER_MP_IMAGE_H
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25#undef printf //FIXME
26#undef fprintf //FIXME
27#include "mp_msg.h"
28#include "libavutil/avutil.h"
29#include "libavutil/avassert.h"
30#undef realloc
31#undef malloc
32#undef free
33#undef rand
34#undef srand
35#undef printf
36#undef strncpy
37#define ASMALIGN(ZEROBITS) ".p2align " #ZEROBITS "\n\t"
38#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC).
39
40enum AVPixelFormat ff_mp2ff_pix_fmt(int mp);
41
42//--------- codec's requirements (filled by the codec/vf) ---------
43
44//--- buffer content restrictions:
45// set if buffer content shouldn't be modified:
46#define MP_IMGFLAG_PRESERVE 0x01
47// set if buffer content will be READ.
48// This can be e.g. for next frame's MC: (I/P mpeg frames) -
49// then in combination with MP_IMGFLAG_PRESERVE - or it
50// can be because a video filter or codec will read a significant
51// amount of data while processing that frame (e.g. blending something
52// onto the frame, MV based intra prediction).
53// A frame marked like this should not be placed in to uncachable
54// video RAM for example.
55#define MP_IMGFLAG_READABLE 0x02
56
57//--- buffer width/stride/plane restrictions: (used for direct rendering)
58// stride _have_to_ be aligned to MB boundary: [for DR restrictions]
59#define MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE 0x4
60// stride should be aligned to MB boundary: [for buffer allocation]
61#define MP_IMGFLAG_PREFER_ALIGNED_STRIDE 0x8
62// codec accept any stride (>=width):
63#define MP_IMGFLAG_ACCEPT_STRIDE 0x10
64// codec accept any width (width*bpp=stride -> stride%bpp==0) (>=width):
65#define MP_IMGFLAG_ACCEPT_WIDTH 0x20
66//--- for planar formats only:
67// uses only stride[0], and stride[1]=stride[2]=stride[0]>>mpi->chroma_x_shift
68#define MP_IMGFLAG_COMMON_STRIDE 0x40
69// uses only planes[0], and calculates planes[1,2] from width,height,imgfmt
70#define MP_IMGFLAG_COMMON_PLANE 0x80
71
72#define MP_IMGFLAGMASK_RESTRICTIONS 0xFF
73
74//--------- color info (filled by ff_mp_image_setfmt() ) -----------
75// set if number of planes > 1
76#define MP_IMGFLAG_PLANAR 0x100
77// set if it's YUV colorspace
78#define MP_IMGFLAG_YUV 0x200
79// set if it's swapped (BGR or YVU) plane/byteorder
80#define MP_IMGFLAG_SWAPPED 0x400
81// set if you want memory for palette allocated and managed by ff_vf_get_image etc.
82#define MP_IMGFLAG_RGB_PALETTE 0x800
83
84#define MP_IMGFLAGMASK_COLORS 0xF00
85
86// codec uses drawing/rendering callbacks (draw_slice()-like thing, DR method 2)
87// [the codec will set this flag if it supports callbacks, and the vo _may_
88// clear it in get_image() if draw_slice() not implemented]
89#define MP_IMGFLAG_DRAW_CALLBACK 0x1000
90// set if it's in video buffer/memory: [set by vo/vf's get_image() !!!]
91#define MP_IMGFLAG_DIRECT 0x2000
92// set if buffer is allocated (used in destination images):
93#define MP_IMGFLAG_ALLOCATED 0x4000
94
95// buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!)
96#define MP_IMGFLAG_TYPE_DISPLAYED 0x8000
97
98// codec doesn't support any form of direct rendering - it has own buffer
99// allocation. so we just export its buffer pointers:
100#define MP_IMGTYPE_EXPORT 0
101// codec requires a static WO buffer, but it does only partial updates later:
102#define MP_IMGTYPE_STATIC 1
103// codec just needs some WO memory, where it writes/copies the whole frame to:
104#define MP_IMGTYPE_TEMP 2
105// I+P type, requires 2+ independent static R/W buffers
106#define MP_IMGTYPE_IP 3
107// I+P+B type, requires 2+ independent static R/W and 1+ temp WO buffers
108#define MP_IMGTYPE_IPB 4
109// Upper 16 bits give desired buffer number, -1 means get next available
110#define MP_IMGTYPE_NUMBERED 5
111// Doesn't need any buffer, incomplete image (probably a first field only)
112// we need this type to be able to differentiate between half frames and
113// all other cases
114#define MP_IMGTYPE_INCOMPLETE 6
115
116#define MP_MAX_PLANES 4
117
118#define MP_IMGFIELD_ORDERED 0x01
119#define MP_IMGFIELD_TOP_FIRST 0x02
120#define MP_IMGFIELD_REPEAT_FIRST 0x04
121#define MP_IMGFIELD_TOP 0x08
122#define MP_IMGFIELD_BOTTOM 0x10
123#define MP_IMGFIELD_INTERLACED 0x20
124
125typedef struct mp_image {
126 unsigned int flags;
127 unsigned char type;
128 int number;
129 unsigned char bpp; // bits/pixel. NOT depth! for RGB it will be n*8
130 unsigned int imgfmt;
131 int width,height; // stored dimensions
132 int x,y,w,h; // visible dimensions
133 unsigned char* planes[MP_MAX_PLANES];
134 int stride[MP_MAX_PLANES];
135 char * qscale;
136 int qstride;
137 int pict_type; // 0->unknown, 1->I, 2->P, 3->B
138 int fields;
139 int qscale_type; // 0->mpeg1/4/h263, 1->mpeg2
140 int num_planes;
141 /* these are only used by planar formats Y,U(Cb),V(Cr) */
142 int chroma_width;
143 int chroma_height;
144 int chroma_x_shift; // horizontal
145 int chroma_y_shift; // vertical
146 int usage_count;
147 /* for private use by filter or vo driver (to store buffer id or dmpi) */
148 void* priv;
149} mp_image_t;
150
151void ff_mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt);
152mp_image_t* ff_new_mp_image(int w,int h);
153void ff_free_mp_image(mp_image_t* mpi);
154
155mp_image_t* ff_alloc_mpi(int w, int h, unsigned long int fmt);
156void ff_mp_image_alloc_planes(mp_image_t *mpi);
157void ff_copy_mpi(mp_image_t *dmpi, mp_image_t *mpi);
158
159#endif /* MPLAYER_MP_IMAGE_H */