5512
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <string.h>
|
|
4
|
|
5 #include "../config.h"
|
|
6 #include "../mp_msg.h"
|
|
7
|
5518
|
8 #include "../libvo/img_format.h"
|
5512
|
9 #include "../mp_image.h"
|
|
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;
|
|
17 };
|
|
18
|
|
19 //===========================================================================//
|
|
20
|
5518
|
21 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
|
|
22 switch(fmt){
|
|
23 case IMGFMT_YV12:
|
|
24 case IMGFMT_I420:
|
|
25 case IMGFMT_IYUV:
|
|
26 return vf_next_query_format(vf,fmt);
|
|
27 }
|
|
28 return 0;
|
|
29 }
|
|
30
|
5512
|
31 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
|
32 if(vf->priv->pp&0xFFFF) return; // non-local filters enabled
|
5513
|
33 if((mpi->type==MP_IMGTYPE_IPB || vf->priv->pp) &&
|
|
34 mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
|
5512
|
35 // ok, we can do pp in-place (or pp disabled):
|
|
36 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt,
|
|
37 mpi->type, mpi->flags, mpi->w, mpi->h);
|
|
38 mpi->planes[0]=vf->priv->dmpi->planes[0];
|
|
39 mpi->stride[0]=vf->priv->dmpi->stride[0];
|
|
40 mpi->width=vf->priv->dmpi->width;
|
|
41 if(mpi->flags&MP_IMGFLAG_PLANAR){
|
|
42 mpi->planes[1]=vf->priv->dmpi->planes[1];
|
|
43 mpi->planes[2]=vf->priv->dmpi->planes[2];
|
|
44 mpi->stride[1]=vf->priv->dmpi->stride[1];
|
|
45 mpi->stride[2]=vf->priv->dmpi->stride[2];
|
|
46 }
|
|
47 mpi->flags|=MP_IMGFLAG_DIRECT;
|
|
48 }
|
|
49
|
|
50 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
|
51 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
|
|
52 // no DR, so get a new image! hope we'll get DR buffer:
|
|
53 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt,
|
|
54 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ALIGNED_STRIDE,
|
|
55 mpi->w,mpi->h);
|
|
56 }
|
|
57
|
|
58 if(vf->priv->pp || !(mpi->flags&MP_IMGFLAG_DIRECT)){
|
|
59 // do the postprocessing! (or copy if no DR)
|
|
60 postprocess(mpi->planes,mpi->stride[0],
|
|
61 vf->priv->dmpi->planes,vf->priv->dmpi->stride[0],
|
|
62 mpi->w,mpi->h,
|
|
63 mpi->qscale, mpi->qstride,
|
|
64 vf->priv->pp);
|
|
65 }
|
|
66
|
|
67 vf_next_put_image(vf,vf->priv->dmpi);
|
|
68 }
|
|
69
|
|
70 //===========================================================================//
|
|
71
|
|
72 extern int divx_quality;
|
|
73
|
|
74 static int open(vf_instance_t *vf, char* args){
|
5514
|
75 char *endptr;
|
5518
|
76 vf->query_format=query_format;
|
5512
|
77 vf->get_image=get_image;
|
|
78 vf->put_image=put_image;
|
|
79 vf->priv=malloc(sizeof(struct vf_priv_s));
|
5514
|
80 if(args){
|
|
81 vf->priv->pp=strtol(args, &endptr, 0);
|
|
82 if(!(*endptr)) return 1;
|
|
83 }
|
5512
|
84 vf->priv->pp=divx_quality;
|
|
85 return 1;
|
|
86 }
|
|
87
|
|
88 vf_info_t vf_info_pp = {
|
|
89 "postprocessing",
|
|
90 "pp",
|
|
91 "A'rpi",
|
|
92 "",
|
|
93 open
|
|
94 };
|
|
95
|
|
96 //===========================================================================//
|