Mercurial > mplayer.hg
annotate libmpcodecs/mp_image.c @ 30997:9a886693ff14
Mark ffaac as buggy (thus making faad default again) and
document the know issues.
author | reimar |
---|---|
date | Thu, 15 Apr 2010 18:51:07 +0000 |
parents | 6e9ece21c004 |
children | 00825525514e |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30115
diff
changeset
|
17 */ |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
18 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
19 #include "config.h" |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
20 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
21 #include <stdio.h> |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
22 #include <stdlib.h> |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
23 #include <string.h> |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
24 |
28594
df67d03dde3b
Convert HAVE_MALLOC_H into a 0/1 definition, fixes the warning:
diego
parents:
23994
diff
changeset
|
25 #if HAVE_MALLOC_H |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
26 #include <malloc.h> |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
27 #endif |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
28 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
29 #include "libmpcodecs/img_format.h" |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
30 #include "libmpcodecs/mp_image.h" |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
31 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
32 #include "libvo/fastmemcpy.h" |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
33 |
30112 | 34 void mp_image_alloc_planes(mp_image_t *mpi) { |
35 // IF09 - allocate space for 4. plane delta info - unused | |
36 if (mpi->imgfmt == IMGFMT_IF09) { | |
37 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+ | |
38 mpi->chroma_width*mpi->chroma_height); | |
39 } else | |
40 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8); | |
41 if (mpi->flags&MP_IMGFLAG_PLANAR) { | |
42 int bpp = IMGFMT_IS_YUVP16(mpi->imgfmt)? 2 : 1; | |
43 // YV12/I420/YVU9/IF09. feel free to add other planar formats here... | |
30115
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30112
diff
changeset
|
44 mpi->stride[0]=mpi->stride[3]=bpp*mpi->width; |
30112 | 45 if(mpi->num_planes > 2){ |
46 mpi->stride[1]=mpi->stride[2]=bpp*mpi->chroma_width; | |
47 if(mpi->flags&MP_IMGFLAG_SWAPPED){ | |
48 // I420/IYUV (Y,U,V) | |
49 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height; | |
50 mpi->planes[2]=mpi->planes[1]+mpi->stride[1]*mpi->chroma_height; | |
30115
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30112
diff
changeset
|
51 if (mpi->num_planes > 3) |
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30112
diff
changeset
|
52 mpi->planes[3]=mpi->planes[2]+mpi->stride[2]*mpi->chroma_height; |
30112 | 53 } else { |
54 // YV12,YVU9,IF09 (Y,V,U) | |
55 mpi->planes[2]=mpi->planes[0]+mpi->stride[0]*mpi->height; | |
56 mpi->planes[1]=mpi->planes[2]+mpi->stride[1]*mpi->chroma_height; | |
30115
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30112
diff
changeset
|
57 if (mpi->num_planes > 3) |
ad61464d02a7
Add support for YUV format with alpha and fix the codecs.conf entry for vp6a
reimar
parents:
30112
diff
changeset
|
58 mpi->planes[3]=mpi->planes[1]+mpi->stride[1]*mpi->chroma_height; |
30112 | 59 } |
60 } else { | |
61 // NV12/NV21 | |
62 mpi->stride[1]=mpi->chroma_width; | |
63 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height; | |
64 } | |
65 } else { | |
66 mpi->stride[0]=mpi->width*mpi->bpp/8; | |
67 if (mpi->flags & MP_IMGFLAG_RGB_PALETTE) | |
68 mpi->planes[1] = memalign(64, 1024); | |
69 } | |
70 mpi->flags|=MP_IMGFLAG_ALLOCATED; | |
71 } | |
72 | |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
73 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:
diff
changeset
|
74 mp_image_t* mpi = new_mp_image(w,h); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
75 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
76 mp_image_setfmt(mpi,fmt); |
30112 | 77 mp_image_alloc_planes(mpi); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28594
diff
changeset
|
78 |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
79 return mpi; |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
80 } |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
81 |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
82 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:
diff
changeset
|
83 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
84 memcpy_pic(dmpi->planes[0],mpi->planes[0], mpi->w, mpi->h, |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
85 dmpi->stride[0],mpi->stride[0]); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
86 memcpy_pic(dmpi->planes[1],mpi->planes[1], mpi->chroma_width, mpi->chroma_height, |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
87 dmpi->stride[1],mpi->stride[1]); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
88 memcpy_pic(dmpi->planes[2], mpi->planes[2], mpi->chroma_width, mpi->chroma_height, |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
89 dmpi->stride[2],mpi->stride[2]); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
90 } else { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28594
diff
changeset
|
91 memcpy_pic(dmpi->planes[0],mpi->planes[0], |
23994
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
92 mpi->w*(dmpi->bpp/8), mpi->h, |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
93 dmpi->stride[0],mpi->stride[0]); |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
94 } |
8572d2ef5263
Move alloc_mpi and copy_mpi from libmenu/vf_menu.c to libmpcodecs/mp_image.c.
cehoyos
parents:
diff
changeset
|
95 } |
30996
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
96 |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
97 void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
98 mpi->flags&=~(MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV|MP_IMGFLAG_SWAPPED); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
99 mpi->imgfmt=out_fmt; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
100 // compressed formats |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
101 if(out_fmt == IMGFMT_MPEGPES || |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
102 out_fmt == IMGFMT_ZRMJPEGNI || out_fmt == IMGFMT_ZRMJPEGIT || out_fmt == IMGFMT_ZRMJPEGIB || |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
103 IMGFMT_IS_VDPAU(out_fmt) || IMGFMT_IS_XVMC(out_fmt)){ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
104 mpi->bpp=0; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
105 return; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
106 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
107 mpi->num_planes=1; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
108 if (IMGFMT_IS_RGB(out_fmt)) { |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
109 if (IMGFMT_RGB_DEPTH(out_fmt) < 8 && !(out_fmt&128)) |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
110 mpi->bpp = IMGFMT_RGB_DEPTH(out_fmt); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
111 else |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
112 mpi->bpp=(IMGFMT_RGB_DEPTH(out_fmt)+7)&(~7); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
113 return; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
114 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
115 if (IMGFMT_IS_BGR(out_fmt)) { |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
116 if (IMGFMT_BGR_DEPTH(out_fmt) < 8 && !(out_fmt&128)) |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
117 mpi->bpp = IMGFMT_BGR_DEPTH(out_fmt); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
118 else |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
119 mpi->bpp=(IMGFMT_BGR_DEPTH(out_fmt)+7)&(~7); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
120 mpi->flags|=MP_IMGFLAG_SWAPPED; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
121 return; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
122 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
123 mpi->flags|=MP_IMGFLAG_YUV; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
124 mpi->num_planes=3; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
125 if (mp_get_chroma_shift(out_fmt, NULL, NULL)) { |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
126 mpi->flags|=MP_IMGFLAG_PLANAR; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
127 mpi->bpp = mp_get_chroma_shift(out_fmt, &mpi->chroma_x_shift, &mpi->chroma_y_shift); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
128 mpi->chroma_width = mpi->width >> mpi->chroma_x_shift; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
129 mpi->chroma_height = mpi->height >> mpi->chroma_y_shift; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
130 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
131 switch(out_fmt){ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
132 case IMGFMT_I420: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
133 case IMGFMT_IYUV: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
134 mpi->flags|=MP_IMGFLAG_SWAPPED; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
135 case IMGFMT_YV12: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
136 return; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
137 case IMGFMT_420A: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
138 case IMGFMT_IF09: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
139 mpi->num_planes=4; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
140 case IMGFMT_YVU9: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
141 case IMGFMT_444P: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
142 case IMGFMT_422P: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
143 case IMGFMT_411P: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
144 case IMGFMT_440P: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
145 case IMGFMT_444P16_LE: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
146 case IMGFMT_444P16_BE: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
147 case IMGFMT_422P16_LE: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
148 case IMGFMT_422P16_BE: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
149 case IMGFMT_420P16_LE: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
150 case IMGFMT_420P16_BE: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
151 return; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
152 case IMGFMT_Y800: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
153 case IMGFMT_Y8: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
154 /* they're planar ones, but for easier handling use them as packed */ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
155 // mpi->flags|=MP_IMGFLAG_PLANAR; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
156 mpi->bpp=8; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
157 mpi->num_planes=1; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
158 return; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
159 case IMGFMT_UYVY: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
160 mpi->flags|=MP_IMGFLAG_SWAPPED; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
161 case IMGFMT_YUY2: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
162 mpi->bpp=16; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
163 mpi->num_planes=1; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
164 return; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
165 case IMGFMT_NV12: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
166 mpi->flags|=MP_IMGFLAG_SWAPPED; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
167 case IMGFMT_NV21: |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
168 mpi->flags|=MP_IMGFLAG_PLANAR; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
169 mpi->bpp=12; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
170 mpi->num_planes=2; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
171 mpi->chroma_width=(mpi->width>>0); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
172 mpi->chroma_height=(mpi->height>>1); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
173 mpi->chroma_x_shift=0; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
174 mpi->chroma_y_shift=1; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
175 return; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
176 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
177 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"mp_image: unknown out_fmt: 0x%X\n",out_fmt); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
178 mpi->bpp=0; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
179 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
180 |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
181 mp_image_t* new_mp_image(int w,int h){ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
182 mp_image_t* mpi = malloc(sizeof(mp_image_t)); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
183 if(!mpi) return NULL; // error! |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
184 memset(mpi,0,sizeof(mp_image_t)); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
185 mpi->width=mpi->w=w; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
186 mpi->height=mpi->h=h; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
187 return mpi; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
188 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
189 |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
190 void free_mp_image(mp_image_t* mpi){ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
191 if(!mpi) return; |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
192 if(mpi->flags&MP_IMGFLAG_ALLOCATED){ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
193 /* becouse we allocate the whole image in once */ |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
194 if(mpi->planes[0]) free(mpi->planes[0]); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
195 if (mpi->flags & MP_IMGFLAG_RGB_PALETTE) |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
196 free(mpi->planes[1]); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
197 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
198 free(mpi); |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
199 } |
6e9ece21c004
Move functions that really do not need to be inlined from the header
reimar
parents:
30421
diff
changeset
|
200 |