annotate libmpcodecs/vf_crop.c @ 10663:711159267b2d

clean up field flags: 1) cosmetic change, no reason these need to be mpeg2-specific 2) add a flag to tell when fields are ordered, so we don't have to assume bff (which would usually be wrong) when field flags are not available. 3) add other flags for future use :)
author rfelker
date Mon, 18 Aug 2003 14:49:06 +0000
parents 30cad6ad9dbc
children 6ff3379a0862
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
1 #include <stdio.h>
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
2 #include <stdlib.h>
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
3 #include <string.h>
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
4
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
5 #include "../config.h"
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
6 #include "../mp_msg.h"
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
7
8802
dc9f50b54a87 ehh.. 10l again
arpi
parents: 8801
diff changeset
8 #include "img_format.h"
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
9 #include "mp_image.h"
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
10 #include "vf.h"
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
11
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
12 #include "m_option.h"
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
13 #include "m_struct.h"
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
14
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
15 static struct vf_priv_s {
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
16 int crop_w,crop_h;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
17 int crop_x,crop_y;
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
18 } vf_priv_dflt = {
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
19 -1,-1,
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
20 -1,-1
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
21 };
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
22
6060
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
23 extern int opt_screen_size_x;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
24 extern int opt_screen_size_y;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
25
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
26 //===========================================================================//
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
27
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
28 static int config(struct vf_instance_s* vf,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
29 int width, int height, int d_width, int d_height,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
30 unsigned int flags, unsigned int outfmt){
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
31 // calculate the missing parameters:
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
32 if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
33 if(vf->priv->crop_h<=0 || vf->priv->crop_h>height) vf->priv->crop_h=height;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
34 if(vf->priv->crop_x<0) vf->priv->crop_x=(width-vf->priv->crop_w)/2;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
35 if(vf->priv->crop_y<0) vf->priv->crop_y=(height-vf->priv->crop_h)/2;
8801
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
36 // rounding:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
37 if(!IMGFMT_IS_RGB(outfmt) && !IMGFMT_IS_BGR(outfmt)){
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
38 switch(outfmt){
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
39 case IMGFMT_444P:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
40 case IMGFMT_Y800:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
41 case IMGFMT_Y8:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
42 break;
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
43 case IMGFMT_YVU9:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
44 case IMGFMT_IF09:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
45 vf->priv->crop_y&=~3;
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
46 case IMGFMT_411P:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
47 vf->priv->crop_x&=~3;
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
48 break;
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
49 case IMGFMT_YV12:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
50 case IMGFMT_I420:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
51 case IMGFMT_IYUV:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
52 vf->priv->crop_y&=~1;
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
53 default:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
54 vf->priv->crop_x&=~1;
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
55 }
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
56 }
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
57 // check:
6060
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
58 if(vf->priv->crop_w+vf->priv->crop_x>width ||
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
59 vf->priv->crop_h+vf->priv->crop_y>height){
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
60 printf("crop: bad position/width/height - cropped area is out of the original!\n");
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
61 return 0;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
62 }
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
63 if(!opt_screen_size_x && !opt_screen_size_y){
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
64 d_width=d_width*vf->priv->crop_w/width;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
65 d_height=d_height*vf->priv->crop_h/height;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
66 }
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
67 return vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt);
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
68 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
69
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 6060
diff changeset
70 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
10008
89cb47cb1fc4 at least 100l for me, the last commit was nonsense
rfelker
parents: 10007
diff changeset
71 mp_image_t *dmpi;
89cb47cb1fc4 at least 100l for me, the last commit was nonsense
rfelker
parents: 10007
diff changeset
72 if (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)
10140
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
73 return vf_next_put_image(vf,vf->dmpi);
10008
89cb47cb1fc4 at least 100l for me, the last commit was nonsense
rfelker
parents: 10007
diff changeset
74 dmpi=vf_get_image(vf->next,mpi->imgfmt,
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
75 MP_IMGTYPE_EXPORT, 0,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
76 vf->priv->crop_w, vf->priv->crop_h);
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
77 if(mpi->flags&MP_IMGFLAG_PLANAR){
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
78 dmpi->planes[0]=mpi->planes[0]+
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
79 vf->priv->crop_y*mpi->stride[0]+vf->priv->crop_x;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
80 dmpi->planes[1]=mpi->planes[1]+
8801
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
81 (vf->priv->crop_y>>mpi->chroma_y_shift)*mpi->stride[1]+(vf->priv->crop_x>>mpi->chroma_x_shift);
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
82 dmpi->planes[2]=mpi->planes[2]+
8801
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
83 (vf->priv->crop_y>>mpi->chroma_y_shift)*mpi->stride[2]+(vf->priv->crop_x>>mpi->chroma_x_shift);
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
84 dmpi->stride[1]=mpi->stride[1];
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
85 dmpi->stride[2]=mpi->stride[2];
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
86 } else {
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
87 dmpi->planes[0]=mpi->planes[0]+
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
88 vf->priv->crop_y*mpi->stride[0]+
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
89 vf->priv->crop_x*(mpi->bpp/8);
9279
12741a866acd fixed palette support
arpi
parents: 8869
diff changeset
90 dmpi->planes[1]=mpi->planes[1]; // passthrough rgb8 palette
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
91 }
5614
b2b1942b16d5 export width too
arpi
parents: 5607
diff changeset
92 dmpi->stride[0]=mpi->stride[0];
b2b1942b16d5 export width too
arpi
parents: 5607
diff changeset
93 dmpi->width=mpi->width;
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 6060
diff changeset
94 return vf_next_put_image(vf,dmpi);
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
95 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
96
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
97 static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){
10140
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
98 vf->dmpi = vf_get_image(vf->next, mpi->imgfmt, mpi->type, mpi->flags,
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
99 vf->priv->crop_w, vf->priv->crop_h);
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
100 }
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
101
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
102 static void draw_slice(struct vf_instance_s* vf,
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
103 unsigned char** src, int* stride, int w,int h, int x, int y){
10008
89cb47cb1fc4 at least 100l for me, the last commit was nonsense
rfelker
parents: 10007
diff changeset
104 unsigned char *src2[3];
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
105 src2[0] = src[0];
10140
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
106 if (vf->dmpi->flags & MP_IMGFLAG_PLANAR) {
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
107 src2[1] = src[1];
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
108 src2[2] = src[2];
10008
89cb47cb1fc4 at least 100l for me, the last commit was nonsense
rfelker
parents: 10007
diff changeset
109 }
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
110 //mp_msg(MSGT_VFILTER, MSGL_V, "crop slice %d %d %d %d ->", w,h,x,y);
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
111 if ((x -= vf->priv->crop_x) < 0) {
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
112 x = -x;
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
113 src2[0] += x;
10140
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
114 if (vf->dmpi->flags & MP_IMGFLAG_PLANAR) {
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
115 src2[1] += x>>vf->dmpi->chroma_x_shift;
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
116 src2[2] += x>>vf->dmpi->chroma_x_shift;
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
117 }
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
118 w -= x;
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
119 x = 0;
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
120 }
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
121 if ((y -= vf->priv->crop_y) < 0) {
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
122 y = -y;
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
123 src2[0] += y*stride[0];
10140
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
124 if (vf->dmpi->flags & MP_IMGFLAG_PLANAR) {
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
125 src2[1] += (y>>vf->dmpi->chroma_y_shift)*stride[1];
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
126 src2[2] += (y>>vf->dmpi->chroma_y_shift)*stride[2];
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
127 }
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
128 h -= y;
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
129 y = 0;
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
130 }
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
131 if (x+w > vf->priv->crop_w) w = vf->priv->crop_w-x;
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
132 if (y+h > vf->priv->crop_h) h = vf->priv->crop_h-y;
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
133 //mp_msg(MSGT_VFILTER, MSGL_V, "%d %d %d %d\n", w,h,x,y);
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
134 if ((w < 0) || (h < 0)) return;
10008
89cb47cb1fc4 at least 100l for me, the last commit was nonsense
rfelker
parents: 10007
diff changeset
135 vf_next_draw_slice(vf,src2,stride,w,h,x,y);
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
136 }
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
137
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
138 //===========================================================================//
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
139
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
140 static int open(vf_instance_t *vf, char* args){
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
141 vf->config=config;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
142 vf->put_image=put_image;
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
143 vf->start_slice=start_slice;
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
144 vf->draw_slice=draw_slice;
5565
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5507
diff changeset
145 vf->default_reqs=VFCAP_ACCEPT_STRIDE;
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
146 if(!vf->priv) {
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
147 vf->priv=malloc(sizeof(struct vf_priv_s));
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
148 // TODO: parse args ->
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
149 vf->priv->crop_x=
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
150 vf->priv->crop_y=
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
151 vf->priv->crop_w=
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
152 vf->priv->crop_h=-1;
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
153 } //if(!vf->priv)
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
154 if(args) sscanf(args, "%d:%d:%d:%d",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
155 &vf->priv->crop_w,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
156 &vf->priv->crop_h,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
157 &vf->priv->crop_x,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
158 &vf->priv->crop_y);
8869
9df3c03b2ffe use mp_msg for messages. prolly more filters need to be fixed like this too
rfelker
parents: 8802
diff changeset
159 mp_msg(MSGT_VFILTER, MSGL_INFO, "Crop: %d x %d, %d ; %d\n",
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
160 vf->priv->crop_w,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
161 vf->priv->crop_h,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
162 vf->priv->crop_x,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
163 vf->priv->crop_y);
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
164 return 1;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
165 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
166
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
167 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
168 static m_option_t vf_opts_fields[] = {
9602
74e8cd83708f 10L again with the options mins
albeu
parents: 9599
diff changeset
169 {"w", ST_OFF(crop_w), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL},
74e8cd83708f 10L again with the options mins
albeu
parents: 9599
diff changeset
170 {"h", ST_OFF(crop_h), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL},
74e8cd83708f 10L again with the options mins
albeu
parents: 9599
diff changeset
171 {"x", ST_OFF(crop_x), CONF_TYPE_INT, M_OPT_MIN,-1 ,0, NULL},
74e8cd83708f 10L again with the options mins
albeu
parents: 9599
diff changeset
172 {"y", ST_OFF(crop_y), CONF_TYPE_INT, M_OPT_MIN,-1 ,0, NULL},
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
173 { NULL, NULL, 0, 0, 0, 0, NULL }
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
174 };
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
175
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
176 static m_struct_t vf_opts = {
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
177 "crop",
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
178 sizeof(struct vf_priv_s),
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
179 &vf_priv_dflt,
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
180 vf_opts_fields
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
181 };
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
182
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
183 vf_info_t vf_info_crop = {
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
184 "cropping",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
185 "crop",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
186 "A'rpi",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
187 "",
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9279
diff changeset
188 open,
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
189 &vf_opts
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
190 };
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
191
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
192 //===========================================================================//