demux_demuxers: Fix crash with -audiofile and audio disabled
[mplayer/glamo.git] / libmpcodecs / mp_image.h
blobdd69788f2663f48a0b289181901065ab90e72f91
1 /*
2 * This file is part of MPlayer.
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.
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.
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.
19 #ifndef MPLAYER_MP_IMAGE_H
20 #define MPLAYER_MP_IMAGE_H
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include "mp_msg.h"
27 //--------- codec's requirements (filled by the codec/vf) ---------
29 //--- buffer content restrictions:
30 // set if buffer content shouldn't be modified:
31 #define MP_IMGFLAG_PRESERVE 0x01
32 // set if buffer content will be READ for next frame's MC: (I/P mpeg frames)
33 #define MP_IMGFLAG_READABLE 0x02
35 //--- buffer width/stride/plane restrictions: (used for direct rendering)
36 // stride _have_to_ be aligned to MB boundary: [for DR restrictions]
37 #define MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE 0x4
38 // stride should be aligned to MB boundary: [for buffer allocation]
39 #define MP_IMGFLAG_PREFER_ALIGNED_STRIDE 0x8
40 // codec accept any stride (>=width):
41 #define MP_IMGFLAG_ACCEPT_STRIDE 0x10
42 // codec accept any width (width*bpp=stride -> stride%bpp==0) (>=width):
43 #define MP_IMGFLAG_ACCEPT_WIDTH 0x20
44 //--- for planar formats only:
45 // uses only stride[0], and stride[1]=stride[2]=stride[0]>>mpi->chroma_x_shift
46 #define MP_IMGFLAG_COMMON_STRIDE 0x40
47 // uses only planes[0], and calculates planes[1,2] from width,height,imgfmt
48 #define MP_IMGFLAG_COMMON_PLANE 0x80
50 #define MP_IMGFLAGMASK_RESTRICTIONS 0xFF
52 //--------- color info (filled by mp_image_setfmt() ) -----------
53 // set if number of planes > 1
54 #define MP_IMGFLAG_PLANAR 0x100
55 // set if it's YUV colorspace
56 #define MP_IMGFLAG_YUV 0x200
57 // set if it's swapped (BGR or YVU) plane/byteorder
58 #define MP_IMGFLAG_SWAPPED 0x400
59 // set if you want memory for palette allocated and managed by vf_get_image etc.
60 #define MP_IMGFLAG_RGB_PALETTE 0x800
62 #define MP_IMGFLAGMASK_COLORS 0xF00
64 // codec uses drawing/rendering callbacks (draw_slice()-like thing, DR method 2)
65 // [the codec will set this flag if it supports callbacks, and the vo _may_
66 // clear it in get_image() if draw_slice() not implemented]
67 #define MP_IMGFLAG_DRAW_CALLBACK 0x1000
68 // set if it's in video buffer/memory: [set by vo/vf's get_image() !!!]
69 #define MP_IMGFLAG_DIRECT 0x2000
70 // set if buffer is allocated (used in destination images):
71 #define MP_IMGFLAG_ALLOCATED 0x4000
73 // buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!)
74 #define MP_IMGFLAG_TYPE_DISPLAYED 0x8000
76 // codec doesn't support any form of direct rendering - it has own buffer
77 // allocation. so we just export its buffer pointers:
78 #define MP_IMGTYPE_EXPORT 0
79 // codec requires a static WO buffer, but it does only partial updates later:
80 #define MP_IMGTYPE_STATIC 1
81 // codec just needs some WO memory, where it writes/copies the whole frame to:
82 #define MP_IMGTYPE_TEMP 2
83 // I+P type, requires 2+ independent static R/W buffers
84 #define MP_IMGTYPE_IP 3
85 // I+P+B type, requires 2+ independent static R/W and 1+ temp WO buffers
86 #define MP_IMGTYPE_IPB 4
87 // Upper 16 bits give desired buffer number, -1 means get next available
88 #define MP_IMGTYPE_NUMBERED 5
90 #define MP_MAX_PLANES 4
92 #define MP_IMGFIELD_ORDERED 0x01
93 #define MP_IMGFIELD_TOP_FIRST 0x02
94 #define MP_IMGFIELD_REPEAT_FIRST 0x04
95 #define MP_IMGFIELD_TOP 0x08
96 #define MP_IMGFIELD_BOTTOM 0x10
97 #define MP_IMGFIELD_INTERLACED 0x20
99 typedef struct mp_image {
100 unsigned int flags;
101 unsigned char type;
102 int number;
103 unsigned char bpp; // bits/pixel. NOT depth! for RGB it will be n*8
104 unsigned int imgfmt;
105 int width,height; // stored dimensions
106 int x,y,w,h; // visible dimensions
107 unsigned char* planes[MP_MAX_PLANES];
108 int stride[MP_MAX_PLANES];
109 char * qscale;
110 int qstride;
111 int pict_type; // 0->unknown, 1->I, 2->P, 3->B
112 int fields;
113 int qscale_type; // 0->mpeg1/4/h263, 1->mpeg2
114 int num_planes;
115 /* these are only used by planar formats Y,U(Cb),V(Cr) */
116 int chroma_width;
117 int chroma_height;
118 int chroma_x_shift; // horizontal
119 int chroma_y_shift; // vertical
120 int usage_count;
121 /* for private use by filter or vo driver (to store buffer id or dmpi) */
122 void* priv;
123 } mp_image_t;
125 void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt);
126 mp_image_t* new_mp_image(int w,int h);
127 void free_mp_image(mp_image_t* mpi);
129 mp_image_t* alloc_mpi(int w, int h, unsigned long int fmt);
130 void mp_image_alloc_planes(mp_image_t *mpi);
131 void copy_mpi(mp_image_t *dmpi, mp_image_t *mpi);
133 #endif /* MPLAYER_MP_IMAGE_H */