The following commit will make it useless. The crop_scale_vflip FATE test changes because of off-by-one differences in output when vflipped slices are passed to sws.
Unified · Split
| @@ -1946,21 +1946,6 @@ Adler-32 checksum of each plane of the input frame, expressed in the form · 1945 unmodified lines | |||
| 1946 | "[@var{c0} @var{c1} @var{c2} @var{c3}]" | 1946 | "[@var{c0} @var{c1} @var{c2} @var{c3}]" |
| 1947 | @end table | 1947 | @end table |
| 1948 | 1948 | ||
| 1949 | @section slicify | ||
| 1950 | |||
| 1951 | Pass the images of input video on to next video filter as multiple | ||
| 1952 | slices. | ||
| 1953 | |||
| 1954 | @example | ||
| 1955 | ./avconv -i in.avi -vf "slicify=32" out.avi | ||
| 1956 | @end example | ||
| 1957 | |||
| 1958 | The filter accepts the slice height as parameter. If the parameter is | ||
| 1959 | not specified it will use the default value of 16. | ||
| 1960 | |||
| 1961 | Adding this in the beginning of filter chains should make filtering | ||
| 1962 | faster due to better use of the memory cache. | ||
| 1963 | |||
| 1964 | @section split | 1949 | @section split |
| 1965 | 1950 | ||
| 1966 | Split input video into several identical outputs. | 1951 | Split input video into several identical outputs. |
| @@ -74,7 +74,6 @@ OBJS-$(CONFIG_SETPTS_FILTER) += vf_setpts.o · 73 unmodified lines | |||
| 74 | OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o | 74 | OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o |
| 75 | OBJS-$(CONFIG_SETTB_FILTER) += vf_settb.o | 75 | OBJS-$(CONFIG_SETTB_FILTER) += vf_settb.o |
| 76 | OBJS-$(CONFIG_SHOWINFO_FILTER) += vf_showinfo.o | 76 | OBJS-$(CONFIG_SHOWINFO_FILTER) += vf_showinfo.o |
| 77 | OBJS-$(CONFIG_SLICIFY_FILTER) += vf_slicify.o | ||
| 78 | OBJS-$(CONFIG_SPLIT_FILTER) += split.o | 77 | OBJS-$(CONFIG_SPLIT_FILTER) += split.o |
| 79 | OBJS-$(CONFIG_TRANSPOSE_FILTER) += vf_transpose.o | 78 | OBJS-$(CONFIG_TRANSPOSE_FILTER) += vf_transpose.o |
| 80 | OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o | 79 | OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o |
| @@ -85,7 +85,6 @@ void avfilter_register_all(void) · 84 unmodified lines | |||
| 85 | REGISTER_FILTER (SETSAR, setsar, vf); | 85 | REGISTER_FILTER (SETSAR, setsar, vf); |
| 86 | REGISTER_FILTER (SETTB, settb, vf); | 86 | REGISTER_FILTER (SETTB, settb, vf); |
| 87 | REGISTER_FILTER (SHOWINFO, showinfo, vf); | 87 | REGISTER_FILTER (SHOWINFO, showinfo, vf); |
| 88 | REGISTER_FILTER (SLICIFY, slicify, vf); | ||
| 89 | REGISTER_FILTER (SPLIT, split, vf); | 88 | REGISTER_FILTER (SPLIT, split, vf); |
| 90 | REGISTER_FILTER (TRANSPOSE, transpose, vf); | 89 | REGISTER_FILTER (TRANSPOSE, transpose, vf); |
| 91 | REGISTER_FILTER (UNSHARP, unsharp, vf); | 90 | REGISTER_FILTER (UNSHARP, unsharp, vf); |
| @@ -1,141 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2007 Bobby Bingham | ||
| 3 | * | ||
| 4 | * This file is part of Libav. | ||
| 5 | * | ||
| 6 | * Libav 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 | * Libav 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 Libav; 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 | ||
| 23 | * video slicing filter | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include "avfilter.h" | ||
| 27 | #include "internal.h" | ||
| 28 | #include "video.h" | ||
| 29 | #include "libavutil/common.h" | ||
| 30 | #include "libavutil/pixdesc.h" | ||
| 31 | |||
| 32 | typedef struct { | ||
| 33 | int h; ///< output slice height | ||
| 34 | int vshift; ///< vertical chroma subsampling shift | ||
| 35 | uint32_t lcg_state; ///< LCG state used to compute random slice height | ||
| 36 | int use_random_h; ///< enable the use of random slice height values | ||
| 37 | } SliceContext; | ||
| 38 | |||
| 39 | static av_cold int init(AVFilterContext *ctx, const char *args) | ||
| 40 | { | ||
| 41 | SliceContext *slice = ctx->priv; | ||
| 42 | |||
| 43 | slice->h = 16; | ||
| 44 | if (args) { | ||
| 45 | if (!strcmp(args, "random")) { | ||
| 46 | slice->use_random_h = 1; | ||
| 47 | } else { | ||
| 48 | sscanf(args, "%d", &slice->h); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | return 0; | ||
| 52 | } | ||
| 53 | |||
| 54 | static int config_props(AVFilterLink *link) | ||
| 55 | { | ||
| 56 | SliceContext *slice = link->dst->priv; | ||
| 57 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); | ||
| 58 | |||
| 59 | slice->vshift = desc->log2_chroma_h; | ||
| 60 | |||
| 61 | return 0; | ||
| 62 | } | ||
| 63 | |||
| 64 | static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) | ||
| 65 | { | ||
| 66 | SliceContext *slice = link->dst->priv; | ||
| 67 | |||
| 68 | if (slice->use_random_h) { | ||
| 69 | slice->lcg_state = slice->lcg_state * 1664525 + 1013904223; | ||
| 70 | slice->h = 8 + (uint64_t)slice->lcg_state * 25 / UINT32_MAX; | ||
| 71 | } | ||
| 72 | |||
| 73 | /* ensure that slices play nice with chroma subsampling, and enforce | ||
| 74 | * a reasonable minimum size for the slices */ | ||
| 75 | slice->h = FFMAX(8, slice->h & (-1 << slice->vshift)); | ||
| 76 | |||
| 77 | av_log(link->dst, AV_LOG_DEBUG, "h:%d\n", slice->h); | ||
| 78 | link->cur_buf = NULL; | ||
| 79 | |||
| 80 | return ff_start_frame(link->dst->outputs[0], picref); | ||
| 81 | } | ||
| 82 | |||
| 83 | static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir) | ||
| 84 | { | ||
| 85 | SliceContext *slice = link->dst->priv; | ||
| 86 | int y2, ret = 0; | ||
| 87 | |||
| 88 | if (slice_dir == 1) { | ||
| 89 | for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h) { | ||
| 90 | ret = ff_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir); | ||
| 91 | if (ret < 0) | ||
| 92 | return ret; | ||
| 93 | } | ||
| 94 | |||
| 95 | if (y2 < y + h) | ||
| 96 | return ff_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir); | ||
| 97 | } else if (slice_dir == -1) { | ||
| 98 | for (y2 = y + h; y2 - slice->h >= y; y2 -= slice->h) { | ||
| 99 | ret = ff_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir); | ||
| 100 | if (ret < 0) | ||
| 101 | return ret; | ||
| 102 | } | ||
| 103 | |||
| 104 | if (y2 > y) | ||
| 105 | return ff_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir); | ||
| 106 | } | ||
| 107 | return 0; | ||
| 108 | } | ||
| 109 | |||
| 110 | static const AVFilterPad avfilter_vf_slicify_inputs[] = { | ||
| 111 | { | ||
| 112 | .name = "default", | ||
| 113 | .type = AVMEDIA_TYPE_VIDEO, | ||
| 114 | .get_video_buffer = ff_null_get_video_buffer, | ||
| 115 | .start_frame = start_frame, | ||
| 116 | .draw_slice = draw_slice, | ||
| 117 | .config_props = config_props, | ||
| 118 | .end_frame = ff_null_end_frame, | ||
| 119 | }, | ||
| 120 | { NULL } | ||
| 121 | }; | ||
| 122 | |||
| 123 | static const AVFilterPad avfilter_vf_slicify_outputs[] = { | ||
| 124 | { | ||
| 125 | .name = "default", | ||
| 126 | .type = AVMEDIA_TYPE_VIDEO, | ||
| 127 | }, | ||
| 128 | { NULL } | ||
| 129 | }; | ||
| 130 | |||
| 131 | AVFilter avfilter_vf_slicify = { | ||
| 132 | .name = "slicify", | ||
| 133 | .description = NULL_IF_CONFIG_SMALL("Pass the images of input video on to next video filter as multiple slices."), | ||
| 134 | |||
| 135 | .init = init, | ||
| 136 | |||
| 137 | .priv_size = sizeof(SliceContext), | ||
| 138 | |||
| 139 | .inputs = avfilter_vf_slicify_inputs, | ||
| 140 | .outputs = avfilter_vf_slicify_outputs, | ||
| 141 | }; | ||
| @@ -21,10 +21,8 @@ do_video_filter() { · 20 unmodified lines | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | do_lavfi() { | 23 | do_lavfi() { |
| 24 | vfilters="slicify=random,$2" | ||
| 25 | |||
| 26 | if [ $test = $1 ] ; then | 24 | if [ $test = $1 ] ; then |
| 27 | do_video_filter $test "$vfilters" | 25 | do_video_filter $test "$2" |
| 28 | fi | 26 | fi |
| 29 | } | 27 | } |
| 30 | 28 | ||
| @@ -54,7 +52,7 @@ do_lavfi_pixfmts(){ · 23 unmodified lines | |||
| 54 | 52 | ||
| 55 | pix_fmts=$($showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ print $3 }' | sort | comm -12 - $out_fmts) | 53 | pix_fmts=$($showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ print $3 }' | sort | comm -12 - $out_fmts) |
| 56 | for pix_fmt in $pix_fmts; do | 54 | for pix_fmt in $pix_fmts; do |
| 57 | do_video_filter $pix_fmt "slicify=random,format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt | 55 | do_video_filter $pix_fmt "format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt |
| 58 | done | 56 | done |
| 59 | 57 | ||
| 60 | rm $exclude_fmts $out_fmts | 58 | rm $exclude_fmts $out_fmts |
| @@ -72,7 +70,7 @@ do_lavfi_pixfmts "vflip" "" · 11 unmodified lines | |||
| 72 | if [ -n "$do_pixdesc" ]; then | 70 | if [ -n "$do_pixdesc" ]; then |
| 73 | pix_fmts="$($avconv -pix_fmts list 2>/dev/null | awk 'NR > 8 && /^IO/ { print $2 }' | sort)" | 71 | pix_fmts="$($avconv -pix_fmts list 2>/dev/null | awk 'NR > 8 && /^IO/ { print $2 }' | sort)" |
| 74 | for pix_fmt in $pix_fmts; do | 72 | for pix_fmt in $pix_fmts; do |
| 75 | do_video_filter $pix_fmt "slicify=random,format=$pix_fmt,pixdesctest" -pix_fmt $pix_fmt | 73 | do_video_filter $pix_fmt "format=$pix_fmt,pixdesctest" -pix_fmt $pix_fmt |
| 76 | done | 74 | done |
| 77 | fi | 75 | fi |
| 78 | 76 | ||
| @@ -1 +1 @@ | |||
| 1 | crop_scale_vflip e88a4dfb960d0bb28ee875567bedde5d | 1 | crop_scale_vflip 3e2c7694d37733ca52e1723d5262af36 |