History

Add pixdesctest filter and corresponding test.

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

Stefano Sabatini committed 16 years ago

Commit ce2e4ae1 parent 4d508e47 files · +164 −1Browse files

Unified · Split

7 files
  1. Makefile +1 −0
  2. doc/filters.texi +12 −0
  3. libavfilter/Makefile +1 −0
  4. libavfilter/allfilters.c +1 −0
  5. libavfilter/avfilter.h +1 −1
  6. libavfilter/vf_pixdesctest.c +128 −0
  7. tests/lavfi-regression.sh +20 −0
Makefile+1−0
@@ -268,6 +268,7 @@ LAVFI_TESTS = \ · 267 unmodified lines
268268 vflip \
269269 vflip_crop \
270270 vflip_vflip \
271+ lavfi_pixdesc \
271272 # lavfi_pix_fmts \
272273
273274 ACODEC_TESTS := $(addprefix regtest-, $(ACODEC_TESTS) $(ACODEC_TESTS-yes))
doc/filters.texi+12−0
@@ -112,6 +112,18 @@ The default value of @var{color} is ``black''. · 111 unmodified lines
112112
113113 @end table
114114
115+@section pixdesctest
116+
117+Pixel format descriptor test filter, mainly useful for internal
118+testing. The output video should be equal to the input video.
119+
120+For example:
121+@example
122+format=monow, pixdesctest
123+@end example
124+
125+can be used to test the monowhite pixel format descriptor definition.
126+
115127 @section scale
116128
117129 Scale the input video to @var{width}:@var{height} and/or convert the image format.
libavfilter/Makefile+1−0
@@ -20,6 +20,7 @@ OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o · 19 unmodified lines
2020 OBJS-$(CONFIG_NOFORMAT_FILTER) += vf_format.o
2121 OBJS-$(CONFIG_NULL_FILTER) += vf_null.o
2222 OBJS-$(CONFIG_PAD_FILTER) += vf_pad.o
23+OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o
2324 OBJS-$(CONFIG_PIXELASPECT_FILTER) += vf_aspect.o
2425 OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o
2526 OBJS-$(CONFIG_SLICIFY_FILTER) += vf_slicify.o
libavfilter/allfilters.c+1−0
@@ -40,6 +40,7 @@ void avfilter_register_all(void) · 39 unmodified lines
4040 REGISTER_FILTER (NOFORMAT, noformat, vf);
4141 REGISTER_FILTER (NULL, null, vf);
4242 REGISTER_FILTER (PAD, pad, vf);
43+ REGISTER_FILTER (PIXDESCTEST, pixdesctest, vf);
4344 REGISTER_FILTER (PIXELASPECT, pixelaspect, vf);
4445 REGISTER_FILTER (SCALE, scale, vf);
4546 REGISTER_FILTER (SLICIFY, slicify, vf);
libavfilter/avfilter.h+1−1
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525 #include "libavutil/avutil.h"
2626
2727 #define LIBAVFILTER_VERSION_MAJOR 1
28−#define LIBAVFILTER_VERSION_MINOR 21
28+#define LIBAVFILTER_VERSION_MINOR 22
2929 #define LIBAVFILTER_VERSION_MICRO 0
3030
3131 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
libavfilter/vf_pixdesctest.c+128−0
@@ -0,0 +1,128 @@
1+/*
2+ * This file is part of FFmpeg.
3+ * copyright (C) 2009 Stefano Sabatini
4+ *
5+ * FFmpeg is free software; you can redistribute it and/or
6+ * modify it under the terms of the GNU Lesser General Public
7+ * License as published by the Free Software Foundation; either
8+ * version 2.1 of the License, or (at your option) any later version.
9+ *
10+ * FFmpeg is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+ * Lesser General Public License for more details.
14+ *
15+ * You should have received a copy of the GNU Lesser General Public
16+ * License along with FFmpeg; if not, write to the Free Software
17+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+ */
19+
20+/**
21+ * @file
22+ * pixdesc test filter
23+ */
24+
25+#include "libavutil/pixdesc.h"
26+#include "avfilter.h"
27+
28+typedef struct {
29+ const AVPixFmtDescriptor *pix_desc;
30+ uint16_t *line;
31+} PixdescTestContext;
32+
33+static av_cold void uninit(AVFilterContext *ctx)
34+{
35+ PixdescTestContext *priv = ctx->priv;
36+ av_freep(&priv->line);
37+}
38+
39+static int config_props(AVFilterLink *inlink)
40+{
41+ PixdescTestContext *priv = inlink->dst->priv;
42+
43+ priv->pix_desc = &av_pix_fmt_descriptors[inlink->format];
44+
45+ if (!(priv->line = av_malloc(sizeof(*priv->line) * inlink->w)))
46+ return AVERROR(ENOMEM);
47+
48+ return 0;
49+}
50+
51+static void start_frame(AVFilterLink *inlink, AVFilterPicRef *picref)
52+{
53+ PixdescTestContext *priv = inlink->dst->priv;
54+ AVFilterLink *outlink = inlink->dst->outputs[0];
55+ AVFilterPicRef *outpicref;
56+ int i;
57+
58+ outlink->outpic = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
59+ outlink->w, outlink->h);
60+ outpicref = outlink->outpic;
61+ avfilter_copy_picref_props(outpicref, picref);
62+
63+ for (i = 0; i < 4; i++) {
64+ int h = outlink->h;
65+ h = i == 1 || i == 2 ? h>>priv->pix_desc->log2_chroma_h : h;
66+ if (outpicref->data[i]) {
67+ uint8_t *data = outpicref->data[i] +
68+ (outpicref->linesize[i] > 0 ? 0 : outpicref->linesize[i] * (h-1));
69+ memset(data, 0, FFABS(outpicref->linesize[i]) * h);
70+ }
71+ }
72+
73+ /* copy palette */
74+ if (priv->pix_desc->flags & PIX_FMT_PAL)
75+ memcpy(outpicref->data[1], outpicref->data[1], 256*4);
76+
77+ avfilter_start_frame(outlink, avfilter_ref_pic(outpicref, ~0));
78+}
79+
80+static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
81+{
82+ PixdescTestContext *priv = inlink->dst->priv;
83+ AVFilterPicRef *inpic = inlink->cur_pic;
84+ AVFilterPicRef *outpic = inlink->dst->outputs[0]->outpic;
85+ int i, c, w = inlink->w;
86+
87+ for (c = 0; c < priv->pix_desc->nb_components; c++) {
88+ int w1 = c == 1 || c == 2 ? w>>priv->pix_desc->log2_chroma_w : w;
89+ int h1 = c == 1 || c == 2 ? h>>priv->pix_desc->log2_chroma_h : h;
90+ int y1 = c == 1 || c == 2 ? y>>priv->pix_desc->log2_chroma_h : y;
91+
92+ for (i = y1; i < y1 + h1; i++) {
93+ read_line(priv->line,
94+ inpic->data,
95+ inpic->linesize,
96+ priv->pix_desc,
97+ 0, i, c, w1, 0);
98+
99+ write_line(priv->line,
100+ outpic->data,
101+ outpic->linesize,
102+ priv->pix_desc,
103+ 0, i, c, w1);
104+ }
105+ }
106+
107+ avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
108+}
109+
110+AVFilter avfilter_vf_pixdesctest = {
111+ .name = "pixdesctest",
112+ .description = "Test pixel format definitions.",
113+
114+ .priv_size = sizeof(PixdescTestContext),
115+ .uninit = uninit,
116+
117+ .inputs = (AVFilterPad[]) {{ .name = "default",
118+ .type = AVMEDIA_TYPE_VIDEO,
119+ .start_frame = start_frame,
120+ .draw_slice = draw_slice,
121+ .config_props = config_props,
122+ .min_perms = AV_PERM_READ, },
123+ { .name = NULL}},
124+
125+ .outputs = (AVFilterPad[]) {{ .name = "default",
126+ .type = AVMEDIA_TYPE_VIDEO, },
127+ { .name = NULL}},
128+};
tests/lavfi-regression.sh+20−0
@@ -86,6 +86,26 @@ if [ -n "$do_lavfi_pix_fmts" ]; then · 85 unmodified lines
8686 done
8787 fi
8888
89+if [ -n "$do_lavfi_pixdesc" ]; then
90+ pix_fmts="$($ffmpeg -pix_fmts list 2>/dev/null | sed -ne '9,$p' | grep '^IO' | cut -d' ' -f2)"
91+
92+ ref_file=tests/ref/lavfi/lavfi_pixdesc
93+ rm -f $ref_file
94+ res_file=$logfile
95+
96+ for pix_fmt in $pix_fmts; do
97+ # print to the reference logfile
98+ logfile=$ref_file
99+ do_video_encoding "lavfi_pixdesc-${pix_fmt}.nut" "" \
100+ "-vf slicify=random,format=$pix_fmt -vcodec rawvideo -pix_fmt $pix_fmt"
101+
102+ # print to the result logfile
103+ logfile=$res_file
104+ do_video_encoding "lavfi_pixdesc-${pix_fmt}.nut" "" \
105+ "-vf slicify=random,format=$pix_fmt,pixdesctest -vcodec rawvideo -pix_fmt $pix_fmt"
106+ done
107+fi
108+
89109 # TODO: add tests for
90110 # direct rendering,
91111 # chains with feedback loops

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