1 /*
2  * V210 decoder DSP init
3  *
4  * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at>
5  * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #ifndef AVCODEC_V210DEC_INIT_H
25 #define AVCODEC_V210DEC_INIT_H
26 
27 #include <stdint.h>
28 
29 #include "config.h"
30 #include "libavutil/attributes.h"
31 #include "libavutil/bswap.h"
32 #include "v210dec.h"
33 
34 #define READ_PIXELS(a, b, c)         \
35     do {                             \
36         val  = av_le2ne32(*src++);   \
37         *a++ =  val & 0x3FF;         \
38         *b++ = (val >> 10) & 0x3FF;  \
39         *c++ = (val >> 20) & 0x3FF;  \
40     } while (0)
41 
v210_planar_unpack_c(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width)42 static void v210_planar_unpack_c(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width)
43 {
44     uint32_t val;
45 
46     for (int i = 0; i < width - 5; i += 6) {
47         READ_PIXELS(u, y, v);
48         READ_PIXELS(y, u, y);
49         READ_PIXELS(v, y, u);
50         READ_PIXELS(y, v, y);
51     }
52 }
53 
ff_v210dec_init(V210DecContext *s)54 static av_unused av_cold void ff_v210dec_init(V210DecContext *s)
55 {
56     s->unpack_frame = v210_planar_unpack_c;
57 #if ARCH_X86
58     ff_v210_x86_init(s);
59 #endif
60 }
61 
62 #endif /* AVCODEC_V210DEC_INIT_H */
63