2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "codec-cfg.h"
28 #include "stream/stream.h"
29 #include "libmpdemux/demuxer.h"
30 #include "libmpdemux/stheader.h"
32 #include "stream/stream.h"
33 #include "libmpdemux/muxer.h"
35 #include "img_format.h"
40 //===========================================================================//
45 #define mux_v (vf->priv->mux)
47 static int set_format(struct vf_instance
*vf
, unsigned int fmt
) {
49 mux_v
->bih
->biCompression
= fmt
;
51 mux_v
->bih
->biPlanes
= 1;
52 if (IMGFMT_IS_RGB(fmt
)) {
53 if (IMGFMT_RGB_DEPTH(fmt
) < 8 && !(fmt
&128))
54 mux_v
->bih
->biBitCount
= IMGFMT_RGB_DEPTH(fmt
);
56 mux_v
->bih
->biBitCount
= (IMGFMT_RGB_DEPTH(fmt
)+7)&(~7);
59 if (IMGFMT_IS_BGR(fmt
)) {
60 if (IMGFMT_BGR_DEPTH(fmt
) < 8 && !(fmt
&128))
61 mux_v
->bih
->biBitCount
= IMGFMT_BGR_DEPTH(fmt
);
63 mux_v
->bih
->biBitCount
= (IMGFMT_BGR_DEPTH(fmt
)+7)&(~7);
71 mux_v
->bih
->biPlanes
= 3;
72 mux_v
->bih
->biBitCount
= 12;
75 mux_v
->bih
->biPlanes
= 3;
76 mux_v
->bih
->biBitCount
= 24;
79 mux_v
->bih
->biPlanes
= 3;
80 mux_v
->bih
->biBitCount
= 16;
83 mux_v
->bih
->biPlanes
= 4;
85 mux_v
->bih
->biBitCount
= 9;
89 mux_v
->bih
->biBitCount
= 16;
92 mux_v
->bih
->biBitCount
= 8;
95 mp_msg(MSGT_MENCODER
, MSGL_INFO
, MSGTR_MPCODECS_OutputWithFourccNotSupported
, fmt
);
96 mux_v
->bih
->biCompression
= 0;
103 static int config(struct vf_instance
*vf
,
104 int width
, int height
, int d_width
, int d_height
,
105 unsigned int flags
, unsigned int outfmt
)
108 mux_v
->bih
->biWidth
= width
;
109 mux_v
->bih
->biHeight
= height
;
110 mux_v
->aspect
= (float)d_width
/d_height
;
111 ret
= set_format(vf
, outfmt
);
114 mux_v
->bih
->biSizeImage
= mux_v
->bih
->biWidth
*mux_v
->bih
->biHeight
*mux_v
->bih
->biBitCount
/8;
118 static int control(struct vf_instance
*vf
, int request
, void *data
) {
119 return CONTROL_UNKNOWN
;
122 static int query_format(struct vf_instance
*vf
, unsigned int fmt
) {
123 if (IMGFMT_IS_RGB(fmt
) || IMGFMT_IS_BGR(fmt
))
124 return VFCAP_CSP_SUPPORTED
| VFCAP_CSP_SUPPORTED_BY_HW
;
137 return VFCAP_CSP_SUPPORTED
| VFCAP_CSP_SUPPORTED_BY_HW
;
143 static int put_image(struct vf_instance
*vf
, mp_image_t
*mpi
, double pts
) {
144 mux_v
->buffer
= mpi
->planes
[0];
145 muxer_write_chunk(mux_v
, mpi
->width
*mpi
->height
*mux_v
->bih
->biBitCount
/8, 0x10, pts
, pts
);
149 //===========================================================================//
151 static int vf_open(vf_instance_t
*vf
, char* args
){
153 vf
->default_caps
= VFCAP_CONSTANT
;
154 vf
->control
= control
;
155 vf
->query_format
= query_format
;
156 vf
->put_image
= put_image
;
157 vf
->default_caps
= 0;
158 vf
->priv
= malloc(sizeof(struct vf_priv_s
));
159 memset(vf
->priv
, 0, sizeof(struct vf_priv_s
));
160 vf
->priv
->mux
= (muxer_stream_t
*)args
;
162 mux_v
->bih
= calloc(1, sizeof(BITMAPINFOHEADER
));
163 mux_v
->bih
->biSize
= sizeof(BITMAPINFOHEADER
);
164 mux_v
->bih
->biWidth
= 0;
165 mux_v
->bih
->biHeight
= 0;
170 vf_info_t ve_info_raw
= {
178 //===========================================================================//