]> git.sesse.net Git - vlc/blob - modules/arm_neon/i420_yuy2.c
Use var_Inherit* instead of var_CreateGet*.
[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 vlc_module_end ()
37
38 void i420_yuyv_neon (uint8_t *out, const uint8_t **in,
39                      unsigned int pitch, unsigned int s_off,
40                      unsigned int 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 height = filter->fmt_in.video.i_height;
47     int i_pitch = (dst->p->i_pitch >> 1) & ~0xF;
48     int s_offset = src->p->i_pitch - i_pitch;
49
50     i420_yuyv_neon (out, yuv, i_pitch, s_offset, height);
51 }
52
53 void i420_uyvy_neon (uint8_t *out, const uint8_t **in,
54                      uintptr_t pitch, uintptr_t s_off, uintptr_t height);
55
56 static void I420_UYVY (filter_t *filter, picture_t *src, picture_t *dst)
57 {
58     uint8_t *out = dst->p->p_pixels;
59     const uint8_t *yuv[3] = { src->Y_PIXELS, src->U_PIXELS, src->V_PIXELS, };
60     size_t height = filter->fmt_in.video.i_height;
61     int i_pitch = (dst->p->i_pitch >> 1) & ~0xF;
62     int s_offset = src->p->i_pitch - i_pitch;
63
64     i420_uyvy_neon (out, yuv, i_pitch, s_offset, height);
65 }
66
67 VIDEO_FILTER_WRAPPER (I420_YUYV)
68 VIDEO_FILTER_WRAPPER (I420_UYVY)
69
70 static int Open (vlc_object_t *obj)
71 {
72     filter_t *filter = (filter_t *)obj;
73
74     if (((filter->fmt_in.video.i_width | filter->fmt_in.video.i_height) & 1)
75      || (filter->fmt_in.video.i_width != filter->fmt_out.video.i_width)
76      || (filter->fmt_in.video.i_height != filter->fmt_out.video.i_height))
77         return VLC_EGENERIC;
78
79     switch (filter->fmt_in.video.i_chroma)
80     {
81         case VLC_CODEC_YV12:
82         case VLC_CODEC_I420:
83             switch (filter->fmt_out.video.i_chroma)
84             {
85                 case VLC_CODEC_YUYV:
86                     filter->pf_video_filter = I420_YUYV_Filter;
87                     break;
88                 case VLC_CODEC_UYVY:
89                     filter->pf_video_filter = I420_UYVY_Filter;
90                     break;
91                 default:
92                     return VLC_EGENERIC;
93             }
94             break;
95
96         default:
97             return VLC_EGENERIC;
98     }
99     return VLC_SUCCESS;
100 }