[FFmpeg-devel] [PATCH 2/3] lavc: Split out common components used by vulkan prores encoder
From: IndecisiveTurtle
---
libavcodec/Makefile | 2 +-
libavcodec/proresenc_kostya.c| 414 +--
libavcodec/proresenc_kostya_common.c | 364 +++
libavcodec/proresenc_kostya_common.h | 131 +
4 files changed, 511 insertions(+), 400 deletions(-)
create mode 100644 libavcodec/proresenc_kostya_common.c
create mode 100644 libavcodec/proresenc_kostya_common.h
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3d036de4b6..d8e1ac5a54 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -638,7 +638,7 @@ OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o
OBJS-$(CONFIG_PRORES_DECODER) += proresdec.o proresdsp.o proresdata.o
OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o proresdata.o
OBJS-$(CONFIG_PRORES_AW_ENCODER) += proresenc_anatoliy.o proresdata.o
-OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o
+OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o
proresenc_kostya_common.o
OBJS-$(CONFIG_PRORES_RAW_DECODER) += prores_raw.o proresdsp.o proresdata.o
OBJS-$(CONFIG_PRORES_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
OBJS-$(CONFIG_PROSUMER_DECODER)+= prosumer.o
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index b98bc5c195..31d22a14ac 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -33,179 +33,7 @@
#include "profiles.h"
#include "bytestream.h"
#include "proresdata.h"
-
-#define CFACTOR_Y422 2
-#define CFACTOR_Y444 3
-
-#define MAX_MBS_PER_SLICE 8
-
-#define MAX_PLANES 4
-
-enum {
-PRORES_PROFILE_AUTO = -1,
-PRORES_PROFILE_PROXY = 0,
-PRORES_PROFILE_LT,
-PRORES_PROFILE_STANDARD,
-PRORES_PROFILE_HQ,
-PRORES_PROFILE_,
-PRORES_PROFILE_XQ,
-};
-
-enum {
-QUANT_MAT_PROXY = 0,
-QUANT_MAT_PROXY_CHROMA,
-QUANT_MAT_LT,
-QUANT_MAT_STANDARD,
-QUANT_MAT_HQ,
-QUANT_MAT_XQ_LUMA,
-QUANT_MAT_DEFAULT,
-};
-
-static const uint8_t prores_quant_matrices[][64] = {
-{ // proxy
- 4, 7, 9, 11, 13, 14, 15, 63,
- 7, 7, 11, 12, 14, 15, 63, 63,
- 9, 11, 13, 14, 15, 63, 63, 63,
-11, 11, 13, 14, 63, 63, 63, 63,
-11, 13, 14, 63, 63, 63, 63, 63,
-13, 14, 63, 63, 63, 63, 63, 63,
-13, 63, 63, 63, 63, 63, 63, 63,
-63, 63, 63, 63, 63, 63, 63, 63,
-},
-{ // proxy chromas
-4, 7, 9, 11, 13, 14, 63, 63,
-7, 7, 11, 12, 14, 63, 63, 63,
-9, 11, 13, 14, 63, 63, 63, 63,
-11, 11, 13, 14, 63, 63, 63, 63,
-11, 13, 14, 63, 63, 63, 63, 63,
-13, 14, 63, 63, 63, 63, 63, 63,
-13, 63, 63, 63, 63, 63, 63, 63,
-63, 63, 63, 63, 63, 63, 63, 63
-},
-{ // LT
- 4, 5, 6, 7, 9, 11, 13, 15,
- 5, 5, 7, 8, 11, 13, 15, 17,
- 6, 7, 9, 11, 13, 15, 15, 17,
- 7, 7, 9, 11, 13, 15, 17, 19,
- 7, 9, 11, 13, 14, 16, 19, 23,
- 9, 11, 13, 14, 16, 19, 23, 29,
- 9, 11, 13, 15, 17, 21, 28, 35,
-11, 13, 16, 17, 21, 28, 35, 41,
-},
-{ // standard
- 4, 4, 5, 5, 6, 7, 7, 9,
- 4, 4, 5, 6, 7, 7, 9, 9,
- 5, 5, 6, 7, 7, 9, 9, 10,
- 5, 5, 6, 7, 7, 9, 9, 10,
- 5, 6, 7, 7, 8, 9, 10, 12,
- 6, 7, 7, 8, 9, 10, 12, 15,
- 6, 7, 7, 9, 10, 11, 14, 17,
- 7, 7, 9, 10, 11, 14, 17, 21,
-},
-{ // high quality
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 5,
- 4, 4, 4, 4, 4, 4, 5, 5,
- 4, 4, 4, 4, 4, 5, 5, 6,
- 4, 4, 4, 4, 5, 5, 6, 7,
- 4, 4, 4, 4, 5, 6, 7, 7,
-},
-{ // XQ luma
-2, 2, 2, 2, 2, 2, 2, 2,
-2, 2, 2, 2, 2, 2, 2, 2,
-2, 2, 2, 2, 2, 2, 2, 2,
-2, 2, 2, 2, 2, 2, 2, 3,
-2, 2, 2, 2, 2, 2, 3, 3,
-2, 2, 2, 2, 2, 3, 3, 3,
-2, 2, 2, 2, 3, 3, 3, 4,
-2, 2, 2, 2, 3, 3, 4, 4,
-},
-{ // codec default
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
-},
-};
-
-#define NUM_MB_LIMITS 4
-static const int prores_mb_limits[NUM_MB_LIMITS] = {
-1620, // up to 720x576
-2700, // up to 960x720
-6075, // up to 1440x1080
-9216, // up to 2048x1152
-};
-
-static const struct prores_profile {
-const char *full_name;
-uint32_ttag;
-int min_quant;
-int max_quant;
-int br_tab[NUM_MB_LIMITS];
-int quant;
-int
[FFmpeg-devel] [PATCH 3/3] lavc: implement a Vulkan-based prores encoder
From: IndecisiveTurtle
Adds a vulkan implementation of the reference prores kostya encoder. Provides
about 3-4x speedup over the CPU code
---
configure |1 +
libavcodec/Makefile |1 +
libavcodec/allcodecs.c|1 +
libavcodec/proresenc_kostya_vulkan.c | 1068 +
libavcodec/vulkan/Makefile|7 +
libavcodec/vulkan/prores_ks_alpha_data.comp | 67 ++
libavcodec/vulkan/prores_ks_encode_slice.comp | 230
.../vulkan/prores_ks_estimate_slice.comp | 267 +
libavcodec/vulkan/prores_ks_slice_data.comp | 265
libavcodec/vulkan/prores_ks_trellis_node.comp | 177 +++
10 files changed, 2084 insertions(+)
create mode 100644 libavcodec/proresenc_kostya_vulkan.c
create mode 100644 libavcodec/vulkan/prores_ks_alpha_data.comp
create mode 100644 libavcodec/vulkan/prores_ks_encode_slice.comp
create mode 100644 libavcodec/vulkan/prores_ks_estimate_slice.comp
create mode 100644 libavcodec/vulkan/prores_ks_slice_data.comp
create mode 100644 libavcodec/vulkan/prores_ks_trellis_node.comp
diff --git a/configure b/configure
index 7ec4c3975b..4db8a7c581 100755
--- a/configure
+++ b/configure
@@ -3099,6 +3099,7 @@ prores_decoder_select="blockdsp idctdsp"
prores_encoder_select="fdctdsp"
prores_aw_encoder_select="fdctdsp"
prores_ks_encoder_select="fdctdsp"
+prores_ks_vulkan_encoder_select="vulkan spirv_compiler"
prores_raw_decoder_select="blockdsp idctdsp"
qcelp_decoder_select="lsp"
qdm2_decoder_select="mpegaudiodsp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d8e1ac5a54..1964c787d7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -639,6 +639,7 @@ OBJS-$(CONFIG_PRORES_DECODER) += proresdec.o
proresdsp.o proresdata.o
OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o proresdata.o
OBJS-$(CONFIG_PRORES_AW_ENCODER) += proresenc_anatoliy.o proresdata.o
OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o
proresenc_kostya_common.o
+OBJS-$(CONFIG_PRORES_KS_VULKAN_ENCODER) += proresenc_kostya_vulkan.o
proresdata.o proresenc_kostya_common.o
OBJS-$(CONFIG_PRORES_RAW_DECODER) += prores_raw.o proresdsp.o proresdata.o
OBJS-$(CONFIG_PRORES_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
OBJS-$(CONFIG_PROSUMER_DECODER)+= prosumer.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index f5ec2e01e8..1b4a5f769c 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -269,6 +269,7 @@ extern const FFCodec ff_prores_encoder;
extern const FFCodec ff_prores_decoder;
extern const FFCodec ff_prores_aw_encoder;
extern const FFCodec ff_prores_ks_encoder;
+extern const FFCodec ff_prores_ks_vulkan_encoder;
extern const FFCodec ff_prores_raw_decoder;
extern const FFCodec ff_prosumer_decoder;
extern const FFCodec ff_psd_decoder;
diff --git a/libavcodec/proresenc_kostya_vulkan.c
b/libavcodec/proresenc_kostya_vulkan.c
new file mode 100644
index 00..6413b2f9d4
--- /dev/null
+++ b/libavcodec/proresenc_kostya_vulkan.c
@@ -0,0 +1,1068 @@
+/*
+ * Apple ProRes encoder
+ *
+ * Copyright (c) 2011 Anatoliy Wasserman
+ * Copyright (c) 2012 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/buffer.h"
+#include "libavutil/macros.h"
+#include "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/vulkan_spirv.h"
+#include "libavutil/hwcontext_vulkan.h"
+#include "libavutil/vulkan_loader.h"
+#include "libavutil/vulkan.h"
+#include "avcodec.h"
+#include "codec.h"
+#include "codec_internal.h"
+#include "encode.h"
+#include "packet.h"
+#include "put_bits.h"
+#include "profiles.h"
+#include "bytestream.h"
+#include "proresdata.h"
+#include "proresenc_kostya_common.h"
+#include "hwconfig.h"
+
+#define DCTSIZE 8
+
+typedef struct ProresDataTables {
+int16_t qmat[128][64];
+int16_t qmat_chroma[128][64];
+uint8_t scan[64];
+uint8_t dc_codebook[7];
+uint8_t run_to_cb[16];
+uint8_t level_to_cb[10];
+} ProresDataTables;
+
+typedef struct SliceDataInfo {
+int plane;
+int pictures_per_frame;
+int line_add;
+}
[FFmpeg-devel] [PATCH 1/3] vulkan: Support samplerless images
From: IndecisiveTurtle
---
libavutil/vulkan.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index ef755ad6f7..74eab88434 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -2507,7 +2507,8 @@ print:
GLSLA("layout (set = %i, binding = %i", FFMAX(shd->nb_descriptor_sets
- 1, 0), i);
if (desc[i].mem_layout &&
-(desc[i].type != VK_DESCRIPTOR_TYPE_STORAGE_IMAGE))
+(desc[i].type != VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) &&
+(desc[i].type != VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE))
GLSLA(", %s", desc[i].mem_layout);
GLSLA(")");
@@ -2520,7 +2521,7 @@ print:
if (prop->type) {
GLSLA(" ");
-if (desc[i].type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) {
+if (desc[i].type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE ||
desc[i].type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) {
if (desc[i].mem_layout) {
int len = strlen(desc[i].mem_layout);
if (desc[i].mem_layout[len - 1] == 'i' &&
--
2.50.1
___
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
