annotate libmpcodecs/vf_yuvcsp.c @ 22563:6398fe5193ef

Remove superfluous rule and variables, X_LIB does not exist any longer.
author diego
date Wed, 14 Mar 2007 20:50:48 +0000
parents 20aca9baf5d8
children e5b4a794ac92
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11536
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
1 #include <stdio.h>
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
2 #include <stdlib.h>
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
3 #include <string.h>
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
4 #include <inttypes.h>
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
5
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 11536
diff changeset
6 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 11536
diff changeset
7 #include "mp_msg.h"
11536
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
8
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
9 #include "img_format.h"
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
10 #include "mp_image.h"
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
11 #include "vf.h"
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
12
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
13 struct vf_priv_s {
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
14 int csp;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
15 };
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
16
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
17 //===========================================================================//
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
18
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
19 static int config(struct vf_instance_s* vf,
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
20 int width, int height, int d_width, int d_height,
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
21 unsigned int flags, unsigned int outfmt){
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
22 return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
23 }
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
24
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
25 static inline int clamp_y(int x){
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
26 return (x > 235) ? 235 : (x < 16) ? 16 : x;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
27 }
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
28
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
29 static inline int clamp_c(int x){
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
30 return (x > 240) ? 240 : (x < 16) ? 16 : x;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
31 }
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
32
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
33 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
11536
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
34 int i,j;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
35 uint8_t *y_in, *cb_in, *cr_in;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
36 uint8_t *y_out, *cb_out, *cr_out;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
37
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
38 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
39 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
40 mpi->width, mpi->height);
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
41
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
42 y_in = mpi->planes[0];
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
43 cb_in = mpi->planes[1];
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
44 cr_in = mpi->planes[2];
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
45
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
46 y_out = vf->dmpi->planes[0];
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
47 cb_out = vf->dmpi->planes[1];
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
48 cr_out = vf->dmpi->planes[2];
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
49
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
50 for (i = 0; i < mpi->height; i++)
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
51 for (j = 0; j < mpi->width; j++)
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
52 y_out[i*vf->dmpi->stride[0]+j] = clamp_y(y_in[i*mpi->stride[0]+j]);
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
53
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
54 for (i = 0; i < mpi->chroma_height; i++)
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
55 for (j = 0; j < mpi->chroma_width; j++)
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
56 {
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
57 cb_out[i*vf->dmpi->stride[1]+j] = clamp_c(cb_in[i*mpi->stride[1]+j]);
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
58 cr_out[i*vf->dmpi->stride[2]+j] = clamp_c(cr_in[i*mpi->stride[2]+j]);
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
59 }
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
60
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
61 return vf_next_put_image(vf,vf->dmpi, pts);
11536
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
62 }
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
63
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
64 //===========================================================================//
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
65
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
66 static void uninit(struct vf_instance_s* vf){
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
67 free(vf->priv);
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
68 }
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
69
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
70 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
71 switch(fmt){
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
72 case IMGFMT_YV12:
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
73 case IMGFMT_I420:
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
74 case IMGFMT_IYUV:
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
75 return 1;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
76 }
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
77 return 0;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
78 }
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
79
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
80 static int open(vf_instance_t *vf, char* args){
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
81 vf->config=config;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
82 vf->put_image=put_image;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
83 // vf->uninit=uninit;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
84 vf->query_format=query_format;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
85 // vf->priv=calloc(1, sizeof(struct vf_priv_s));
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
86 // if (args)
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
87 // vf->priv->csp = atoi(args);
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
88 return 1;
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
89 }
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
90
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
91 vf_info_t vf_info_yuvcsp = {
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
92 "yuv colorspace converter",
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
93 "yuvcsp",
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
94 "Alex Beregszaszi",
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
95 "",
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
96 open,
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
97 NULL
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
98 };
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
99
017a7e90fcf1 yuv colorspace converter
alex
parents:
diff changeset
100 //===========================================================================//