annotate libmpcodecs/vf_crop.c @ 32822:deebe1cc3729

Remove needless cast.
author ib
date Wed, 16 Feb 2011 15:56:54 +0000
parents 3d23e24c5c60
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 10140
diff changeset
23 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 10140
diff changeset
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
dc9f50b54a87 ehh.. 10l again
arpi
parents: 8801
diff changeset
27 #include "img_format.h"
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
28 #include "mp_image.h"
30653
3d23e24c5c60 Declare externally used variables from vd.c as extern in vd.h.
diego
parents: 30642
diff changeset
29 #include "vd.h"
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
30 #include "vf.h"
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
31
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
32 #include "m_option.h"
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
33 #include "m_struct.h"
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
34
24969
c2b7ba444ade begin moving const filter data to .text/.rodata sections
rfelker
parents: 22027
diff changeset
35 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
36 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
37 int crop_x,crop_y;
24969
c2b7ba444ade begin moving const filter data to .text/.rodata sections
rfelker
parents: 22027
diff changeset
38 } vf_priv_dflt = {
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
39 -1,-1,
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
40 -1,-1
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
41 };
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
42
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
43 //===========================================================================//
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
44
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
45 static int config(struct vf_instance *vf,
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
46 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
47 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
48 // calculate the missing parameters:
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
49 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
50 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
51 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
52 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
53 // rounding:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
54 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
55 switch(outfmt){
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
56 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
57 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
58 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
59 break;
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_YVU9:
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
61 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
62 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
63 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
64 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
65 break;
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
66 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
67 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
68 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
69 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
70 default:
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_x&=~1;
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
72 }
db98910fea8f - added x/y rounding for YUV formats (should be moved to mp_image.c|h later)
arpi
parents: 7368
diff changeset
73 }
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
74 // check:
6060
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
75 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
76 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
77 mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_CropBadPositionWidthHeight);
6060
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
78 return 0;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
79 }
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
80 if(!opt_screen_size_x && !opt_screen_size_y){
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
81 d_width=d_width*vf->priv->crop_w/width;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
82 d_height=d_height*vf->priv->crop_h/height;
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
83 }
61f39b98ba4d keep aspect ratio - based on Fredrik Kuivinen's idea
arpi
parents: 5614
diff changeset
84 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
85 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
86
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
87 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
10008
89cb47cb1fc4 at least 100l for me, the last commit was nonsense
rfelker
parents: 10007
diff changeset
88 mp_image_t *dmpi;
89cb47cb1fc4 at least 100l for me, the last commit was nonsense
rfelker
parents: 10007
diff changeset
89 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
90 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
91 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
92 MP_IMGTYPE_EXPORT, 0,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
93 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
94 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
95 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
96 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
97 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
98 (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
99 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
100 (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
101 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
102 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
103 } else {
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
104 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
105 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
106 vf->priv->crop_x*(mpi->bpp/8);
9279
12741a866acd fixed palette support
arpi
parents: 8869
diff changeset
107 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
108 }
5614
b2b1942b16d5 export width too
arpi
parents: 5607
diff changeset
109 dmpi->stride[0]=mpi->stride[0];
b2b1942b16d5 export width too
arpi
parents: 5607
diff changeset
110 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
111 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
112 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
113
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
114 static void start_slice(struct vf_instance *vf, mp_image_t *mpi){
10140
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
115 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
116 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
117 }
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
118
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
119 static void draw_slice(struct vf_instance *vf,
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
120 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
121 unsigned char *src2[3];
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
122 src2[0] = src[0];
10140
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
123 if (vf->dmpi->flags & MP_IMGFLAG_PLANAR) {
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
124 src2[1] = src[1];
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
125 src2[2] = src[2];
10008
89cb47cb1fc4 at least 100l for me, the last commit was nonsense
rfelker
parents: 10007
diff changeset
126 }
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
127 //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
128 if ((x -= vf->priv->crop_x) < 0) {
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
129 x = -x;
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
130 src2[0] += x;
10140
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
131 if (vf->dmpi->flags & MP_IMGFLAG_PLANAR) {
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
132 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
133 src2[2] += x>>vf->dmpi->chroma_x_shift;
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
134 }
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
135 w -= x;
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
136 x = 0;
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
137 }
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
138 if ((y -= vf->priv->crop_y) < 0) {
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
139 y = -y;
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
140 src2[0] += y*stride[0];
10140
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
141 if (vf->dmpi->flags & MP_IMGFLAG_PLANAR) {
30cad6ad9dbc fix segfaults with slices. support slice rendering into a filter even
rfelker
parents: 10027
diff changeset
142 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
143 src2[2] += (y>>vf->dmpi->chroma_y_shift)*stride[2];
10027
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
144 }
898a50ad6839 100l in my 100l fix! :(
rfelker
parents: 10008
diff changeset
145 h -= y;
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
146 y = 0;
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
147 }
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
148 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
149 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
150 //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
151 if (w <= 0 || h <= 0) return;
10008
89cb47cb1fc4 at least 100l for me, the last commit was nonsense
rfelker
parents: 10007
diff changeset
152 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
153 }
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
154
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
155 //===========================================================================//
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
156
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30421
diff changeset
157 static int vf_open(vf_instance_t *vf, char *args){
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
158 vf->config=config;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
159 vf->put_image=put_image;
10007
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
160 vf->start_slice=start_slice;
b2d257e35577 slices support for vf_crop. now cropping black borders should make a
rfelker
parents: 9602
diff changeset
161 vf->draw_slice=draw_slice;
5565
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5507
diff changeset
162 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
163 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
164 vf->priv->crop_w,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
165 vf->priv->crop_h,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
166 vf->priv->crop_x,
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
167 vf->priv->crop_y);
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
168 return 1;
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
169 }
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
170
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
171 #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
172 static const m_option_t vf_opts_fields[] = {
9602
74e8cd83708f 10L again with the options mins
albeu
parents: 9599
diff changeset
173 {"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
174 {"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
175 {"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
176 {"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
177 { NULL, NULL, 0, 0, 0, 0, NULL }
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
178 };
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
179
24969
c2b7ba444ade begin moving const filter data to .text/.rodata sections
rfelker
parents: 22027
diff changeset
180 static const m_struct_t vf_opts = {
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
181 "crop",
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
182 sizeof(struct vf_priv_s),
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
183 &vf_priv_dflt,
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
184 vf_opts_fields
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
185 };
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
186
24969
c2b7ba444ade begin moving const filter data to .text/.rodata sections
rfelker
parents: 22027
diff changeset
187 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
188 "cropping",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
189 "crop",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
190 "A'rpi",
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
191 "",
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30421
diff changeset
192 vf_open,
9599
77bddc6d9266 Support for the new options stuff
albeu
parents: 9593
diff changeset
193 &vf_opts
5507
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
194 };
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
195
d0d029fda134 video filter layer - written from scratch, but inspired a lot by Fredrik Kuivinen's patch
arpi
parents:
diff changeset
196 //===========================================================================//