annotate libmpcodecs/mp_image.h @ 28518:bc49856e5024

Replace fprintf call by mp_msg, fixes the warning: In file included from libmpcodecs/vf_fspp.c:58: libmpcodecs/mp_image.h: In function 'mp_image_setfmt': libmpcodecs/mp_image.h:207: warning: implicit declaration of function 'please_use_av_log_instead_of_fprintf'
author diego
date Sat, 14 Feb 2009 11:43:14 +0000
parents e9174807756c
children 6d0da4fd4544
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26029
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25535
diff changeset
1 #ifndef MPLAYER_MP_IMAGE_H
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25535
diff changeset
2 #define MPLAYER_MP_IMAGE_H
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
3
26147
41652035483c Add necessary header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
4 #include <stdio.h>
41652035483c Add necessary header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
5 #include <stdlib.h>
41652035483c Add necessary header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
6 #include <string.h>
28518
bc49856e5024 Replace fprintf call by mp_msg, fixes the warning:
diego
parents: 28517
diff changeset
7 #include "mp_msg.h"
26147
41652035483c Add necessary header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
8
6875
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
9 //--------- codec's requirements (filled by the codec/vf) ---------
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
10
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
11 //--- buffer content restrictions:
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
12 // set if buffer content shouldn't be modified:
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
13 #define MP_IMGFLAG_PRESERVE 0x01
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
14 // set if buffer content will be READ for next frame's MC: (I/P mpeg frames)
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
15 #define MP_IMGFLAG_READABLE 0x02
6875
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
16
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
17 //--- buffer width/stride/plane restrictions: (used for direct rendering)
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
18 // stride _have_to_ be aligned to MB boundary: [for DR restrictions]
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
19 #define MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE 0x4
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
20 // stride should be aligned to MB boundary: [for buffer allocation]
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
21 #define MP_IMGFLAG_PREFER_ALIGNED_STRIDE 0x8
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
22 // codec accept any stride (>=width):
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
23 #define MP_IMGFLAG_ACCEPT_STRIDE 0x10
6875
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
24 // codec accept any width (width*bpp=stride -> stride%bpp==0) (>=width):
4962
993f274191ff ACCEPT_WIDTH flag added
arpi
parents: 4933
diff changeset
25 #define MP_IMGFLAG_ACCEPT_WIDTH 0x20
6875
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
26 //--- for planar formats only:
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
27 // uses only stride[0], and stride[1]=stride[2]=stride[0]>>mpi->chroma_x_shift
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
28 #define MP_IMGFLAG_COMMON_STRIDE 0x40
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
29 // uses only planes[0], and calculates planes[1,2] from width,height,imgfmt
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
30 #define MP_IMGFLAG_COMMON_PLANE 0x80
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
31
6875
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
32 #define MP_IMGFLAGMASK_RESTRICTIONS 0xFF
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
33
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
34 //--------- color info (filled by mp_image_setfmt() ) -----------
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
35 // set if number of planes > 1
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
36 #define MP_IMGFLAG_PLANAR 0x100
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
37 // set if it's YUV colorspace
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
38 #define MP_IMGFLAG_YUV 0x200
6875
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
39 // set if it's swapped (BGR or YVU) plane/byteorder
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
40 #define MP_IMGFLAG_SWAPPED 0x400
6478
feb97a44080b added yvu9
alex
parents: 5737
diff changeset
41 // using palette for RGB data
6875
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
42 #define MP_IMGFLAG_RGB_PALETTE 0x800
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
43
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
44 #define MP_IMGFLAGMASK_COLORS 0xF00
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
45
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
46 // codec uses drawing/rendering callbacks (draw_slice()-like thing, DR method 2)
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
47 // [the codec will set this flag if it supports callbacks, and the vo _may_
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
48 // clear it in get_image() if draw_slice() not implemented]
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
49 #define MP_IMGFLAG_DRAW_CALLBACK 0x1000
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
50 // set if it's in video buffer/memory: [set by vo/vf's get_image() !!!]
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
51 #define MP_IMGFLAG_DIRECT 0x2000
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
52 // set if buffer is allocated (used in destination images):
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
53 #define MP_IMGFLAG_ALLOCATED 0x4000
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
54
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
55 // buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!)
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 6863
diff changeset
56 #define MP_IMGFLAG_TYPE_DISPLAYED 0x8000
28515
134689b7b548 Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
reimar
parents: 26147
diff changeset
57 // set if it can not be reused yet (for MP_IMGTYPE_NUMBERED)
134689b7b548 Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
reimar
parents: 26147
diff changeset
58 #define MP_IMGFLAG_IN_USE 0x10000
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
59
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
60 // codec doesn't support any form of direct rendering - it has own buffer
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
61 // allocation. so we just export its buffer pointers:
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
62 #define MP_IMGTYPE_EXPORT 0
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
63 // codec requires a static WO buffer, but it does only partial updates later:
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
64 #define MP_IMGTYPE_STATIC 1
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
65 // codec just needs some WO memory, where it writes/copies the whole frame to:
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
66 #define MP_IMGTYPE_TEMP 2
4877
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
67 // I+P type, requires 2+ independent static R/W buffers
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
68 #define MP_IMGTYPE_IP 3
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
69 // I+P+B type, requires 2+ independent static R/W and 1+ temp WO buffers
9d97874d8691 new flags added for direct rendering (libmpcodecs core)
arpi
parents: 4187
diff changeset
70 #define MP_IMGTYPE_IPB 4
28515
134689b7b548 Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
reimar
parents: 26147
diff changeset
71 // Upper 16 bits give desired buffer number, -1 means get next available
134689b7b548 Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
reimar
parents: 26147
diff changeset
72 #define MP_IMGTYPE_NUMBERED 5
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
73
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
74 #define MP_MAX_PLANES 4
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
75
10663
711159267b2d clean up field flags:
rfelker
parents: 10510
diff changeset
76 #define MP_IMGFIELD_ORDERED 0x01
711159267b2d clean up field flags:
rfelker
parents: 10510
diff changeset
77 #define MP_IMGFIELD_TOP_FIRST 0x02
711159267b2d clean up field flags:
rfelker
parents: 10510
diff changeset
78 #define MP_IMGFIELD_REPEAT_FIRST 0x04
711159267b2d clean up field flags:
rfelker
parents: 10510
diff changeset
79 #define MP_IMGFIELD_TOP 0x08
711159267b2d clean up field flags:
rfelker
parents: 10510
diff changeset
80 #define MP_IMGFIELD_BOTTOM 0x10
11669
bcf9862f61b2 set top_field first for lavc decoding and add MP_IMGFIELD_INTERLACED
michael
parents: 11386
diff changeset
81 #define MP_IMGFIELD_INTERLACED 0x20
10510
73b3e4336cd4 Add mpeg2_flags to mp_image_t, copy flags in vd_libmpeg2.c,
ranma
parents: 10316
diff changeset
82
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
83 typedef struct mp_image_s {
28515
134689b7b548 Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
reimar
parents: 26147
diff changeset
84 unsigned int flags;
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
85 unsigned char type;
28515
134689b7b548 Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
reimar
parents: 26147
diff changeset
86 int number;
4186
f5c38da17b59 bpp != depth
arpi
parents: 4185
diff changeset
87 unsigned char bpp; // bits/pixel. NOT depth! for RGB it will be n*8
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
88 unsigned int imgfmt;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
89 int width,height; // stored dimensions
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
90 int x,y,w,h; // visible dimensions
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
91 unsigned char* planes[MP_MAX_PLANES];
14792
6c12ee26fab9 stride must be signed! otherwise negative stride is broken on 64bit systems
rfelker
parents: 11669
diff changeset
92 int stride[MP_MAX_PLANES];
7984
a57c1fc0c2fc change qscale type to int8 and fix qscale ordering
michael
parents: 7957
diff changeset
93 char * qscale;
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
94 int qstride;
7957
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 6911
diff changeset
95 int pict_type; // 0->unknown, 1->I, 2->P, 3->B
10663
711159267b2d clean up field flags:
rfelker
parents: 10510
diff changeset
96 int fields;
9925
420640a0f6d0 passing qscale_type around so the pp code can fix the mpeg2 <<1 thing
michael
parents: 9171
diff changeset
97 int qscale_type; // 0->mpeg1/4/h263, 1->mpeg2
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
98 int num_planes;
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
99 /* these are only used by planar formats Y,U(Cb),V(Cr) */
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
100 int chroma_width;
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
101 int chroma_height;
6539
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6538
diff changeset
102 int chroma_x_shift; // horizontal
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6538
diff changeset
103 int chroma_y_shift; // vertical
6759
415be01747ae added 'priv' field to mpi - requires for tracking frames with different
arpi
parents: 6707
diff changeset
104 /* for private use by filter or vo driver (to store buffer id or dmpi) */
415be01747ae added 'priv' field to mpi - requires for tracking frames with different
arpi
parents: 6707
diff changeset
105 void* priv;
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
106 } mp_image_t;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
107
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
108 #ifdef IMGFMT_YUY2
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
109 static inline void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
110 mpi->flags&=~(MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV|MP_IMGFLAG_SWAPPED);
4187
arpi
parents: 4186
diff changeset
111 mpi->imgfmt=out_fmt;
28517
e9174807756c Cosmetics: handle all special/compressed formats in a single if in mp_image_setfmt
reimar
parents: 28516
diff changeset
112 // compressed formats
e9174807756c Cosmetics: handle all special/compressed formats in a single if in mp_image_setfmt
reimar
parents: 28516
diff changeset
113 if(out_fmt == IMGFMT_MPEGPES ||
e9174807756c Cosmetics: handle all special/compressed formats in a single if in mp_image_setfmt
reimar
parents: 28516
diff changeset
114 out_fmt == IMGFMT_ZRMJPEGNI || out_fmt == IMGFMT_ZRMJPEGIT || out_fmt == IMGFMT_ZRMJPEGIB ||
e9174807756c Cosmetics: handle all special/compressed formats in a single if in mp_image_setfmt
reimar
parents: 28516
diff changeset
115 IMGFMT_IS_VDPAU(out_fmt) || IMGFMT_IS_XVMC(out_fmt)){
10316
fdc349b9bd1d basic xvmc image support
iive
parents: 9925
diff changeset
116 mpi->bpp=0;
fdc349b9bd1d basic xvmc image support
iive
parents: 9925
diff changeset
117 return;
fdc349b9bd1d basic xvmc image support
iive
parents: 9925
diff changeset
118 }
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
119 mpi->num_planes=1;
6707
3f0c724dac75 better support for rgb/bgr formats
alex
parents: 6576
diff changeset
120 if (IMGFMT_IS_RGB(out_fmt)) {
9171
898e5270a46e fixing rgb4 & bgr4 (2 pixels per byte)
michael
parents: 7984
diff changeset
121 if (IMGFMT_RGB_DEPTH(out_fmt) < 8 && !(out_fmt&128))
6707
3f0c724dac75 better support for rgb/bgr formats
alex
parents: 6576
diff changeset
122 mpi->bpp = IMGFMT_RGB_DEPTH(out_fmt);
3f0c724dac75 better support for rgb/bgr formats
alex
parents: 6576
diff changeset
123 else
3f0c724dac75 better support for rgb/bgr formats
alex
parents: 6576
diff changeset
124 mpi->bpp=(IMGFMT_RGB_DEPTH(out_fmt)+7)&(~7);
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
125 return;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
126 }
6707
3f0c724dac75 better support for rgb/bgr formats
alex
parents: 6576
diff changeset
127 if (IMGFMT_IS_BGR(out_fmt)) {
9171
898e5270a46e fixing rgb4 & bgr4 (2 pixels per byte)
michael
parents: 7984
diff changeset
128 if (IMGFMT_BGR_DEPTH(out_fmt) < 8 && !(out_fmt&128))
6707
3f0c724dac75 better support for rgb/bgr formats
alex
parents: 6576
diff changeset
129 mpi->bpp = IMGFMT_BGR_DEPTH(out_fmt);
3f0c724dac75 better support for rgb/bgr formats
alex
parents: 6576
diff changeset
130 else
3f0c724dac75 better support for rgb/bgr formats
alex
parents: 6576
diff changeset
131 mpi->bpp=(IMGFMT_BGR_DEPTH(out_fmt)+7)&(~7);
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
132 mpi->flags|=MP_IMGFLAG_SWAPPED;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
133 return;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
134 }
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
135 mpi->flags|=MP_IMGFLAG_YUV;
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
136 mpi->num_planes=3;
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
137 switch(out_fmt){
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
138 case IMGFMT_I420:
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
139 case IMGFMT_IYUV:
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
140 mpi->flags|=MP_IMGFLAG_SWAPPED;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
141 case IMGFMT_YV12:
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
142 mpi->flags|=MP_IMGFLAG_PLANAR;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
143 mpi->bpp=12;
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
144 mpi->chroma_width=(mpi->width>>1);
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
145 mpi->chroma_height=(mpi->height>>1);
6539
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6538
diff changeset
146 mpi->chroma_x_shift=1;
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6538
diff changeset
147 mpi->chroma_y_shift=1;
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
148 return;
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 6478
diff changeset
149 case IMGFMT_IF09:
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
150 mpi->num_planes=4;
6478
feb97a44080b added yvu9
alex
parents: 5737
diff changeset
151 case IMGFMT_YVU9:
feb97a44080b added yvu9
alex
parents: 5737
diff changeset
152 mpi->flags|=MP_IMGFLAG_PLANAR;
feb97a44080b added yvu9
alex
parents: 5737
diff changeset
153 mpi->bpp=9;
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
154 mpi->chroma_width=(mpi->width>>2);
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
155 mpi->chroma_height=(mpi->height>>2);
6539
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6538
diff changeset
156 mpi->chroma_x_shift=2;
79b536a37e40 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6538
diff changeset
157 mpi->chroma_y_shift=2;
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
158 return;
6863
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
159 case IMGFMT_444P:
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
160 mpi->flags|=MP_IMGFLAG_PLANAR;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
161 mpi->bpp=24;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
162 mpi->chroma_width=(mpi->width);
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
163 mpi->chroma_height=(mpi->height);
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
164 mpi->chroma_x_shift=0;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
165 mpi->chroma_y_shift=0;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
166 return;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
167 case IMGFMT_422P:
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
168 mpi->flags|=MP_IMGFLAG_PLANAR;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
169 mpi->bpp=16;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
170 mpi->chroma_width=(mpi->width>>1);
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
171 mpi->chroma_height=(mpi->height);
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
172 mpi->chroma_x_shift=1;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
173 mpi->chroma_y_shift=0;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
174 return;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
175 case IMGFMT_411P:
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
176 mpi->flags|=MP_IMGFLAG_PLANAR;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
177 mpi->bpp=12;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
178 mpi->chroma_width=(mpi->width>>2);
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
179 mpi->chroma_height=(mpi->height);
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
180 mpi->chroma_x_shift=2;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
181 mpi->chroma_y_shift=0;
713182435a76 planar yuv 444 422 411 support
michael
parents: 6759
diff changeset
182 return;
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
183 case IMGFMT_Y800:
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
184 case IMGFMT_Y8:
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
185 /* they're planar ones, but for easier handling use them as packed */
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
186 // mpi->flags|=MP_IMGFLAG_PLANAR;
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
187 mpi->bpp=8;
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
188 mpi->num_planes=1;
6478
feb97a44080b added yvu9
alex
parents: 5737
diff changeset
189 return;
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
190 case IMGFMT_UYVY:
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
191 mpi->flags|=MP_IMGFLAG_SWAPPED;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
192 case IMGFMT_YUY2:
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
193 mpi->bpp=16;
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
194 mpi->num_planes=1;
5144
9651a7bb874d accept IMGFMT_MPEGPES
arpi
parents: 4972
diff changeset
195 return;
10742
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
196 case IMGFMT_NV12:
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
197 mpi->flags|=MP_IMGFLAG_SWAPPED;
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
198 case IMGFMT_NV21:
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
199 mpi->flags|=MP_IMGFLAG_PLANAR;
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
200 mpi->bpp=12;
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
201 mpi->num_planes=2;
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
202 mpi->chroma_width=(mpi->width>>0);
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
203 mpi->chroma_height=(mpi->height>>1);
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
204 mpi->chroma_x_shift=0;
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
205 mpi->chroma_y_shift=1;
794b55a44528 basic nv12 and nv21 support by Angelo Cano <angelo_cano@fastmail.fm>
alex
parents: 10663
diff changeset
206 return;
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
207 }
28518
bc49856e5024 Replace fprintf call by mp_msg, fixes the warning:
diego
parents: 28517
diff changeset
208 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"mp_image: unknown out_fmt: 0x%X\n",out_fmt);
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
209 mpi->bpp=0;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
210 }
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
211 #endif
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
212
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
213 static inline mp_image_t* new_mp_image(int w,int h){
6911
695bd84c1b24 warning fix
arpi
parents: 6875
diff changeset
214 mp_image_t* mpi=(mp_image_t*)malloc(sizeof(mp_image_t));
4185
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
215 if(!mpi) return NULL; // error!
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
216 memset(mpi,0,sizeof(mp_image_t));
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
217 mpi->width=mpi->w=w;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
218 mpi->height=mpi->h=h;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
219 return mpi;
85c90bb8729a initial stuff. comments welcomed...
arpi
parents:
diff changeset
220 }
4933
429994672d8c 're-include' possibility
nick
parents: 4877
diff changeset
221
5737
de47aebf654c filters uninit
arpi
parents: 5609
diff changeset
222 static inline void free_mp_image(mp_image_t* mpi){
de47aebf654c filters uninit
arpi
parents: 5609
diff changeset
223 if(!mpi) return;
de47aebf654c filters uninit
arpi
parents: 5609
diff changeset
224 if(mpi->flags&MP_IMGFLAG_ALLOCATED){
6538
afb4f3c107e7 better planar support, chroma subsampling support and Y8/Y800 support
alex
parents: 6525
diff changeset
225 /* becouse we allocate the whole image in once */
5737
de47aebf654c filters uninit
arpi
parents: 5609
diff changeset
226 if(mpi->planes[0]) free(mpi->planes[0]);
de47aebf654c filters uninit
arpi
parents: 5609
diff changeset
227 }
de47aebf654c filters uninit
arpi
parents: 5609
diff changeset
228 free(mpi);
de47aebf654c filters uninit
arpi
parents: 5609
diff changeset
229 }
de47aebf654c filters uninit
arpi
parents: 5609
diff changeset
230
23994
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents: 23689
diff changeset
231 mp_image_t* alloc_mpi(int w, int h, unsigned long int fmt);
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents: 23689
diff changeset
232 void copy_mpi(mp_image_t *dmpi, mp_image_t *mpi);
8572d2ef5263 Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents: 23689
diff changeset
233
26029
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25535
diff changeset
234 #endif /* MPLAYER_MP_IMAGE_H */