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/arm/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_cistatic av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id,
49cabdff1aSopenharmony_ci                                        const int bit_depth,
50cabdff1aSopenharmony_ci                                        const int chroma_format_idc)
51cabdff1aSopenharmony_ci{
52cabdff1aSopenharmony_ci#if HAVE_NEON
53cabdff1aSopenharmony_ci    const int high_depth = bit_depth > 8;
54cabdff1aSopenharmony_ci
55cabdff1aSopenharmony_ci    if (high_depth)
56cabdff1aSopenharmony_ci        return;
57cabdff1aSopenharmony_ci
58cabdff1aSopenharmony_ci    if (chroma_format_idc <= 1) {
59cabdff1aSopenharmony_ci        h->pred8x8[VERT_PRED8x8     ] = ff_pred8x8_vert_neon;
60cabdff1aSopenharmony_ci        h->pred8x8[HOR_PRED8x8      ] = ff_pred8x8_hor_neon;
61cabdff1aSopenharmony_ci        if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
62cabdff1aSopenharmony_ci            h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon;
63cabdff1aSopenharmony_ci        h->pred8x8[DC_128_PRED8x8   ] = ff_pred8x8_128_dc_neon;
64cabdff1aSopenharmony_ci        if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 &&
65cabdff1aSopenharmony_ci            codec_id != AV_CODEC_ID_VP8) {
66cabdff1aSopenharmony_ci            h->pred8x8[DC_PRED8x8     ] = ff_pred8x8_dc_neon;
67cabdff1aSopenharmony_ci            h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon;
68cabdff1aSopenharmony_ci            h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon;
69cabdff1aSopenharmony_ci            h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon;
70cabdff1aSopenharmony_ci            h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon;
71cabdff1aSopenharmony_ci            h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon;
72cabdff1aSopenharmony_ci            h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon;
73cabdff1aSopenharmony_ci        }
74cabdff1aSopenharmony_ci    }
75cabdff1aSopenharmony_ci
76cabdff1aSopenharmony_ci    h->pred16x16[DC_PRED8x8     ] = ff_pred16x16_dc_neon;
77cabdff1aSopenharmony_ci    h->pred16x16[VERT_PRED8x8   ] = ff_pred16x16_vert_neon;
78cabdff1aSopenharmony_ci    h->pred16x16[HOR_PRED8x8    ] = ff_pred16x16_hor_neon;
79cabdff1aSopenharmony_ci    h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon;
80cabdff1aSopenharmony_ci    h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon;
81cabdff1aSopenharmony_ci    h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon;
82cabdff1aSopenharmony_ci    if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 &&
83cabdff1aSopenharmony_ci        codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8)
84cabdff1aSopenharmony_ci        h->pred16x16[PLANE_PRED8x8  ] = ff_pred16x16_plane_neon;
85cabdff1aSopenharmony_ci#endif // HAVE_NEON
86cabdff1aSopenharmony_ci}
87cabdff1aSopenharmony_ci
88cabdff1aSopenharmony_ciav_cold void ff_h264_pred_init_arm(H264PredContext *h, int codec_id,
89cabdff1aSopenharmony_ci                                   int bit_depth, const int chroma_format_idc)
90cabdff1aSopenharmony_ci{
91cabdff1aSopenharmony_ci    int cpu_flags = av_get_cpu_flags();
92cabdff1aSopenharmony_ci
93cabdff1aSopenharmony_ci    if (have_neon(cpu_flags))
94cabdff1aSopenharmony_ci        h264_pred_init_neon(h, codec_id, bit_depth, chroma_format_idc);
95cabdff1aSopenharmony_ci}
96