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