Mercurial > mplayer.hg
comparison libmpcodecs/vf_palette.c @ 32702:7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
author | cehoyos |
---|---|
date | Fri, 14 Jan 2011 22:10:21 +0000 |
parents | 878762329600 |
children | 389d43c448b3 |
comparison
equal
deleted
inserted
replaced
32701:02bc7c860503 | 32702:7af3e6f901fd |
---|---|
78 const unsigned int* p; | 78 const unsigned int* p; |
79 if(fmt==IMGFMT_BGR8) p=bgr_list; | 79 if(fmt==IMGFMT_BGR8) p=bgr_list; |
80 else if(fmt==IMGFMT_RGB8) p=rgb_list; | 80 else if(fmt==IMGFMT_RGB8) p=rgb_list; |
81 else return 0; | 81 else return 0; |
82 while(*p){ | 82 while(*p){ |
83 ret=vf->next->query_format(vf->next,*p); | 83 ret=vf->next->query_format(vf->next,*p); |
84 mp_msg(MSGT_VFILTER,MSGL_DBG2,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3); | 84 mp_msg(MSGT_VFILTER,MSGL_DBG2,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3); |
85 if(ret&VFCAP_CSP_SUPPORTED_BY_HW){ best=*p; break;} // no conversion -> bingo! | 85 if(ret&VFCAP_CSP_SUPPORTED_BY_HW){ best=*p; break;} // no conversion -> bingo! |
86 if(ret&VFCAP_CSP_SUPPORTED && !best) best=*p; // best with conversion | 86 if(ret&VFCAP_CSP_SUPPORTED && !best) best=*p; // best with conversion |
87 ++p; | 87 ++p; |
88 } | 88 } |
89 return best; | 89 return best; |
90 } | 90 } |
91 | 91 |
92 //===========================================================================// | 92 //===========================================================================// |
96 int pal_msg; | 96 int pal_msg; |
97 }; | 97 }; |
98 | 98 |
99 static int config(struct vf_instance *vf, | 99 static int config(struct vf_instance *vf, |
100 int width, int height, int d_width, int d_height, | 100 int width, int height, int d_width, int d_height, |
101 unsigned int flags, unsigned int outfmt){ | 101 unsigned int flags, unsigned int outfmt){ |
102 if (!vf->priv->fmt) | 102 if (!vf->priv->fmt) |
103 vf->priv->fmt=find_best(vf,outfmt); | 103 vf->priv->fmt=find_best(vf,outfmt); |
104 if(!vf->priv->fmt){ | 104 if(!vf->priv->fmt){ |
105 // no matching fmt, so force one... | 105 // no matching fmt, so force one... |
106 if(outfmt==IMGFMT_RGB8) vf->priv->fmt=IMGFMT_RGB32; | 106 if(outfmt==IMGFMT_RGB8) vf->priv->fmt=IMGFMT_RGB32; |
107 else if(outfmt==IMGFMT_BGR8) vf->priv->fmt=IMGFMT_BGR32; | 107 else if(outfmt==IMGFMT_BGR8) vf->priv->fmt=IMGFMT_BGR32; |
108 else return 0; | 108 else return 0; |
109 } | 109 } |
110 return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); | 110 return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); |
111 } | 111 } |
112 | 112 |
113 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ | 113 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ |
114 mp_image_t *dmpi; | 114 mp_image_t *dmpi; |
115 uint8_t *old_palette = mpi->planes[1]; | 115 uint8_t *old_palette = mpi->planes[1]; |
116 | 116 |
117 // hope we'll get DR buffer: | 117 // hope we'll get DR buffer: |
118 dmpi=vf_get_image(vf->next,vf->priv->fmt, | 118 dmpi=vf_get_image(vf->next,vf->priv->fmt, |
119 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | 119 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
120 mpi->w, mpi->h); | 120 mpi->w, mpi->h); |
121 | 121 |
122 if (!mpi->planes[1]) | 122 if (!mpi->planes[1]) |
123 { | 123 { |
124 if(!vf->priv->pal_msg){ | 124 if(!vf->priv->pal_msg){ |
125 mp_msg(MSGT_VFILTER,MSGL_V,"[%s] no palette given, assuming builtin grayscale one\n",vf->info->name); | 125 mp_msg(MSGT_VFILTER,MSGL_V,"[%s] no palette given, assuming builtin grayscale one\n",vf->info->name); |
126 vf->priv->pal_msg=1; | 126 vf->priv->pal_msg=1; |
127 } | 127 } |
128 mpi->planes[1] = (unsigned char*)gray_pal; | 128 mpi->planes[1] = (unsigned char*)gray_pal; |
129 } | 129 } |
130 | 130 |
131 if(mpi->w==mpi->stride[0] && dmpi->w*(dmpi->bpp>>3)==dmpi->stride[0]){ | 131 if(mpi->w==mpi->stride[0] && dmpi->w*(dmpi->bpp>>3)==dmpi->stride[0]){ |
132 // no stride conversion needed | 132 // no stride conversion needed |
133 switch(IMGFMT_RGB_DEPTH(dmpi->imgfmt)){ | 133 switch(IMGFMT_RGB_DEPTH(dmpi->imgfmt)){ |
134 case 15: | 134 case 15: |
135 case 16: | 135 case 16: |
136 if (IMGFMT_IS_BGR(dmpi->imgfmt)) | 136 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
137 palette8tobgr16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); | 137 palette8tobgr16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
138 else | 138 else |
139 palette8torgb16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); | 139 palette8torgb16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
140 break; | 140 break; |
141 case 24: | 141 case 24: |
142 if (IMGFMT_IS_BGR(dmpi->imgfmt)) | 142 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
143 sws_convertPalette8ToPacked24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); | 143 sws_convertPalette8ToPacked24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
144 else | 144 else |
145 sws_convertPalette8ToPacked24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); | 145 sws_convertPalette8ToPacked24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
146 break; | 146 break; |
147 case 32: | 147 case 32: |
148 if (IMGFMT_IS_BGR(dmpi->imgfmt)) | 148 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
149 sws_convertPalette8ToPacked32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); | 149 sws_convertPalette8ToPacked32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
150 else | 150 else |
151 sws_convertPalette8ToPacked32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); | 151 sws_convertPalette8ToPacked32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]); |
152 break; | 152 break; |
153 } | 153 } |
154 } else { | 154 } else { |
155 int y; | 155 int y; |
156 for(y=0;y<mpi->h;y++){ | 156 for(y=0;y<mpi->h;y++){ |
157 unsigned char* src=mpi->planes[0]+y*mpi->stride[0]; | 157 unsigned char* src=mpi->planes[0]+y*mpi->stride[0]; |
158 unsigned char* dst=dmpi->planes[0]+y*dmpi->stride[0]; | 158 unsigned char* dst=dmpi->planes[0]+y*dmpi->stride[0]; |
159 switch(IMGFMT_RGB_DEPTH(dmpi->imgfmt)){ | 159 switch(IMGFMT_RGB_DEPTH(dmpi->imgfmt)){ |
160 case 15: | 160 case 15: |
161 case 16: | 161 case 16: |
162 if (IMGFMT_IS_BGR(dmpi->imgfmt)) | 162 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
163 palette8tobgr16(src,dst,mpi->w,mpi->planes[1]); | 163 palette8tobgr16(src,dst,mpi->w,mpi->planes[1]); |
164 else | 164 else |
165 palette8torgb16(src,dst,mpi->w,mpi->planes[1]); | 165 palette8torgb16(src,dst,mpi->w,mpi->planes[1]); |
166 break; | 166 break; |
167 case 24: | 167 case 24: |
168 if (IMGFMT_IS_BGR(dmpi->imgfmt)) | 168 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
169 sws_convertPalette8ToPacked24(src,dst,mpi->w,mpi->planes[1]); | 169 sws_convertPalette8ToPacked24(src,dst,mpi->w,mpi->planes[1]); |
170 else | 170 else |
171 sws_convertPalette8ToPacked24(src,dst,mpi->w,mpi->planes[1]); | 171 sws_convertPalette8ToPacked24(src,dst,mpi->w,mpi->planes[1]); |
172 break; | 172 break; |
173 case 32: | 173 case 32: |
174 if (IMGFMT_IS_BGR(dmpi->imgfmt)) | 174 if (IMGFMT_IS_BGR(dmpi->imgfmt)) |
175 sws_convertPalette8ToPacked32(src,dst,mpi->w,mpi->planes[1]); | 175 sws_convertPalette8ToPacked32(src,dst,mpi->w,mpi->planes[1]); |
176 else | 176 else |
177 sws_convertPalette8ToPacked32(src,dst,mpi->w,mpi->planes[1]); | 177 sws_convertPalette8ToPacked32(src,dst,mpi->w,mpi->planes[1]); |
178 break; | 178 break; |
179 } | 179 } |
180 } | 180 } |
181 } | 181 } |
182 mpi->planes[1] = old_palette; | 182 mpi->planes[1] = old_palette; |
183 | 183 |
184 return vf_next_put_image(vf,dmpi, pts); | 184 return vf_next_put_image(vf,dmpi, pts); |
185 } | 185 } |
205 vf->priv=malloc(sizeof(struct vf_priv_s)); | 205 vf->priv=malloc(sizeof(struct vf_priv_s)); |
206 memset(vf->priv, 0, sizeof(struct vf_priv_s)); | 206 memset(vf->priv, 0, sizeof(struct vf_priv_s)); |
207 for(i=0;i<256;i++) gray_pal[i]=0x01010101*i; | 207 for(i=0;i<256;i++) gray_pal[i]=0x01010101*i; |
208 if (args) | 208 if (args) |
209 { | 209 { |
210 if (!strcasecmp(args,"rgb15")) vf->priv->fmt=IMGFMT_RGB15; else | 210 if (!strcasecmp(args,"rgb15")) vf->priv->fmt=IMGFMT_RGB15; else |
211 if (!strcasecmp(args,"rgb16")) vf->priv->fmt=IMGFMT_RGB16; else | 211 if (!strcasecmp(args,"rgb16")) vf->priv->fmt=IMGFMT_RGB16; else |
212 if (!strcasecmp(args,"rgb24")) vf->priv->fmt=IMGFMT_RGB24; else | 212 if (!strcasecmp(args,"rgb24")) vf->priv->fmt=IMGFMT_RGB24; else |
213 if (!strcasecmp(args,"rgb32")) vf->priv->fmt=IMGFMT_RGB32; else | 213 if (!strcasecmp(args,"rgb32")) vf->priv->fmt=IMGFMT_RGB32; else |
214 if (!strcasecmp(args,"bgr15")) vf->priv->fmt=IMGFMT_BGR15; else | 214 if (!strcasecmp(args,"bgr15")) vf->priv->fmt=IMGFMT_BGR15; else |
215 if (!strcasecmp(args,"bgr16")) vf->priv->fmt=IMGFMT_BGR16; else | 215 if (!strcasecmp(args,"bgr16")) vf->priv->fmt=IMGFMT_BGR16; else |
216 if (!strcasecmp(args,"bgr24")) vf->priv->fmt=IMGFMT_BGR24; else | 216 if (!strcasecmp(args,"bgr24")) vf->priv->fmt=IMGFMT_BGR24; else |
217 if (!strcasecmp(args,"bgr32")) vf->priv->fmt=IMGFMT_BGR32; else | 217 if (!strcasecmp(args,"bgr32")) vf->priv->fmt=IMGFMT_BGR32; else |
218 { | 218 { |
219 mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_UnknownFormatName, args); | 219 mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_UnknownFormatName, args); |
220 return 0; | 220 return 0; |
221 } | 221 } |
222 } | 222 } |
223 return 1; | 223 return 1; |
224 } | 224 } |
225 | 225 |
226 const vf_info_t vf_info_palette = { | 226 const vf_info_t vf_info_palette = { |