FFmpeg
Loading...
Searching...
No Matches
h264_intrapred_init.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Tristan Matthews <tmatth@videolan.org>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg 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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <stddef.h>
22#include <stdint.h>
23#include "config.h"
25#include "libavutil/cpu.h"
26#include "libavutil/riscv/cpu.h"
27#include "libavcodec/codec_id.h"
28#include "libavcodec/h264pred.h"
29
30#define PRED8x8(TYPE, DEPTH, SUFFIX) \
31void ff_pred8x8_ ## TYPE ## _ ## DEPTH ## _ ## SUFFIX (uint8_t *src, \
32 ptrdiff_t stride);
33
34#define PRED16x16(TYPE, DEPTH, SUFFIX) \
35void ff_pred16x16_ ## TYPE ## _ ## DEPTH ## _ ## SUFFIX (uint8_t *src, \
36 ptrdiff_t stride);
37
38/* 8-bit versions */
39PRED8x8(horizontal, 8, rvv_vl128)
40PRED8x8(horizontal, 8, rvv_vl256)
41PRED8x8(plane, 8, rvv_vl128)
42PRED8x8(plane, 8, rvv_vl256)
43PRED16x16(horizontal, 8, rvv_vl128)
44PRED16x16(horizontal, 8, rvv_vl256)
45PRED16x16(vertical, 8, rvv_vl128)
46PRED16x16(vertical, 8, rvv_vl256)
47PRED16x16(dc, 8, rvv_vl128)
48PRED16x16(dc, 8, rvv_vl256)
49PRED16x16(128_dc, 8, rvv_vl128)
50PRED16x16(128_dc, 8, rvv_vl256)
51PRED16x16(left_dc, 8, rvv_vl128)
52PRED16x16(left_dc, 8, rvv_vl256)
53PRED16x16(top_dc, 8, rvv_vl128)
54PRED16x16(top_dc, 8, rvv_vl256)
55PRED16x16(plane, 8, rvv_vl128)
56PRED16x16(plane, 8, rvv_vl256)
57
59 const int bit_depth,
60 const int chroma_format_idc)
61{
62#if HAVE_RVV
64
65 if (!(cpu_flags & AV_CPU_FLAG_RVV_I32) || !ff_rv_vlen_least(128)) return;
66
67 const int vlen = 8 * ff_get_rv_vlenb();
68
69 if (bit_depth == 8) {
70 if (chroma_format_idc <= 1) {
73 if (vlen >= 256) {
74 h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_8_rvv_vl256;
75 } else {
76 h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_8_rvv_vl128;
77 }
78 }
79 if (vlen >= 256) {
80 h->pred8x8[HOR_PRED8x8] = ff_pred8x8_horizontal_8_rvv_vl256;
81 } else {
82 h->pred8x8[HOR_PRED8x8] = ff_pred8x8_horizontal_8_rvv_vl128;
83 }
84 }
85 if (vlen >= 256) {
86 h->pred16x16[HOR_PRED8x8] = ff_pred16x16_horizontal_8_rvv_vl256;
87 h->pred16x16[DC_PRED8x8] = ff_pred16x16_dc_8_rvv_vl256;
88 h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_8_rvv_vl256;
90 h->pred16x16[TOP_DC_PRED8x8] = ff_pred16x16_top_dc_8_rvv_vl256;
91 h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_8_rvv_vl256;
92 h->pred16x16[DC_128_PRED8x8] = ff_pred16x16_128_dc_8_rvv_vl256;
93 } else {
94 h->pred16x16[HOR_PRED8x8] = ff_pred16x16_horizontal_8_rvv_vl128;
95 h->pred16x16[DC_PRED8x8] = ff_pred16x16_dc_8_rvv_vl128;
96 h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_8_rvv_vl128;
98 h->pred16x16[TOP_DC_PRED8x8] = ff_pred16x16_top_dc_8_rvv_vl128;
99 h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_8_rvv_vl128;
100 h->pred16x16[DC_128_PRED8x8] = ff_pred16x16_128_dc_8_rvv_vl128;
101 }
105 if (vlen >= 256) {
106 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_8_rvv_vl256;
107 } else {
108 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_8_rvv_vl128;
109 }
110 }
111 }
112#endif
113}
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition af_astats.c:246
@ AV_CODEC_ID_SVQ3
Definition codec_id.h:73
@ AV_CODEC_ID_VP7
Definition codec_id.h:230
@ AV_CODEC_ID_VP8
Definition codec_id.h:190
@ AV_CODEC_ID_RV40
Definition codec_id.h:119
H.264 / AVC / MPEG-4 prediction functions.
#define TOP_DC_PRED8x8
Definition h264pred.h:75
#define HOR_PRED8x8
Definition h264pred.h:69
#define VERT_PRED8x8
Definition h264pred.h:70
void ff_h264_pred_init_riscv(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc)
#define DC_PRED8x8
Definition h264pred.h:68
#define LEFT_DC_PRED8x8
Definition h264pred.h:74
#define PLANE_PRED8x8
Definition h264pred.h:71
#define DC_128_PRED8x8
Definition h264pred.h:76
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
static atomic_int cpu_flags
Definition cpu.c:56
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define AV_CPU_FLAG_RVB
B (bit manipulations)
Definition cpu.h:104
#define AV_CPU_FLAG_RVV_I32
Vectors of 8/16/32-bit int's *‍/.
Definition cpu.h:97
#define PRED8x8(TYPE, DEPTH, SUFFIX)
#define PRED16x16(TYPE, DEPTH, SUFFIX)
Context for storing H.264 prediction functions.
Definition h264pred.h:94
enum AVCodecID codec_id