chroma_yuv.c 4.83 KB
Newer Older
1
/*****************************************************************************
2
 * i420_yuy2.c : ARM NEONv1 YUV 4:2:0 to YUV :2:2 chroma conversion for VLC
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 *****************************************************************************
 * Copyright (C) 2009 Rémi Denis-Courmont
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
28
#include <vlc_cpu.h>
29
#include "chroma_neon.h"
30
31
32
33
34
35
36
37
38

static int Open (vlc_object_t *);

vlc_module_begin ()
    set_description (N_("ARM NEON video chroma conversions"))
    set_capability ("video filter2", 250)
    set_callbacks (Open, NULL)
vlc_module_end ()

39
40
41
42
43
44
45
46
#define DEFINE_PACK(pack, pict) \
    struct yuv_pack pack = { (pict)->Y_PIXELS, (pict)->Y_PITCH }
#define DEFINE_PLANES(planes, pict) \
    struct yuv_planes planes = { \
        (pict)->Y_PIXELS, (pict)->U_PIXELS, (pict)->V_PIXELS, (pict)->Y_PITCH }
#define DEFINE_PLANES_SWAP(planes, pict) \
    struct yuv_planes planes = { \
        (pict)->Y_PIXELS, (pict)->V_PIXELS, (pict)->U_PIXELS, (pict)->Y_PITCH }
47
48
49

static void I420_YUYV (filter_t *filter, picture_t *src, picture_t *dst)
{
50
51
52
53
    DEFINE_PACK(out, dst);
    DEFINE_PLANES(in, src);
    i420_yuyv_neon (&out, &in, filter->fmt_in.video.i_width,
                    filter->fmt_in.video.i_height);
54
}
55
56
VIDEO_FILTER_WRAPPER (I420_YUYV)

57
static void I420_YVYU (filter_t *filter, picture_t *src, picture_t *dst)
58
{
59
60
61
62
    DEFINE_PACK(out, dst);
    DEFINE_PLANES_SWAP(in, src);
    i420_yuyv_neon (&out, &in, filter->fmt_in.video.i_width,
                    filter->fmt_in.video.i_height);
63
}
64
VIDEO_FILTER_WRAPPER (I420_YVYU)
65
66
67

static void I420_UYVY (filter_t *filter, picture_t *src, picture_t *dst)
{
68
69
70
71
    DEFINE_PACK(out, dst);
    DEFINE_PLANES(in, src);
    i420_uyvy_neon (&out, &in, filter->fmt_in.video.i_width,
                    filter->fmt_in.video.i_height);
72
73
74
}
VIDEO_FILTER_WRAPPER (I420_UYVY)

75
static void I420_VYUY (filter_t *filter, picture_t *src, picture_t *dst)
76
{
77
78
79
80
    DEFINE_PACK(out, dst);
    DEFINE_PLANES_SWAP(in, src);
    i420_uyvy_neon (&out, &in, filter->fmt_in.video.i_width,
                    filter->fmt_in.video.i_height);
81
}
82
VIDEO_FILTER_WRAPPER (I420_VYUY)
83

84
85
86
87
static int Open (vlc_object_t *obj)
{
    filter_t *filter = (filter_t *)obj;

88
89
    if (!(vlc_CPU() & CPU_CAPABILITY_NEON))
        return VLC_EGENERIC;
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    if (((filter->fmt_in.video.i_width | filter->fmt_in.video.i_height) & 1)
     || (filter->fmt_in.video.i_width != filter->fmt_out.video.i_width)
     || (filter->fmt_in.video.i_height != filter->fmt_out.video.i_height))
        return VLC_EGENERIC;

    switch (filter->fmt_in.video.i_chroma)
    {
        case VLC_CODEC_I420:
            switch (filter->fmt_out.video.i_chroma)
            {
                case VLC_CODEC_YUYV:
                    filter->pf_video_filter = I420_YUYV_Filter;
                    break;
                case VLC_CODEC_UYVY:
                    filter->pf_video_filter = I420_UYVY_Filter;
                    break;
106
107
108
109
110
111
                case VLC_CODEC_YVYU:
                    filter->pf_video_filter = I420_YVYU_Filter;
                    break;
                case VLC_CODEC_VYUY:
                    filter->pf_video_filter = I420_VYUY_Filter;
                    break;
112
113
114
115
116
                default:
                    return VLC_EGENERIC;
            }
            break;

117
118
119
120
        case VLC_CODEC_YV12:
            switch (filter->fmt_out.video.i_chroma)
            {
                case VLC_CODEC_YUYV:
121
                    filter->pf_video_filter = I420_YVYU_Filter;
122
123
                    break;
                case VLC_CODEC_UYVY:
124
125
126
127
128
129
130
                    filter->pf_video_filter = I420_VYUY_Filter;
                    break;
                case VLC_CODEC_YVYU:
                    filter->pf_video_filter = I420_YUYV_Filter;
                    break;
                case VLC_CODEC_VYUY:
                    filter->pf_video_filter = I420_UYVY_Filter;
131
132
133
134
135
136
                    break;
                default:
                    return VLC_EGENERIC;
            }
            break;

137
138
139
140
141
        default:
            return VLC_EGENERIC;
    }
    return VLC_SUCCESS;
}