Originally committed as revision 24092 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -268,6 +268,7 @@ LAVFI_TESTS = \ · 267 unmodified lines | |||
| 268 | vflip \ | 268 | vflip \ |
| 269 | vflip_crop \ | 269 | vflip_crop \ |
| 270 | vflip_vflip \ | 270 | vflip_vflip \ |
| 271 | lavfi_pixdesc \ | ||
| 271 | # lavfi_pix_fmts \ | 272 | # lavfi_pix_fmts \ |
| 272 | 273 | ||
| 273 | ACODEC_TESTS := $(addprefix regtest-, $(ACODEC_TESTS) $(ACODEC_TESTS-yes)) | 274 | ACODEC_TESTS := $(addprefix regtest-, $(ACODEC_TESTS) $(ACODEC_TESTS-yes)) |
| @@ -112,6 +112,18 @@ The default value of @var{color} is ``black''. · 111 unmodified lines | |||
| 112 | 112 | ||
| 113 | @end table | 113 | @end table |
| 114 | 114 | ||
| 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 | |||
| 115 | @section scale | 127 | @section scale |
| 116 | 128 | ||
| 117 | Scale the input video to @var{width}:@var{height} and/or convert the image format. | 129 | Scale the input video to @var{width}:@var{height} and/or convert the image format. |
| @@ -20,6 +20,7 @@ OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o · 19 unmodified lines | |||
| 20 | OBJS-$(CONFIG_NOFORMAT_FILTER) += vf_format.o | 20 | OBJS-$(CONFIG_NOFORMAT_FILTER) += vf_format.o |
| 21 | OBJS-$(CONFIG_NULL_FILTER) += vf_null.o | 21 | OBJS-$(CONFIG_NULL_FILTER) += vf_null.o |
| 22 | OBJS-$(CONFIG_PAD_FILTER) += vf_pad.o | 22 | OBJS-$(CONFIG_PAD_FILTER) += vf_pad.o |
| 23 | OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o | ||
| 23 | OBJS-$(CONFIG_PIXELASPECT_FILTER) += vf_aspect.o | 24 | OBJS-$(CONFIG_PIXELASPECT_FILTER) += vf_aspect.o |
| 24 | OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o | 25 | OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o |
| 25 | OBJS-$(CONFIG_SLICIFY_FILTER) += vf_slicify.o | 26 | OBJS-$(CONFIG_SLICIFY_FILTER) += vf_slicify.o |
| @@ -40,6 +40,7 @@ void avfilter_register_all(void) · 39 unmodified lines | |||
| 40 | REGISTER_FILTER (NOFORMAT, noformat, vf); | 40 | REGISTER_FILTER (NOFORMAT, noformat, vf); |
| 41 | REGISTER_FILTER (NULL, null, vf); | 41 | REGISTER_FILTER (NULL, null, vf); |
| 42 | REGISTER_FILTER (PAD, pad, vf); | 42 | REGISTER_FILTER (PAD, pad, vf); |
| 43 | REGISTER_FILTER (PIXDESCTEST, pixdesctest, vf); | ||
| 43 | REGISTER_FILTER (PIXELASPECT, pixelaspect, vf); | 44 | REGISTER_FILTER (PIXELASPECT, pixelaspect, vf); |
| 44 | REGISTER_FILTER (SCALE, scale, vf); | 45 | REGISTER_FILTER (SCALE, scale, vf); |
| 45 | REGISTER_FILTER (SLICIFY, slicify, vf); | 46 | REGISTER_FILTER (SLICIFY, slicify, vf); |
| @@ -25,7 +25,7 @@ · 24 unmodified lines | |||
| 25 | #include "libavutil/avutil.h" | 25 | #include "libavutil/avutil.h" |
| 26 | 26 | ||
| 27 | #define LIBAVFILTER_VERSION_MAJOR 1 | 27 | #define LIBAVFILTER_VERSION_MAJOR 1 |
| 28 | #define LIBAVFILTER_VERSION_MINOR 21 | 28 | #define LIBAVFILTER_VERSION_MINOR 22 |
| 29 | #define LIBAVFILTER_VERSION_MICRO 0 | 29 | #define LIBAVFILTER_VERSION_MICRO 0 |
| 30 | 30 | ||
| 31 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ | 31 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
| @@ -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 | }; | ||
| @@ -86,6 +86,26 @@ if [ -n "$do_lavfi_pix_fmts" ]; then · 85 unmodified lines | |||
| 86 | done | 86 | done |
| 87 | fi | 87 | fi |
| 88 | 88 | ||
| 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 | |||
| 89 | # TODO: add tests for | 109 | # TODO: add tests for |
| 90 | # direct rendering, | 110 | # direct rendering, |
| 91 | # chains with feedback loops | 111 | # chains with feedback loops |