1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
3cabdff1aSopenharmony_ci *
4cabdff1aSopenharmony_ci * This file is part of FFmpeg.
5cabdff1aSopenharmony_ci *
6cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
7cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
8cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
9cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
10cabdff1aSopenharmony_ci *
11cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
12cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
13cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14cabdff1aSopenharmony_ci * Lesser General Public License for more details.
15cabdff1aSopenharmony_ci *
16cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
17cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
18cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19cabdff1aSopenharmony_ci */
20cabdff1aSopenharmony_ci
21cabdff1aSopenharmony_ci#include <stdint.h>
22cabdff1aSopenharmony_ci
23cabdff1aSopenharmony_ci#include "libavutil/attributes.h"
24cabdff1aSopenharmony_ci#include "libavutil/aarch64/cpu.h"
25cabdff1aSopenharmony_ci#include "libavcodec/avcodec.h"
26cabdff1aSopenharmony_ci#include "libavcodec/h264pred.h"
27cabdff1aSopenharmony_ci
28cabdff1aSopenharmony_civoid ff_pred16x16_vert_neon(uint8_t *src, ptrdiff_t stride);
29cabdff1aSopenharmony_civoid ff_pred16x16_hor_neon(uint8_t *src, ptrdiff_t stride);
30cabdff1aSopenharmony_civoid ff_pred16x16_plane_neon(uint8_t *src, ptrdiff_t stride);
31cabdff1aSopenharmony_civoid ff_pred16x16_dc_neon(uint8_t *src, ptrdiff_t stride);
32cabdff1aSopenharmony_civoid ff_pred16x16_128_dc_neon(uint8_t *src, ptrdiff_t stride);
33cabdff1aSopenharmony_civoid ff_pred16x16_left_dc_neon(uint8_t *src, ptrdiff_t stride);
34cabdff1aSopenharmony_civoid ff_pred16x16_top_dc_neon(uint8_t *src, ptrdiff_t stride);
35cabdff1aSopenharmony_ci
36cabdff1aSopenharmony_civoid ff_pred8x8_vert_neon(uint8_t *src, ptrdiff_t stride);
37cabdff1aSopenharmony_civoid ff_pred8x8_hor_neon(uint8_t *src, ptrdiff_t stride);
38cabdff1aSopenharmony_civoid ff_pred8x8_plane_neon(uint8_t *src, ptrdiff_t stride);
39cabdff1aSopenharmony_civoid ff_pred8x8_dc_neon(uint8_t *src, ptrdiff_t stride);
40cabdff1aSopenharmony_civoid ff_pred8x8_128_dc_neon(uint8_t *src, ptrdiff_t stride);
41cabdff1aSopenharmony_civoid ff_pred8x8_left_dc_neon(uint8_t *src, ptrdiff_t stride);
42cabdff1aSopenharmony_civoid ff_pred8x8_top_dc_neon(uint8_t *src, ptrdiff_t stride);
43cabdff1aSopenharmony_civoid ff_pred8x8_l0t_dc_neon(uint8_t *src, ptrdiff_t stride);
44cabdff1aSopenharmony_civoid ff_pred8x8_0lt_dc_neon(uint8_t *src, ptrdiff_t stride);
45cabdff1aSopenharmony_civoid ff_pred8x8_l00_dc_neon(uint8_t *src, ptrdiff_t stride);
46cabdff1aSopenharmony_civoid ff_pred8x8_0l0_dc_neon(uint8_t *src, ptrdiff_t stride);
47cabdff1aSopenharmony_ci
48cabdff1aSopenharmony_civoid ff_pred16x16_vert_neon_10(uint8_t *src, ptrdiff_t stride);
49cabdff1aSopenharmony_civoid ff_pred16x16_hor_neon_10(uint8_t *src, ptrdiff_t stride);
50cabdff1aSopenharmony_civoid ff_pred16x16_plane_neon_10(uint8_t *src, ptrdiff_t stride);
51cabdff1aSopenharmony_civoid ff_pred16x16_dc_neon_10(uint8_t *src, ptrdiff_t stride);
52cabdff1aSopenharmony_civoid ff_pred16x16_top_dc_neon_10(uint8_t *src, ptrdiff_t stride);
53cabdff1aSopenharmony_ci
54cabdff1aSopenharmony_civoid ff_pred8x8_vert_neon_10(uint8_t *src, ptrdiff_t stride);
55cabdff1aSopenharmony_civoid ff_pred8x8_hor_neon_10(uint8_t *src, ptrdiff_t stride);
56cabdff1aSopenharmony_civoid ff_pred8x8_plane_neon_10(uint8_t *src, ptrdiff_t stride);
57cabdff1aSopenharmony_civoid ff_pred8x8_dc_neon_10(uint8_t *src, ptrdiff_t stride);
58cabdff1aSopenharmony_civoid ff_pred8x8_128_dc_neon_10(uint8_t *src, ptrdiff_t stride);
59cabdff1aSopenharmony_civoid ff_pred8x8_left_dc_neon_10(uint8_t *src, ptrdiff_t stride);
60cabdff1aSopenharmony_civoid ff_pred8x8_top_dc_neon_10(uint8_t *src, ptrdiff_t stride);
61cabdff1aSopenharmony_civoid ff_pred8x8_l0t_dc_neon_10(uint8_t *src, ptrdiff_t stride);
62cabdff1aSopenharmony_civoid ff_pred8x8_0lt_dc_neon_10(uint8_t *src, ptrdiff_t stride);
63cabdff1aSopenharmony_civoid ff_pred8x8_l00_dc_neon_10(uint8_t *src, ptrdiff_t stride);
64cabdff1aSopenharmony_civoid ff_pred8x8_0l0_dc_neon_10(uint8_t *src, ptrdiff_t stride);
65cabdff1aSopenharmony_ci
66cabdff1aSopenharmony_cistatic av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id,
67cabdff1aSopenharmony_ci                                        const int bit_depth,
68cabdff1aSopenharmony_ci                                        const int chroma_format_idc)
69cabdff1aSopenharmony_ci{
70cabdff1aSopenharmony_ci    if (bit_depth == 8) {
71cabdff1aSopenharmony_ci        if (chroma_format_idc <= 1) {
72cabdff1aSopenharmony_ci            h->pred8x8[VERT_PRED8x8     ] = ff_pred8x8_vert_neon;
73cabdff1aSopenharmony_ci            h->pred8x8[HOR_PRED8x8      ] = ff_pred8x8_hor_neon;
74cabdff1aSopenharmony_ci            if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
75cabdff1aSopenharmony_ci                h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon;
76cabdff1aSopenharmony_ci            h->pred8x8[DC_128_PRED8x8   ] = ff_pred8x8_128_dc_neon;
77cabdff1aSopenharmony_ci            if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 &&
78cabdff1aSopenharmony_ci                codec_id != AV_CODEC_ID_VP8) {
79cabdff1aSopenharmony_ci                h->pred8x8[DC_PRED8x8     ] = ff_pred8x8_dc_neon;
80cabdff1aSopenharmony_ci                h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon;
81cabdff1aSopenharmony_ci                h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon;
82cabdff1aSopenharmony_ci                h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon;
83cabdff1aSopenharmony_ci                h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon;
84cabdff1aSopenharmony_ci                h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon;
85cabdff1aSopenharmony_ci                h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon;
86cabdff1aSopenharmony_ci            }
87cabdff1aSopenharmony_ci        }
88cabdff1aSopenharmony_ci
89cabdff1aSopenharmony_ci        h->pred16x16[DC_PRED8x8     ] = ff_pred16x16_dc_neon;
90cabdff1aSopenharmony_ci        h->pred16x16[VERT_PRED8x8   ] = ff_pred16x16_vert_neon;
91cabdff1aSopenharmony_ci        h->pred16x16[HOR_PRED8x8    ] = ff_pred16x16_hor_neon;
92cabdff1aSopenharmony_ci        h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon;
93cabdff1aSopenharmony_ci        h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon;
94cabdff1aSopenharmony_ci        h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon;
95cabdff1aSopenharmony_ci        if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 &&
96cabdff1aSopenharmony_ci            codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
97cabdff1aSopenharmony_ci            h->pred16x16[PLANE_PRED8x8  ] = ff_pred16x16_plane_neon;
98cabdff1aSopenharmony_ci    }
99cabdff1aSopenharmony_ci    if (bit_depth == 10) {
100cabdff1aSopenharmony_ci        if (chroma_format_idc <= 1) {
101cabdff1aSopenharmony_ci            h->pred8x8[VERT_PRED8x8     ] = ff_pred8x8_vert_neon_10;
102cabdff1aSopenharmony_ci            h->pred8x8[HOR_PRED8x8      ] = ff_pred8x8_hor_neon_10;
103cabdff1aSopenharmony_ci            if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
104cabdff1aSopenharmony_ci                h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon_10;
105cabdff1aSopenharmony_ci            h->pred8x8[DC_128_PRED8x8   ] = ff_pred8x8_128_dc_neon_10;
106cabdff1aSopenharmony_ci            if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 &&
107cabdff1aSopenharmony_ci                codec_id != AV_CODEC_ID_VP8) {
108cabdff1aSopenharmony_ci                h->pred8x8[DC_PRED8x8     ] = ff_pred8x8_dc_neon_10;
109cabdff1aSopenharmony_ci                h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon_10;
110cabdff1aSopenharmony_ci                h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon_10;
111cabdff1aSopenharmony_ci                h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon_10;
112cabdff1aSopenharmony_ci                h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon_10;
113cabdff1aSopenharmony_ci                h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon_10;
114cabdff1aSopenharmony_ci                h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon_10;
115cabdff1aSopenharmony_ci            }
116cabdff1aSopenharmony_ci        }
117cabdff1aSopenharmony_ci
118cabdff1aSopenharmony_ci        h->pred16x16[DC_PRED8x8     ] = ff_pred16x16_dc_neon_10;
119cabdff1aSopenharmony_ci        h->pred16x16[VERT_PRED8x8   ] = ff_pred16x16_vert_neon_10;
120cabdff1aSopenharmony_ci        h->pred16x16[HOR_PRED8x8    ] = ff_pred16x16_hor_neon_10;
121cabdff1aSopenharmony_ci        h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon_10;
122cabdff1aSopenharmony_ci        if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 &&
123cabdff1aSopenharmony_ci            codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
124cabdff1aSopenharmony_ci            h->pred16x16[PLANE_PRED8x8  ] = ff_pred16x16_plane_neon_10;
125cabdff1aSopenharmony_ci    }
126cabdff1aSopenharmony_ci}
127cabdff1aSopenharmony_ci
128cabdff1aSopenharmony_ciav_cold void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id,
129cabdff1aSopenharmony_ci                                       int bit_depth, const int chroma_format_idc)
130cabdff1aSopenharmony_ci{
131cabdff1aSopenharmony_ci    int cpu_flags = av_get_cpu_flags();
132cabdff1aSopenharmony_ci
133cabdff1aSopenharmony_ci    if (have_neon(cpu_flags))
134cabdff1aSopenharmony_ci        h264_pred_init_neon(h, codec_id, bit_depth, chroma_format_idc);
135cabdff1aSopenharmony_ci}
136