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 "img_format.h"
35 //===========================================================================//
37 static int config(struct vf_instance
* vf
,
38 int width
, int height
, int d_width
, int d_height
,
39 unsigned int flags
, unsigned int outfmt
){
40 return vf_next_config(vf
, width
, height
, d_width
, d_height
, flags
, outfmt
);
43 static inline int clamp_y(int x
){
44 return (x
> 235) ? 235 : (x
< 16) ? 16 : x
;
47 static inline int clamp_c(int x
){
48 return (x
> 240) ? 240 : (x
< 16) ? 16 : x
;
51 static int put_image(struct vf_instance
* vf
, mp_image_t
*mpi
, double pts
){
53 uint8_t *y_in
, *cb_in
, *cr_in
;
54 uint8_t *y_out
, *cb_out
, *cr_out
;
56 vf
->dmpi
=vf_get_image(vf
->next
,mpi
->imgfmt
,
57 MP_IMGTYPE_TEMP
, MP_IMGFLAG_ACCEPT_STRIDE
,
58 mpi
->width
, mpi
->height
);
60 y_in
= mpi
->planes
[0];
61 cb_in
= mpi
->planes
[1];
62 cr_in
= mpi
->planes
[2];
64 y_out
= vf
->dmpi
->planes
[0];
65 cb_out
= vf
->dmpi
->planes
[1];
66 cr_out
= vf
->dmpi
->planes
[2];
68 for (i
= 0; i
< mpi
->height
; i
++)
69 for (j
= 0; j
< mpi
->width
; j
++)
70 y_out
[i
*vf
->dmpi
->stride
[0]+j
] = clamp_y(y_in
[i
*mpi
->stride
[0]+j
]);
72 for (i
= 0; i
< mpi
->chroma_height
; i
++)
73 for (j
= 0; j
< mpi
->chroma_width
; j
++)
75 cb_out
[i
*vf
->dmpi
->stride
[1]+j
] = clamp_c(cb_in
[i
*mpi
->stride
[1]+j
]);
76 cr_out
[i
*vf
->dmpi
->stride
[2]+j
] = clamp_c(cr_in
[i
*mpi
->stride
[2]+j
]);
79 return vf_next_put_image(vf
,vf
->dmpi
, pts
);
82 //===========================================================================//
85 static void uninit(struct vf_instance* vf){
90 static int query_format(struct vf_instance
* vf
, unsigned int fmt
){
100 static int vf_open(vf_instance_t
*vf
, char *args
){
102 vf
->put_image
=put_image
;
103 // vf->uninit=uninit;
104 vf
->query_format
=query_format
;
105 // vf->priv=calloc(1, sizeof(struct vf_priv_s));
107 // vf->priv->csp = atoi(args);
111 const vf_info_t vf_info_yuvcsp
= {
112 "yuv colorspace converter",
120 //===========================================================================//