Mercurial > mplayer.hg
annotate libmpcodecs/ve_raw.c @ 20962:a95ed9a69caf
Put files fully owned by my under GPL v2 "or later"
author | reimar |
---|---|
date | Fri, 17 Nov 2006 10:03:33 +0000 |
parents | bcd805923554 |
children | ca9da45d13e9 |
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" | |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
7 #include "help_mp.h" |
11966 | 8 |
9 #include "codec-cfg.h" | |
10 #include "stream.h" | |
11 #include "demuxer.h" | |
12 #include "stheader.h" | |
13 | |
14 #include "muxer.h" | |
15 | |
16 #include "img_format.h" | |
17 #include "mp_image.h" | |
18 #include "vf.h" | |
19 | |
20 | |
21 //===========================================================================// | |
22 | |
23 struct vf_priv_s { | |
24 muxer_stream_t* mux; | |
25 }; | |
26 #define mux_v (vf->priv->mux) | |
27 | |
28 static int set_format(struct vf_instance_s *vf, unsigned int fmt) { | |
29 mux_v->bih->biCompression = fmt; | |
30 | |
31 mux_v->bih->biPlanes = 1; | |
32 if (IMGFMT_IS_RGB(fmt)) { | |
33 if (IMGFMT_RGB_DEPTH(fmt) < 8 && !(fmt&128)) | |
34 mux_v->bih->biBitCount = IMGFMT_RGB_DEPTH(fmt); | |
35 else | |
36 mux_v->bih->biBitCount = (IMGFMT_RGB_DEPTH(fmt)+7)&(~7); | |
37 return 1; | |
38 } | |
39 if (IMGFMT_IS_BGR(fmt)) { | |
40 if (IMGFMT_BGR_DEPTH(fmt) < 8 && !(fmt&128)) | |
41 mux_v->bih->biBitCount = IMGFMT_BGR_DEPTH(fmt); | |
42 else | |
43 mux_v->bih->biBitCount = (IMGFMT_BGR_DEPTH(fmt)+7)&(~7); | |
44 return 1; | |
45 } | |
46 switch (fmt) { | |
47 case IMGFMT_I420: | |
48 case IMGFMT_IYUV: | |
49 case IMGFMT_YV12: | |
50 case IMGFMT_411P: | |
51 mux_v->bih->biPlanes = 3; | |
52 mux_v->bih->biBitCount = 12; | |
53 break; | |
54 case IMGFMT_444P: | |
55 mux_v->bih->biPlanes = 3; | |
56 mux_v->bih->biBitCount = 24; | |
57 break; | |
58 case IMGFMT_422P: | |
59 mux_v->bih->biPlanes = 3; | |
60 mux_v->bih->biBitCount = 16; | |
61 break; | |
62 case IMGFMT_IF09: | |
63 mux_v->bih->biPlanes = 4; | |
64 case IMGFMT_YVU9: | |
65 mux_v->bih->biBitCount = 9; | |
66 break; | |
67 case IMGFMT_UYVY: | |
68 case IMGFMT_YUY2: | |
69 mux_v->bih->biBitCount = 16; | |
70 break; | |
71 default: | |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
72 mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_MPCODECS_OutputWithFourccNotSupported, fmt); |
11966 | 73 mux_v->bih->biCompression = 0; |
74 return 0; | |
75 } | |
76 return 1; | |
77 } | |
78 | |
79 | |
80 static int config(struct vf_instance_s *vf, | |
81 int width, int height, int d_width, int d_height, | |
82 unsigned int flags, unsigned int outfmt) | |
83 { | |
84 int ret; | |
85 mux_v->bih->biWidth = width; | |
86 mux_v->bih->biHeight = height; | |
12061 | 87 mux_v->aspect = (float)d_width/d_height; |
11966 | 88 ret = set_format(vf, outfmt); |
89 if (!ret) return 0; | |
90 | |
91 mux_v->bih->biSizeImage = mux_v->bih->biWidth*mux_v->bih->biHeight*mux_v->bih->biBitCount/8; | |
92 return 1; | |
93 } | |
94 | |
95 static int control(struct vf_instance_s *vf, int request, void *data) { | |
96 return CONTROL_UNKNOWN; | |
97 } | |
98 | |
99 static int query_format(struct vf_instance_s *vf, unsigned int fmt) { | |
100 if (IMGFMT_IS_RGB(fmt) || IMGFMT_IS_BGR(fmt)) | |
101 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; | |
102 switch (fmt) { | |
103 case IMGFMT_I420: | |
104 case IMGFMT_IYUV: | |
105 case IMGFMT_YV12: | |
106 case IMGFMT_411P: | |
107 case IMGFMT_444P: | |
108 case IMGFMT_422P: | |
109 case IMGFMT_UYVY: | |
110 case IMGFMT_YUY2: | |
111 case IMGFMT_YVU9: | |
112 case IMGFMT_IF09: | |
113 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; | |
114 } | |
115 | |
116 return 0; | |
117 } | |
118 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17487
diff
changeset
|
119 static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts) { |
11966 | 120 mux_v->buffer = mpi->planes[0]; |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17487
diff
changeset
|
121 muxer_write_chunk(mux_v, mpi->width*mpi->height*mux_v->bih->biBitCount/8, 0x10, pts, pts); |
11966 | 122 return 1; |
123 } | |
124 | |
125 //===========================================================================// | |
126 | |
127 static int vf_open(vf_instance_t *vf, char* args){ | |
128 vf->config = config; | |
14878 | 129 vf->default_caps = VFCAP_CONSTANT; |
11966 | 130 vf->control = control; |
131 vf->query_format = query_format; | |
132 vf->put_image = put_image; | |
14303 | 133 vf->default_caps = 0; |
11966 | 134 vf->priv = malloc(sizeof(struct vf_priv_s)); |
135 memset(vf->priv, 0, sizeof(struct vf_priv_s)); | |
136 vf->priv->mux = (muxer_stream_t*)args; | |
137 | |
14549
acf3241be19b
Initialized BITMAPINFOHEADER to 0 to avoid problems, esp. windows has problems
reimar
parents:
14303
diff
changeset
|
138 mux_v->bih = calloc(1, sizeof(BITMAPINFOHEADER)); |
11966 | 139 mux_v->bih->biSize = sizeof(BITMAPINFOHEADER); |
140 mux_v->bih->biWidth = 0; | |
141 mux_v->bih->biHeight = 0; | |
142 | |
143 return 1; | |
144 } | |
145 | |
146 vf_info_t ve_info_raw = { | |
147 "raw encoder", | |
148 "raw", | |
149 "jwe21@cam.ac.uk", | |
150 "Based on rawrgb", | |
151 vf_open | |
152 }; | |
153 | |
154 //===========================================================================// |