]> git.sesse.net Git - vlc/blob - modules/arm_neon/i420_yuy2.c
Move ARM NEON optimizations to arm_neon/
[vlc] / modules / arm_neon / i420_yuy2.c
1 /*****************************************************************************
2  * i420_yuy2.c : ARM NEONv1 YUV 4:2:0 to YUV :2:2 chroma conversion for VLC
3  *****************************************************************************
4  * Copyright (C) 2009 RĂ©mi Denis-Courmont
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
24
25 #include <vlc_common.h>
26 #include <vlc_plugin.h>
27 #include <vlc_filter.h>
28 #include <vlc_cpu.h>
29
30 static int Open (vlc_object_t *);
31
32 vlc_module_begin ()
33     set_description (N_("ARM NEON video chroma conversions"))
34     set_capability ("video filter2", 250)
35     set_callbacks (Open, NULL)
36     add_requirement (NEON)
37 vlc_module_end ()
38
39 void i420_yuyv_neon (uint8_t *out, const uint8_t **in,
40                      uintptr_t pitch, uintptr_t height);
41
42 static void I420_YUYV (filter_t *filter, picture_t *src, picture_t *dst)
43 {
44     uint8_t *out = dst->p->p_pixels;
45     const uint8_t *yuv[3] = { src->Y_PIXELS, src->U_PIXELS, src->V_PIXELS, };
46     size_t pitch = (filter->fmt_in.video.i_width + 15) & ~15;
47     size_t height = filter->fmt_in.video.i_height;
48
49     i420_yuyv_neon (out, yuv, pitch, height);
50 }
51
52 void i420_uyvy_neon (uint8_t *out, const uint8_t **in,
53                      uintptr_t pitch, uintptr_t height);
54
55 static void I420_UYVY (filter_t *filter, picture_t *src, picture_t *dst)
56 {
57     uint8_t *out = dst->p->p_pixels;
58     const uint8_t *yuv[3] = { src->Y_PIXELS, src->U_PIXELS, src->V_PIXELS, };
59     size_t pitch = (filter->fmt_in.video.i_width + 15) & ~15;
60     size_t height = filter->fmt_in.video.i_height;
61
62     i420_yuyv_neon (out, yuv, pitch, height);
63 }
64
65 VIDEO_FILTER_WRAPPER (I420_YUYV)
66 VIDEO_FILTER_WRAPPER (I420_UYVY)
67
68 static int Open (vlc_object_t *obj)
69 {
70     filter_t *filter = (filter_t *)obj;
71
72     if (((filter->fmt_in.video.i_width | filter->fmt_in.video.i_height) & 1)
73      || (filter->fmt_in.video.i_width != filter->fmt_out.video.i_width)
74      || (filter->fmt_in.video.i_height != filter->fmt_out.video.i_height))
75         return VLC_EGENERIC;
76
77     switch (filter->fmt_in.video.i_chroma)
78     {
79         case VLC_CODEC_YV12:
80         case VLC_CODEC_I420:
81             switch (filter->fmt_out.video.i_chroma)
82             {
83                 case VLC_CODEC_YUYV:
84                     filter->pf_video_filter = I420_YUYV_Filter;
85                     break;
86                 case VLC_CODEC_UYVY:
87                     filter->pf_video_filter = I420_UYVY_Filter;
88                     break;
89                 default:
90                     return VLC_EGENERIC;
91             }
92             break;
93
94         default:
95             return VLC_EGENERIC;
96     }
97     return VLC_SUCCESS;
98 }