Mercurial > mplayer.hg
annotate libmpcodecs/vf_palette.c @ 36767:18428293fb7f
spudec: fix spudec_apply_palette_crop return value.
author | reimar |
---|---|
date | Sun, 16 Feb 2014 16:30:01 +0000 |
parents | 389d43c448b3 |
children |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30072
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30072
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30072
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30072
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:
30072
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:
30072
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:
30072
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30072
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30072
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:
30072
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:
30072
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:
30072
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30072
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30072
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:
30072
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:
30072
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:
30072
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30072
diff
changeset
|
18 |
5774 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 #include <string.h> | |
35903 | 22 #include <strings.h> |
5774 | 23 #include <inttypes.h> |
24 | |
17012 | 25 #include "config.h" |
26 #include "mp_msg.h" | |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
27 #include "help_mp.h" |
5774 | 28 |
29 #include "img_format.h" | |
30 #include "mp_image.h" | |
31 #include "vf.h" | |
31237
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
32 #include "mpbswap.h" |
5774 | 33 |
31235
661755507236
deprecate palette8topacked32 in favor of public API functions sws_convertPalette8ToPacked32 and -24
siretart
parents:
31232
diff
changeset
|
34 #include "libswscale/swscale.h" |
5774 | 35 |
36 //===========================================================================// | |
37 | |
11512
4ff38d168c2f
fix for vf_palette, because paletted 8-bit to BGR{15,16} conversion is incorrect.
joey
parents:
9593
diff
changeset
|
38 // commented out 16 and 15 bit output support, because the conversion |
4ff38d168c2f
fix for vf_palette, because paletted 8-bit to BGR{15,16} conversion is incorrect.
joey
parents:
9593
diff
changeset
|
39 // routines are incorrrect. they assume the palette to be of the same |
4ff38d168c2f
fix for vf_palette, because paletted 8-bit to BGR{15,16} conversion is incorrect.
joey
parents:
9593
diff
changeset
|
40 // depth as the output, which is incorrect. --Joey |
4ff38d168c2f
fix for vf_palette, because paletted 8-bit to BGR{15,16} conversion is incorrect.
joey
parents:
9593
diff
changeset
|
41 |
30662 | 42 static const unsigned int bgr_list[]={ |
5774 | 43 IMGFMT_BGR32, |
44 IMGFMT_BGR24, | |
11512
4ff38d168c2f
fix for vf_palette, because paletted 8-bit to BGR{15,16} conversion is incorrect.
joey
parents:
9593
diff
changeset
|
45 // IMGFMT_BGR16, |
4ff38d168c2f
fix for vf_palette, because paletted 8-bit to BGR{15,16} conversion is incorrect.
joey
parents:
9593
diff
changeset
|
46 // IMGFMT_BGR15, |
6188 | 47 0 |
5774 | 48 }; |
30662 | 49 static const unsigned int rgb_list[]={ |
5774 | 50 IMGFMT_RGB32, |
51 IMGFMT_RGB24, | |
11512
4ff38d168c2f
fix for vf_palette, because paletted 8-bit to BGR{15,16} conversion is incorrect.
joey
parents:
9593
diff
changeset
|
52 // IMGFMT_RGB16, |
4ff38d168c2f
fix for vf_palette, because paletted 8-bit to BGR{15,16} conversion is incorrect.
joey
parents:
9593
diff
changeset
|
53 // IMGFMT_RGB15, |
6188 | 54 0 |
5774 | 55 }; |
56 | |
31237
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
57 /** |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
58 * Palette is assumed to contain BGR16, see rgb32to16 to convert the palette. |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
59 */ |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
60 static void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
61 { |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
62 long i; |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
63 for (i=0; i<num_pixels; i++) |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
64 ((uint16_t *)dst)[i] = ((const uint16_t *)palette)[src[i]]; |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
65 } |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
66 |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
67 static void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
68 { |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
69 long i; |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
70 for (i=0; i<num_pixels; i++) |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
71 ((uint16_t *)dst)[i] = bswap_16(((const uint16_t *)palette)[src[i]]); |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
72 } |
878762329600
avoid using swscale internals by copying in palette8torbg16 and its bgr variant
siretart
parents:
31235
diff
changeset
|
73 |
6232 | 74 static unsigned int gray_pal[256]; |
75 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
76 static unsigned int find_best(struct vf_instance *vf, unsigned int fmt){ |
5774 | 77 unsigned int best=0; |
78 int ret; | |
30662 | 79 const unsigned int* p; |
5774 | 80 if(fmt==IMGFMT_BGR8) p=bgr_list; |
81 else if(fmt==IMGFMT_RGB8) p=rgb_list; | |
82 else return 0; | |
83 while(*p){ | |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
84 ret=vf->next->query_format(vf->next,*p); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
85 mp_msg(MSGT_VFILTER,MSGL_DBG2,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
86 if(ret&VFCAP_CSP_SUPPORTED_BY_HW){ best=*p; break;} // no conversion -> bingo! |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
87 if(ret&VFCAP_CSP_SUPPORTED && !best) best=*p; // best with conversion |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
88 ++p; |
5774 | 89 } |
90 return best; | |
91 } | |
92 | |
93 //===========================================================================// | |
94 | |
95 struct vf_priv_s { | |
96 unsigned int fmt; | |
9276 | 97 int pal_msg; |
5774 | 98 }; |
99 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
100 static int config(struct vf_instance *vf, |
5774 | 101 int width, int height, int d_width, int d_height, |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
102 unsigned int flags, unsigned int outfmt){ |
7160
447066802e64
added bgr support and support for forcing output format
alex
parents:
7127
diff
changeset
|
103 if (!vf->priv->fmt) |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
104 vf->priv->fmt=find_best(vf,outfmt); |
5774 | 105 if(!vf->priv->fmt){ |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
106 // no matching fmt, so force one... |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
107 if(outfmt==IMGFMT_RGB8) vf->priv->fmt=IMGFMT_RGB32; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
108 else if(outfmt==IMGFMT_BGR8) vf->priv->fmt=IMGFMT_BGR32; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
109 else return 0; |
5774 | 110 } |
111 return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); | |
112 } | |
113 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
114 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ |
5774 | 115 mp_image_t *dmpi; |
30072
e86cf531b110
Restore the old value of planes[1] in vf_palette at the end to ensure
reimar
parents:
29263
diff
changeset
|
116 uint8_t *old_palette = mpi->planes[1]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27788
diff
changeset
|
117 |
5774 | 118 // hope we'll get DR buffer: |
119 dmpi=vf_get_image(vf->next,vf->priv->fmt, | |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
120 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
121 mpi->w, mpi->h); |
5774 | 122 |
7160
447066802e64
added bgr support and support for forcing output format
alex
parents:
7127
diff
changeset
|
123 if (!mpi->planes[1]) |
447066802e64
added bgr support and support for forcing output format
alex
parents:
7127
diff
changeset
|
124 { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
125 if(!vf->priv->pal_msg){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
126 mp_msg(MSGT_VFILTER,MSGL_V,"[%s] no palette given, assuming builtin grayscale one\n",vf->info->name); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
127 vf->priv->pal_msg=1; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
128 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
129 mpi->planes[1] = (unsigned char*)gray_pal; |
7160
447066802e64
added bgr support and support for forcing output format
alex
parents:
7127
diff
changeset
|
130 } |
6232 | 131 |
5774 | 132 if(mpi->w==mpi->stride[0] && dmpi->w*(dmpi->bpp>>3)==dmpi->stride[0]){ |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
133 // no stride conversion needed |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
134 switch(IMGFMT_RGB_DEPTH(dmpi->imgfmt)){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
135 case 15: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
136 case 16: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
137 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
138 palette8tobgr16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
139 else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
140 palette8torgb16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
141 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
142 case 24: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
143 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
144 sws_convertPalette8ToPacked24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
145 else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
146 sws_convertPalette8ToPacked24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
147 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
148 case 32: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
149 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
150 sws_convertPalette8ToPacked32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
151 else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
152 sws_convertPalette8ToPacked32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
153 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
154 } |
5774 | 155 } else { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
156 int y; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
157 for(y=0;y<mpi->h;y++){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
158 unsigned char* src=mpi->planes[0]+y*mpi->stride[0]; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
159 unsigned char* dst=dmpi->planes[0]+y*dmpi->stride[0]; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
160 switch(IMGFMT_RGB_DEPTH(dmpi->imgfmt)){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
161 case 15: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
162 case 16: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
163 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
164 palette8tobgr16(src,dst,mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
165 else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
166 palette8torgb16(src,dst,mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
167 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
168 case 24: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
169 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
170 sws_convertPalette8ToPacked24(src,dst,mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
171 else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
172 sws_convertPalette8ToPacked24(src,dst,mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
173 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
174 case 32: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
175 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
176 sws_convertPalette8ToPacked32(src,dst,mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
177 else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
178 sws_convertPalette8ToPacked32(src,dst,mpi->w,mpi->planes[1]); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
179 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
180 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
181 } |
5774 | 182 } |
30072
e86cf531b110
Restore the old value of planes[1] in vf_palette at the end to ensure
reimar
parents:
29263
diff
changeset
|
183 mpi->planes[1] = old_palette; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27788
diff
changeset
|
184 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
185 return vf_next_put_image(vf,dmpi, pts); |
5774 | 186 } |
187 | |
188 //===========================================================================// | |
189 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
190 static int query_format(struct vf_instance *vf, unsigned int fmt){ |
5774 | 191 int best=find_best(vf,fmt); |
192 if(!best) return 0; // no match | |
193 return vf->next->query_format(vf->next,best); | |
194 } | |
195 | |
13641 | 196 static void uninit(vf_instance_t *vf) { |
197 free(vf->priv); | |
198 } | |
199 | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30421
diff
changeset
|
200 static int vf_open(vf_instance_t *vf, char *args){ |
6232 | 201 unsigned int i; |
5774 | 202 vf->config=config; |
13641 | 203 vf->uninit=uninit; |
5774 | 204 vf->put_image=put_image; |
205 vf->query_format=query_format; | |
206 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
7160
447066802e64
added bgr support and support for forcing output format
alex
parents:
7127
diff
changeset
|
207 memset(vf->priv, 0, sizeof(struct vf_priv_s)); |
6232 | 208 for(i=0;i<256;i++) gray_pal[i]=0x01010101*i; |
7160
447066802e64
added bgr support and support for forcing output format
alex
parents:
7127
diff
changeset
|
209 if (args) |
447066802e64
added bgr support and support for forcing output format
alex
parents:
7127
diff
changeset
|
210 { |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
211 if (!strcasecmp(args,"rgb15")) vf->priv->fmt=IMGFMT_RGB15; else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
212 if (!strcasecmp(args,"rgb16")) vf->priv->fmt=IMGFMT_RGB16; else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
213 if (!strcasecmp(args,"rgb24")) vf->priv->fmt=IMGFMT_RGB24; else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
214 if (!strcasecmp(args,"rgb32")) vf->priv->fmt=IMGFMT_RGB32; else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
215 if (!strcasecmp(args,"bgr15")) vf->priv->fmt=IMGFMT_BGR15; else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
216 if (!strcasecmp(args,"bgr16")) vf->priv->fmt=IMGFMT_BGR16; else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
217 if (!strcasecmp(args,"bgr24")) vf->priv->fmt=IMGFMT_BGR24; else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
218 if (!strcasecmp(args,"bgr32")) vf->priv->fmt=IMGFMT_BGR32; else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
219 { |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
220 mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_UnknownFormatName, args); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
221 return 0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
31237
diff
changeset
|
222 } |
7160
447066802e64
added bgr support and support for forcing output format
alex
parents:
7127
diff
changeset
|
223 } |
5774 | 224 return 1; |
225 } | |
226 | |
25221 | 227 const vf_info_t vf_info_palette = { |
5774 | 228 "8bpp indexed (using palette) -> BGR 15/16/24/32 conversion", |
229 "palette", | |
7160
447066802e64
added bgr support and support for forcing output format
alex
parents:
7127
diff
changeset
|
230 "A'rpi & Alex", |
5774 | 231 "", |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
30421
diff
changeset
|
232 vf_open, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9276
diff
changeset
|
233 NULL |
5774 | 234 }; |
235 | |
236 //===========================================================================// |