Mercurial > mplayer.hg
annotate libmpcodecs/vf_crop.c @ 30434:92b0eee57acb
Add missing license header.
author | diego |
---|---|
date | Sun, 31 Jan 2010 10:54:08 +0000 |
parents | bbb6ebec87a0 |
children | a7b908875c14 |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30203
diff
changeset
|
18 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
19 #include <stdio.h> |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
20 #include <stdlib.h> |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
21 #include <string.h> |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
22 |
17012 | 23 #include "config.h" |
24 #include "mp_msg.h" | |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
25 #include "help_mp.h" |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
26 |
8802 | 27 #include "img_format.h" |
5607 | 28 #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
|
29 #include "vf.h" |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
30 |
9599 | 31 #include "m_option.h" |
32 #include "m_struct.h" | |
33 | |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
22027
diff
changeset
|
34 static const 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
|
35 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
|
36 int crop_x,crop_y; |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
22027
diff
changeset
|
37 } vf_priv_dflt = { |
9599 | 38 -1,-1, |
39 -1,-1 | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
40 }; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
41 |
6060 | 42 extern int opt_screen_size_x; |
43 extern int opt_screen_size_y; | |
44 | |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
45 //===========================================================================// |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
46 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 // calculate the missing parameters: |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 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
|
55 // rounding: |
db98910fea8f
- added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents:
7368
diff
changeset
|
56 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
|
57 switch(outfmt){ |
db98910fea8f
- added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents:
7368
diff
changeset
|
58 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
|
59 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
|
60 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
|
61 break; |
db98910fea8f
- added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents:
7368
diff
changeset
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 break; |
db98910fea8f
- added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents:
7368
diff
changeset
|
68 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
|
69 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
|
70 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
|
71 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
|
72 default: |
db98910fea8f
- added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents:
7368
diff
changeset
|
73 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
|
74 } |
db98910fea8f
- added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents:
7368
diff
changeset
|
75 } |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
76 // check: |
6060 | 77 if(vf->priv->crop_w+vf->priv->crop_x>width || |
78 vf->priv->crop_h+vf->priv->crop_y>height){ | |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
79 mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_CropBadPositionWidthHeight); |
6060 | 80 return 0; |
81 } | |
82 if(!opt_screen_size_x && !opt_screen_size_y){ | |
83 d_width=d_width*vf->priv->crop_w/width; | |
84 d_height=d_height*vf->priv->crop_h/height; | |
85 } | |
86 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
|
87 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
88 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
89 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
10008
89cb47cb1fc4
at least 100l for me, the last commit was nonsense
rfelker
parents:
10007
diff
changeset
|
90 mp_image_t *dmpi; |
89cb47cb1fc4
at least 100l for me, the last commit was nonsense
rfelker
parents:
10007
diff
changeset
|
91 if (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK) |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
92 return vf_next_put_image(vf,vf->dmpi, pts); |
10008
89cb47cb1fc4
at least 100l for me, the last commit was nonsense
rfelker
parents:
10007
diff
changeset
|
93 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
|
94 MP_IMGTYPE_EXPORT, 0, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 (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
|
101 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
|
102 (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
|
103 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
|
104 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
|
105 } else { |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
106 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
|
107 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
|
108 vf->priv->crop_x*(mpi->bpp/8); |
9279 | 109 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
|
110 } |
5614 | 111 dmpi->stride[0]=mpi->stride[0]; |
112 dmpi->width=mpi->width; | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
113 return vf_next_put_image(vf,dmpi, pts); |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
114 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
115 |
10007
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
116 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
|
117 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
|
118 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
|
119 } |
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 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
|
122 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
|
123 unsigned char *src2[3]; |
10027 | 124 src2[0] = src[0]; |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
10027
diff
changeset
|
125 if (vf->dmpi->flags & MP_IMGFLAG_PLANAR) { |
10027 | 126 src2[1] = src[1]; |
127 src2[2] = src[2]; | |
10008
89cb47cb1fc4
at least 100l for me, the last commit was nonsense
rfelker
parents:
10007
diff
changeset
|
128 } |
10007
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
129 //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
|
130 if ((x -= vf->priv->crop_x) < 0) { |
10027 | 131 x = -x; |
132 src2[0] += x; | |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
10027
diff
changeset
|
133 if (vf->dmpi->flags & MP_IMGFLAG_PLANAR) { |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
10027
diff
changeset
|
134 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
|
135 src2[2] += x>>vf->dmpi->chroma_x_shift; |
10027 | 136 } |
137 w -= x; | |
10007
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
138 x = 0; |
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
139 } |
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
140 if ((y -= vf->priv->crop_y) < 0) { |
10027 | 141 y = -y; |
142 src2[0] += y*stride[0]; | |
10140
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
10027
diff
changeset
|
143 if (vf->dmpi->flags & MP_IMGFLAG_PLANAR) { |
30cad6ad9dbc
fix segfaults with slices. support slice rendering into a filter even
rfelker
parents:
10027
diff
changeset
|
144 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
|
145 src2[2] += (y>>vf->dmpi->chroma_y_shift)*stride[2]; |
10027 | 146 } |
147 h -= y; | |
10007
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
148 y = 0; |
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
149 } |
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
150 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
|
151 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
|
152 //mp_msg(MSGT_VFILTER, MSGL_V, "%d %d %d %d\n", w,h,x,y); |
30203
3888e3862fe0
vf crop: do not generate 0-size slices, they are pointless and also confuse
reimar
parents:
29903
diff
changeset
|
153 if (w <= 0 || h <= 0) return; |
10008
89cb47cb1fc4
at least 100l for me, the last commit was nonsense
rfelker
parents:
10007
diff
changeset
|
154 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
|
155 } |
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
156 |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
157 //===========================================================================// |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
158 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
159 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
|
160 vf->config=config; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
161 vf->put_image=put_image; |
10007
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
162 vf->start_slice=start_slice; |
b2d257e35577
slices support for vf_crop. now cropping black borders should make a
rfelker
parents:
9602
diff
changeset
|
163 vf->draw_slice=draw_slice; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5507
diff
changeset
|
164 vf->default_reqs=VFCAP_ACCEPT_STRIDE; |
8869
9df3c03b2ffe
use mp_msg for messages. prolly more filters need to be fixed like this too
rfelker
parents:
8802
diff
changeset
|
165 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
|
166 vf->priv->crop_w, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
167 vf->priv->crop_h, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
168 vf->priv->crop_x, |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
169 vf->priv->crop_y); |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
170 return 1; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
171 } |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
172 |
9599 | 173 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
22027
diff
changeset
|
174 static const m_option_t vf_opts_fields[] = { |
9602 | 175 {"w", ST_OFF(crop_w), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL}, |
176 {"h", ST_OFF(crop_h), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL}, | |
177 {"x", ST_OFF(crop_x), CONF_TYPE_INT, M_OPT_MIN,-1 ,0, NULL}, | |
178 {"y", ST_OFF(crop_y), CONF_TYPE_INT, M_OPT_MIN,-1 ,0, NULL}, | |
9599 | 179 { NULL, NULL, 0, 0, 0, 0, NULL } |
180 }; | |
181 | |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
22027
diff
changeset
|
182 static const m_struct_t vf_opts = { |
9599 | 183 "crop", |
184 sizeof(struct vf_priv_s), | |
185 &vf_priv_dflt, | |
186 vf_opts_fields | |
187 }; | |
188 | |
24969
c2b7ba444ade
begin moving const filter data to .text/.rodata sections
rfelker
parents:
22027
diff
changeset
|
189 const vf_info_t vf_info_crop = { |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
190 "cropping", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
191 "crop", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
192 "A'rpi", |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
193 "", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9279
diff
changeset
|
194 open, |
9599 | 195 &vf_opts |
5507
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
196 }; |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
197 |
d0d029fda134
video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff
changeset
|
198 //===========================================================================// |