Mercurial > mplayer.hg
annotate libmpcodecs/vf_pp.c @ 7081:66c2e2d0504f
- changed re-muxed packet structure (see struct dp_hdr_t)
now the packets can be encapsulated into avi or other file formats
- skip redundant/resent fragments (bit 0x20 set of first byte of frag)
author | arpi |
---|---|
date | Sat, 24 Aug 2002 22:39:27 +0000 |
parents | 255b150a75a5 |
children | 1e47c2e7aa8e |
rev | line source |
---|---|
5512 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 | |
5 #include "../config.h" | |
6 #include "../mp_msg.h" | |
7 | |
5607 | 8 #include "img_format.h" |
9 #include "mp_image.h" | |
5512 | 10 #include "vf.h" |
11 | |
12 #include "../postproc/postprocess.h" | |
13 | |
14 struct vf_priv_s { | |
15 unsigned int pp; | |
16 mp_image_t *dmpi; | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
17 unsigned int outfmt; |
5512 | 18 }; |
19 | |
20 //===========================================================================// | |
21 | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
22 static int config(struct vf_instance_s* vf, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
23 int width, int height, int d_width, int d_height, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
24 unsigned int voflags, unsigned int outfmt){ |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
25 return vf_next_config(vf,width,height,d_width,d_height,voflags,vf->priv->outfmt); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
26 } |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
27 |
5518 | 28 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ |
29 switch(fmt){ | |
30 case IMGFMT_YV12: | |
31 case IMGFMT_I420: | |
32 case IMGFMT_IYUV: | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
33 return vf_next_query_format(vf,vf->priv->outfmt); |
5518 | 34 } |
35 return 0; | |
36 } | |
37 | |
5519 | 38 static int control(struct vf_instance_s* vf, int request, void* data){ |
39 switch(request){ | |
40 case VFCTRL_QUERY_MAX_PP_LEVEL: | |
41 return GET_PP_QUALITY_MAX; | |
42 case VFCTRL_SET_PP_LEVEL: | |
43 vf->priv->pp=getPpModeForQuality(*((unsigned int*)data)); | |
44 return CONTROL_TRUE; | |
45 } | |
46 return vf_next_control(vf,request,data); | |
47 } | |
48 | |
5512 | 49 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
50 if(vf->priv->pp&0xFFFF) return; // non-local filters enabled | |
5513 | 51 if((mpi->type==MP_IMGTYPE_IPB || vf->priv->pp) && |
52 mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
53 if(!(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE) && mpi->imgfmt!=vf->priv->outfmt) |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
54 return; // colorspace differ |
5512 | 55 // ok, we can do pp in-place (or pp disabled): |
56 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
57 mpi->type, mpi->flags, mpi->w, mpi->h); | |
58 mpi->planes[0]=vf->priv->dmpi->planes[0]; | |
59 mpi->stride[0]=vf->priv->dmpi->stride[0]; | |
60 mpi->width=vf->priv->dmpi->width; | |
61 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
62 mpi->planes[1]=vf->priv->dmpi->planes[1]; | |
63 mpi->planes[2]=vf->priv->dmpi->planes[2]; | |
64 mpi->stride[1]=vf->priv->dmpi->stride[1]; | |
65 mpi->stride[2]=vf->priv->dmpi->stride[2]; | |
66 } | |
67 mpi->flags|=MP_IMGFLAG_DIRECT; | |
68 } | |
69 | |
70 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
71 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
72 // no DR, so get a new image! hope we'll get DR buffer: | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
73 vf->priv->dmpi=vf_get_image(vf->next,vf->priv->outfmt, |
6875 | 74 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, |
75 // MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
76 // mpi->w,mpi->h); | |
77 (mpi->w+7)&(~7),(mpi->h+7)&(~7)); | |
78 vf->priv->dmpi->w=mpi->w; vf->priv->dmpi->h=mpi->h; // display w;h | |
5512 | 79 } |
80 | |
81 if(vf->priv->pp || !(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
82 // do the postprocessing! (or copy if no DR) | |
83 postprocess(mpi->planes,mpi->stride[0], | |
84 vf->priv->dmpi->planes,vf->priv->dmpi->stride[0], | |
6875 | 85 (mpi->w+7)&(~7),mpi->h, |
5512 | 86 mpi->qscale, mpi->qstride, |
87 vf->priv->pp); | |
88 } | |
89 | |
90 vf_next_put_image(vf,vf->priv->dmpi); | |
91 } | |
92 | |
93 //===========================================================================// | |
94 | |
95 extern int divx_quality; | |
96 | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
97 static unsigned int fmt_list[]={ |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
98 IMGFMT_YV12, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
99 IMGFMT_I420, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
100 IMGFMT_IYUV, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
101 NULL |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
102 }; |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
103 |
5512 | 104 static int open(vf_instance_t *vf, char* args){ |
5514 | 105 char *endptr; |
5518 | 106 vf->query_format=query_format; |
5519 | 107 vf->control=control; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
108 vf->config=config; |
5512 | 109 vf->get_image=get_image; |
110 vf->put_image=put_image; | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
111 vf->default_caps=VFCAP_ACCEPT_STRIDE|VFCAP_POSTPROC; |
5512 | 112 vf->priv=malloc(sizeof(struct vf_priv_s)); |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
113 |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
114 // check csp: |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
115 vf->priv->outfmt=vf_match_csp(&vf->next,fmt_list,IMGFMT_YV12); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
116 if(!vf->priv->outfmt) return 0; // no csp match :( |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
117 |
5514 | 118 if(args){ |
119 vf->priv->pp=strtol(args, &endptr, 0); | |
120 if(!(*endptr)) return 1; | |
121 } | |
5512 | 122 vf->priv->pp=divx_quality; |
123 return 1; | |
124 } | |
125 | |
126 vf_info_t vf_info_pp = { | |
127 "postprocessing", | |
128 "pp", | |
129 "A'rpi", | |
130 "", | |
131 open | |
132 }; | |
133 | |
134 //===========================================================================// |