Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 19f4bd57e3d60dc6e40bc1ff96fbb91916dd7cc4 Mon Sep 17 00:00:00 2001
From 6fe97a207e1094365f4be54dff0a2412d3130042 Mon Sep 17 00:00:00 2001
From: Jing Sun <[email protected]>
Date: Wed, 21 Nov 2018 11:33:04 +0800
Subject: [PATCH] lavc/svt_hevc: add libsvt hevc encoder wrapper
Expand All @@ -21,46 +21,46 @@ UPDATED 2025-06-20 by Martin Pulec: rebased against 45a30e036 + fix compile
create mode 100644 libavcodec/libsvt_hevc.c

diff --git a/configure b/configure
index e1809a3e58..936cea82ab 100755
index 60e33e26e4..da24e814a4 100755
--- a/configure
+++ b/configure
@@ -339,6 +339,7 @@ External library support:
@@ -345,6 +345,7 @@ External library support:
--enable-whisper enable whisper filter [no]
--disable-xlib disable xlib [autodetect]
--disable-zlib disable zlib [autodetect]
+ --enable-libsvthevc enable HEVC encoding via svt [no]

The following libraries provide various hardware acceleration features:
--disable-amf disable AMF video encoding code [autodetect]
@@ -1979,6 +1980,7 @@ EXTERNAL_LIBRARY_LIST="
@@ -2052,6 +2053,7 @@ EXTERNAL_LIBRARY_LIST="
libsrt
libssh
libsvtav1
+ libsvthevc
libsvtjpegxs
libtensorflow
libtesseract
libtheora
@@ -3678,6 +3680,7 @@ vapoursynth_demuxer_deps="vapoursynth"
@@ -3792,6 +3794,7 @@ vapoursynth_demuxer_deps="vapoursynth"
videotoolbox_suggest="coreservices"
videotoolbox_deps="corefoundation coremedia corevideo VTDecompressionSessionDecodeFrame"
videotoolbox_encoder_deps="videotoolbox VTCompressionSessionPrepareToEncodeFrames"
+libsvt_hevc_encoder_deps="libsvthevc"

# demuxers / muxers
ac3_demuxer_select="ac3_parser"
@@ -7149,6 +7152,7 @@ enabled libssh && require_pkg_config libssh "libssh >= 0.6.0" libssh/
@@ -7313,6 +7316,7 @@ enabled libssh && require_pkg_config libssh "libssh >= 0.6.0" libssh/
enabled libspeex && require_pkg_config libspeex speex speex/speex.h speex_decoder_init
enabled libsrt && require_pkg_config libsrt "srt >= 1.3.0" srt/srt.h srt_socket
enabled libsvtav1 && require_pkg_config libsvtav1 "SvtAv1Enc >= 0.9.0" EbSvtAv1Enc.h svt_av1_enc_init_handle
+enabled libsvthevc && require_pkg_config libsvthevc SvtHevcEnc EbApi.h EbInitHandle
enabled libsvtjpegxs && require_pkg_config libsvtjpegxs "SvtJpegxs >= 0.10.0" SvtJpegxsEnc.h svt_jpeg_xs_encoder_init
enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h TF_Version -ltensorflow
enabled libtesseract && require_pkg_config libtesseract tesseract tesseract/capi.h TessBaseAPICreate
enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 35408949ac..12f534a1d7 100644
index 3d60347a19..db09ee37de 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1202,6 +1202,7 @@ OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER) += libwebpenc_common.o libwebpenc_anim
@@ -1225,6 +1225,7 @@ OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER) += libwebpenc_common.o libwebpenc_anim
OBJS-$(CONFIG_LIBX262_ENCODER) += libx264.o
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o
OBJS-$(CONFIG_LIBX265_ENCODER) += libx265.o
Expand All @@ -69,10 +69,10 @@ index 35408949ac..12f534a1d7 100644
OBJS-$(CONFIG_LIBXAVS2_ENCODER) += libxavs2.o
OBJS-$(CONFIG_LIBXEVD_DECODER) += libxevd.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index f5ec2e01e8..7844040a00 100644
index 042b07c895..69005226ef 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -827,6 +827,7 @@ extern const FFCodec ff_libxavs_encoder;
@@ -841,6 +841,7 @@ extern const FFCodec ff_libxavs_encoder;
extern const FFCodec ff_libxavs2_encoder;
extern const FFCodec ff_libxvid_encoder;
extern const FFCodec ff_libzvbi_teletext_decoder;
Expand Down Expand Up @@ -671,5 +671,5 @@ index 0000000000..07f62fa762
+ .p.wrapper_name = "libsvt_hevc",
+};
--
2.50.1
2.52.0

40 changes: 19 additions & 21 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ if test $cuda_req != no; then
# nvcc is intentional here
AC_PATH_PROG(NVCC, nvcc, [], [$CUDA_PATH_SEP$PATH]dnl
[$PATH_SEPARATOR/opt/cuda/bin$PATH_SEPARATOR/usr/local/cuda/bin])
if -z "$NVCC" && -e "$CUDACXX"; then
NVCC=$CUDACXX
fi
fi

if test -n "${NVCC?}" && test "${cross_compile?}" = no && test "${cuda_req?}" != no
Expand Down Expand Up @@ -1095,8 +1098,6 @@ AC_ARG_ENABLE(deltacast,
[deltacast_req=$enableval],
[deltacast_req=$build_default]
)
DELTACAST_PATH=$DELTACAST_DIRECTORY

AC_ARG_WITH(deltacast,
[ --with-deltacast=DIR specify location of DELTACAST],
[DELTACAST_PATH=$withval
Expand All @@ -1106,21 +1107,26 @@ if test "$deltacast_req" != no; then
if test "$system" = Linux || test "$system" = Windows; then
AC_LANG_PUSH(C++)

if test -n "$DELTACAST_PATH"; then
DELTA_INC="-I$DELTACAST_PATH/Include\
-I$DELTACAST_PATH/include/videomaster"
CXXFLAGS_SAVE=$CXXFLAGS
CXXFLAGS="$CXXFLAGS ${DELTA_INC?}"
CPPFLAGS_SAVE=$CPPFLAGS
CPPFLAGS="$CPPFLAGS ${DELTA_INC?}"
fi

if test $system = Windows; then
if test ${system?} = Windows; then
DELTACAST_PATH=\
${DELTACAST_DIRECTORY:-/c/PROGRA~1/DELTACAST/VideoMaster/resources}
DELTA_INC=-I$DELTACAST_PATH/include
DELTACAST_LIB=-L$DELTACAST_PATH/lib
EXTRA_HEADERS="#include <windows.h>"
else
DELTACAST_PATH=${DELTACAST_DIRECTORY:-/usr}
DELTA_INC=-I$DELTACAST_PATH/include/videomaster
DELTA_INC="$DELTA_INC -I$DELTACAST_PATH/Include" # old SDK compat
DELTACAST_LIB=-L$DELTACAST_PATH/lib
# no lib path compat for old SDKs - install them with 'make install'
EXTRA_HEADERS=
fi

CXXFLAGS_SAVE=$CXXFLAGS
CXXFLAGS="$CXXFLAGS ${DELTA_INC?}"
CPPFLAGS_SAVE=$CPPFLAGS
CPPFLAGS="$CPPFLAGS ${DELTA_INC?}"

AC_CHECK_HEADERS([VideoMasterHD_Core.h VideoMasterHD_Sdi.h VideoMasterHD_Sdi_Audio.h],
[], [],
[[$EXTRA_HEADERS
Expand All @@ -1133,15 +1139,7 @@ if test "$deltacast_req" != no; then
]])

SAVED_LIBS=$LIBS
DELTACAST_LIB="-lvideomasterhd_audio -lvideomasterhd"
if test -n "$DELTACAST_PATH"; then
if test "${ac_cv_sizeof_int_p?}" -eq 8 &&
test "${system?}" = Linux; then
DELTACAST_LIB="$DELTACAST_LIB -L$DELTACAST_PATH/Library/x64"
else
DELTACAST_LIB="$DELTACAST_LIB -L$DELTACAST_PATH/Library/x86"
fi
fi
DELTACAST_LIB="$DELTACAST_LIB -lvideomasterhd_audio -lvideomasterhd"
LIBS="$LIBS $DELTACAST_LIB"
AC_MSG_CHECKING([DELTACAST library presence])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[$EXTRA_HEADERS
Expand Down
44 changes: 30 additions & 14 deletions src/control_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ using namespace std;

struct client {
fd_t fd;
char buff[1024];
char buff[2048];
int buff_len;

struct client *prev;
Expand Down Expand Up @@ -655,17 +655,25 @@ static int process_msg(struct control_state *s, fd_t client_fd, char *message, s
dump_tree(s->root_module, 0);
resp = new_response(RESPONSE_OK, NULL);
} else { // assume message in format "path message"
struct msg_universal *msg = (struct msg_universal *)
new_message(sizeof(struct msg_universal));

if (strchr(message, ' ')) {
memcpy(path, message, strchr(message, ' ') - message);
strncpy(msg->text, strchr(message, ' ') + 1, sizeof(path) - 1);
} else {
strncpy(path, message, sizeof(path) - 1); // empty message ??
struct msg_universal *msg = (struct msg_universal *)
new_message(sizeof(struct msg_universal));

if (strchr(message, ' ')) {
size_t path_len = strchr(message, ' ') - message;
memcpy(path, message, path_len);
path[path_len] = '\0';
strncpy(msg->text, strchr(message, ' ') + 1, sizeof(msg->text) - 1);

// If path is "root", send directly to root module
if (strcmp(path, "root") == 0) {
path[0] = '\0';
}
} else {
path[0] = '\0';
strncpy(msg->text, message, sizeof(msg->text) - 1);
}

resp = send_message(s->root_module, path, (struct message *) msg);
resp = send_message_sync(s->root_module, path, (struct message *) msg, 100, 0);
}

if(!resp) {
Expand Down Expand Up @@ -695,8 +703,12 @@ static void send_response(fd_t fd, struct response *resp)
if (ret < 0) {
socket_error("Unable to write response");
}
#ifndef _WIN32
// Force flush on POSIX systems
fsync(fd);
#endif

free_response(resp);
free_response(resp);
}

static bool parse_msg(char *buffer, int buffer_len, /* out */ char *message, int *new_buffer_len)
Expand Down Expand Up @@ -852,7 +864,6 @@ static void * control_thread(void *args)
socket_error("[control socket] accept");
continue;
}

// all remote sockets are written sequentially so
// we don't want to block if one gets stuck
set_socket_nonblock(fd);
Expand Down Expand Up @@ -1063,7 +1074,8 @@ get_control_state(struct module *mod)
return (struct control_state *) control_mod->priv_data;
}

static void print_control_help() {

static void print_control_help() {
color_printf("Control internal commands:\n"
TBOLD("\texit") "\n"
TBOLD("\tpause") "\n"
Expand All @@ -1081,10 +1093,14 @@ static void print_control_help() {
" - (un)mutes audio sender or receiver\n"
TBOLD("\tpostprocess <new_postprocess> | flush") "\n"
TBOLD("\tdump-tree")"\n");
color_printf("\nHD-RUM Translator commands:\n"
TBOLD("\tcreate-port <host:port> [compression]") " - create new output port\n"
TBOLD("\tdelete-port <index|ip_address|port_name>") " - remove output port\n"
TBOLD("\tlist-ports") " - show all configured output ports and their IP addresses\n");
color_printf("\nOther commands can be issued directly to individual "
"modules (see \"" TBOLD("dump-tree") "\"), eg.:\n"
"\t" TBOLD("capture.filter mirror") "\n"
"\nSometimes those modules support help (eg. \"" TBOLD("capture.filter help") "\")\n\n");
color_printf(TBOLD(u8"¹") " audio commands applying to receiver\n\n");
}
}

1 change: 1 addition & 0 deletions src/control_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct module;
* @retval 0 if success
*/
int control_init(int port, int connection_type, struct control_state **state, struct module *root_module, int force_ip_version);
int control_get_port(struct control_state *state);
struct control_state *get_control_state(struct module *mod);
void control_start(struct control_state *state);
void control_done(struct control_state *s);
Expand Down
Loading