Originally committed as revision 24806 to svn://svn.ffmpeg.org/ffmpeg/trunk
Stefano Sabatini authored on 2010/08/17 23:59:12... | ... |
@@ -1492,6 +1492,7 @@ mpg_test_deps="mpeg1system_muxer mpegps_demuxer" |
1492 | 1492 |
|
1493 | 1493 |
set_ne_test_deps pixdesc |
1494 | 1494 |
set_ne_test_deps pixfmts_crop |
1495 |
+set_ne_test_deps pixfmts_hflip |
|
1495 | 1496 |
set_ne_test_deps pixfmts_null |
1496 | 1497 |
set_ne_test_deps pixfmts_pad |
1497 | 1498 |
set_ne_test_deps pixfmts_scale |
... | ... |
@@ -56,6 +56,16 @@ The following command: |
56 | 56 |
|
57 | 57 |
will convert the input video to the format ``yuv420p''. |
58 | 58 |
|
59 |
+@section hflip |
|
60 |
+ |
|
61 |
+Flip the input video horizontally. |
|
62 |
+ |
|
63 |
+For example to horizontally flip the video in input with |
|
64 |
+@file{ffmpeg}: |
|
65 |
+@example |
|
66 |
+ffmpeg -i in.avi -vf "hflip" out.avi |
|
67 |
+@end example |
|
68 |
+ |
|
59 | 69 |
@section noformat |
60 | 70 |
|
61 | 71 |
Force libavfilter not to use any of the specified pixel formats for the |
... | ... |
@@ -17,6 +17,7 @@ OBJS = allfilters.o \ |
17 | 17 |
OBJS-$(CONFIG_ASPECT_FILTER) += vf_aspect.o |
18 | 18 |
OBJS-$(CONFIG_CROP_FILTER) += vf_crop.o |
19 | 19 |
OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o |
20 |
+OBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o |
|
20 | 21 |
OBJS-$(CONFIG_NOFORMAT_FILTER) += vf_format.o |
21 | 22 |
OBJS-$(CONFIG_NULL_FILTER) += vf_null.o |
22 | 23 |
OBJS-$(CONFIG_PAD_FILTER) += vf_pad.o |
... | ... |
@@ -37,6 +37,7 @@ void avfilter_register_all(void) |
37 | 37 |
REGISTER_FILTER (ASPECT, aspect, vf); |
38 | 38 |
REGISTER_FILTER (CROP, crop, vf); |
39 | 39 |
REGISTER_FILTER (FORMAT, format, vf); |
40 |
+ REGISTER_FILTER (HFLIP, hflip, vf); |
|
40 | 41 |
REGISTER_FILTER (NOFORMAT, noformat, vf); |
41 | 42 |
REGISTER_FILTER (NULL, null, vf); |
42 | 43 |
REGISTER_FILTER (PAD, pad, vf); |
... | ... |
@@ -25,8 +25,8 @@ |
25 | 25 |
#include "libavutil/avutil.h" |
26 | 26 |
|
27 | 27 |
#define LIBAVFILTER_VERSION_MAJOR 1 |
28 |
-#define LIBAVFILTER_VERSION_MINOR 34 |
|
29 |
-#define LIBAVFILTER_VERSION_MICRO 1 |
|
28 |
+#define LIBAVFILTER_VERSION_MINOR 35 |
|
29 |
+#define LIBAVFILTER_VERSION_MICRO 0 |
|
30 | 30 |
|
31 | 31 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
32 | 32 |
LIBAVFILTER_VERSION_MINOR, \ |
33 | 33 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,167 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2007 Benoit Fouet |
|
2 |
+ * Copyright (c) 2010 Stefano Sabatini |
|
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 |
+ * @flip |
|
23 |
+ * horizontal flip filter |
|
24 |
+ */ |
|
25 |
+ |
|
26 |
+#include "avfilter.h" |
|
27 |
+#include "libavutil/pixdesc.h" |
|
28 |
+#include "libavutil/intreadwrite.h" |
|
29 |
+ |
|
30 |
+typedef struct { |
|
31 |
+ int max_step[4]; ///< max pixel step for each plane, expressed as a number of bytes |
|
32 |
+ int hsub, vsub; ///< chroma subsampling |
|
33 |
+} FlipContext; |
|
34 |
+ |
|
35 |
+static int query_formats(AVFilterContext *ctx) |
|
36 |
+{ |
|
37 |
+ static const enum PixelFormat pix_fmts[] = { |
|
38 |
+ PIX_FMT_RGB48BE, PIX_FMT_RGB48LE, |
|
39 |
+ PIX_FMT_ARGB, PIX_FMT_RGBA, |
|
40 |
+ PIX_FMT_ABGR, PIX_FMT_BGRA, |
|
41 |
+ PIX_FMT_RGB24, PIX_FMT_BGR24, |
|
42 |
+ PIX_FMT_RGB565BE, PIX_FMT_RGB565LE, |
|
43 |
+ PIX_FMT_RGB555BE, PIX_FMT_RGB555LE, |
|
44 |
+ PIX_FMT_BGR565BE, PIX_FMT_BGR565LE, |
|
45 |
+ PIX_FMT_BGR555BE, PIX_FMT_BGR555LE, |
|
46 |
+ PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE, |
|
47 |
+ PIX_FMT_YUV420P16LE, PIX_FMT_YUV420P16BE, |
|
48 |
+ PIX_FMT_YUV422P16LE, PIX_FMT_YUV422P16BE, |
|
49 |
+ PIX_FMT_YUV444P16LE, PIX_FMT_YUV444P16BE, |
|
50 |
+ PIX_FMT_YUV444P, PIX_FMT_YUV422P, |
|
51 |
+ PIX_FMT_YUV420P, PIX_FMT_YUV411P, |
|
52 |
+ PIX_FMT_YUV410P, PIX_FMT_YUV440P, |
|
53 |
+ PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, |
|
54 |
+ PIX_FMT_YUVJ420P, PIX_FMT_YUVJ440P, |
|
55 |
+ PIX_FMT_YUVA420P, |
|
56 |
+ PIX_FMT_RGB8, PIX_FMT_BGR8, |
|
57 |
+ PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, |
|
58 |
+ PIX_FMT_PAL8, PIX_FMT_GRAY8, |
|
59 |
+ PIX_FMT_NONE |
|
60 |
+ }; |
|
61 |
+ |
|
62 |
+ avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); |
|
63 |
+ return 0; |
|
64 |
+} |
|
65 |
+ |
|
66 |
+static int config_props(AVFilterLink *inlink) |
|
67 |
+{ |
|
68 |
+ FlipContext *flip = inlink->dst->priv; |
|
69 |
+ const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format]; |
|
70 |
+ int i; |
|
71 |
+ |
|
72 |
+ memset(flip->max_step, 0, sizeof(flip->max_step)); |
|
73 |
+ for (i = 0; i < 4; i++) { |
|
74 |
+ const AVComponentDescriptor *comp = &(pix_desc->comp[i]); |
|
75 |
+ if ((comp->step_minus1+1) > flip->max_step[comp->plane]) |
|
76 |
+ flip->max_step[comp->plane] = comp->step_minus1+1; |
|
77 |
+ } |
|
78 |
+ |
|
79 |
+ flip->hsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_w; |
|
80 |
+ flip->vsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_h; |
|
81 |
+ |
|
82 |
+ return 0; |
|
83 |
+} |
|
84 |
+ |
|
85 |
+static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
|
86 |
+{ |
|
87 |
+ FlipContext *flip = inlink->dst->priv; |
|
88 |
+ AVFilterBufferRef *inpic = inlink->cur_buf; |
|
89 |
+ AVFilterBufferRef *outpic = inlink->dst->outputs[0]->out_buf; |
|
90 |
+ uint8_t *inrow, *outrow; |
|
91 |
+ int i, j, plane, step, hsub, vsub; |
|
92 |
+ |
|
93 |
+ for (plane = 0; plane < 4 && inpic->data[plane]; plane++) { |
|
94 |
+ step = flip->max_step[plane]; |
|
95 |
+ hsub = (plane == 1 || plane == 2) ? flip->hsub : 0; |
|
96 |
+ vsub = (plane == 1 || plane == 2) ? flip->vsub : 0; |
|
97 |
+ |
|
98 |
+ outrow = outpic->data[plane] + (y>>vsub) * outpic->linesize[plane]; |
|
99 |
+ inrow = inpic ->data[plane] + (y>>vsub) * inpic ->linesize[plane] + ((inlink->w >> hsub) - 1) * step; |
|
100 |
+ for (i = 0; i < h>>vsub; i++) { |
|
101 |
+ switch (step) { |
|
102 |
+ case 1: |
|
103 |
+ { |
|
104 |
+ for (j = 0; j < (inlink->w >> hsub); j++) |
|
105 |
+ outrow[j] = inrow[-j]; |
|
106 |
+ } |
|
107 |
+ break; |
|
108 |
+ |
|
109 |
+ case 2: |
|
110 |
+ { |
|
111 |
+ uint16_t *outrow16 = (uint16_t *)outrow; |
|
112 |
+ uint16_t * inrow16 = (uint16_t *) inrow; |
|
113 |
+ for (j = 0; j < (inlink->w >> hsub); j++) |
|
114 |
+ outrow16[j] = inrow16[-j]; |
|
115 |
+ } |
|
116 |
+ break; |
|
117 |
+ |
|
118 |
+ case 3: |
|
119 |
+ { |
|
120 |
+ uint8_t *in = inrow; |
|
121 |
+ uint8_t *out = outrow; |
|
122 |
+ for (j = 0; j < (inlink->w >> hsub); j++, out += 3, in -= 3) { |
|
123 |
+ int32_t v = AV_RB24(in); |
|
124 |
+ AV_WB24(out, v); |
|
125 |
+ } |
|
126 |
+ } |
|
127 |
+ break; |
|
128 |
+ |
|
129 |
+ case 4: |
|
130 |
+ { |
|
131 |
+ uint32_t *outrow32 = (uint32_t *)outrow; |
|
132 |
+ uint32_t * inrow32 = (uint32_t *) inrow; |
|
133 |
+ for (j = 0; j < (inlink->w >> hsub); j++) |
|
134 |
+ outrow32[j] = inrow32[-j]; |
|
135 |
+ } |
|
136 |
+ break; |
|
137 |
+ |
|
138 |
+ default: |
|
139 |
+ for (j = 0; j < (inlink->w >> hsub); j++) |
|
140 |
+ memcpy(outrow + j*step, inrow - j*step, step); |
|
141 |
+ } |
|
142 |
+ |
|
143 |
+ inrow += inpic ->linesize[plane]; |
|
144 |
+ outrow += outpic->linesize[plane]; |
|
145 |
+ } |
|
146 |
+ } |
|
147 |
+ |
|
148 |
+ avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); |
|
149 |
+} |
|
150 |
+ |
|
151 |
+AVFilter avfilter_vf_hflip = { |
|
152 |
+ .name = "hflip", |
|
153 |
+ .description = NULL_IF_CONFIG_SMALL("Horizontally flip the input video."), |
|
154 |
+ .priv_size = sizeof(FlipContext), |
|
155 |
+ .query_formats = query_formats, |
|
156 |
+ |
|
157 |
+ .inputs = (AVFilterPad[]) {{ .name = "default", |
|
158 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
159 |
+ .draw_slice = draw_slice, |
|
160 |
+ .config_props = config_props, |
|
161 |
+ .min_perms = AV_PERM_READ, }, |
|
162 |
+ { .name = NULL}}, |
|
163 |
+ .outputs = (AVFilterPad[]) {{ .name = "default", |
|
164 |
+ .type = AVMEDIA_TYPE_VIDEO, }, |
|
165 |
+ { .name = NULL}}, |
|
166 |
+}; |
... | ... |
@@ -59,6 +59,7 @@ do_lavfi_pixfmts(){ |
59 | 59 |
|
60 | 60 |
# all these filters have exactly one input and exactly one output |
61 | 61 |
do_lavfi_pixfmts "crop" "100:100:100:100" |
62 |
+do_lavfi_pixfmts "hflip" "" |
|
62 | 63 |
do_lavfi_pixfmts "null" "" |
63 | 64 |
do_lavfi_pixfmts "pad" "500:400:20:20" |
64 | 65 |
do_lavfi_pixfmts "scale" "200:100" |
65 | 66 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,72 @@ |
0 |
+49468c6c9ceee5d52b08b1270a909323 *./tests/data/lavfi/pixfmts_hflip_le-abgr.nut |
|
1 |
+20276703 ./tests/data/lavfi/pixfmts_hflip_le-abgr.nut |
|
2 |
+50ba9f16c6475530602f2983278b82d0 *./tests/data/lavfi/pixfmts_hflip_le-argb.nut |
|
3 |
+20276703 ./tests/data/lavfi/pixfmts_hflip_le-argb.nut |
|
4 |
+cc53d2011d097972db0d22756c3699e3 *./tests/data/lavfi/pixfmts_hflip_le-bgr24.nut |
|
5 |
+15207903 ./tests/data/lavfi/pixfmts_hflip_le-bgr24.nut |
|
6 |
+aac987e7d1a6a96477cfc0b48a4285de *./tests/data/lavfi/pixfmts_hflip_le-bgr4_byte.nut |
|
7 |
+5070254 ./tests/data/lavfi/pixfmts_hflip_le-bgr4_byte.nut |
|
8 |
+ccee08679bac84a1f960c6c9070c5538 *./tests/data/lavfi/pixfmts_hflip_le-bgr555le.nut |
|
9 |
+10139054 ./tests/data/lavfi/pixfmts_hflip_le-bgr555le.nut |
|
10 |
+3703466e19e1b52e03a34fd244a8e8e4 *./tests/data/lavfi/pixfmts_hflip_le-bgr565le.nut |
|
11 |
+10139054 ./tests/data/lavfi/pixfmts_hflip_le-bgr565le.nut |
|
12 |
+50b505a889f0428242305acb642da107 *./tests/data/lavfi/pixfmts_hflip_le-bgr8.nut |
|
13 |
+5070254 ./tests/data/lavfi/pixfmts_hflip_le-bgr8.nut |
|
14 |
+01ca21e7e6a8d1281b4553bde8e8a404 *./tests/data/lavfi/pixfmts_hflip_le-bgra.nut |
|
15 |
+20276703 ./tests/data/lavfi/pixfmts_hflip_le-bgra.nut |
|
16 |
+03efcb4ab52a24c0af0e03cfd26c9377 *./tests/data/lavfi/pixfmts_hflip_le-gray.nut |
|
17 |
+5070254 ./tests/data/lavfi/pixfmts_hflip_le-gray.nut |
|
18 |
+9bcbca979601ddc4869f846f08f3d1dd *./tests/data/lavfi/pixfmts_hflip_le-gray16be.nut |
|
19 |
+10139054 ./tests/data/lavfi/pixfmts_hflip_le-gray16be.nut |
|
20 |
+c1b8965adcc7f847ee343149ff507073 *./tests/data/lavfi/pixfmts_hflip_le-gray16le.nut |
|
21 |
+10139054 ./tests/data/lavfi/pixfmts_hflip_le-gray16le.nut |
|
22 |
+754f1722fc738590cc407ac65749bfe8 *./tests/data/lavfi/pixfmts_hflip_le-rgb24.nut |
|
23 |
+15207903 ./tests/data/lavfi/pixfmts_hflip_le-rgb24.nut |
|
24 |
+10743e1577dc3198dbbc7c0b3b8f429e *./tests/data/lavfi/pixfmts_hflip_le-rgb48be.nut |
|
25 |
+30414303 ./tests/data/lavfi/pixfmts_hflip_le-rgb48be.nut |
|
26 |
+dd945a44f39119221407bf7a04f1bc49 *./tests/data/lavfi/pixfmts_hflip_le-rgb48le.nut |
|
27 |
+30414303 ./tests/data/lavfi/pixfmts_hflip_le-rgb48le.nut |
|
28 |
+c8a3f995fcf3e0919239ea2c413ddc29 *./tests/data/lavfi/pixfmts_hflip_le-rgb4_byte.nut |
|
29 |
+5070254 ./tests/data/lavfi/pixfmts_hflip_le-rgb4_byte.nut |
|
30 |
+8778ee0cf58ce9ad1d99a1eca9f95e87 *./tests/data/lavfi/pixfmts_hflip_le-rgb555le.nut |
|
31 |
+10139054 ./tests/data/lavfi/pixfmts_hflip_le-rgb555le.nut |
|
32 |
+2cb690eb3fcb72da3771ad6a48931158 *./tests/data/lavfi/pixfmts_hflip_le-rgb565le.nut |
|
33 |
+10139054 ./tests/data/lavfi/pixfmts_hflip_le-rgb565le.nut |
|
34 |
+9e462b811b9b6173397b9cfc1f6b2f17 *./tests/data/lavfi/pixfmts_hflip_le-rgb8.nut |
|
35 |
+5070254 ./tests/data/lavfi/pixfmts_hflip_le-rgb8.nut |
|
36 |
+d3d0dc1ecef3ed72f26a2986d0efc204 *./tests/data/lavfi/pixfmts_hflip_le-rgba.nut |
|
37 |
+20276703 ./tests/data/lavfi/pixfmts_hflip_le-rgba.nut |
|
38 |
+acb543ebbbf63eefe533e6faffc006da *./tests/data/lavfi/pixfmts_hflip_le-yuv410p.nut |
|
39 |
+5703854 ./tests/data/lavfi/pixfmts_hflip_le-yuv410p.nut |
|
40 |
+c626cf6d191139b4ca7efc0155f957f1 *./tests/data/lavfi/pixfmts_hflip_le-yuv411p.nut |
|
41 |
+7604654 ./tests/data/lavfi/pixfmts_hflip_le-yuv411p.nut |
|
42 |
+2d5c80f9ba2ddd85b2aeda3564cc7d64 *./tests/data/lavfi/pixfmts_hflip_le-yuv420p.nut |
|
43 |
+7604654 ./tests/data/lavfi/pixfmts_hflip_le-yuv420p.nut |
|
44 |
+758b0c1e2113b15e7afde48da4e4d024 *./tests/data/lavfi/pixfmts_hflip_le-yuv420p16be.nut |
|
45 |
+15207903 ./tests/data/lavfi/pixfmts_hflip_le-yuv420p16be.nut |
|
46 |
+480ccd951dcb806bc875d307e02e50a0 *./tests/data/lavfi/pixfmts_hflip_le-yuv420p16le.nut |
|
47 |
+15207903 ./tests/data/lavfi/pixfmts_hflip_le-yuv420p16le.nut |
|
48 |
+6e728f4eb9eae287c224f396d84be6ea *./tests/data/lavfi/pixfmts_hflip_le-yuv422p.nut |
|
49 |
+10139054 ./tests/data/lavfi/pixfmts_hflip_le-yuv422p.nut |
|
50 |
+a05d43cd62b790087bd37083174557de *./tests/data/lavfi/pixfmts_hflip_le-yuv422p16be.nut |
|
51 |
+20276703 ./tests/data/lavfi/pixfmts_hflip_le-yuv422p16be.nut |
|
52 |
+6954abebcbc62d81068d58d0c62bdd5b *./tests/data/lavfi/pixfmts_hflip_le-yuv422p16le.nut |
|
53 |
+20276703 ./tests/data/lavfi/pixfmts_hflip_le-yuv422p16le.nut |
|
54 |
+a99e2b57ed601f39852715c9d675d0d3 *./tests/data/lavfi/pixfmts_hflip_le-yuv440p.nut |
|
55 |
+10139054 ./tests/data/lavfi/pixfmts_hflip_le-yuv440p.nut |
|
56 |
+947e47f7bb5fdccc659d19b7df2b6fc3 *./tests/data/lavfi/pixfmts_hflip_le-yuv444p.nut |
|
57 |
+15207903 ./tests/data/lavfi/pixfmts_hflip_le-yuv444p.nut |
|
58 |
+e5ef45bc3d2f5b0b2542d5151340c382 *./tests/data/lavfi/pixfmts_hflip_le-yuv444p16be.nut |
|
59 |
+30414303 ./tests/data/lavfi/pixfmts_hflip_le-yuv444p16be.nut |
|
60 |
+70793e3d66d0c23a0cdedabe9c24c2a7 *./tests/data/lavfi/pixfmts_hflip_le-yuv444p16le.nut |
|
61 |
+30414303 ./tests/data/lavfi/pixfmts_hflip_le-yuv444p16le.nut |
|
62 |
+d83ec0c01498189f179ec574918185f1 *./tests/data/lavfi/pixfmts_hflip_le-yuva420p.nut |
|
63 |
+12673454 ./tests/data/lavfi/pixfmts_hflip_le-yuva420p.nut |
|
64 |
+df3aaaec3bb157c3bde5f0365af30f4f *./tests/data/lavfi/pixfmts_hflip_le-yuvj420p.nut |
|
65 |
+7604654 ./tests/data/lavfi/pixfmts_hflip_le-yuvj420p.nut |
|
66 |
+d113871528d510a192797af59df9c05c *./tests/data/lavfi/pixfmts_hflip_le-yuvj422p.nut |
|
67 |
+10139054 ./tests/data/lavfi/pixfmts_hflip_le-yuvj422p.nut |
|
68 |
+e8f7ed76e57c892a1e9e27a3f29452db *./tests/data/lavfi/pixfmts_hflip_le-yuvj440p.nut |
|
69 |
+10139054 ./tests/data/lavfi/pixfmts_hflip_le-yuvj440p.nut |
|
70 |
+2c3ae369607608c6dcb0d830f00f971a *./tests/data/lavfi/pixfmts_hflip_le-yuvj444p.nut |
|
71 |
+15207903 ./tests/data/lavfi/pixfmts_hflip_le-yuvj444p.nut |