~ubuntu-branches/ubuntu/trusty/gst-libav1.0/trusty-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavfilter/vf_vflip.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-09-24 17:07:00 UTC
  • mfrom: (1.1.17) (7.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20130924170700-4dg62s3pwl0pdakz
Tags: 1.2.0-1
* New upstream stable release:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.2.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 * video vertical flip filter
24
24
 */
25
25
 
 
26
#include "libavutil/internal.h"
26
27
#include "libavutil/pixdesc.h"
27
28
#include "avfilter.h"
 
29
#include "internal.h"
 
30
#include "video.h"
28
31
 
29
32
typedef struct {
30
33
    int vsub;   ///< vertical chroma subsampling
33
36
static int config_input(AVFilterLink *link)
34
37
{
35
38
    FlipContext *flip = link->dst->priv;
 
39
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
36
40
 
37
 
    flip->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h;
 
41
    flip->vsub = desc->log2_chroma_h;
38
42
 
39
43
    return 0;
40
44
}
47
51
    int i;
48
52
 
49
53
    if (!(perms & AV_PERM_NEG_LINESIZES))
50
 
        return avfilter_default_get_video_buffer(link, perms, w, h);
51
 
 
52
 
    picref = avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
 
54
        return ff_default_get_video_buffer(link, perms, w, h);
 
55
 
 
56
    picref = ff_get_video_buffer(link->dst->outputs[0], perms, w, h);
 
57
    if (!picref)
 
58
        return NULL;
 
59
 
53
60
    for (i = 0; i < 4; i ++) {
54
61
        int vsub = i == 1 || i == 2 ? flip->vsub : 0;
55
62
 
62
69
    return picref;
63
70
}
64
71
 
65
 
static void start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref)
 
72
static int filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
66
73
{
67
74
    FlipContext *flip = link->dst->priv;
68
 
    AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
69
75
    int i;
70
76
 
71
77
    for (i = 0; i < 4; i ++) {
72
78
        int vsub = i == 1 || i == 2 ? flip->vsub : 0;
73
79
 
74
 
        if (outpicref->data[i]) {
75
 
            outpicref->data[i] += ((link->h >> vsub)-1) * outpicref->linesize[i];
76
 
            outpicref->linesize[i] = -outpicref->linesize[i];
 
80
        if (frame->data[i]) {
 
81
            frame->data[i] += ((link->h >> vsub)-1) * frame->linesize[i];
 
82
            frame->linesize[i] = -frame->linesize[i];
77
83
        }
78
84
    }
79
85
 
80
 
    avfilter_start_frame(link->dst->outputs[0], outpicref);
81
 
}
82
 
 
83
 
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
84
 
{
85
 
    AVFilterContext *ctx = link->dst;
86
 
 
87
 
    avfilter_draw_slice(ctx->outputs[0], link->h - (y+h), h, -1 * slice_dir);
88
 
}
 
86
    return ff_filter_frame(link->dst->outputs[0], frame);
 
87
}
 
88
static const AVFilterPad avfilter_vf_vflip_inputs[] = {
 
89
    {
 
90
        .name             = "default",
 
91
        .type             = AVMEDIA_TYPE_VIDEO,
 
92
        .get_video_buffer = get_video_buffer,
 
93
        .filter_frame     = filter_frame,
 
94
        .config_props     = config_input,
 
95
    },
 
96
    { NULL }
 
97
};
 
98
 
 
99
static const AVFilterPad avfilter_vf_vflip_outputs[] = {
 
100
    {
 
101
        .name = "default",
 
102
        .type = AVMEDIA_TYPE_VIDEO,
 
103
    },
 
104
    { NULL }
 
105
};
89
106
 
90
107
AVFilter avfilter_vf_vflip = {
91
108
    .name      = "vflip",
93
110
 
94
111
    .priv_size = sizeof(FlipContext),
95
112
 
96
 
    .inputs    = (AVFilterPad[]) {{ .name             = "default",
97
 
                                    .type             = AVMEDIA_TYPE_VIDEO,
98
 
                                    .get_video_buffer = get_video_buffer,
99
 
                                    .start_frame      = start_frame,
100
 
                                    .draw_slice       = draw_slice,
101
 
                                    .config_props     = config_input, },
102
 
                                  { .name = NULL}},
103
 
    .outputs   = (AVFilterPad[]) {{ .name             = "default",
104
 
                                    .type             = AVMEDIA_TYPE_VIDEO, },
105
 
                                  { .name = NULL}},
 
113
    .inputs    = avfilter_vf_vflip_inputs,
 
114
    .outputs   = avfilter_vf_vflip_outputs,
106
115
};