16 #include "img_format.h"
21 //===========================================================================//
26 #define mux_v (vf->priv->mux)
28 static int set_format(struct vf_instance_s
*vf
, unsigned int fmt
) {
29 mux_v
->bih
->biCompression
= fmt
;
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
);
36 mux_v
->bih
->biBitCount
= (IMGFMT_RGB_DEPTH(fmt
)+7)&(~7);
39 if (IMGFMT_IS_BGR(fmt
)) {
40 if (IMGFMT_BGR_DEPTH(fmt
) < 8 && !(fmt
&128))
41 mux_v
->bih
->biBitCount
= IMGFMT_BGR_DEPTH(fmt
);
43 mux_v
->bih
->biBitCount
= (IMGFMT_BGR_DEPTH(fmt
)+7)&(~7);
51 mux_v
->bih
->biPlanes
= 3;
52 mux_v
->bih
->biBitCount
= 12;
55 mux_v
->bih
->biPlanes
= 3;
56 mux_v
->bih
->biBitCount
= 24;
59 mux_v
->bih
->biPlanes
= 3;
60 mux_v
->bih
->biBitCount
= 16;
63 mux_v
->bih
->biPlanes
= 4;
65 mux_v
->bih
->biBitCount
= 9;
69 mux_v
->bih
->biBitCount
= 16;
72 mp_msg(MSGT_MENCODER
, MSGL_INFO
, MSGTR_MPCODECS_OutputWithFourccNotSupported
, fmt
);
73 mux_v
->bih
->biCompression
= 0;
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
)
85 mux_v
->bih
->biWidth
= width
;
86 mux_v
->bih
->biHeight
= height
;
87 mux_v
->aspect
= (float)d_width
/d_height
;
88 ret
= set_format(vf
, outfmt
);
91 mux_v
->bih
->biSizeImage
= mux_v
->bih
->biWidth
*mux_v
->bih
->biHeight
*mux_v
->bih
->biBitCount
/8;
95 static int control(struct vf_instance_s
*vf
, int request
, void *data
) {
96 return CONTROL_UNKNOWN
;
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
;
113 return VFCAP_CSP_SUPPORTED
| VFCAP_CSP_SUPPORTED_BY_HW
;
119 static int put_image(struct vf_instance_s
*vf
, mp_image_t
*mpi
, double pts
) {
120 mux_v
->buffer
= mpi
->planes
[0];
121 muxer_write_chunk(mux_v
, mpi
->width
*mpi
->height
*mux_v
->bih
->biBitCount
/8, 0x10, pts
, pts
);
125 //===========================================================================//
127 static int vf_open(vf_instance_t
*vf
, char* args
){
129 vf
->default_caps
= VFCAP_CONSTANT
;
130 vf
->control
= control
;
131 vf
->query_format
= query_format
;
132 vf
->put_image
= put_image
;
133 vf
->default_caps
= 0;
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
;
138 mux_v
->bih
= calloc(1, sizeof(BITMAPINFOHEADER
));
139 mux_v
->bih
->biSize
= sizeof(BITMAPINFOHEADER
);
140 mux_v
->bih
->biWidth
= 0;
141 mux_v
->bih
->biHeight
= 0;
146 vf_info_t ve_info_raw
= {
154 //===========================================================================//