History

Add slicify video filter.

Originally committed as revision 20445 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini committed 17 years ago

Commit bc37ec91 parent da23d425 files · +126 −2Browse files

Unified · Split

5 files
  1. doc/libavfilter.texi +15 −0
  2. libavfilter/Makefile +1 −0
  3. libavfilter/allfilters.c +1 −0
  4. libavfilter/avfilter.h +2 −2
  5. libavfilter/vf_slicify.c +107 −0
doc/libavfilter.texi+15−0
@@ -149,6 +149,21 @@ input to the vflip filter. · 148 unmodified lines
149 149
150Pass the source unchanged to the output.150Pass the source unchanged to the output.
151 151
152@section slicify
153
154Pass the images of input video on to next video filter as multiple
155slices.
156
157@example
158./ffmpeg -i in.avi -vfilters "slicify=32" out.avi
159@end example
160
161The filter accepts the slice height as parameter. If the parameter is
162not specified it will use the default value of 16.
163
164Adding this in the beginning of filter chains should make filtering
165faster due to better use of the memory cache.
166
152@section vflip167@section vflip
153 168
154Flip the input video vertically.169Flip the input video vertically.
libavfilter/Makefile+1−0
@@ -15,6 +15,7 @@ OBJS-$(CONFIG_CROP_FILTER) += vf_crop.o · 14 unmodified lines
15OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o15OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o
16OBJS-$(CONFIG_NOFORMAT_FILTER) += vf_format.o16OBJS-$(CONFIG_NOFORMAT_FILTER) += vf_format.o
17OBJS-$(CONFIG_NULL_FILTER) += vf_null.o17OBJS-$(CONFIG_NULL_FILTER) += vf_null.o
18OBJS-$(CONFIG_SLICIFY_FILTER) += vf_slicify.o
18OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o19OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o
19 20
20include $(SUBDIR)../subdir.mak21include $(SUBDIR)../subdir.mak
libavfilter/allfilters.c+1−0
@@ -38,5 +38,6 @@ void avfilter_register_all(void) · 37 unmodified lines
38 REGISTER_FILTER (FORMAT,format,vf);38 REGISTER_FILTER (FORMAT,format,vf);
39 REGISTER_FILTER (NOFORMAT,noformat,vf);39 REGISTER_FILTER (NOFORMAT,noformat,vf);
40 REGISTER_FILTER (NULL,null,vf);40 REGISTER_FILTER (NULL,null,vf);
41 REGISTER_FILTER (SLICIFY,slicify,vf);
41 REGISTER_FILTER (VFLIP,vflip,vf);42 REGISTER_FILTER (VFLIP,vflip,vf);
42}43}
libavfilter/avfilter.h+2−2
@@ -23,8 +23,8 @@ · 22 unmodified lines
23#define AVFILTER_AVFILTER_H23#define AVFILTER_AVFILTER_H
24 24
25#define LIBAVFILTER_VERSION_MAJOR 125#define LIBAVFILTER_VERSION_MAJOR 1
26#define LIBAVFILTER_VERSION_MINOR 626#define LIBAVFILTER_VERSION_MINOR 7
27#define LIBAVFILTER_VERSION_MICRO 127#define LIBAVFILTER_VERSION_MICRO 0
28 28
29#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \29#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
30 LIBAVFILTER_VERSION_MINOR, \30 LIBAVFILTER_VERSION_MINOR, \
libavfilter/vf_slicify.c+107−0
@@ -0,0 +1,107 @@
1/*
2 * copyright (c) 2007 Bobby Bingham
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file libavfilter/vf_slicify.c
23 * video slicing filter
24 */
25
26#include "avfilter.h"
27
28typedef struct {
29 int h; ///< output slice height
30 int vshift; ///< vertical chroma subsampling shift
31} SliceContext;
32
33static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
34{
35 SliceContext *slice = ctx->priv;
36
37 slice->h = 16;
38 if (args)
39 sscanf(args, "%d", &slice->h);
40
41 return 0;
42}
43
44static int config_props(AVFilterLink *link)
45{
46 SliceContext *slice = link->dst->priv;
47 int tmp;
48
49 avcodec_get_chroma_sub_sample(link->format, &tmp, &slice->vshift);
50
51 /* ensure that slices play nice with chroma subsampling, and enforce
52 * a reasonable minimum size for the slices */
53 slice->h = FFMAX(8, slice->h & (-1 << slice->vshift));
54
55 av_log(link->dst, AV_LOG_INFO, "h:%d\n", slice->h);
56
57 return 0;
58}
59
60static AVFilterPicRef *get_video_buffer(AVFilterLink *link, int perms,
61 int w, int h)
62{
63 return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
64}
65
66static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
67{
68 avfilter_start_frame(link->dst->outputs[0], picref);
69}
70
71static void end_frame(AVFilterLink *link)
72{
73 avfilter_end_frame(link->dst->outputs[0]);
74}
75
76static void draw_slice(AVFilterLink *link, int y, int h)
77{
78 SliceContext *slice = link->dst->priv;
79 int y2;
80
81 for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h)
82 avfilter_draw_slice(link->dst->outputs[0], y2, slice->h);
83
84 if (y2 < y + h)
85 avfilter_draw_slice(link->dst->outputs[0], y2, y + h - y2);
86}
87
88AVFilter avfilter_vf_slicify = {
89 .name = "slicify",
90 .description = "Pass the images of input video on to next video filter as multiple slices.",
91
92 .init = init,
93
94 .priv_size = sizeof(SliceContext),
95
96 .inputs = (AVFilterPad[]) {{ .name = "default",
97 .type = CODEC_TYPE_VIDEO,
98 .get_video_buffer = get_video_buffer,
99 .start_frame = start_frame,
100 .draw_slice = draw_slice,
101 .config_props = config_props,
102 .end_frame = end_frame, },
103 { .name = NULL}},
104 .outputs = (AVFilterPad[]) {{ .name = "default",
105 .type = CODEC_TYPE_VIDEO, },
106 { .name = NULL}},
107};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t