Use proper length specifiers in mp_msg calls, fixes the warnings:
[mplayer/greg.git] / libmpcodecs / vf_mirror.c
blobf2cf09ee085460820afe9354144e13c97e8648e5
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <inttypes.h>
6 #include "config.h"
7 #include "mp_msg.h"
9 #include "img_format.h"
10 #include "mp_image.h"
11 #include "vf.h"
14 static void mirror(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,unsigned int fmt){
15 int y;
16 for(y=0;y<h;y++){
17 int x;
18 switch(bpp){
19 case 1:
20 for(x=0;x<w;x++) dst[x]=src[w-x-1];
21 break;
22 case 2:
23 switch(fmt){
24 case IMGFMT_UYVY: {
25 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp:
26 int w2=w>>1;
27 for(x=0;x<w2;x++){
28 // TODO: optimize this...
29 dst[x*4+0]=src[0+(w2-x-1)*4];
30 dst[x*4+1]=src[3+(w2-x-1)*4];
31 dst[x*4+2]=src[2+(w2-x-1)*4];
32 dst[x*4+3]=src[1+(w2-x-1)*4];
34 break; }
35 case IMGFMT_YUY2:
36 case IMGFMT_YVYU: {
37 // packed YUV is tricky. U,V are 32bpp while Y is 16bpp:
38 int w2=w>>1;
39 for(x=0;x<w2;x++){
40 // TODO: optimize this...
41 dst[x*4+0]=src[2+(w2-x-1)*4];
42 dst[x*4+1]=src[1+(w2-x-1)*4];
43 dst[x*4+2]=src[0+(w2-x-1)*4];
44 dst[x*4+3]=src[3+(w2-x-1)*4];
46 break; }
47 default:
48 for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+(w-x-1)*2));
50 break;
51 case 3:
52 for(x=0;x<w;x++){
53 dst[x*3+0]=src[0+(w-x-1)*3];
54 dst[x*3+1]=src[1+(w-x-1)*3];
55 dst[x*3+2]=src[2+(w-x-1)*3];
57 break;
58 case 4:
59 for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+(w-x-1)*4));
61 src+=srcstride;
62 dst+=dststride;
66 //===========================================================================//
68 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
69 mp_image_t *dmpi;
71 // hope we'll get DR buffer:
72 dmpi=vf_get_image(vf->next,mpi->imgfmt,
73 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
74 mpi->w, mpi->h);
76 if(mpi->flags&MP_IMGFLAG_PLANAR){
77 mirror(dmpi->planes[0],mpi->planes[0],
78 dmpi->stride[0],mpi->stride[0],
79 dmpi->w,dmpi->h,1,mpi->imgfmt);
80 mirror(dmpi->planes[1],mpi->planes[1],
81 dmpi->stride[1],mpi->stride[1],
82 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt);
83 mirror(dmpi->planes[2],mpi->planes[2],
84 dmpi->stride[2],mpi->stride[2],
85 dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,mpi->imgfmt);
86 } else {
87 mirror(dmpi->planes[0],mpi->planes[0],
88 dmpi->stride[0],mpi->stride[0],
89 dmpi->w,dmpi->h,dmpi->bpp>>3,mpi->imgfmt);
90 dmpi->planes[1]=mpi->planes[1]; // passthrough rgb8 palette
93 return vf_next_put_image(vf,dmpi, pts);
96 //===========================================================================//
98 static int open(vf_instance_t *vf, char* args){
99 //vf->config=config;
100 vf->put_image=put_image;
101 return 1;
104 const vf_info_t vf_info_mirror = {
105 "horizontal mirror",
106 "mirror",
107 "Eyck",
109 open,
110 NULL
113 //===========================================================================//