annotate libmpcodecs/vf_cropdetect.c @ 36382:d2ed641667d2

Support 4k AVC-Intra in mov.
author cehoyos
date Fri, 18 Oct 2013 06:16:58 +0000
parents 7af3e6f901fd
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: 30394
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30394
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30394
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30394
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: 30394
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: 30394
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: 30394
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30394
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30394
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: 30394
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: 30394
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: 30394
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30394
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30394
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: 30394
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: 30394
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: 30394
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30394
diff changeset
18
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
19 #include <stdio.h>
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
20 #include <stdlib.h>
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
21 #include <string.h>
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
22 #include <inttypes.h>
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
23
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16107
diff changeset
24 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16107
diff changeset
25 #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
26 #include "help_mp.h"
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
27
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
28 #include "img_format.h"
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
29 #include "mp_image.h"
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
30 #include "vf.h"
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
31
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
32 struct vf_priv_s {
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
33 int x1,y1,x2,y2;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
34 int limit;
13205
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
35 int round;
30394
55bf07ab4c89 Add an option to cropdetect to periodically reset the detected area.
reimar
parents: 29263
diff changeset
36 int reset_count;
6118
f869ece65aab ignore first 2 frames
arpi
parents: 6117
diff changeset
37 int fno;
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
38 };
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
39
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
40 static int checkline(unsigned char* src,int stride,int len,int bpp){
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
41 int total=0;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
42 int div=len;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
43 switch(bpp){
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
44 case 1:
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
45 while(--len>=0){
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
46 total+=src[0]; src+=stride;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
47 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
48 break;
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
49 case 3:
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
50 case 4:
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
51 while(--len>=0){
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
52 total+=src[0]+src[1]+src[2]; src+=stride;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
53 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
54 div*=3;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
55 break;
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
56 }
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
57 total/=div;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
58 // printf("total=%d\n",total);
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
59 return total;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
60 }
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
61
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
62 //===========================================================================//
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
63
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
64 static int config(struct vf_instance *vf,
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
65 int width, int height, int d_width, int d_height,
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
66 unsigned int flags, unsigned int outfmt){
14588
36b24b57ab53 x1 and y1 give last used position, must be < width/height
reimar
parents: 13233
diff changeset
67 vf->priv->x1=width - 1;
36b24b57ab53 x1 and y1 give last used position, must be < width/height
reimar
parents: 13233
diff changeset
68 vf->priv->y1=height - 1;
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
69 vf->priv->x2=0;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
70 vf->priv->y2=0;
30394
55bf07ab4c89 Add an option to cropdetect to periodically reset the detected area.
reimar
parents: 29263
diff changeset
71 vf->priv->fno=-2;
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
72 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
73 }
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
74
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
75 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
76 mp_image_t *dmpi;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
77 int bpp=mpi->bpp/8;
13205
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
78 int w,h,x,y,shrink_by;
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
79
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
80 // hope we'll get DR buffer:
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
81 dmpi=vf_get_image(vf->next,mpi->imgfmt,
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
82 MP_IMGTYPE_EXPORT, 0,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
83 mpi->w, mpi->h);
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
84
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
85 dmpi->planes[0]=mpi->planes[0];
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
86 dmpi->planes[1]=mpi->planes[1];
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
87 dmpi->planes[2]=mpi->planes[2];
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
88 dmpi->stride[0]=mpi->stride[0];
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
89 dmpi->stride[1]=mpi->stride[1];
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
90 dmpi->stride[2]=mpi->stride[2];
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
91 dmpi->width=mpi->width;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
92 dmpi->height=mpi->height;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
93
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
94 if(++vf->priv->fno>0){ // ignore first 2 frames - they may be empty
30394
55bf07ab4c89 Add an option to cropdetect to periodically reset the detected area.
reimar
parents: 29263
diff changeset
95
55bf07ab4c89 Add an option to cropdetect to periodically reset the detected area.
reimar
parents: 29263
diff changeset
96 // Reset the crop area every reset_count frames, if reset_count is > 0
55bf07ab4c89 Add an option to cropdetect to periodically reset the detected area.
reimar
parents: 29263
diff changeset
97 if(vf->priv->reset_count > 0 && vf->priv->fno > vf->priv->reset_count){
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
98 vf->priv->x1=mpi->w-1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
99 vf->priv->y1=mpi->h-1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
100 vf->priv->x2=0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
101 vf->priv->y2=0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
102 vf->priv->fno=1;
30394
55bf07ab4c89 Add an option to cropdetect to periodically reset the detected area.
reimar
parents: 29263
diff changeset
103 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25221
diff changeset
104
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
105 for(y=0;y<vf->priv->y1;y++){
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
106 if(checkline(mpi->planes[0]+mpi->stride[0]*y,bpp,mpi->w,bpp)>vf->priv->limit){
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
107 vf->priv->y1=y;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
108 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
109 }
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
110 }
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
111
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
112 for(y=mpi->h-1;y>vf->priv->y2;y--){
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
113 if(checkline(mpi->planes[0]+mpi->stride[0]*y,bpp,mpi->w,bpp)>vf->priv->limit){
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
114 vf->priv->y2=y;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
115 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
116 }
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
117 }
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
118
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
119 for(y=0;y<vf->priv->x1;y++){
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
120 if(checkline(mpi->planes[0]+bpp*y,mpi->stride[0],mpi->h,bpp)>vf->priv->limit){
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
121 vf->priv->x1=y;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
122 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
123 }
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
124 }
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
125
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
126 for(y=mpi->w-1;y>vf->priv->x2;y--){
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
127 if(checkline(mpi->planes[0]+bpp*y,mpi->stride[0],mpi->h,bpp)>vf->priv->limit){
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
128 vf->priv->x2=y;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
129 break;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
130 }
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
131 }
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
132
13205
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
133 // round x and y (up), important for yuv colorspaces
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
134 // make sure they stay rounded!
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
135 x=(vf->priv->x1+1)&(~1);
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
136 y=(vf->priv->y1+1)&(~1);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25221
diff changeset
137
14588
36b24b57ab53 x1 and y1 give last used position, must be < width/height
reimar
parents: 13233
diff changeset
138 w = vf->priv->x2 - x + 1;
36b24b57ab53 x1 and y1 give last used position, must be < width/height
reimar
parents: 13233
diff changeset
139 h = vf->priv->y2 - y + 1;
13205
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
140
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
141 // w and h must be divisible by 2 as well because of yuv
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
142 // colorspace problems.
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
143 if (vf->priv->round <= 1)
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
144 vf->priv->round = 16;
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
145 if (vf->priv->round % 2)
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
146 vf->priv->round *= 2;
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
147
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
148 shrink_by = w % vf->priv->round;
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
149 w -= shrink_by;
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
150 x += (shrink_by / 2 + 1) & ~1;
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
151
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
152 shrink_by = h % vf->priv->round;
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
153 h -= shrink_by;
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
154 y += (shrink_by / 2 + 1) & ~1;
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
155
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
156 mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_CropArea,
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
157 vf->priv->x1,vf->priv->x2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
158 vf->priv->y1,vf->priv->y2,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 30642
diff changeset
159 w,h,x,y);
13205
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
160
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
161
6118
f869ece65aab ignore first 2 frames
arpi
parents: 6117
diff changeset
162 }
f869ece65aab ignore first 2 frames
arpi
parents: 6117
diff changeset
163
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
164 return vf_next_put_image(vf,dmpi, pts);
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
165 }
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
166
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
167 static int query_format(struct vf_instance *vf, unsigned int fmt) {
16107
8d4a3c9001de restrict to YV12 since the default limit does not work well for anything else.
reimar
parents: 14588
diff changeset
168 switch(fmt) {
8d4a3c9001de restrict to YV12 since the default limit does not work well for anything else.
reimar
parents: 14588
diff changeset
169 // the default limit value works only right with YV12 right now.
8d4a3c9001de restrict to YV12 since the default limit does not work well for anything else.
reimar
parents: 14588
diff changeset
170 case IMGFMT_YV12:
8d4a3c9001de restrict to YV12 since the default limit does not work well for anything else.
reimar
parents: 14588
diff changeset
171 return vf_next_query_format(vf, fmt);
8d4a3c9001de restrict to YV12 since the default limit does not work well for anything else.
reimar
parents: 14588
diff changeset
172 }
8d4a3c9001de restrict to YV12 since the default limit does not work well for anything else.
reimar
parents: 14588
diff changeset
173 return 0;
8d4a3c9001de restrict to YV12 since the default limit does not work well for anything else.
reimar
parents: 14588
diff changeset
174 }
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
175 //===========================================================================//
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
176
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30421
diff changeset
177 static int vf_open(vf_instance_t *vf, char *args){
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
178 vf->config=config;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
179 vf->put_image=put_image;
16107
8d4a3c9001de restrict to YV12 since the default limit does not work well for anything else.
reimar
parents: 14588
diff changeset
180 vf->query_format=query_format;
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
181 vf->priv=malloc(sizeof(struct vf_priv_s));
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
182 vf->priv->limit=24; // should be option
13233
3b85939d9f0a missing initialization of round
reimar
parents: 13205
diff changeset
183 vf->priv->round = 0;
30394
55bf07ab4c89 Add an option to cropdetect to periodically reset the detected area.
reimar
parents: 29263
diff changeset
184 vf->priv->reset_count = 0;
55bf07ab4c89 Add an option to cropdetect to periodically reset the detected area.
reimar
parents: 29263
diff changeset
185 if(args) sscanf(args, "%d:%d:%d",
13205
08bb01a9905a Adds rounding parameter for width and height values returned.
reimar
parents: 11261
diff changeset
186 &vf->priv->limit,
30394
55bf07ab4c89 Add an option to cropdetect to periodically reset the detected area.
reimar
parents: 29263
diff changeset
187 &vf->priv->round,
55bf07ab4c89 Add an option to cropdetect to periodically reset the detected area.
reimar
parents: 29263
diff changeset
188 &vf->priv->reset_count);
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
189 return 1;
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
190 }
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
191
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 23373
diff changeset
192 const vf_info_t vf_info_cropdetect = {
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
193 "autodetect crop size",
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
194 "cropdetect",
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
195 "A'rpi",
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
196 "",
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 30421
diff changeset
197 vf_open,
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 7472
diff changeset
198 NULL
6061
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
199 };
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
200
5343ef6b8c23 new filter, to detect best crop size
arpi
parents:
diff changeset
201 //===========================================================================//