Mercurial > mplayer.hg
annotate libmpcodecs/ve_raw.c @ 17838:4ed5dece9d09
remove useless cruft (binds variable)
author | reimar |
---|---|
date | Sun, 12 Mar 2006 21:47:15 +0000 |
parents | fa17424b4c7b |
children | 20aca9baf5d8 |
rev | line source |
---|---|
11966 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 | |
17012 | 5 #include "config.h" |
6 #include "mp_msg.h" | |
11966 | 7 |
8 #include "codec-cfg.h" | |
9 #include "stream.h" | |
10 #include "demuxer.h" | |
11 #include "stheader.h" | |
12 | |
13 #include "muxer.h" | |
14 | |
15 #include "img_format.h" | |
16 #include "mp_image.h" | |
17 #include "vf.h" | |
18 | |
19 | |
20 //===========================================================================// | |
21 | |
22 struct vf_priv_s { | |
23 muxer_stream_t* mux; | |
24 }; | |
25 #define mux_v (vf->priv->mux) | |
26 | |
27 static int set_format(struct vf_instance_s *vf, unsigned int fmt) { | |
28 mux_v->bih->biCompression = fmt; | |
29 | |
30 mux_v->bih->biPlanes = 1; | |
31 if (IMGFMT_IS_RGB(fmt)) { | |
32 if (IMGFMT_RGB_DEPTH(fmt) < 8 && !(fmt&128)) | |
33 mux_v->bih->biBitCount = IMGFMT_RGB_DEPTH(fmt); | |
34 else | |
35 mux_v->bih->biBitCount = (IMGFMT_RGB_DEPTH(fmt)+7)&(~7); | |
36 return 1; | |
37 } | |
38 if (IMGFMT_IS_BGR(fmt)) { | |
39 if (IMGFMT_BGR_DEPTH(fmt) < 8 && !(fmt&128)) | |
40 mux_v->bih->biBitCount = IMGFMT_BGR_DEPTH(fmt); | |
41 else | |
42 mux_v->bih->biBitCount = (IMGFMT_BGR_DEPTH(fmt)+7)&(~7); | |
43 return 1; | |
44 } | |
45 switch (fmt) { | |
46 case IMGFMT_I420: | |
47 case IMGFMT_IYUV: | |
48 case IMGFMT_YV12: | |
49 case IMGFMT_411P: | |
50 mux_v->bih->biPlanes = 3; | |
51 mux_v->bih->biBitCount = 12; | |
52 break; | |
53 case IMGFMT_444P: | |
54 mux_v->bih->biPlanes = 3; | |
55 mux_v->bih->biBitCount = 24; | |
56 break; | |
57 case IMGFMT_422P: | |
58 mux_v->bih->biPlanes = 3; | |
59 mux_v->bih->biBitCount = 16; | |
60 break; | |
61 case IMGFMT_IF09: | |
62 mux_v->bih->biPlanes = 4; | |
63 case IMGFMT_YVU9: | |
64 mux_v->bih->biBitCount = 9; | |
65 break; | |
66 case IMGFMT_UYVY: | |
67 case IMGFMT_YUY2: | |
68 mux_v->bih->biBitCount = 16; | |
69 break; | |
70 default: | |
71 printf("ve_raw: raw output with fourcc [%x] not supported!\n", fmt); | |
72 mux_v->bih->biCompression = 0; | |
73 return 0; | |
74 } | |
75 return 1; | |
76 } | |
77 | |
78 | |
79 static int config(struct vf_instance_s *vf, | |
80 int width, int height, int d_width, int d_height, | |
81 unsigned int flags, unsigned int outfmt) | |
82 { | |
83 int ret; | |
84 mux_v->bih->biWidth = width; | |
85 mux_v->bih->biHeight = height; | |
12061 | 86 mux_v->aspect = (float)d_width/d_height; |
11966 | 87 ret = set_format(vf, outfmt); |
88 if (!ret) return 0; | |
89 | |
90 mux_v->bih->biSizeImage = mux_v->bih->biWidth*mux_v->bih->biHeight*mux_v->bih->biBitCount/8; | |
91 return 1; | |
92 } | |
93 | |
94 static int control(struct vf_instance_s *vf, int request, void *data) { | |
95 return CONTROL_UNKNOWN; | |
96 } | |
97 | |
98 static int query_format(struct vf_instance_s *vf, unsigned int fmt) { | |
99 if (IMGFMT_IS_RGB(fmt) || IMGFMT_IS_BGR(fmt)) | |
100 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; | |
101 switch (fmt) { | |
102 case IMGFMT_I420: | |
103 case IMGFMT_IYUV: | |
104 case IMGFMT_YV12: | |
105 case IMGFMT_411P: | |
106 case IMGFMT_444P: | |
107 case IMGFMT_422P: | |
108 case IMGFMT_UYVY: | |
109 case IMGFMT_YUY2: | |
110 case IMGFMT_YVU9: | |
111 case IMGFMT_IF09: | |
112 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; | |
113 } | |
114 | |
115 return 0; | |
116 } | |
117 | |
118 static int put_image(struct vf_instance_s *vf, mp_image_t *mpi) { | |
119 mux_v->buffer = mpi->planes[0]; | |
17487
fa17424b4c7b
change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents:
17012
diff
changeset
|
120 muxer_write_chunk(mux_v, mpi->width*mpi->height*mux_v->bih->biBitCount/8, 0x10, MP_NOPTS_VALUE, MP_NOPTS_VALUE); |
11966 | 121 return 1; |
122 } | |
123 | |
124 //===========================================================================// | |
125 | |
126 static int vf_open(vf_instance_t *vf, char* args){ | |
127 vf->config = config; | |
14878 | 128 vf->default_caps = VFCAP_CONSTANT; |
11966 | 129 vf->control = control; |
130 vf->query_format = query_format; | |
131 vf->put_image = put_image; | |
14303 | 132 vf->default_caps = 0; |
11966 | 133 vf->priv = malloc(sizeof(struct vf_priv_s)); |
134 memset(vf->priv, 0, sizeof(struct vf_priv_s)); | |
135 vf->priv->mux = (muxer_stream_t*)args; | |
136 | |
14549
acf3241be19b
Initialized BITMAPINFOHEADER to 0 to avoid problems, esp. windows has problems
reimar
parents:
14303
diff
changeset
|
137 mux_v->bih = calloc(1, sizeof(BITMAPINFOHEADER)); |
11966 | 138 mux_v->bih->biSize = sizeof(BITMAPINFOHEADER); |
139 mux_v->bih->biWidth = 0; | |
140 mux_v->bih->biHeight = 0; | |
141 | |
142 return 1; | |
143 } | |
144 | |
145 vf_info_t ve_info_raw = { | |
146 "raw encoder", | |
147 "raw", | |
148 "jwe21@cam.ac.uk", | |
149 "Based on rawrgb", | |
150 vf_open | |
151 }; | |
152 | |
153 //===========================================================================// |