comparison libmpcodecs/vf_expand.c @ 15252:b5456142675d

- preserve ordering of the slices - make sure that the black buffer is actually allocated to avoid sig11
author henry
date Sun, 24 Apr 2005 09:29:01 +0000
parents bfb91d085f22
children 4119b6ef4e87
comparison
equal deleted inserted replaced
15251:c39173a67cbb 15252:b5456142675d
26 static struct vf_priv_s { 26 static struct vf_priv_s {
27 int exp_w,exp_h; 27 int exp_w,exp_h;
28 int exp_x,exp_y; 28 int exp_x,exp_y;
29 int osd; 29 int osd;
30 unsigned char* fb_ptr; 30 unsigned char* fb_ptr;
31 int first_slice;
31 } vf_priv_dflt = { 32 } vf_priv_dflt = {
32 -1,-1, 33 -1,-1,
33 -1,-1, 34 -1,-1,
34 0, 35 0,
35 NULL 36 NULL,
37 0
36 }; 38 };
37 39
38 extern int opt_screen_size_x; 40 extern int opt_screen_size_x;
39 extern int opt_screen_size_y; 41 extern int opt_screen_size_y;
40 42
248 } 250 }
249 // they want slices!!! allocate the buffer. 251 // they want slices!!! allocate the buffer.
250 if(!mpi->priv) 252 if(!mpi->priv)
251 mpi->priv=vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, 253 mpi->priv=vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
252 // MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE, 254 // MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
253 mpi->type, mpi->flags, 255 MP_IMGTYPE_TEMP, mpi->flags,
254 MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x), 256 MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x),
255 MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y)); 257 MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));
256 if(!(vf->dmpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) 258 if(!(vf->dmpi->flags&MP_IMGFLAG_DRAW_CALLBACK))
257 printf("WARNING! next filter doesn't support SLICES, get ready for sig11...\n"); // shouldn't happen. 259 printf("WARNING! next filter doesn't support SLICES, get ready for sig11...\n"); // shouldn't happen.
258 } 260 vf->priv->first_slice = 1;
259 261 }
260 static void draw_slice(struct vf_instance_s* vf, 262
261 unsigned char** src, int* stride, int w,int h, int x, int y){ 263 static void draw_top_blackbar_slice(struct vf_instance_s* vf,
262 // printf("draw_slice() called %d at %d\n",h,y); 264 unsigned char** src, int* stride, int w,int h, int x, int y){
263 if(vf->priv->exp_y>0 && y == 0) 265 if(vf->priv->exp_y>0 && y == 0) {
264 vf_next_draw_slice(vf, vf->dmpi->planes, vf->dmpi->stride, 266 vf_next_draw_slice(vf, vf->dmpi->planes, vf->dmpi->stride,
265 vf->dmpi->w,vf->priv->exp_y,0,0); 267 vf->dmpi->w,vf->priv->exp_y,0,0);
266 vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y); 268 }
269
270 }
271
272 static void draw_bottom_blackbar_slice(struct vf_instance_s* vf,
273 unsigned char** src, int* stride, int w,int h, int x, int y){
267 if(vf->priv->exp_y+vf->h<vf->dmpi->h && y+h == vf->h) { 274 if(vf->priv->exp_y+vf->h<vf->dmpi->h && y+h == vf->h) {
268 unsigned char *src2[MP_MAX_PLANES]; 275 unsigned char *src2[MP_MAX_PLANES];
269 src2[0] = vf->dmpi->planes[0] 276 src2[0] = vf->dmpi->planes[0]
270 + (vf->priv->exp_y+vf->h)*vf->dmpi->stride[0]; 277 + (vf->priv->exp_y+vf->h)*vf->dmpi->stride[0];
271 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){ 278 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
274 src2[2] = vf->dmpi->planes[2] 281 src2[2] = vf->dmpi->planes[2]
275 + ((vf->priv->exp_y+vf->h)>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2]; 282 + ((vf->priv->exp_y+vf->h)>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2];
276 } else { 283 } else {
277 src2[1] = vf->dmpi->planes[1]; // passthrough rgb8 palette 284 src2[1] = vf->dmpi->planes[1]; // passthrough rgb8 palette
278 } 285 }
279
280 vf_next_draw_slice(vf, src2, vf->dmpi->stride, 286 vf_next_draw_slice(vf, src2, vf->dmpi->stride,
281 vf->dmpi->w,vf->dmpi->h-(vf->priv->exp_y+vf->h), 287 vf->dmpi->w,vf->dmpi->h-(vf->priv->exp_y+vf->h),
282 0,vf->priv->exp_y+vf->h); 288 0,vf->priv->exp_y+vf->h);
283 } 289 }
290 }
291
292 static void draw_slice(struct vf_instance_s* vf,
293 unsigned char** src, int* stride, int w,int h, int x, int y){
294 // printf("draw_slice() called %d at %d\n",h,y);
295
296 if (y == 0 && y+h == vf->h) {
297 // special case - only one slice
298 draw_top_blackbar_slice(vf, src, stride, w, h, x, y);
299 vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y);
300 draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y);
301 return;
302 }
303 if (vf->priv->first_slice) {
304 draw_top_blackbar_slice(vf, src, stride, w, h, x, y);
305 draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y);
306 }
307 vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y);
308 if (!vf->priv->first_slice) {
309 draw_top_blackbar_slice(vf, src, stride, w, h, x, y);
310 draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y);
311 }
312 vf->priv->first_slice = 0;
284 } 313 }
285 314
286 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ 315 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
287 if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){ 316 if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){
288 vf->dmpi=mpi->priv; 317 vf->dmpi=mpi->priv;