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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5512
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
1 #include <stdio.h>
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
2 #include <stdlib.h>
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
3 #include <string.h>
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
4
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
5 #include "../config.h"
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
6 #include "../mp_msg.h"
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
7
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
8 #include "img_format.h"
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
9 #include "mp_image.h"
5512
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
10 #include "vf.h"
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
11
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
12 #include "../postproc/postprocess.h"
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
13
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
14 struct vf_priv_s {
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
15 unsigned int pp;
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
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
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
18 };
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
19
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
20 //===========================================================================//
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
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
04a40454bdbb accept only 4:2:0 planar yuv formats
arpi
parents: 5514
diff changeset
28 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
04a40454bdbb accept only 4:2:0 planar yuv formats
arpi
parents: 5514
diff changeset
29 switch(fmt){
04a40454bdbb accept only 4:2:0 planar yuv formats
arpi
parents: 5514
diff changeset
30 case IMGFMT_YV12:
04a40454bdbb accept only 4:2:0 planar yuv formats
arpi
parents: 5514
diff changeset
31 case IMGFMT_I420:
04a40454bdbb accept only 4:2:0 planar yuv formats
arpi
parents: 5514
diff changeset
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
04a40454bdbb accept only 4:2:0 planar yuv formats
arpi
parents: 5514
diff changeset
34 }
04a40454bdbb accept only 4:2:0 planar yuv formats
arpi
parents: 5514
diff changeset
35 return 0;
04a40454bdbb accept only 4:2:0 planar yuv formats
arpi
parents: 5514
diff changeset
36 }
04a40454bdbb accept only 4:2:0 planar yuv formats
arpi
parents: 5514
diff changeset
37
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
38 static int control(struct vf_instance_s* vf, int request, void* data){
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
39 switch(request){
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
40 case VFCTRL_QUERY_MAX_PP_LEVEL:
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
41 return GET_PP_QUALITY_MAX;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
42 case VFCTRL_SET_PP_LEVEL:
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
43 vf->priv->pp=getPpModeForQuality(*((unsigned int*)data));
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
44 return CONTROL_TRUE;
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
45 }
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
46 return vf_next_control(vf,request,data);
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
47 }
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
48
5512
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
49 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
50 if(vf->priv->pp&0xFFFF) return; // non-local filters enabled
5513
73696051e3ce mpeg+pp0 fixed
arpi
parents: 5512
diff changeset
51 if((mpi->type==MP_IMGTYPE_IPB || vf->priv->pp) &&
73696051e3ce mpeg+pp0 fixed
arpi
parents: 5512
diff changeset
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
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
55 // ok, we can do pp in-place (or pp disabled):
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
56 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt,
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
57 mpi->type, mpi->flags, mpi->w, mpi->h);
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
58 mpi->planes[0]=vf->priv->dmpi->planes[0];
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
59 mpi->stride[0]=vf->priv->dmpi->stride[0];
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
60 mpi->width=vf->priv->dmpi->width;
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
61 if(mpi->flags&MP_IMGFLAG_PLANAR){
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
62 mpi->planes[1]=vf->priv->dmpi->planes[1];
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
63 mpi->planes[2]=vf->priv->dmpi->planes[2];
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
64 mpi->stride[1]=vf->priv->dmpi->stride[1];
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
65 mpi->stride[2]=vf->priv->dmpi->stride[2];
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
66 }
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
67 mpi->flags|=MP_IMGFLAG_DIRECT;
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
68 }
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
69
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
70 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
71 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
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
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 5607
diff changeset
74 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 5607
diff changeset
75 // MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 5607
diff changeset
76 // mpi->w,mpi->h);
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 5607
diff changeset
77 (mpi->w+7)&(~7),(mpi->h+7)&(~7));
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 5607
diff changeset
78 vf->priv->dmpi->w=mpi->w; vf->priv->dmpi->h=mpi->h; // display w;h
5512
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
79 }
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
80
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
81 if(vf->priv->pp || !(mpi->flags&MP_IMGFLAG_DIRECT)){
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
82 // do the postprocessing! (or copy if no DR)
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
83 postprocess(mpi->planes,mpi->stride[0],
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
84 vf->priv->dmpi->planes,vf->priv->dmpi->stride[0],
6875
255b150a75a5 - some reorder/cleanup of mp_image flags
arpi
parents: 5607
diff changeset
85 (mpi->w+7)&(~7),mpi->h,
5512
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
86 mpi->qscale, mpi->qstride,
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
87 vf->priv->pp);
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
88 }
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
89
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
90 vf_next_put_image(vf,vf->priv->dmpi);
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
91 }
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
92
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
93 //===========================================================================//
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
94
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
95 extern int divx_quality;
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
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
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
104 static int open(vf_instance_t *vf, char* args){
5514
127f2a84e933 accept -pp value from args
arpi
parents: 5513
diff changeset
105 char *endptr;
5518
04a40454bdbb accept only 4:2:0 planar yuv formats
arpi
parents: 5514
diff changeset
106 vf->query_format=query_format;
5519
868c13f78f08 vf control codes added, autoq support
arpi
parents: 5518
diff changeset
107 vf->control=control;
5565
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5519
diff changeset
108 vf->config=config;
5512
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
109 vf->get_image=get_image;
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
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
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
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
127f2a84e933 accept -pp value from args
arpi
parents: 5513
diff changeset
118 if(args){
127f2a84e933 accept -pp value from args
arpi
parents: 5513
diff changeset
119 vf->priv->pp=strtol(args, &endptr, 0);
127f2a84e933 accept -pp value from args
arpi
parents: 5513
diff changeset
120 if(!(*endptr)) return 1;
127f2a84e933 accept -pp value from args
arpi
parents: 5513
diff changeset
121 }
5512
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
122 vf->priv->pp=divx_quality;
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
123 return 1;
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
124 }
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
125
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
126 vf_info_t vf_info_pp = {
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
127 "postprocessing",
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
128 "pp",
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
129 "A'rpi",
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
130 "",
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
131 open
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
132 };
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
133
4ccfa77d8e86 postprocessing filter (fixme: -pp 0)
arpi
parents:
diff changeset
134 //===========================================================================//