annotate libmpcodecs/vf_1bpp.c @ 16307:03cd6abe5664

avoid reading more than maxlen bytes. Has the sideeffect that the amount read will be close to maxlen instead of minlen as before.
author reimar
date Thu, 25 Aug 2005 19:46:20 +0000
parents e9a2af584986
children 6ff3379a0862
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7755
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
1 #include <stdio.h>
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
2 #include <stdlib.h>
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
3 #include <string.h>
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
4 #include <inttypes.h>
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
5
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
6 #include "../config.h"
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
7 #include "../mp_msg.h"
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
8
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
9 #include "img_format.h"
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
10 #include "mp_image.h"
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
11 #include "vf.h"
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
12
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
13 #include "../postproc/rgb2rgb.h"
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
14
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
15 //===========================================================================//
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
16
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
17 static unsigned int bgr_list[]={
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
18 IMGFMT_Y800,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
19 IMGFMT_Y8,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
20 IMGFMT_BGR8,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
21 IMGFMT_RGB8,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
22
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
23 IMGFMT_YVU9,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
24 IMGFMT_411P,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
25 IMGFMT_YV12,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
26 IMGFMT_I420,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
27 IMGFMT_IYUV,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
28 IMGFMT_422P,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
29 IMGFMT_444P,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
30
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
31 IMGFMT_YUY2,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
32 IMGFMT_BGR15,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
33 IMGFMT_RGB15,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
34 IMGFMT_BGR16,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
35 IMGFMT_RGB16,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
36
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
37 IMGFMT_BGR32,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
38 IMGFMT_RGB32,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
39
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
40 // IMGFMT_BGR24,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
41 // IMGFMT_RGB24,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
42 0
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
43 };
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
44
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
45 static unsigned int find_best(struct vf_instance_s* vf){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
46 unsigned int best=0;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
47 int ret;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
48 unsigned int* p=bgr_list;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
49 while(*p){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
50 ret=vf->next->query_format(vf->next,*p);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
51 mp_msg(MSGT_VFILTER,MSGL_V,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
52 if(ret&VFCAP_CSP_SUPPORTED_BY_HW){ best=*p; break;} // no conversion -> bingo!
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
53 if(ret&VFCAP_CSP_SUPPORTED && !best) best=*p; // best with conversion
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
54 ++p;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
55 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
56 return best;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
57 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
58
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
59 //===========================================================================//
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
60
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
61 struct vf_priv_s {
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
62 unsigned int fmt;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
63 };
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
64
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
65 static int config(struct vf_instance_s* vf,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
66 int width, int height, int d_width, int d_height,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
67 unsigned int flags, unsigned int outfmt){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
68 if (!vf->priv->fmt)
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
69 vf->priv->fmt=find_best(vf);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
70 if(!vf->priv->fmt){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
71 // no matching fmt, so force one...
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
72 if(outfmt==IMGFMT_RGB8) vf->priv->fmt=IMGFMT_RGB32;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
73 else if(outfmt==IMGFMT_BGR8) vf->priv->fmt=IMGFMT_BGR32;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
74 else return 0;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
75 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
76 return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
77 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
78
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
79 static int bittab[8]={128,64,32,16,8,4,2,1};
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
80
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
81 static void convert(mp_image_t *mpi, mp_image_t *dmpi, int value0, int value1,int bpp){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
82 int y;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
83 for(y=0;y<mpi->h;y++){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
84 unsigned char* src=mpi->planes[0]+mpi->stride[0]*y;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
85 switch(bpp){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
86 case 1: {
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
87 unsigned char* dst=dmpi->planes[0]+dmpi->stride[0]*y;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
88 int x;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
89 for(x=0;x<mpi->w;x++)
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
90 dst[x]=(src[x>>3]&bittab[x&7]) ? value1 : value0;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
91 break; }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
92 case 2: {
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
93 uint16_t* dst=(uint16_t*)(dmpi->planes[0]+dmpi->stride[0]*y);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
94 int x;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
95 for(x=0;x<mpi->w;x++)
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
96 dst[x]=(src[x>>3]&bittab[x&7]) ? value1 : value0;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
97 break; }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
98 case 4: {
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
99 uint32_t* dst=(uint32_t*)(dmpi->planes[0]+dmpi->stride[0]*y);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
100 int x;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
101 for(x=0;x<mpi->w;x++)
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
102 dst[x]=(src[x>>3]&bittab[x&7]) ? value1 : value0;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
103 break; }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
104 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
105 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
106 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
107
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
108 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
109 mp_image_t *dmpi;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
110
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
111 // hope we'll get DR buffer:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
112 dmpi=vf_get_image(vf->next,vf->priv->fmt,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
113 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
114 mpi->w, mpi->h);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
115
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
116 switch(dmpi->imgfmt){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
117 case IMGFMT_Y800:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
118 case IMGFMT_Y8:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
119 case IMGFMT_BGR8:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
120 case IMGFMT_RGB8:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
121 convert(mpi,dmpi,0,255,1);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
122 break;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
123 case IMGFMT_YVU9:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
124 case IMGFMT_411P:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
125 case IMGFMT_YV12:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
126 case IMGFMT_I420:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
127 case IMGFMT_IYUV:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
128 case IMGFMT_422P:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
129 case IMGFMT_444P:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
130 convert(mpi,dmpi,0,255,1);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
131 memset(dmpi->planes[1],128,dmpi->stride[1]*dmpi->chroma_height);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
132 memset(dmpi->planes[2],128,dmpi->stride[2]*dmpi->chroma_height);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
133 break;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
134 case IMGFMT_YUY2:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
135 convert(mpi,dmpi,0x8000,0x80ff,2);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
136 break;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
137 case IMGFMT_BGR15:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
138 case IMGFMT_RGB15:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
139 convert(mpi,dmpi,0,0x7fff,2);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
140 break;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
141 case IMGFMT_BGR16:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
142 case IMGFMT_RGB16:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
143 convert(mpi,dmpi,0,0xffff,2);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
144 break;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
145 case IMGFMT_BGR32:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
146 case IMGFMT_RGB32:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
147 convert(mpi,dmpi,0,0x00ffffff,4);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
148 break;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
149 default:
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
150 mp_msg(MSGT_VFILTER,MSGL_ERR,"Unhandled format: 0x%X\n",dmpi->imgfmt);
7848
3c1d30a1afc0 compiler warning fixes by Dominik
arpi
parents: 7755
diff changeset
151 return 0;
7755
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
152 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
153
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
154 return vf_next_put_image(vf,dmpi);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
155 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
156
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
157 //===========================================================================//
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
158
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
159 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
160 int best;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
161 if(fmt!=IMGFMT_RGB1 && fmt!=IMGFMT_BGR1) return 0;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
162 best=find_best(vf);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
163 if(!best) return 0; // no match
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
164 return vf->next->query_format(vf->next,best);
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
165 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
166
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
167 static int open(vf_instance_t *vf, char* args){
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
168 vf->config=config;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
169 vf->put_image=put_image;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
170 vf->query_format=query_format;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
171 vf->priv=malloc(sizeof(struct vf_priv_s));
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
172 memset(vf->priv, 0, sizeof(struct vf_priv_s));
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
173 return 1;
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
174 }
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
175
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
176 vf_info_t vf_info_1bpp = {
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
177 "1bpp bitmap -> YUV/BGR 8/15/16/32 conversion",
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
178 "1bpp",
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
179 "A'rpi",
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
180 "",
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8123
diff changeset
181 open,
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8123
diff changeset
182 NULL
7755
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
183 };
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
184
7637b72ef1f9 new filter: 1bpp - converts 1bpp image to yuv/rgb 8/16/32 bpp
arpi
parents:
diff changeset
185 //===========================================================================//