annotate libmpcodecs/vf_rgbtest.c @ 27219:ef71399cd7e2

1000l, fix demux_lavf compilation
author reimar
date Fri, 11 Jul 2008 18:04:36 +0000
parents ef8d3d2d9d73
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
1 #include <stdio.h>
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
2 #include <stdlib.h>
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
3 #include <string.h>
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
4 #include <inttypes.h>
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
5
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 13145
diff changeset
6 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 13145
diff changeset
7 #include "mp_msg.h"
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
8
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
9 #include "img_format.h"
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
10 #include "mp_image.h"
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
11 #include "vf.h"
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
12
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
13 //===========================================================================//
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
14
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
15 struct vf_priv_s {
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
16 unsigned int fmt;
25988
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
17 int w, h;
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
18 };
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
19
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
20 static unsigned int getfmt(unsigned int outfmt){
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
21 switch(outfmt){
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
22 case IMGFMT_RGB15:
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
23 case IMGFMT_RGB16:
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
24 case IMGFMT_RGB24:
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
25 case IMGFMT_RGBA:
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
26 case IMGFMT_ARGB:
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
27 case IMGFMT_BGR15:
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
28 case IMGFMT_BGR16:
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
29 case IMGFMT_BGR24:
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
30 case IMGFMT_BGRA:
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
31 case IMGFMT_ABGR:
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
32 return outfmt;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
33 }
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
34 return 0;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
35 }
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
36
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
37 static void put_pixel(uint8_t *buf, int x, int y, int stride, int r, int g, int b, int fmt){
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
38 switch(fmt){
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
39 case IMGFMT_BGR15: ((uint16_t*)(buf + y*stride))[x]= ((r>>3)<<10) | ((g>>3)<<5) | (b>>3);
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
40 break;
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
41 case IMGFMT_RGB15: ((uint16_t*)(buf + y*stride))[x]= ((b>>3)<<10) | ((g>>3)<<5) | (r>>3);
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
42 break;
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
43 case IMGFMT_BGR16: ((uint16_t*)(buf + y*stride))[x]= ((r>>3)<<11) | ((g>>2)<<5) | (b>>3);
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
44 break;
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
45 case IMGFMT_RGB16: ((uint16_t*)(buf + y*stride))[x]= ((b>>3)<<11) | ((g>>2)<<5) | (r>>3);
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
46 break;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
47 case IMGFMT_RGB24:
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
48 buf[3*x + y*stride + 0]= r;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
49 buf[3*x + y*stride + 1]= g;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
50 buf[3*x + y*stride + 2]= b;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
51 break;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
52 case IMGFMT_BGR24:
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
53 buf[3*x + y*stride + 0]= b;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
54 buf[3*x + y*stride + 1]= g;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
55 buf[3*x + y*stride + 2]= r;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
56 break;
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
57 case IMGFMT_RGBA:
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
58 buf[4*x + y*stride + 0]= r;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
59 buf[4*x + y*stride + 1]= g;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
60 buf[4*x + y*stride + 2]= b;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
61 break;
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
62 case IMGFMT_BGRA:
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
63 buf[4*x + y*stride + 0]= b;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
64 buf[4*x + y*stride + 1]= g;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
65 buf[4*x + y*stride + 2]= r;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
66 break;
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
67 case IMGFMT_ARGB:
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
68 buf[4*x + y*stride + 1]= r;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
69 buf[4*x + y*stride + 2]= g;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
70 buf[4*x + y*stride + 3]= b;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
71 break;
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
72 case IMGFMT_ABGR:
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
73 buf[4*x + y*stride + 1]= b;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
74 buf[4*x + y*stride + 2]= g;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
75 buf[4*x + y*stride + 3]= r;
13145
be7ed0dfe056 change to match current bgr/rgb definition
michael
parents: 11894
diff changeset
76 break;
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
77 }
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
78 }
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
79
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
80 static int config(struct vf_instance_s* vf,
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
81 int width, int height, int d_width, int d_height,
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
82 unsigned int flags, unsigned int outfmt){
25988
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
83 if (vf->priv->w > 0) { d_width = width = vf->priv->w; }
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
84 if (vf->priv->h > 0) { d_height = height = vf->priv->h; }
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
85 vf->priv->fmt=getfmt(outfmt);
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
86 mp_msg(MSGT_VFILTER,MSGL_V,"rgb test format:%s\n", vo_format_name(outfmt));
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
87 return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt);
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
88 }
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
89
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
90 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
91 mp_image_t *dmpi;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
92 int x, y;
25988
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
93 int w = vf->priv->w > 0 ? vf->priv->w : mpi->w;
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
94 int h = vf->priv->h > 0 ? vf->priv->h : mpi->h;
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
95
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
96 // hope we'll get DR buffer:
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
97 dmpi=vf_get_image(vf->next,vf->priv->fmt,
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
98 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
25988
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
99 w, h);
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
100
25988
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
101 for(y=0; y<h; y++){
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
102 for(x=0; x<w; x++){
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
103 int c= 256*x/w;
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
104 int r=0,g=0,b=0;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
105
25988
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
106 if(3*y<h) r=c;
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
107 else if(3*y<2*h) g=c;
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
108 else b=c;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
109
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
110 put_pixel(dmpi->planes[0], x, y, dmpi->stride[0], r, g, b, vf->priv->fmt);
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
111 }
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
112 }
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
113
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
114 return vf_next_put_image(vf,dmpi, pts);
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
115 }
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
116
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
117 //===========================================================================//
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
118
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
119 static int query_format(struct vf_instance_s* vf, unsigned int outfmt){
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
120 unsigned int fmt=getfmt(outfmt);
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
121 if(!fmt) return 0;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
122 return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW);
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
123 }
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
124
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
125 static int open(vf_instance_t *vf, char* args){
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
126 vf->config=config;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
127 vf->put_image=put_image;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
128 vf->query_format=query_format;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
129 vf->priv=malloc(sizeof(struct vf_priv_s));
25988
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
130 vf->priv->w = vf->priv->h = 0;
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
131 if (args)
ef8d3d2d9d73 Allow specifying a size for -vf rgbtest
reimar
parents: 25221
diff changeset
132 sscanf(args, "%d:%d", &vf->priv->w, &vf->priv->h);
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
133 return 1;
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
134 }
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
135
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 23373
diff changeset
136 const vf_info_t vf_info_rgbtest = {
11894
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
137 "rgbtest",
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
138 "rgbtest",
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
139 "Michael Niedermayer",
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
140 "",
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
141 open,
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
142 NULL
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
143 };
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
144
4c24bad2a86b rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
michael
parents:
diff changeset
145 //===========================================================================//