annotate libmpcodecs/vf_unsharp.c @ 33672:e576232a39d5

Prevent balance from hopping. Only recalculate the balance if the balance has changed, not if just the volume has changed. Because (at least with my soundcard) not all volume values can be stored, but seem to be mapped onto a discrete value set, recalculation the balance from the volume isn't accurate enough.
author ib
date Tue, 28 Jun 2011 18:16:06 +0000
parents c4287381e2ea
children b510e6c95427
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
1 /*
26727
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
2 * Copyright (C) 2002 Remi Guyomarch <rguyom@pobox.com>
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
3 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
4 * This file is part of MPlayer.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
5 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
7 * it under the terms of the GNU General Public License as published by
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
9 * (at your option) any later version.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
10 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
14 * GNU General Public License for more details.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
15 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
16 * You should have received a copy of the GNU General Public License along
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
19 */
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
20
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
21 #include <stdio.h>
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
22 #include <stdlib.h>
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
23 #include <string.h>
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
24 #include <inttypes.h>
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
25 #include <math.h>
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
26
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14542
diff changeset
27 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14542
diff changeset
28 #include "mp_msg.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14542
diff changeset
29 #include "cpudetect.h"
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
30
28594
df67d03dde3b Convert HAVE_MALLOC_H into a 0/1 definition, fixes the warning:
diego
parents: 28290
diff changeset
31 #if HAVE_MALLOC_H
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
32 #include <malloc.h>
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
33 #endif
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
34
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
35 #include "img_format.h"
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
36 #include "mp_image.h"
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
37 #include "vf.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14542
diff changeset
38 #include "libvo/fastmemcpy.h"
22377
fd54975f9135 Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
reimar
parents: 17906
diff changeset
39 #include "libavutil/common.h"
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
40
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
41 //===========================================================================//
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
42
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
43 #define MIN_MATRIX_SIZE 3
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
44 #define MAX_MATRIX_SIZE 63
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
45
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
46 typedef struct FilterParam {
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
47 int msizeX, msizeY;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
48 double amount;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
49 uint32_t *SC[MAX_MATRIX_SIZE-1];
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
50 } FilterParam;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
51
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
52 struct vf_priv_s {
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
53 FilterParam lumaParam;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
54 FilterParam chromaParam;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
55 unsigned int outfmt;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
56 };
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
57
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
58
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
59 //===========================================================================//
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
60
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
61 /* This code is based on :
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
62
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
63 An Efficient algorithm for Gaussian blur using finite-state machines
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
64 Frederick M. Waltz and John W. V. Miller
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
65
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
66 SPIE Conf. on Machine Vision Systems for Inspection and Metrology VII
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
67 Originally published Boston, Nov 98
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
68
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
69 */
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
70
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
71 static void unsharp( uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int width, int height, FilterParam *fp ) {
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
72
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
73 uint32_t **SC = fp->SC;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
74 uint32_t SR[MAX_MATRIX_SIZE-1], Tmp1, Tmp2;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
75 uint8_t* src2 = src; // avoid gcc warning
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
76
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
77 int32_t res;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
78 int x, y, z;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
79 int amount = fp->amount * 65536.0;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
80 int stepsX = fp->msizeX/2;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
81 int stepsY = fp->msizeY/2;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
82 int scalebits = (stepsX+stepsY)*2;
8015
403f7a58ccf2 vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents: 7966
diff changeset
83 int32_t halfscale = 1 << ((stepsX+stepsY)*2-1);
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
84
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
85 if( !fp->amount ) {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
86 if( src == dst )
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
87 return;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
88 if( dstStride == srcStride )
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
89 fast_memcpy( dst, src, srcStride*height );
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
90 else
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
91 for( y=0; y<height; y++, dst+=dstStride, src+=srcStride )
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
92 fast_memcpy( dst, src, width );
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
93 return;
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
94 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
95
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
96 for( y=0; y<2*stepsY; y++ )
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
97 memset( SC[y], 0, sizeof(SC[y][0]) * (width+2*stepsX) );
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
98
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
99 for( y=-stepsY; y<height+stepsY; y++ ) {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
100 if( y < height ) src2 = src;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
101 memset( SR, 0, sizeof(SR[0]) * (2*stepsX-1) );
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
102 for( x=-stepsX; x<width+stepsX; x++ ) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
103 Tmp1 = x<=0 ? src2[0] : x>=width ? src2[width-1] : src2[x];
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
104 for( z=0; z<stepsX*2; z+=2 ) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
105 Tmp2 = SR[z+0] + Tmp1; SR[z+0] = Tmp1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
106 Tmp1 = SR[z+1] + Tmp2; SR[z+1] = Tmp2;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
107 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
108 for( z=0; z<stepsY*2; z+=2 ) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
109 Tmp2 = SC[z+0][x+stepsX] + Tmp1; SC[z+0][x+stepsX] = Tmp1;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
110 Tmp1 = SC[z+1][x+stepsX] + Tmp2; SC[z+1][x+stepsX] = Tmp2;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
111 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
112 if( x>=stepsX && y>=stepsY ) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
113 uint8_t* srx = src - stepsY*srcStride + x - stepsX;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
114 uint8_t* dsx = dst - stepsY*dstStride + x - stepsX;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
115
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
116 res = (int32_t)*srx + ( ( ( (int32_t)*srx - (int32_t)((Tmp1+halfscale) >> scalebits) ) * amount ) >> 16 );
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
117 *dsx = res>255 ? 255 : res<0 ? 0 : (uint8_t)res;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
118 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
119 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
120 if( y >= 0 ) {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
121 dst += dstStride;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
122 src += srcStride;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
123 }
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
124 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
125 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
126
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
127 //===========================================================================//
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
128
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
129 static int config( struct vf_instance *vf,
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
130 int width, int height, int d_width, int d_height,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
131 unsigned int flags, unsigned int outfmt ) {
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
132
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
133 int z, stepsX, stepsY;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
134 FilterParam *fp;
33450
c4287381e2ea Add const to variable storing string constant pointers.
reimar
parents: 32702
diff changeset
135 const char *effect;
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
136
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
137 // allocate buffers
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
138
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
139 fp = &vf->priv->lumaParam;
8015
403f7a58ccf2 vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents: 7966
diff changeset
140 effect = fp->amount == 0 ? "don't touch" : fp->amount < 0 ? "blur" : "sharpen";
403f7a58ccf2 vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents: 7966
diff changeset
141 mp_msg( MSGT_VFILTER, MSGL_INFO, "unsharp: %dx%d:%0.2f (%s luma) \n", fp->msizeX, fp->msizeY, fp->amount, effect );
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
142 memset( fp->SC, 0, sizeof( fp->SC ) );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
143 stepsX = fp->msizeX/2;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
144 stepsY = fp->msizeY/2;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
145 for( z=0; z<2*stepsY; z++ )
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
146 fp->SC[z] = av_malloc(sizeof(*(fp->SC[z])) * (width+2*stepsX));
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
147
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
148 fp = &vf->priv->chromaParam;
8015
403f7a58ccf2 vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents: 7966
diff changeset
149 effect = fp->amount == 0 ? "don't touch" : fp->amount < 0 ? "blur" : "sharpen";
403f7a58ccf2 vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents: 7966
diff changeset
150 mp_msg( MSGT_VFILTER, MSGL_INFO, "unsharp: %dx%d:%0.2f (%s chroma)\n", fp->msizeX, fp->msizeY, fp->amount, effect );
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
151 memset( fp->SC, 0, sizeof( fp->SC ) );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
152 stepsX = fp->msizeX/2;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
153 stepsY = fp->msizeY/2;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
154 for( z=0; z<2*stepsY; z++ )
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
155 fp->SC[z] = av_malloc(sizeof(*(fp->SC[z])) * (width+2*stepsX));
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
156
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
157 return vf_next_config( vf, width, height, d_width, d_height, flags, outfmt );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
158 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
159
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
160 //===========================================================================//
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
161
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
162 static void get_image( struct vf_instance *vf, mp_image_t *mpi ) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
163 if( mpi->flags & MP_IMGFLAG_PRESERVE )
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
164 return; // don't change
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
165 if( mpi->imgfmt!=vf->priv->outfmt )
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
166 return; // colorspace differ
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
167
10141
7d6a854a5fe5 cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents: 9934
diff changeset
168 vf->dmpi = vf_get_image( vf->next, mpi->imgfmt, mpi->type, mpi->flags, mpi->w, mpi->h );
7d6a854a5fe5 cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents: 9934
diff changeset
169 mpi->planes[0] = vf->dmpi->planes[0];
7d6a854a5fe5 cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents: 9934
diff changeset
170 mpi->stride[0] = vf->dmpi->stride[0];
7d6a854a5fe5 cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents: 9934
diff changeset
171 mpi->width = vf->dmpi->width;
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
172 if( mpi->flags & MP_IMGFLAG_PLANAR ) {
10141
7d6a854a5fe5 cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents: 9934
diff changeset
173 mpi->planes[1] = vf->dmpi->planes[1];
7d6a854a5fe5 cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents: 9934
diff changeset
174 mpi->planes[2] = vf->dmpi->planes[2];
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
175 mpi->stride[1] = vf->dmpi->stride[1];
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
176 mpi->stride[2] = vf->dmpi->stride[2];
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
177 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
178 mpi->flags |= MP_IMGFLAG_DIRECT;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
179 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
180
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
181 static int put_image( struct vf_instance *vf, mp_image_t *mpi, double pts) {
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
182 mp_image_t *dmpi;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
183
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
184 if( !(mpi->flags & MP_IMGFLAG_DIRECT) )
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
185 // no DR, so get a new image! hope we'll get DR buffer:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
186 vf->dmpi = vf_get_image( vf->next,vf->priv->outfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->w, mpi->h);
10141
7d6a854a5fe5 cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents: 9934
diff changeset
187 dmpi= vf->dmpi;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
188
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
189 unsharp( dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, &vf->priv->lumaParam );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
190 unsharp( dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, &vf->priv->chromaParam );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
191 unsharp( dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2, &vf->priv->chromaParam );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
192
9934
89da8ec89558 vf_clone_mpi_attributes()
michael
parents: 9593
diff changeset
193 vf_clone_mpi_attributes(dmpi, mpi);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
194
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27754
diff changeset
195 #if HAVE_MMX
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
196 if(gCpuCaps.hasMMX)
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
197 __asm__ volatile ("emms\n\t");
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
198 #endif
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27754
diff changeset
199 #if HAVE_MMX2
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
200 if(gCpuCaps.hasMMX2)
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
201 __asm__ volatile ("sfence\n\t");
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
202 #endif
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
203
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17367
diff changeset
204 return vf_next_put_image( vf, dmpi, pts);
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
205 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
206
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
207 static void uninit( struct vf_instance *vf ) {
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
208 unsigned int z;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
209 FilterParam *fp;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
210
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
211 if( !vf->priv ) return;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
212
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
213 fp = &vf->priv->lumaParam;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
214 for( z=0; z<sizeof(fp->SC)/sizeof(fp->SC[0]); z++ ) {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
215 av_free( fp->SC[z] );
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
216 fp->SC[z] = NULL;
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
217 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
218 fp = &vf->priv->chromaParam;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
219 for( z=0; z<sizeof(fp->SC)/sizeof(fp->SC[0]); z++ ) {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
220 av_free( fp->SC[z] );
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
221 fp->SC[z] = NULL;
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
222 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
223
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
224 free( vf->priv );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
225 vf->priv = NULL;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
226 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
227
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
228 //===========================================================================//
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
229
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
230 static int query_format( struct vf_instance *vf, unsigned int fmt ) {
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
231 switch(fmt) {
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
232 case IMGFMT_YV12:
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
233 case IMGFMT_I420:
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
234 case IMGFMT_IYUV:
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
235 return vf_next_query_format( vf, vf->priv->outfmt );
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
236 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
237 return 0;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
238 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
239
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
240 //===========================================================================//
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
241
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
242 static void parse( FilterParam *fp, char* args ) {
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
243
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
244 // l7x5:0.8:c3x3:-0.2
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
245
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
246 char *z;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
247 char *pos = args;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
248 char *max = args + strlen(args);
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
249
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
250 // parse matrix sizes
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
251 fp->msizeX = ( pos && pos+1<max ) ? atoi( pos+1 ) : 0;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
252 z = strchr( pos+1, 'x' );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
253 fp->msizeY = ( z && z+1<max ) ? atoi( pos=z+1 ) : fp->msizeX;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
254
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
255 // min/max & odd
22377
fd54975f9135 Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
reimar
parents: 17906
diff changeset
256 fp->msizeX = 1 | av_clip(fp->msizeX, MIN_MATRIX_SIZE, MAX_MATRIX_SIZE);
fd54975f9135 Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
reimar
parents: 17906
diff changeset
257 fp->msizeY = 1 | av_clip(fp->msizeY, MIN_MATRIX_SIZE, MAX_MATRIX_SIZE);
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
258
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
259 // parse amount
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
260 pos = strchr( pos+1, ':' );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
261 fp->amount = ( pos && pos+1<max ) ? atof( pos+1 ) : 0;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
262 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
263
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
264 //===========================================================================//
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
265
30708
8a96d56b01f0 Mark all fmt_list arrays as const.
diego
parents: 30642
diff changeset
266 static const unsigned int fmt_list[] = {
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
267 IMGFMT_YV12,
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
268 IMGFMT_I420,
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
269 IMGFMT_IYUV,
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
270 0
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
271 };
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
272
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 29263
diff changeset
273 static int vf_open( vf_instance_t *vf, char *args ) {
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
274 vf->config = config;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
275 vf->put_image = put_image;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
276 vf->get_image = get_image;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
277 vf->query_format = query_format;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
278 vf->uninit = uninit;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
279 vf->priv = malloc( sizeof(struct vf_priv_s) );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
280 memset( vf->priv, 0, sizeof(struct vf_priv_s) );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
281
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
282 if( args ) {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
283 char *args2 = strchr( args, 'l' );
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
284 if( args2 )
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
285 parse( &vf->priv->lumaParam, args2 );
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
286 else {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
287 vf->priv->lumaParam.amount =
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
288 vf->priv->lumaParam.msizeX =
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
289 vf->priv->lumaParam.msizeY = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
290 }
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
291
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
292 args2 = strchr( args, 'c' );
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
293 if( args2 )
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
294 parse( &vf->priv->chromaParam, args2 );
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
295 else {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
296 vf->priv->chromaParam.amount =
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
297 vf->priv->chromaParam.msizeX =
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
298 vf->priv->chromaParam.msizeY = 0;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
299 }
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
300
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
301 if( !vf->priv->lumaParam.msizeX && !vf->priv->chromaParam.msizeX )
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
302 return 0; // nothing to do
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
303 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
304
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
305 // check csp:
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
306 vf->priv->outfmt = vf_match_csp( &vf->next, fmt_list, IMGFMT_YV12 );
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
307 if( !vf->priv->outfmt ) {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
308 uninit( vf );
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
309 return 0; // no csp match :(
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
310 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
311
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
312 return 1;
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
313 }
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
314
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 23457
diff changeset
315 const vf_info_t vf_info_unsharp = {
8015
403f7a58ccf2 vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents: 7966
diff changeset
316 "unsharp mask & gaussian blur",
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
317 "unsharp",
22507
a46ab26b2d5e Source files should not contain non-ASCII characters.
diego
parents: 22377
diff changeset
318 "Remi Guyomarch",
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
319 "",
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 29263
diff changeset
320 vf_open,
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8083
diff changeset
321 NULL
7966
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
322 };
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
323
a03235a5f395 new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff changeset
324 //===========================================================================//