]> git.sesse.net Git - vlc/blob - modules/video_chroma/neon.c
i420->YUYV NEON: rewrite using VZIP
[vlc] / modules / video_chroma / neon.c
1 /*****************************************************************************
2  * neon.c : ARM NEONv1 chroma conversion module 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
29 static int Open (vlc_object_t *);
30
31 vlc_module_begin ()
32     set_description (N_("ARM NEON video chroma conversions"))
33     set_capability ("video filter2", 250)
34     set_callbacks (Open, NULL)
35     add_requirement (NEON)
36 vlc_module_end ()
37
38 void i420_yuyv_neon (uint8_t *out, const uint8_t **in,
39                      uintptr_t pitch, uintptr_t height);
40
41 static void I420_YUYV (filter_t *filter, picture_t *src, picture_t *dst)
42 {
43     uint8_t *out = dst->p->p_pixels;
44     const uint8_t *yuv[3] = { src->Y_PIXELS, src->U_PIXELS, src->V_PIXELS, };
45     size_t pitch = (filter->fmt_in.video.i_width + 15) & ~15;
46     size_t height = filter->fmt_in.video.i_height;
47
48     i420_yuyv_neon (out, yuv, pitch, height);
49 }
50
51 void i420_uyvy_neon (uint8_t *out, const uint8_t **in,
52                      uintptr_t pitch, uintptr_t height);
53
54 static void I420_UYVY (filter_t *filter, picture_t *src, picture_t *dst)
55 {
56     uint8_t *out = dst->p->p_pixels;
57     const uint8_t *yuv[3] = { src->Y_PIXELS, src->U_PIXELS, src->V_PIXELS, };
58     size_t pitch = (filter->fmt_in.video.i_width + 15) & ~15;
59     size_t height = filter->fmt_in.video.i_height;
60
61     i420_yuyv_neon (out, yuv, pitch, height);
62 }
63
64 VIDEO_FILTER_WRAPPER (I420_YUYV)
65 VIDEO_FILTER_WRAPPER (I420_UYVY)
66
67 static int Open (vlc_object_t *obj)
68 {
69     filter_t *filter = (filter_t *)obj;
70
71     if (((filter->fmt_in.video.i_width | filter->fmt_in.video.i_height) & 1)
72      || (filter->fmt_in.video.i_width != filter->fmt_out.video.i_width)
73      || (filter->fmt_in.video.i_height != filter->fmt_out.video.i_height))
74         return VLC_EGENERIC;
75
76     switch (filter->fmt_in.video.i_chroma)
77     {
78         case VLC_CODEC_YV12:
79         case VLC_CODEC_I420:
80             switch (filter->fmt_out.video.i_chroma)
81             {
82                 case VLC_CODEC_YUYV:
83                     filter->pf_video_filter = I420_YUYV_Filter;
84                     break;
85                 case VLC_CODEC_UYVY:
86                     filter->pf_video_filter = I420_UYVY_Filter;
87                     break;
88                 default:
89                     return VLC_EGENERIC;
90             }
91             break;
92
93         default:
94             return VLC_EGENERIC;
95     }
96     return VLC_SUCCESS;
97 }