mirror of
https://github.com/libretro/Lakka-LibreELEC.git
synced 2024-11-23 08:20:00 +00:00
Add support for Nintendo Switch (#1536)
This commit is contained in:
parent
3982e1b98b
commit
c03d8024fb
@ -76,6 +76,7 @@ targets="\
|
||||
Amlogic|AMLGX|aarch64|image \
|
||||
Generic||i386|image \
|
||||
Generic||x86_64|image \
|
||||
L4T|Switch|aarch64|image \
|
||||
NXP|iMX6|arm|image \
|
||||
NXP|iMX8|aarch64|image \
|
||||
Rockchip|RK3288|arm|image \
|
||||
|
@ -351,6 +351,8 @@
|
||||
EXCLUDE_LIBRETRO_CORES+=" yabasanshiro"
|
||||
elif [ "${PROJECT}" = "Generic" -a "${ARCH}" = "i386" ]; then
|
||||
EXCLUDE_LIBRETRO_CORES+=" openlara"
|
||||
elif [ "${PROJECT}" = "L4T" -a "${DEVICE}" = "Switch" ]; then
|
||||
EXCLUDE_LIBRETRO_CORES+=" openlara desmume mame2010"
|
||||
fi
|
||||
|
||||
# disable cores that are only for specific targets
|
||||
|
@ -12,6 +12,10 @@ PKG_DEPENDS_TARGET="toolchain alsa-lib dbus libcap libsndfile libtool openssl so
|
||||
PKG_LONGDESC="PulseAudio is a sound system for POSIX OSes, meaning that it is a proxy for your sound applications."
|
||||
PKG_TOOLCHAIN="meson"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_PATCH_DIRS="${PROJECT}"
|
||||
fi
|
||||
|
||||
if [ "${BLUETOOTH_SUPPORT}" = "yes" ]; then
|
||||
PKG_DEPENDS_TARGET+=" sbc"
|
||||
PKG_PULSEAUDIO_BLUETOOTH="-Dbluez5=true"
|
||||
@ -81,6 +85,10 @@ post_makeinstall_target() {
|
||||
|
||||
cp ${PKG_DIR}/config/system.pa ${INSTALL}/etc/pulse/
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
echo load-module module-switch-on-port-available >> ${INSTALL}/etc/pulse/system.pa
|
||||
fi
|
||||
|
||||
sed 's/user="pulse"/user="root"/' -i ${INSTALL}/etc/dbus-1/system.d/pulseaudio-system.conf
|
||||
|
||||
mkdir -p ${INSTALL}/usr/config
|
||||
|
@ -0,0 +1,13 @@
|
||||
diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
|
||||
index 63ae69d..cfde522 100644
|
||||
--- a/build-aux/ltmain.sh
|
||||
+++ b/build-aux/ltmain.sh
|
||||
@@ -8556,7 +8556,7 @@ func_mode_link ()
|
||||
fi
|
||||
else
|
||||
# We cannot seem to hardcode it, guess we'll fake it.
|
||||
- add_dir=-L$libdir
|
||||
+ #add_dir=-L$libdir
|
||||
# Try looking first in the location we're being installed to.
|
||||
if test -n "$inst_prefix_dir"; then
|
||||
case $libdir in
|
@ -0,0 +1,204 @@
|
||||
diff --git a/packages/audio/pulseaudio/patches/pulseaudio-0900.03-eliminates-lags-after-bluetooth-packet-loss.patch b/packages/audio/pulseaudio/patches/pulseaudio-0900.03-eliminates-lags-after-bluetooth-packet-loss.patch
|
||||
new file mode 100644
|
||||
index 0000000..6a7aeab
|
||||
--- /dev/null
|
||||
+++ b/packages/audio/pulseaudio/patches/pulseaudio-0900.03-eliminates-lags-after-bluetooth-packet-loss.patch
|
||||
@@ -0,0 +1,198 @@
|
||||
+diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
|
||||
+index 84e6d55..b96a80d 100644
|
||||
+--- a/src/modules/bluetooth/module-bluez5-device.c
|
||||
++++ b/src/modules/bluetooth/module-bluez5-device.c
|
||||
+@@ -649,6 +649,29 @@ static int a2dp_process_push(struct userdata *u) {
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
++static void update_buffer_size(struct userdata *u) {
|
||||
++ int old_bufsize, new_bufsize;
|
||||
++ socklen_t len = sizeof(int);
|
||||
++ int rc;
|
||||
++
|
||||
++ rc = getsockopt(u->stream_fd, SOL_SOCKET, SO_SNDBUF, &old_bufsize, &len);
|
||||
++ if (rc == -1) {
|
||||
++ pa_log_warn("Changing bluetooth buffer size: Failed to getsockopt(SO_SNDBUF): %s", pa_cstrerror(errno));
|
||||
++ } else {
|
||||
++ bool ok = false;
|
||||
++ for (int n = 2; !ok && n < 16; ++n) {
|
||||
++ new_bufsize = n * u->write_link_mtu;
|
||||
++ rc = setsockopt(u->stream_fd, SOL_SOCKET, SO_SNDBUF, &new_bufsize, len);
|
||||
++ if (rc == -1) {
|
||||
++ pa_log_warn("Changing bluetooth buffer size: Failed to change from %d to %d: %s", old_bufsize, new_bufsize, pa_cstrerror(errno));
|
||||
++ } else {
|
||||
++ ok = true;
|
||||
++ pa_log_info("Changing bluetooth buffer size: Changed from %d to %d", old_bufsize, new_bufsize);
|
||||
++ }
|
||||
++ }
|
||||
++ }
|
||||
++}
|
||||
++
|
||||
+ /* Run from I/O thread */
|
||||
+ static void a2dp_set_bitpool(struct userdata *u, uint8_t bitpool) {
|
||||
+ struct sbc_info *sbc_info;
|
||||
+@@ -683,6 +706,8 @@ static void a2dp_set_bitpool(struct userdata *u, uint8_t bitpool) {
|
||||
+ pa_sink_set_max_request_within_thread(u->sink, u->write_block_size);
|
||||
+ pa_sink_set_fixed_latency_within_thread(u->sink,
|
||||
+ FIXED_LATENCY_PLAYBACK_A2DP + pa_bytes_to_usec(u->write_block_size, &u->sample_spec));
|
||||
++
|
||||
++ update_buffer_size(u);
|
||||
+ }
|
||||
+
|
||||
+ /* Run from I/O thread */
|
||||
+@@ -814,6 +839,8 @@ static void setup_stream(struct userdata *u) {
|
||||
+
|
||||
+ if (u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK)
|
||||
+ a2dp_set_bitpool(u, u->sbc_info.max_bitpool);
|
||||
++
|
||||
++ update_buffer_size(u);
|
||||
+
|
||||
+ u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
|
||||
+ pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
|
||||
+@@ -1327,6 +1354,7 @@ static void thread_func(void *userdata) {
|
||||
+ unsigned do_write = 0;
|
||||
+ unsigned pending_read_bytes = 0;
|
||||
+ bool writable = false;
|
||||
++ pa_usec_t ts_last_frame;
|
||||
+
|
||||
+ pa_assert(u);
|
||||
+ pa_assert(u->transport);
|
||||
+@@ -1341,11 +1369,16 @@ static void thread_func(void *userdata) {
|
||||
+ /* Setup the stream only if the transport was already acquired */
|
||||
+ if (u->transport_acquired)
|
||||
+ setup_stream(u);
|
||||
++ u->started_at = pa_rtclock_now();
|
||||
+
|
||||
++ ts_last_frame = u->started_at;
|
||||
++
|
||||
+ for (;;) {
|
||||
+ struct pollfd *pollfd;
|
||||
+ int ret;
|
||||
+ bool disable_timer = true;
|
||||
++ pa_usec_t ts_now = pa_rtclock_now();
|
||||
++ pa_usec_t ts_next_frame = ts_last_frame + pa_bytes_to_usec(u->write_block_size, &u->sample_spec);
|
||||
+
|
||||
+ pollfd = u->rtpoll_item ? pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL) : NULL;
|
||||
+
|
||||
+@@ -1404,86 +1437,57 @@ static void thread_func(void *userdata) {
|
||||
+ if (pollfd->revents & POLLOUT)
|
||||
+ writable = true;
|
||||
+
|
||||
+- if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && do_write <= 0 && writable) {
|
||||
+- pa_usec_t time_passed;
|
||||
+- pa_usec_t audio_sent;
|
||||
++ if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state))) {
|
||||
+
|
||||
+- /* Hmm, there is no input stream we could synchronize
|
||||
+- * to. So let's do things by time */
|
||||
++ if (ts_now >= ts_next_frame) {
|
||||
+
|
||||
+- time_passed = pa_rtclock_now() - u->started_at;
|
||||
+- audio_sent = pa_bytes_to_usec(u->write_index, &u->sample_spec);
|
||||
++ if (writable) {
|
||||
++ int n_written;
|
||||
++
|
||||
++ if (u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK) {
|
||||
++ if ((n_written = a2dp_process_render(u)) < 0)
|
||||
++ goto fail;
|
||||
++ } else {
|
||||
++ if ((n_written = sco_process_render(u)) < 0)
|
||||
++ goto fail;
|
||||
++ }
|
||||
+
|
||||
+- if (audio_sent <= time_passed) {
|
||||
+- pa_usec_t audio_to_send = time_passed - audio_sent;
|
||||
++ if (n_written == 0)
|
||||
++ pa_log("Broken kernel: we got EAGAIN on write() after POLLOUT!");
|
||||
+
|
||||
+- /* Never try to catch up for more than 100ms */
|
||||
+- if (u->write_index > 0 && audio_to_send > MAX_PLAYBACK_CATCH_UP_USEC) {
|
||||
++ do_write -= n_written;
|
||||
++ writable = false;
|
||||
++ } else {
|
||||
+ pa_usec_t skip_usec;
|
||||
+ uint64_t skip_bytes;
|
||||
++ pa_memchunk tmp;
|
||||
+
|
||||
+- skip_usec = audio_to_send - MAX_PLAYBACK_CATCH_UP_USEC;
|
||||
++ skip_usec = ts_now - ts_last_frame;
|
||||
+ skip_bytes = pa_usec_to_bytes(skip_usec, &u->sample_spec);
|
||||
+
|
||||
+- if (skip_bytes > 0) {
|
||||
+- pa_memchunk tmp;
|
||||
++ pa_log_warn("Skipping %llu us (= %llu bytes) in audio stream",
|
||||
++ (unsigned long long) skip_usec,
|
||||
++ (unsigned long long) skip_bytes);
|
||||
+
|
||||
+- pa_log_warn("Skipping %llu us (= %llu bytes) in audio stream",
|
||||
+- (unsigned long long) skip_usec,
|
||||
+- (unsigned long long) skip_bytes);
|
||||
++ pa_sink_render_full(u->sink, skip_bytes, &tmp);
|
||||
++ pa_memblock_unref(tmp.memblock);
|
||||
++ u->write_index += skip_bytes;
|
||||
+
|
||||
+- pa_sink_render_full(u->sink, skip_bytes, &tmp);
|
||||
+- pa_memblock_unref(tmp.memblock);
|
||||
+- u->write_index += skip_bytes;
|
||||
+-
|
||||
+- if (u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK)
|
||||
+- a2dp_reduce_bitpool(u);
|
||||
+- }
|
||||
++ if (u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK)
|
||||
++ a2dp_reduce_bitpool(u);
|
||||
+ }
|
||||
+-
|
||||
+- do_write = 1;
|
||||
++ ts_last_frame = ts_now;
|
||||
++ // TODO: ts_last_frame might be slightly inaccurate; it should depend on ts_next_frame
|
||||
+ pending_read_bytes = 0;
|
||||
+ }
|
||||
+- }
|
||||
+-
|
||||
+- if (writable && do_write > 0) {
|
||||
+- int n_written;
|
||||
+
|
||||
+- if (u->write_index <= 0)
|
||||
+- u->started_at = pa_rtclock_now();
|
||||
++ {
|
||||
++ pa_usec_t ts_now2 = pa_rtclock_now();
|
||||
++ pa_usec_t sleep_for = ts_now2 > ts_next_frame ? 0 : ts_next_frame - ts_now2;
|
||||
+
|
||||
+- if (u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK) {
|
||||
+- if ((n_written = a2dp_process_render(u)) < 0)
|
||||
+- goto fail;
|
||||
+- } else {
|
||||
+- if ((n_written = sco_process_render(u)) < 0)
|
||||
+- goto fail;
|
||||
++ pa_rtpoll_set_timer_relative(u->rtpoll, sleep_for);
|
||||
++ disable_timer = false;
|
||||
+ }
|
||||
+-
|
||||
+- if (n_written == 0)
|
||||
+- pa_log("Broken kernel: we got EAGAIN on write() after POLLOUT!");
|
||||
+-
|
||||
+- do_write -= n_written;
|
||||
+- writable = false;
|
||||
+- }
|
||||
+-
|
||||
+- if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && do_write <= 0) {
|
||||
+- pa_usec_t sleep_for;
|
||||
+- pa_usec_t time_passed, next_write_at;
|
||||
+-
|
||||
+- if (writable) {
|
||||
+- /* Hmm, there is no input stream we could synchronize
|
||||
+- * to. So let's estimate when we need to wake up the latest */
|
||||
+- time_passed = pa_rtclock_now() - u->started_at;
|
||||
+- next_write_at = pa_bytes_to_usec(u->write_index, &u->sample_spec);
|
||||
+- sleep_for = time_passed < next_write_at ? next_write_at - time_passed : 0;
|
||||
+- /* pa_log("Sleeping for %lu; time passed %lu, next write at %lu", (unsigned long) sleep_for, (unsigned long) time_passed, (unsigned long)next_write_at); */
|
||||
+- } else
|
||||
+- /* drop stream every 500 ms */
|
||||
+- sleep_for = PA_USEC_PER_MSEC * 500;
|
||||
+-
|
||||
+- pa_rtpoll_set_timer_relative(u->rtpoll, sleep_for);
|
||||
+- disable_timer = false;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
@ -35,6 +35,10 @@ PKG_CONFIGURE_OPTS_TARGET="BASH_SHELL=/bin/sh \
|
||||
--enable-lock-elision \
|
||||
--disable-timezone-tools"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET//--enable-kernel=5.4.0/--enable-kernel=3.0.0/}"
|
||||
fi
|
||||
|
||||
if build_with_debug; then
|
||||
PKG_CONFIGURE_OPTS_TARGET+=" --enable-debug"
|
||||
else
|
||||
|
@ -56,4 +56,7 @@ fi
|
||||
post_makeinstall_target() {
|
||||
mkdir -p ${INSTALL}/usr/bin
|
||||
cp -a ${PKG_BUILD}/.${TARGET_NAME}/tests/modetest/modetest ${INSTALL}/usr/bin/
|
||||
if [ "$PROJECT" = "L4T" ]; then
|
||||
rm ${INSTALL}/usr/lib/libdrm.so.2
|
||||
fi
|
||||
}
|
||||
|
@ -21,6 +21,16 @@ if [ "${PROJECT}" = "Generic" ]; then
|
||||
PKG_DEPENDS_TARGET+=" wii-u-gc-adapter joycond"
|
||||
fi
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_DEPENDS_TARGET+=" tegra-bsp"
|
||||
if [ "${DEVICE}" = "Switch" ]; then
|
||||
PKG_DEPENDS_TARGET+=" mergerfs xdotool switch-cpu-profile switch-gpu-profile switch-joycon-bluetooth-dock-configs switch-alsa-ucm-configs"
|
||||
if [ "${PULSEAUDIO_SUPPORT}" = "yes" ]; then
|
||||
PKG_DEPENDS_TARGET+=" switch-pulseaudio-configs"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${PROJECT}" = "RPi" ]; then
|
||||
PKG_DEPENDS_TARGET+=" rpi_disable_hdmi_service"
|
||||
if [ "${DEVICE}" != "GPICase" ] ; then
|
||||
|
@ -116,7 +116,9 @@ if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET+=" --enable-xinerama --disable-vulkan_display"
|
||||
PKG_CONFIGURE_OPTS_TARGET=${PKG_CONFIGURE_OPTS_TARGET//--enable-kms/--disable-kms}
|
||||
PKG_CONFIGURE_OPTS_TARGET=${PKG_CONFIGURE_OPTS_TARGET//--enable-egl/--disable-egl}
|
||||
PKG_MAKE_OPTS_TARGET+=" HAVE_LAKKA_SWITCH=1"
|
||||
if [ "${DEVICE}" = "Switch" ]; then
|
||||
PKG_MAKE_OPTS_TARGET+=" HAVE_LAKKA_SWITCH=1"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${LAKKA_NIGHTLY}" = yes ]; then
|
||||
@ -319,18 +321,13 @@ makeinstall_target() {
|
||||
sed -i -e "s/# menu_show_online_updater = true/menu_show_online_updater = false/" ${INSTALL}/etc/retroarch.cfg
|
||||
sed -i -e "s/# input_joypad_driver =/input_joypad_driver = udev/" ${INSTALL}/etc/retroarch.cfg
|
||||
sed -i -e "s/video_threaded = true/video_threaded = false/" ${INSTALL}/etc/retroarch.cfg
|
||||
sed -i -e "s/input_autodetect_enable = true/input_autodetect_enable = false/" ${INSTALL}/etc/retroarch.cfg
|
||||
|
||||
#Fix joycon index
|
||||
|
||||
#Set Default Joycon index to Combined Joycons.
|
||||
sed -i -e "s/# input_player1_joypad_index = 0/input_player1_joypad_index = \"2\"/" ${INSTALL}/etc/retroarch.cfg
|
||||
|
||||
#Set Joypad as joypad with analog
|
||||
sed -i -e "s/# input_libretro_device_p1 =/input_libretro_device_p1 = \"5\"/" ${INSTALL}/etc/retroarch.cfg
|
||||
|
||||
# Joypad Autoconfig doesn't work as Joy-Cons VID and PID are both 0
|
||||
# Does this still apply with joycond and new driver? Need to check this out.
|
||||
|
||||
cat ${PROJECT_DIR}/L4T/devices/Switch/joypad/Joy-Con_Combined.cfg >> ${INSTALL}/etc/retroarch.cfg
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
input_driver = "udev"
|
||||
input_device = "Nintendo Switch Combined Joy-Cons"
|
||||
input_vendor_id = "1406"
|
||||
input_product_id = "8200"
|
||||
input_b_btn = "0"
|
||||
input_y_btn = "3"
|
||||
input_select_btn = "9"
|
||||
input_start_btn = "10"
|
||||
input_up_btn = "14"
|
||||
input_down_btn = "15"
|
||||
input_left_btn = "16"
|
||||
input_right_btn = "17"
|
||||
input_a_btn = "1"
|
||||
input_x_btn = "2"
|
||||
input_l_btn = "5"
|
||||
input_r_btn = "6"
|
||||
input_l2_btn = "7"
|
||||
input_r2_btn = "8"
|
||||
input_l3_btn = "12"
|
||||
input_r3_btn = "13"
|
||||
input_l_x_plus_axis = "+0"
|
||||
input_l_x_minus_axis = "-0"
|
||||
input_l_y_plus_axis = "+1"
|
||||
input_l_y_minus_axis = "-1"
|
||||
input_r_x_plus_axis = "+2"
|
||||
input_r_x_minus_axis = "-2"
|
||||
input_r_y_plus_axis = "+3"
|
||||
input_r_y_minus_axis = "-3"
|
@ -0,0 +1,28 @@
|
||||
input_driver = "udev"
|
||||
input_device = "Nintendo Switch Pro Controller"
|
||||
input_vendor_id = "1406"
|
||||
input_product_id = "8201"
|
||||
input_b_btn = "0"
|
||||
input_y_btn = "3"
|
||||
input_select_btn = "9"
|
||||
input_start_btn = "10"
|
||||
input_up_btn = "14"
|
||||
input_down_btn = "15"
|
||||
input_left_btn = "16"
|
||||
input_right_btn = "17"
|
||||
input_a_btn = "1"
|
||||
input_x_btn = "2"
|
||||
input_l_btn = "5"
|
||||
input_r_btn = "6"
|
||||
input_l2_btn = "7"
|
||||
input_r2_btn = "8"
|
||||
input_l3_btn = "12"
|
||||
input_r3_btn = "13"
|
||||
input_l_x_plus_axis = "+0"
|
||||
input_l_x_minus_axis = "-0"
|
||||
input_l_y_plus_axis = "+1"
|
||||
input_l_y_minus_axis = "-1"
|
||||
input_r_x_plus_axis = "+2"
|
||||
input_r_x_minus_axis = "-2"
|
||||
input_r_y_plus_axis = "+3"
|
||||
input_r_y_minus_axis = "-3"
|
@ -0,0 +1,28 @@
|
||||
input_driver = "udev"
|
||||
input_device = "Nintendo Switch Snes Controller"
|
||||
input_vendor_id = "1406"
|
||||
input_product_id = "8215"
|
||||
input_b_btn = "0"
|
||||
input_y_btn = "3"
|
||||
input_select_btn = "9"
|
||||
input_start_btn = "10"
|
||||
input_up_btn = "14"
|
||||
input_down_btn = "15"
|
||||
input_left_btn = "16"
|
||||
input_right_btn = "17"
|
||||
input_a_btn = "1"
|
||||
input_x_btn = "2"
|
||||
input_l_btn = "5"
|
||||
input_r_btn = "6"
|
||||
input_l2_btn = "7"
|
||||
input_r2_btn = "8"
|
||||
input_l3_btn = "12"
|
||||
input_r3_btn = "13"
|
||||
input_l_x_plus_axis = "+0"
|
||||
input_l_x_minus_axis = "-0"
|
||||
input_l_y_plus_axis = "+1"
|
||||
input_l_y_minus_axis = "-1"
|
||||
input_r_x_plus_axis = "+2"
|
||||
input_r_x_minus_axis = "-2"
|
||||
input_r_y_plus_axis = "+3"
|
||||
input_r_y_minus_axis = "-3"
|
@ -9,4 +9,15 @@ PKG_TOOLCHAIN="manual"
|
||||
|
||||
makeinstall_target() {
|
||||
make -C ${PKG_BUILD} install INSTALLDIR="${INSTALL}/etc/retroarch-joypad-autoconfig" DOC_DIR="${INSTALL}/etc/doc/."
|
||||
|
||||
#Remove non tested joycon configs
|
||||
rm "${INSTALL}"/etc/retroarch-joypad-autoconfig/udev/Nintendo\ -\ Switch\ Pro\ Controller\ \(bare\).cfg
|
||||
rm "${INSTALL}"/etc/retroarch-joypad-autoconfig/udev/Nintendo\ -\ Switch\ Pro\ Controller.cfg
|
||||
rm "${INSTALL}"/etc/retroarch-joypad-autoconfig/udev/Nintendo-Switch-Online_NES-Controller_Left.cfg
|
||||
rm "${INSTALL}"/etc/retroarch-joypad-autoconfig/udev/Nintendo-Switch-Online_NES-Controller_Right.cfg
|
||||
|
||||
#Place Working configs
|
||||
cp -Pr "${PKG_DIR}"/joypad_configs/* "${INSTALL}"/etc/retroarch-joypad-autoconfig/
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,15 @@ case "${LINUX}" in
|
||||
PKG_SOURCE_NAME="linux-$LINUX-$PKG_VERSION.tar.gz"
|
||||
fi
|
||||
;;
|
||||
L4T)
|
||||
PKG_VERSION=$DEVICE
|
||||
PKG_URL="l4t-kernel-sources"
|
||||
GET_HANDLER_SUPPORT="l4t-kernel-sources"
|
||||
PKG_PATCH_DIRS="${PROJECT} ${PROJECT}/${DEVICE}"
|
||||
PKG_SOURCE_NAME="linux-$DEVICE.tar.gz"
|
||||
#Need to find a better way to do this for l4t platforms!
|
||||
PKG_SHA256=$L4T_COMBINED_KERNEL_SHA256
|
||||
;;
|
||||
*)
|
||||
PKG_VERSION="5.14.9"
|
||||
PKG_SHA256="ba8f07db92d514a2636e882bcd646f79f1c8ab83f5ad82910732dd0ec83c87e6"
|
||||
@ -46,8 +55,6 @@ PKG_KERNEL_CFG_FILE=$(kernel_config_path) || die
|
||||
|
||||
[ "${DISTRO}" = "Lakka" ] && PKG_PATCH_DIRS+=" ${DISTRO}-${LINUX}" || true
|
||||
|
||||
[ "${DISTRO}" = "Lakka" ] && PKG_PATCH_DIRS+=" ${DISTRO}-${LINUX}" || true
|
||||
|
||||
if [ -n "${KERNEL_TOOLCHAIN}" ]; then
|
||||
PKG_DEPENDS_HOST+=" gcc-arm-${KERNEL_TOOLCHAIN}:host"
|
||||
PKG_DEPENDS_TARGET+=" gcc-arm-${KERNEL_TOOLCHAIN}:host"
|
||||
@ -89,19 +96,52 @@ post_patch() {
|
||||
}
|
||||
|
||||
make_host() {
|
||||
:
|
||||
if [ "${LINUX}" = "L4T" ]; then
|
||||
CURRENT_PATH=${PATH}
|
||||
export PATH=${TOOLCHAIN}/lib/gcc-arm-aarch64-none-linux-gnu/bin/:${PATH}
|
||||
|
||||
make \
|
||||
ARCH=arm64 \
|
||||
CROSS_COMPILE=${KERNEL_TOOLCHAIN}- \
|
||||
olddefconfig
|
||||
make \
|
||||
ARCH=arm64 \
|
||||
CROSS_COMPILE=${KERNEL_TOOLCHAIN}- \
|
||||
prepare
|
||||
#make \
|
||||
# ARCH=arm64 \
|
||||
# CROSS_COMPILE=${KERNEL_TOOLCHAIN}- \
|
||||
# modules_prepare
|
||||
make \
|
||||
ARCH=arm64 \
|
||||
headers_check
|
||||
|
||||
export PATH=${CURRENT_PATH}
|
||||
fi
|
||||
}
|
||||
|
||||
makeinstall_host() {
|
||||
make \
|
||||
ARCH=${HEADERS_ARCH:-${TARGET_KERNEL_ARCH}} \
|
||||
HOSTCC="${TOOLCHAIN}/bin/host-gcc" \
|
||||
HOSTCXX="${TOOLCHAIN}/bin/host-g++" \
|
||||
HOSTCFLAGS="${HOST_CFLAGS}" \
|
||||
HOSTCXXFLAGS="${HOST_CXXFLAGS}" \
|
||||
HOSTLDFLAGS="${HOST_LDFLAGS}" \
|
||||
INSTALL_HDR_PATH=dest \
|
||||
headers_install
|
||||
if [ "${LINUX}" = "L4T" ]; then
|
||||
CURRENT_PATH=${PATH}
|
||||
export PATH=${TOOLCHAIN}/lib/gcc-arm-aarch64-none-linux-gnu/bin/:${PATH}
|
||||
make \
|
||||
ARCH=arm64 \
|
||||
CROSS_COMPILE=${KERNEL_TOOLCHAIN}- \
|
||||
INSTALL_HDR_PATH=dest \
|
||||
headers_install
|
||||
export PATH=${CURRENT_PATH}
|
||||
else
|
||||
make \
|
||||
ARCH=${HEADERS_ARCH:-$TARGET_KERNEL_ARCH} \
|
||||
HOSTCC="${TOOLCHAIN}/bin/host-gcc" \
|
||||
HOSTCXX="${TOOLCHAIN}/bin/host-g++" \
|
||||
HOSTCFLAGS="${HOST_CFLAGS}" \
|
||||
HOSTCXXFLAGS="${HOST_CXXFLAGS}" \
|
||||
HOSTLDFLAGS="${HOST_LDFLAGS}" \
|
||||
INSTALL_HDR_PATH=dest \
|
||||
headers_install
|
||||
fi
|
||||
|
||||
mkdir -p ${SYSROOT_PREFIX}/usr/include
|
||||
cp -R dest/include/* ${SYSROOT_PREFIX}/usr/include
|
||||
}
|
||||
@ -158,11 +198,13 @@ pre_make_target() {
|
||||
fi
|
||||
|
||||
# enable nouveau driver when required
|
||||
if listcontains "${GRAPHIC_DRIVERS}" "nouveau"; then
|
||||
${PKG_BUILD}/scripts/config --enable CONFIG_DRM_NOUVEAU
|
||||
${PKG_BUILD}/scripts/config --enable CONFIG_DRM_NOUVEAU_BACKLIGHT
|
||||
${PKG_BUILD}/scripts/config --set-val CONFIG_NOUVEAU_DEBUG 5
|
||||
${PKG_BUILD}/scripts/config --set-val CONFIG_NOUVEAU_DEBUG_DEFAULT 3
|
||||
if [ ! "${LINUX}" = "L4T" ]; then
|
||||
if listcontains "${GRAPHIC_DRIVERS}" "nouveau"; then
|
||||
${PKG_BUILD}/scripts/config --enable CONFIG_DRM_NOUVEAU
|
||||
${PKG_BUILD}/scripts/config --enable CONFIG_DRM_NOUVEAU_BACKLIGHT
|
||||
${PKG_BUILD}/scripts/config --set-val CONFIG_NOUVEAU_DEBUG 5
|
||||
${PKG_BUILD}/scripts/config --set-val CONFIG_NOUVEAU_DEBUG_DEFAULT 3
|
||||
fi
|
||||
fi
|
||||
|
||||
# enable MIDI for Lakka on x86_64, i386 has options set in linux config file
|
||||
@ -244,42 +286,48 @@ pre_make_target() {
|
||||
${PKG_BUILD}/scripts/config --set-str CONFIG_EXTRA_FIRMWARE_DIR "external-firmware"
|
||||
fi
|
||||
|
||||
if [ -f "${DISTRO_DIR}/${DISTRO}/kernel_options_overrides" ]; then
|
||||
while read OPTION; do
|
||||
[ -z "${OPTION}" -o -n "$(echo "${OPTION}" | grep '^#')" ] && continue
|
||||
if [ ! "${LINUX}" = "L4T" ]; then
|
||||
if [ -f "${DISTRO_DIR}/${DISTRO}/kernel_options_overrides" ]; then
|
||||
while read OPTION; do
|
||||
[ -z "${OPTION}" -o -n "$(echo "${OPTION}" | grep '^#')" ] && continue
|
||||
|
||||
OPTION_NAME=${OPTION%%=*}
|
||||
OPTION_VAL_OVR=${OPTION##*=}
|
||||
OPTION_VAL_CFG=$(${PKG_BUILD}/scripts/config --state ${OPTION_NAME})
|
||||
|
||||
OPTION_NAME=${OPTION%%=*}
|
||||
OPTION_VAL_OVR=${OPTION##*=}
|
||||
OPTION_VAL_CFG=$(${PKG_BUILD}/scripts/config --state ${OPTION_NAME})
|
||||
if [ "${OPTION_VAL_OVR}" = "${OPTION_VAL_CFG}" ] || [ "${OPTION_VAL_OVR}" = "n" -a "${OPTION_VAL_CFG}" = "undef" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${OPTION_VAL_OVR}" = "${OPTION_VAL_CFG}" ] || [ "${OPTION_VAL_OVR}" = "n" -a "${OPTION_VAL_CFG}" = "undef" ]; then
|
||||
continue
|
||||
fi
|
||||
case ${OPTION_VAL_OVR} in
|
||||
y)
|
||||
OPTION_ACTION="enable"
|
||||
;;
|
||||
m)
|
||||
OPTION_ACTION="module"
|
||||
;;
|
||||
n)
|
||||
OPTION_ACTION="disable"
|
||||
;;
|
||||
*)
|
||||
OPTION_ACTION="undefine"
|
||||
OPTION_VAL_OVR="u"
|
||||
;;
|
||||
esac
|
||||
|
||||
case ${OPTION_VAL_OVR} in
|
||||
y)
|
||||
OPTION_ACTION="enable"
|
||||
;;
|
||||
m)
|
||||
OPTION_ACTION="module"
|
||||
;;
|
||||
n)
|
||||
OPTION_ACTION="disable"
|
||||
;;
|
||||
*)
|
||||
OPTION_ACTION="undefine"
|
||||
OPTION_VAL_OVR="u"
|
||||
;;
|
||||
esac
|
||||
echo -e "Kernel config override: [${OPTION_VAL_OVR}] ${OPTION_NAME}"
|
||||
${PKG_BUILD}/scripts/config --${OPTION_ACTION} ${OPTION_NAME}
|
||||
|
||||
echo -e "Kernel config override: [${OPTION_VAL_OVR}] ${OPTION_NAME}"
|
||||
${PKG_BUILD}/scripts/config --${OPTION_ACTION} ${OPTION_NAME}
|
||||
|
||||
done < ${DISTRO_DIR}/${DISTRO}/kernel_options_overrides
|
||||
done < ${DISTRO_DIR}/${DISTRO}/kernel_options_overrides
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${DISTRO}" = "Lakka" ]; then
|
||||
if [ "${LINUX}" = "L4T" ]; then
|
||||
kernel_make olddefconfig
|
||||
kernel_make prepare
|
||||
kernel_make modules_prepare
|
||||
elif [ "${DISTRO}" = "Lakka" ]; then
|
||||
kernel_make olddefconfig
|
||||
else
|
||||
kernel_make oldconfig
|
||||
@ -314,42 +362,48 @@ make_target() {
|
||||
KERNEL_UIMAGE_TARGET="${KERNEL_TARGET}"
|
||||
KERNEL_TARGET="${KERNEL_TARGET/uImage/Image}"
|
||||
fi
|
||||
|
||||
DTC_FLAGS=-@ kernel_make ${KERNEL_TARGET} ${KERNEL_MAKE_EXTRACMD} modules
|
||||
|
||||
if [ "${PKG_BUILD_PERF}" = "yes" ]; then
|
||||
( cd tools/perf
|
||||
|
||||
# arch specific perf build args
|
||||
case "${TARGET_ARCH}" in
|
||||
x86_64|i386)
|
||||
PERF_BUILD_ARGS="ARCH=x86"
|
||||
;;
|
||||
aarch64)
|
||||
PERF_BUILD_ARGS="ARCH=arm64"
|
||||
;;
|
||||
*)
|
||||
PERF_BUILD_ARGS="ARCH=${TARGET_ARCH}"
|
||||
;;
|
||||
esac
|
||||
|
||||
WERROR=0 \
|
||||
NO_LIBPERL=1 \
|
||||
NO_LIBPYTHON=1 \
|
||||
NO_SLANG=1 \
|
||||
NO_GTK2=1 \
|
||||
NO_LIBNUMA=1 \
|
||||
NO_LIBAUDIT=1 \
|
||||
NO_LZMA=1 \
|
||||
NO_SDT=1 \
|
||||
CROSS_COMPILE="${TARGET_PREFIX}" \
|
||||
JOBS="${CONCURRENCY_MAKE_LEVEL}" \
|
||||
make ${PERF_BUILD_ARGS}
|
||||
mkdir -p ${INSTALL}/usr/bin
|
||||
cp perf ${INSTALL}/usr/bin
|
||||
)
|
||||
|
||||
if [ "${LINUX}" = "L4T" ]; then
|
||||
export KCFLAGS+="-Wno-error=sizeof-pointer-memaccess -Wno-error=missing-attributes -Wno-error=stringop-truncation -Wno-error=stringop-overflow= -Wno-error=address-of-packed-member -Wno-error=tautological-compare -Wno-error=packed-not-aligned -Wno-error=implicit-function-declaration"
|
||||
fi
|
||||
|
||||
DTC_FLAGS=-@ kernel_make TOOLCHAIN="${TOOLCHAIN}" ${KERNEL_TARGET} ${KERNEL_MAKE_EXTRACMD} modules
|
||||
|
||||
if [ ! "${LINUX}" = "L4T" ]; then
|
||||
if [ "${PKG_BUILD_PERF}" = "yes" ]; then
|
||||
( cd tools/perf
|
||||
|
||||
# arch specific perf build args
|
||||
case "${TARGET_ARCH}" in
|
||||
x86_64)
|
||||
PERF_BUILD_ARGS="ARCH=x86"
|
||||
;;
|
||||
aarch64)
|
||||
PERF_BUILD_ARGS="ARCH=arm64"
|
||||
;;
|
||||
*)
|
||||
PERF_BUILD_ARGS="ARCH=${TARGET_ARCH}"
|
||||
;;
|
||||
esac
|
||||
|
||||
WERROR=0 \
|
||||
NO_LIBPERL=1 \
|
||||
NO_LIBPYTHON=1 \
|
||||
NO_SLANG=1 \
|
||||
NO_GTK2=1 \
|
||||
NO_LIBNUMA=1 \
|
||||
NO_LIBAUDIT=1 \
|
||||
NO_LZMA=1 \
|
||||
NO_SDT=1 \
|
||||
CROSS_COMPILE="${TARGET_PREFIX}" \
|
||||
JOBS="${CONCURRENCY_MAKE_LEVEL}" \
|
||||
make ${PERF_BUILD_ARGS}
|
||||
mkdir -p ${INSTALL}/usr/bin
|
||||
cp perf ${INSTALL}/usr/bin
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${KERNEL_UIMAGE_TARGET}" ]; then
|
||||
# determine compression used for kernel image
|
||||
KERNEL_UIMAGE_COMP=${KERNEL_UIMAGE_TARGET:7}
|
||||
@ -388,7 +442,10 @@ makeinstall_target() {
|
||||
rm -f ${INSTALL}/$(get_kernel_overlay_dir)/lib/modules/*/build
|
||||
rm -f ${INSTALL}/$(get_kernel_overlay_dir)/lib/modules/*/source
|
||||
|
||||
if [ "${BOOTLOADER}" = "u-boot" ]; then
|
||||
if [ "$BOOTLOADER" = "switch-bootloader" ]; then
|
||||
mkdir -p $INSTALL/usr/share/bootloader/boot/
|
||||
cp arch/arm64/boot/dts/tegra210-icosa.dtb $INSTALL/usr/share/bootloader/boot/
|
||||
elif [ "${BOOTLOADER}" = "u-boot" ]; then
|
||||
mkdir -p ${INSTALL}/usr/share/bootloader
|
||||
for dtb in arch/${TARGET_KERNEL_ARCH}/boot/dts/*.dtb arch/${TARGET_KERNEL_ARCH}/boot/dts/*/*.dtb; do
|
||||
if [ -f ${dtb} ]; then
|
||||
|
@ -84,6 +84,15 @@ else
|
||||
PKG_FFMPEG_DEBUG="--disable-debug --enable-stripping"
|
||||
fi
|
||||
|
||||
#Re-enable when patches are rebased on newer version of ffmpeg,for now we use old version.
|
||||
#
|
||||
if [ "$PROJECT" = "L4T" ]; then
|
||||
PKG_DEPENDS_TARGET+=" jetson-ffmpeg"
|
||||
# PKG_PATCH_DIRS+=" L4T"
|
||||
# PKG_FFMPEG_NVMPI="--enable-nvmpi"
|
||||
PKG_FFMPEG_NVMPI=" "
|
||||
fi
|
||||
|
||||
if target_has_feature neon; then
|
||||
PKG_FFMPEG_FPU="--enable-neon"
|
||||
else
|
||||
@ -210,7 +219,8 @@ configure_target() {
|
||||
--enable-asm \
|
||||
--disable-altivec \
|
||||
${PKG_FFMPEG_FPU} \
|
||||
--disable-symver
|
||||
--disable-symver \
|
||||
${PKG_FFMPEG_NVMPI}
|
||||
}
|
||||
|
||||
post_makeinstall_target() {
|
||||
|
@ -34,8 +34,14 @@ PKG_CONFIGURE_OPTS_TARGET="--disable-dependency-tracking \
|
||||
--disable-experimental \
|
||||
--enable-sixaxis \
|
||||
--with-gnu-ld \
|
||||
${BLUEZ_CONFIG} \
|
||||
storagedir=/storage/.cache/bluetooth"
|
||||
${BLUEZ_CONFIG}"
|
||||
|
||||
# bluez had the good idea to use ':' in storage filenames, fat32 doesn't like that
|
||||
if [ "${DEVICE}" = "Switch" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET+=" storagedir=/var/bluetoothconfig"
|
||||
else
|
||||
PKG_CONFIGURE_OPTS_TARGET+=" storagedir=/storage/.cache/bluetooth"
|
||||
fi
|
||||
|
||||
pre_configure_target() {
|
||||
# bluez fails to build in subdirs
|
||||
|
@ -146,6 +146,10 @@ makeinstall_target() {
|
||||
cp ${PKG_DIR}/config/inputrc ${INSTALL}/etc
|
||||
cp ${PKG_DIR}/config/suspend-modules.conf ${INSTALL}/etc
|
||||
|
||||
if [ "${DEVICE}" = "Switch" ]; then
|
||||
sed -i 's/brcmfmac//' ${INSTALL}/etc/suspend-modules.conf
|
||||
fi
|
||||
|
||||
# /etc/fstab is needed by...
|
||||
touch ${INSTALL}/etc/fstab
|
||||
|
||||
@ -209,6 +213,21 @@ makeinstall_init() {
|
||||
|
||||
cp ${PKG_DIR}/scripts/functions ${INSTALL}
|
||||
cp ${PKG_DIR}/scripts/init ${INSTALL}
|
||||
|
||||
#Hack to swap out init, and add early firmware to initramfs for L4T builds
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
# Copy PROJECT related files to filesystem
|
||||
if [ -d "${PROJECT_DIR}/${PROJECT}/initramfs" ]; then
|
||||
cp -PR ${PROJECT_DIR}/${PROJECT}/initramfs/* ${INSTALL}
|
||||
fi
|
||||
|
||||
# Copy DEVICE related initramfs files to initramfs filesystem
|
||||
if [ -n "$DEVICE" -a -d "${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/initramfs" ]; then
|
||||
cp -PR ${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/initramfs/* ${INSTALL}
|
||||
mv ${INSTALL}/lib/firmware ${INSTALL}/usr
|
||||
fi
|
||||
fi
|
||||
|
||||
sed -e "s/@DISTRONAME@/${DISTRONAME}/g" \
|
||||
-e "s/@KERNEL_NAME@/${KERNEL_NAME}/g" \
|
||||
-e "s/@SYSTEM_SIZE@/${SYSTEM_SIZE}/g" \
|
||||
|
@ -551,8 +551,12 @@ mount_flash() {
|
||||
|
||||
wakeonlan
|
||||
|
||||
mount_part "$boot" "/flash" "ro,noatime"
|
||||
|
||||
if [ ! "$NX_BOOT" = "yes" ]; then
|
||||
mount_part "$boot" "/flash" "ro,noatime"
|
||||
else
|
||||
mount_part "$boot" "/flash" "rw,noatime"
|
||||
fi
|
||||
|
||||
if [ -f /flash/post-flash.sh ]; then
|
||||
. /flash/post-flash.sh
|
||||
fi
|
||||
@ -582,8 +586,11 @@ mount_storage() {
|
||||
fi
|
||||
|
||||
wakeonlan
|
||||
|
||||
if [ -n "$disk" ]; then
|
||||
|
||||
if [ "$NX_BOOT" = "yes" ]; then
|
||||
mkdir -p /flash/lakka/storage
|
||||
mount --bind /flash/lakka/storage /storage
|
||||
elif [ -n "$disk" ]; then
|
||||
if [ -n "$OVERLAY" ]; then
|
||||
OVERLAY_DIR=$(cat /sys/class/net/eth0/address | tr -d :)
|
||||
|
||||
@ -942,13 +949,15 @@ prepare_sysroot() {
|
||||
mount --move /flash /sysroot/flash
|
||||
mount --move /storage /sysroot/storage
|
||||
|
||||
if [ ! -d "/sysroot/usr/lib/kernel-overlays/base/lib/modules/$(uname -r)/" -a -f "/sysroot/usr/lib/systemd/systemd" ]; then
|
||||
echo ""
|
||||
echo "NEVER TOUCH boot= in syslinux.conf / cmdline.txt!"
|
||||
echo "If you don't know what you are doing,"
|
||||
echo "your installation is now broken."
|
||||
echo ""
|
||||
StartProgress countdown "Normal startup in 60s... " 60 "NOW"
|
||||
if [ ! "$NX_BOOT" = "yes" ]; then
|
||||
if [ ! -d "/sysroot/usr/lib/kernel-overlays/base/lib/modules/$(uname -r)/" -a -f "/sysroot/usr/lib/systemd/systemd" ]; then
|
||||
echo ""
|
||||
echo "NEVER TOUCH boot= in syslinux.conf / cmdline.txt!"
|
||||
echo "If you don't know what you are doing,"
|
||||
echo "your installation is now broken."
|
||||
echo ""
|
||||
StartProgress countdown "Normal startup in 60s... " 60 "NOW"
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -f "/sysroot/usr/lib/systemd/systemd" ] || error "final_check" "Could not find systemd!"
|
||||
@ -1057,6 +1066,9 @@ for arg in $(cat /proc/cmdline); do
|
||||
ip=*)
|
||||
KERNEL_IPCONFIG="yes"
|
||||
;;
|
||||
nx-boot)
|
||||
NX_BOOT="yes"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
@ -12,20 +12,27 @@ PKG_DEPENDS_TARGET="toolchain xkeyboard-config libxml2"
|
||||
PKG_LONGDESC="xkbcommon is a library to handle keyboard descriptions."
|
||||
|
||||
PKG_MESON_OPTS_TARGET="-Denable-docs=false"
|
||||
if ! [ "${PROJECT}" = "L4T" ]; then
|
||||
|
||||
if [ "${DISPLAYSERVER}" = "x11" ]; then
|
||||
PKG_MESON_OPTS_TARGET+=" -Denable-x11=true \
|
||||
-Denable-wayland=false"
|
||||
elif [ "${DISPLAYSERVER}" = "weston" ]; then
|
||||
PKG_MESON_OPTS_TARGET+=" -Denable-x11=false \
|
||||
-Denable-wayland=true"
|
||||
if [ "${DISPLAYSERVER}" = "x11" ]; then
|
||||
PKG_MESON_OPTS_TARGET+=" -Denable-x11=true \
|
||||
-Denable-wayland=false"
|
||||
elif [ "${DISPLAYSERVER}" = "weston" ]; then
|
||||
PKG_MESON_OPTS_TARGET+=" -Denable-x11=false \
|
||||
-Denable-wayland=true"
|
||||
else
|
||||
PKG_MESON_OPTS_TARGET+=" -Denable-x11=false \
|
||||
-Denable-wayland=false"
|
||||
fi
|
||||
else
|
||||
PKG_MESON_OPTS_TARGET+=" -Denable-x11=false \
|
||||
-Denable-wayland=false"
|
||||
fi
|
||||
|
||||
pre_configure_target() {
|
||||
if [ "${DISPLAYSERVER}" = "x11" ]; then
|
||||
TARGET_LDFLAGS="${LDFLAGS} -lXau -lxcb"
|
||||
if ! [ "${PROJECT}" = "L4T" ]; then
|
||||
if [ "${DISPLAYSERVER}" = "x11" ]; then
|
||||
TARGET_LDFLAGS="${LDFLAGS} -lXau -lxcb"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
10
packages/x11/driver/xf86-video-nouveau/package.mk
Normal file
10
packages/x11/driver/xf86-video-nouveau/package.mk
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
PKG_NAME="xf86-video-nouveau"
|
||||
PKG_VERSION="1.0.16"
|
||||
PKG_LICENSE="OSS"
|
||||
PKG_SITE="http://www.X.org"
|
||||
PKG_DEPENDS_TARGET="toolchain util-macros xorg-server"
|
||||
PKG_URL="http://xorg.freedesktop.org/archive/individual/driver/$PKG_NAME-$PKG_VERSION.tar.bz2"
|
||||
|
||||
PKG_AUTORECONF="yes"
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-glamor --enable-udev --with-xorg-module-dir=$XORG_PATH_MODULES"
|
@ -15,3 +15,7 @@ PKG_CONFIGURE_OPTS_TARGET="--enable-static \
|
||||
--disable-shared \
|
||||
--disable-ipv6 \
|
||||
--without-xmlto"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -16,3 +16,7 @@ PKG_CONFIGURE_OPTS_TARGET="--enable-static \
|
||||
--with-libuuid \
|
||||
--without-xmlto \
|
||||
--without-fop"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -13,3 +13,7 @@ PKG_LONGDESC="X authorization file management libary"
|
||||
PKG_BUILD_FLAGS="+pic"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared --enable-xthreads"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -13,3 +13,7 @@ PKG_LONGDESC="X Composite Library"
|
||||
PKG_BUILD_FLAGS="+pic"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -13,3 +13,7 @@ PKG_LONGDESC="LibXdamage provides an X Window System client interface to the DAM
|
||||
PKG_BUILD_FLAGS="+pic"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -13,3 +13,7 @@ PKG_LONGDESC="X Fixes Library"
|
||||
PKG_BUILD_FLAGS="+pic"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -21,3 +21,7 @@ PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared \
|
||||
--enable-fc \
|
||||
--with-gnu-ld \
|
||||
--without-xmlto"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -22,3 +22,7 @@ PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared \
|
||||
--without-xsltproc \
|
||||
--without-asciidoc \
|
||||
--with-gnu-ld"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -12,3 +12,7 @@ PKG_DEPENDS_TARGET="toolchain util-macros libXext"
|
||||
PKG_LONGDESC="libXinerama is the Xinerama library."
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared --enable-malloc0returnsnull"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -13,3 +13,7 @@ PKG_LONGDESC="LibXmu provides a set of miscellaneous utility convenience functio
|
||||
PKG_BUILD_FLAGS="+pic"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared --with-gnu-ld --without-xmlto"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -13,3 +13,7 @@ PKG_LONGDESC="The X Rendering Extension introduces digital image composition wit
|
||||
PKG_BUILD_FLAGS="+pic"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared --enable-malloc0returnsnull"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -16,6 +16,10 @@ PKG_CONFIGURE_OPTS_TARGET="--enable-static \
|
||||
--with-gnu-ld \
|
||||
--enable-malloc0returnsnull"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
||||
pre_make_target() {
|
||||
make -C util CC=${HOST_CC} \
|
||||
CFLAGS="${HOST_CFLAGS} " \
|
||||
|
@ -12,3 +12,7 @@ PKG_DEPENDS_TARGET="toolchain util-macros libXext libXi libX11"
|
||||
PKG_LONGDESC="The Xtst Library"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared --with-gnu-ld --without-xmlto"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -13,3 +13,7 @@ PKG_LONGDESC="The libxxf86vm provides an interface to the server extension XFree
|
||||
PKG_BUILD_FLAGS="+pic"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared --enable-malloc0returnsnull"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -13,3 +13,7 @@ PKG_LONGDESC="Libfontenc is a library which helps font libraries portably determ
|
||||
PKG_BUILD_FLAGS="+pic"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -12,3 +12,7 @@ PKG_DEPENDS_TARGET="toolchain util-macros libX11"
|
||||
PKG_LONGDESC="Libxkbfile provides an interface to read and manipulate description files for XKB, the X11 keyboard configuration extension."
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -14,3 +14,7 @@ PKG_TOOLCHAIN="autotools"
|
||||
PKG_BUILD_FLAGS="+pic"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static --disable-shared"
|
||||
|
||||
if [ "${PROJECT}" = "L4T" ]; then
|
||||
PKG_CONFIGURE_OPTS_TARGET="${PKG_CONFIGURE_OPTS_TARGET/--disable-shared/--enable-shared}"
|
||||
fi
|
||||
|
@ -38,6 +38,7 @@ targets="\
|
||||
Amlogic|AMLGX|aarch64| \
|
||||
Generic||i386| \
|
||||
Generic||x86_64| \
|
||||
L4T|Switch|aarch64| \
|
||||
NXP|iMX6|arm| \
|
||||
NXP|iMX8|aarch64| \
|
||||
Rockchip|RK3288|arm| \
|
||||
|
@ -0,0 +1,128 @@
|
||||
NVRAMRev=662895
|
||||
sromrev=11
|
||||
boardrev=0x1250
|
||||
boardtype=0x074a
|
||||
boardflags=0x02400001
|
||||
boardflags2=0xc0802000
|
||||
boardflags3=0x00000108
|
||||
macaddr=00:90:4c:1a:a0:01
|
||||
ccode=0
|
||||
regrev=0
|
||||
antswitch=0
|
||||
pdgain5g=4
|
||||
pdgain2g=4
|
||||
muxenab=0x10
|
||||
wowl_gpio=0
|
||||
wowl_gpiopol=0
|
||||
swctrlmap_2g=0x11411141,0x42124212,0x10401040,0x00211212,0x000000ff
|
||||
swctrlmap_5g=0x42124212,0x41114111,0x42124212,0x00211212,0x000000cf
|
||||
swctrlmapext_2g=0x00000000,0x00000000,0x00000000,0x000000,0x003
|
||||
swctrlmapext_5g=0x00000000,0x00000000,0x00000000,0x000000,0x003
|
||||
phycal_tempdelta=50
|
||||
papdtempcomp_tempdelta=20
|
||||
fastpapdgainctrl=1
|
||||
olpc_thresh=0
|
||||
lowpowerrange2g=0
|
||||
tworangetssi2g=1
|
||||
lowpowerrange5g=0
|
||||
tworangetssi5g=1
|
||||
ed_thresh2g=-75
|
||||
ed_thresh5g=-75
|
||||
eu_edthresh2g=-75
|
||||
eu_edthresh5g=-75
|
||||
paprdis=0
|
||||
femctrl=10
|
||||
vendid=0x14e4
|
||||
devid=0x43ec
|
||||
manfid=0x2d0
|
||||
nocrc=1
|
||||
otpimagesize=502
|
||||
xtalfreq=37400
|
||||
rxchain=3
|
||||
txchain=3
|
||||
aa2g=3
|
||||
aa5g=3
|
||||
agbg0=2
|
||||
agbg1=2
|
||||
aga0=2
|
||||
aga1=2
|
||||
tssipos2g=1
|
||||
extpagain2g=2
|
||||
tssipos5g=1
|
||||
extpagain5g=2
|
||||
tempthresh=255
|
||||
tempoffset=255
|
||||
rawtempsense=0x1ff
|
||||
pa2ga0=-181,5872,-700
|
||||
pa2ga1=-180,6148,-728
|
||||
pa2ga2=-193,3535,-495
|
||||
pa2ga3=-201,3608,-499
|
||||
pa5ga0=-189,5900,-717,-190,5874,-715,-189,5921,-718,-194,5812,-708
|
||||
pa5ga1=-194,5925,-724,-196,5852,-718,-189,5858,-712,-196,5767,-707
|
||||
pa5ga2=-187,3550,-504,-176,3713,-526,-189,3597,-505,-192,3532,-496
|
||||
pa5ga3=-187,3567,-507,-187,3543,-506,-181,3589,-512,-187,3582,-508
|
||||
subband5gver=0x4
|
||||
pdoffsetcckma0=0x2
|
||||
pdoffsetcckma1=0x2
|
||||
pdoffset40ma0=0x3344
|
||||
pdoffset80ma0=0x1133
|
||||
pdoffset40ma1=0x3344
|
||||
pdoffset80ma1=0x1133
|
||||
maxp2ga0=76
|
||||
maxp5ga0=74,74,74,74
|
||||
maxp2ga1=76
|
||||
maxp5ga1=74,74,74,74
|
||||
cckbw202gpo=0x0000
|
||||
cckbw20ul2gpo=0x0000
|
||||
mcsbw202gpo=0x99644422
|
||||
mcsbw402gpo=0x99644422
|
||||
dot11agofdmhrbw202gpo=0x6666
|
||||
ofdmlrbw202gpo=0x0022
|
||||
mcsbw205glpo=0x88766663
|
||||
mcsbw405glpo=0x88666663
|
||||
mcsbw805glpo=0xbb666665
|
||||
mcsbw205gmpo=0xd8666663
|
||||
mcsbw405gmpo=0x88666663
|
||||
mcsbw805gmpo=0xcc666665
|
||||
mcsbw205ghpo=0xdc666663
|
||||
mcsbw405ghpo=0xaa666663
|
||||
mcsbw805ghpo=0xdd666665
|
||||
mcslr5glpo=0x0000
|
||||
mcslr5gmpo=0x0000
|
||||
mcslr5ghpo=0x0000
|
||||
sb20in40hrpo=0x0
|
||||
sb20in80and160hr5glpo=0x0
|
||||
sb40and80hr5glpo=0x0
|
||||
sb20in80and160hr5gmpo=0x0
|
||||
sb40and80hr5gmpo=0x0
|
||||
sb20in80and160hr5ghpo=0x0
|
||||
sb40and80hr5ghpo=0x0
|
||||
sb20in40lrpo=0x0
|
||||
sb20in80and160lr5glpo=0x0
|
||||
sb40and80lr5glpo=0x0
|
||||
sb20in80and160lr5gmpo=0x0
|
||||
sb40and80lr5gmpo=0x0
|
||||
sb20in80and160lr5ghpo=0x0
|
||||
sb40and80lr5ghpo=0x0
|
||||
dot11agduphrpo=0x0
|
||||
dot11agduplrpo=0x0
|
||||
temps_period=15
|
||||
temps_hysteresis=15
|
||||
rssicorrnorm_c0=4,4
|
||||
rssicorrnorm_c1=4,4
|
||||
rssicorrnorm5g_c0=1,1,3,1,1,2,1,1,2,1,1,2
|
||||
rssicorrnorm5g_c1=3,3,4,3,3,4,3,3,4,2,2,3
|
||||
initxidx2g=20
|
||||
initxidx5g=20
|
||||
btc_params84=0x8
|
||||
btc_params95=0x0
|
||||
btcdyn_flags=0x3
|
||||
btcdyn_dflt_dsns_level=99
|
||||
btcdyn_low_dsns_level=0
|
||||
btcdyn_mid_dsns_level=22
|
||||
btcdyn_high_dsns_level=24
|
||||
btcdyn_default_btc_mode=5
|
||||
btcdyn_btrssi_hyster=5
|
||||
btcdyn_dsns_rows=1
|
||||
btcdyn_dsns_row0=5,-120,0,-52,-72
|
||||
|
48
projects/L4T/devices/Switch/initramfs/platform_init
Normal file
48
projects/L4T/devices/Switch/initramfs/platform_init
Normal file
@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
#Screen Init
|
||||
echo 4 > /sys/class/graphics/fb0/blank;
|
||||
echo 0 > /sys/class/graphics/fb0/state;
|
||||
echo 0 > /sys/class/graphics/fb0/blank;
|
||||
|
||||
#sysfs poke for reboot2payload
|
||||
echo 1 > /sys/devices/r2p/default_payload_ready
|
||||
|
||||
#Disable USB3 to fix joycons
|
||||
echo 0xffffffff > /sys/devices/70090000.xusb/downgrade_usb3
|
||||
|
||||
#Set up Schedutil
|
||||
|
||||
CPU_SCHEDUTIL_GOV=0
|
||||
|
||||
if [ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors ]; \
|
||||
then
|
||||
read governors < \
|
||||
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
|
||||
|
||||
case $governors in
|
||||
*schedutil*)
|
||||
CPU_SCHEDUTIL_GOV=1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ $CPU_SCHEDUTIL_GOV -eq 1 ]; then
|
||||
for scaling_governor in \
|
||||
/sys/devices/system/cpu/cpu[0-7]/cpufreq/scaling_governor; do
|
||||
echo schedutil > $scaling_governor
|
||||
done
|
||||
if [ -e /sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us ]; \
|
||||
then
|
||||
echo 2000 > \
|
||||
/sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us
|
||||
fi
|
||||
if [ -e /sys/devices/system/cpu/cpufreq/schedutil/up_rate_limit_us ]; then
|
||||
echo 0 > /sys/devices/system/cpu/cpufreq/schedutil/up_rate_limit_us
|
||||
fi
|
||||
if [ -e /sys/devices/system/cpu/cpufreq/schedutil/down_rate_limit_us ]; then
|
||||
echo 500 > /sys/devices/system/cpu/cpufreq/schedutil/down_rate_limit_us
|
||||
fi
|
||||
if [ -e /sys/devices/system/cpu/cpufreq/schedutil/capacity_margin ]; then
|
||||
echo 1024 > /sys/devices/system/cpu/cpufreq/schedutil/capacity_margin
|
||||
fi
|
||||
fi
|
Binary file not shown.
5264
projects/L4T/devices/Switch/linux/linux.aarch64.conf
Normal file
5264
projects/L4T/devices/Switch/linux/linux.aarch64.conf
Normal file
File diff suppressed because it is too large
Load Diff
114
projects/L4T/devices/Switch/options
Normal file
114
projects/L4T/devices/Switch/options
Normal file
@ -0,0 +1,114 @@
|
||||
#we use mesa for includes and headers, but replace the binaries by the nvidia blobs
|
||||
OPENGL="mesa"
|
||||
|
||||
if [ "${DISTRO}" = "Lakka" ]; then
|
||||
VULKAN="vulkan-loader"
|
||||
else
|
||||
#Standard LibreElec doesnt have vulkan-loader or headers, so disable there.
|
||||
VULKAN="no"
|
||||
fi
|
||||
|
||||
BOOTLOADER="switch-bootloader" # this is a fake bootloader since coreboot and u-boot are sideloaded
|
||||
|
||||
ADDITIONAL_DRIVERS+=" xf86-input-libinput"
|
||||
|
||||
LIBRETRO_CORES+=" moonlight-libretro "
|
||||
|
||||
#L4T Kernel/BSP Stuff
|
||||
GENERIC_L4T_VERSION=32.3.1 # Available Options: [ 32.3.1 32.4.2 32.4.3 32.4.4 32.5 32.5.1 ]
|
||||
L4T_DEVICE_TYPE="t210" # Available Options: [ t210 t18x t19x ]
|
||||
|
||||
#Sha256 of generated file.
|
||||
L4T_COMBINED_KERNEL_SHA256="346baf95b5e13f416eb07f7e354b6b2aec1138b72c745ef222b55247c5150211"
|
||||
|
||||
#Optional L4T Options, only set if you need to, these point at nvidia tegra git by default.
|
||||
#Only Use REPO or URL, never both at the same time
|
||||
#Currently URL Downloading is broken. Still needs work.
|
||||
|
||||
#FORCE_GENERIC_L4T_PATCHES=1 # This is default if not using custom kernel branches.
|
||||
|
||||
L4T_DEVICE_CUSTOM_BOARD_NAME="icosa"
|
||||
|
||||
L4T_KERNEL_4_9_REPO="https://gitlab.com/switchroot/kernel/l4t-kernel-4.9.git"
|
||||
L4T_KERNEL_4_9_REPO_BRANCH="linux-3.4.1-dev"
|
||||
L4T_KERNEL_4_9_REPO_SHA256="5301909e43128ddd73f82e0660d2036a573a1c66"
|
||||
#L4T_KERNEL_4_9_URL=""
|
||||
|
||||
L4T_KERNEL_NVIDIA_REPO="https://gitlab.com/switchroot/kernel/l4t-kernel-nvidia.git"
|
||||
L4T_KERNEL_NVIDIA_REPO_BRANCH="linux-3.4.1-dev"
|
||||
L4T_KERNEL_NVIDIA_REPO_SHA256="52664d2faaa4ebe5dca3547b8cfbbc8b652a6468"
|
||||
#L4T_KERNEL_NVIDIA_URL=""
|
||||
|
||||
#L4T_KERNEL_NVGPU_REPO=""
|
||||
#L4T_KERNEL_NVGPU_REPO_BRANCH
|
||||
#L4T_KERNEL_NVGPU_REPO_SHA256=""
|
||||
#L4T_KERNEL_NVGPU_URL=""
|
||||
|
||||
#These depend on L4T_DEVICE_TYPE, and wont be used if not building for t210
|
||||
#L4T_DEVICE_COMMON_T210_REPO=""
|
||||
#L4T_DEVICE_COMMON_T210_REPO_BRANCH=""
|
||||
#L4T_DEVICE_COMMON_T210_REPO_SHA256=""
|
||||
#L4T_DEVICE_COMMON_T210_URL=""
|
||||
|
||||
#L4T_DEVICE_T210_REPO=""
|
||||
#L4T_DEVICE_T210_REPO_BRANCH=""
|
||||
#L4T_DEVICE_T210_REPO_SHA256=""
|
||||
#L4T_DEVICE_T210_URL=""
|
||||
|
||||
#L4T_DEVICE_T210_JETSON_REPO=""
|
||||
#L4T_DEVICE_T210_JETSON_REPO_BRANCH=""
|
||||
#L4T_DEVICE_T210_JETSON_REPO_SHA256=""
|
||||
#L4T_DEVICE_T210_JETSON_URL=""
|
||||
|
||||
#L4T_DEVICE_T210_BATUU_REPO=""
|
||||
#L4T_DEVICE_T210_BATUU_REPO_BRANCH=""
|
||||
#L4T_DEVICE_T210_BATUU_REPO_SHA256=""
|
||||
#L4T_DEVICE_T210_BATUU_URL=""
|
||||
|
||||
#L4T_DEVICE_T210_PORG_REPO=""
|
||||
#L4T_DEVICE_T210_PORG_REPO_BRANCH=""
|
||||
#L4T_DEVICE_T210_PORG_REPO_SHA256=""
|
||||
#L4T_DEVICE_T210_PORG_URL=""
|
||||
|
||||
#These depend on L4T_DEVICE_TYPE, and wont be used if not building for t18x
|
||||
#L4T_DEVICE_COMMON_T18X_REPO=""
|
||||
#L4T_DEVICE_COMMON_T18X_REPO_BRANCH=""
|
||||
#L4T_DEVICE_COMMON_T18X_REPO_SHA256=""
|
||||
#L4T_DEVICE_COMMON_T18X_URL=""
|
||||
|
||||
#L4T_DEVICE_T18X_REPO=""
|
||||
#L4T_DEVICE_T18X_REPO_BRANCH=""
|
||||
#L4T_DEVICE_T18X_REPO_SHA256=""
|
||||
#L4T_DEVICE_T18X_URL=""
|
||||
|
||||
#L4T_DEVICE_T18X_QUILL_REPO=""
|
||||
#L4T_DEVICE_T18X_QUILL_REPO_BRANCH=""
|
||||
#L4T_DEVICE_T18X_QUILL_REPO_SHA256=""
|
||||
#L4T_DEVICE_T18X_QUILL_URL=""
|
||||
|
||||
#These depend on L4T_DEVICE_TYPE, and wont be used if not building for t19x
|
||||
#L4T_DEVICE_COMMON_T19X_REPO=""
|
||||
#L4T_DEVICE_COMMON_T19X_REPO_BRANCH=""
|
||||
#L4T_DEVICE_COMMON_T19X_REPO_SHA256=""
|
||||
#L4T_DEVICE_COMMON_T19X_URL=""
|
||||
|
||||
#L4T_DEVICE_T19X_REPO=""
|
||||
#L4T_DEVICE_T19X_REPO_BRANCH=""
|
||||
#L4T_DEVICE_T19X_REPO_SHA256=""
|
||||
#L4T_DEVICE_T19X_URL=""
|
||||
|
||||
#L4T_DEVICE_T19X_GALEN_REPO=""
|
||||
#L4T_DEVICE_T19X_GALEN_REPO_BRANCH=""
|
||||
#L4T_DEVICE_T19X_GALEN_REPO_SHA256=""
|
||||
#L4T_DEVICE_T19X_GALEN_URL=""
|
||||
|
||||
#L4T_DEVICE_T19X_JAKKU_REPO=""
|
||||
#L4T_DEVICE_T19X_JAKKU_REPO_BRANCH=""
|
||||
#L4T_DEVICE_T19X_JAKKU_REPO_SHA256=""
|
||||
#L4T_DEVICE_T19X_JAKKU_URL=""
|
||||
|
||||
#Apply Custom Device DTS tree.
|
||||
L4T_DEVICE_CUSTOM_REPO="https://gitlab.com/switchroot/kernel/l4t-platform-t210-switch.git"
|
||||
L4T_DEVICE_CUSTOM_REPO_BRANCH="linux-3.4.1-dev"
|
||||
L4T_DEVICE_CUSTOM_REPO_SHA256="f8238035892c8d712c5fb06b59977e97ea70e4ff"
|
||||
#L4T_DEVICE_CUSTOM_REPO_URL=""
|
124
projects/L4T/devices/Switch/packages/Python2/package.mk
Normal file
124
projects/L4T/devices/Switch/packages/Python2/package.mk
Normal file
@ -0,0 +1,124 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
|
||||
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
PKG_NAME="Python2"
|
||||
# When changing PKG_VERSION remember to sync PKG_PYTHON_VERSION!
|
||||
PKG_VERSION="2.7.16"
|
||||
PKG_SHA256="f222ef602647eecb6853681156d32de4450a2c39f4de93bd5b20235f2e660ed7"
|
||||
PKG_LICENSE="OSS"
|
||||
PKG_SITE="http://www.python.org/"
|
||||
PKG_URL="http://www.python.org/ftp/python/$PKG_VERSION/${PKG_NAME::-1}-$PKG_VERSION.tar.xz"
|
||||
PKG_DEPENDS_HOST="zlib:host bzip2:host sqlite:host"
|
||||
PKG_DEPENDS_TARGET="toolchain sqlite expat zlib bzip2 openssl libffi Python2:host ncurses readline"
|
||||
PKG_LONGDESC="Python2 is an interpreted object-oriented programming language."
|
||||
|
||||
PKG_TOOLCHAIN="autotools"
|
||||
PKG_BUILD_FLAGS="-parallel +lto-parallel"
|
||||
|
||||
PKG_PY_DISABLED_MODULES="_tkinter nis gdbm bsddb ossaudiodev"
|
||||
|
||||
PKG_CONFIGURE_OPTS_HOST="--cache-file=config.cache \
|
||||
--without-cxx-main \
|
||||
--with-threads \
|
||||
--enable-unicode=ucs4"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="ac_cv_file_dev_ptc=no \
|
||||
ac_cv_file_dev_ptmx=yes \
|
||||
ac_cv_func_lchflags_works=no \
|
||||
ac_cv_func_chflags_works=no \
|
||||
ac_cv_func_printf_zd=yes \
|
||||
ac_cv_buggy_getaddrinfo=no \
|
||||
ac_cv_header_bluetooth_bluetooth_h=no \
|
||||
ac_cv_header_bluetooth_h=no \
|
||||
ac_cv_file__dev_ptmx=no \
|
||||
ac_cv_file__dev_ptc=no \
|
||||
ac_cv_have_long_long_format=yes \
|
||||
--with-threads \
|
||||
--enable-unicode=ucs4 \
|
||||
--enable-ipv6 \
|
||||
--disable-profiling \
|
||||
--without-pydebug \
|
||||
--without-doc-strings \
|
||||
--without-tsc \
|
||||
--with-pymalloc \
|
||||
--without-fpectl \
|
||||
--without-cxx-main \
|
||||
--with-system-ffi \
|
||||
--with-system-expat"
|
||||
post_patch() {
|
||||
# This is needed to make sure the Python build process doesn't try to
|
||||
# regenerate those files with the pgen program. Otherwise, it builds
|
||||
# pgen for the target, and tries to run it on the host.
|
||||
touch $PKG_BUILD/Include/graminit.h
|
||||
touch $PKG_BUILD/Python/graminit.c
|
||||
}
|
||||
|
||||
make_host() {
|
||||
make PYTHON_MODULES_INCLUDE="$HOST_INCDIR" \
|
||||
PYTHON_MODULES_LIB="$HOST_LIBDIR" \
|
||||
PYTHON_DISABLE_MODULES="readline _curses _curses_panel $PKG_PY_DISABLED_MODULES"
|
||||
|
||||
# python distutils per default adds -L$LIBDIR when linking binary extensions
|
||||
sed -e "s|^ 'LIBDIR':.*| 'LIBDIR': '/usr/lib',|g" -i $(cat pybuilddir.txt)/_sysconfigdata.py
|
||||
}
|
||||
|
||||
makeinstall_host() {
|
||||
make PYTHON_MODULES_INCLUDE="$HOST_INCDIR" \
|
||||
PYTHON_MODULES_LIB="$HOST_LIBDIR" \
|
||||
PYTHON_DISABLE_MODULES="readline _curses _curses_panel $PKG_PY_DISABLED_MODULES" \
|
||||
install
|
||||
}
|
||||
|
||||
post_makeinstall_host() {
|
||||
rm -fr $PKG_BUILD/.$HOST_NAME/build/temp.*
|
||||
}
|
||||
|
||||
pre_configure_target() {
|
||||
export PYTHON_FOR_BUILD=$TOOLCHAIN/bin/python
|
||||
}
|
||||
|
||||
make_target() {
|
||||
make CC="$CC" LDFLAGS="$TARGET_LDFLAGS -L." \
|
||||
PYTHON_DISABLE_MODULES="$PKG_PY_DISABLED_MODULES" \
|
||||
PYTHON_MODULES_INCLUDE="$TARGET_INCDIR" \
|
||||
PYTHON_MODULES_LIB="$TARGET_LIBDIR"
|
||||
}
|
||||
|
||||
makeinstall_target() {
|
||||
make CC="$CC" DESTDIR=$SYSROOT_PREFIX \
|
||||
PYTHON_DISABLE_MODULES="$PKG_PY_DISABLED_MODULES" \
|
||||
PYTHON_MODULES_INCLUDE="$TARGET_INCDIR" \
|
||||
PYTHON_MODULES_LIB="$TARGET_LIBDIR" \
|
||||
install
|
||||
|
||||
make CC="$CC" DESTDIR=$INSTALL \
|
||||
PYTHON_DISABLE_MODULES="$PKG_PY_DISABLED_MODULES" \
|
||||
PYTHON_MODULES_INCLUDE="$TARGET_INCDIR" \
|
||||
PYTHON_MODULES_LIB="$TARGET_LIBDIR" \
|
||||
install
|
||||
}
|
||||
|
||||
post_makeinstall_target() {
|
||||
rm -fr $PKG_BUILD/.$TARGET_NAME/build/temp.*
|
||||
|
||||
for dir in bsddb idlelib lib-tk lib2to3/tests msilib pydoc_data test unittest; do
|
||||
rm -rf $INSTALL/usr/lib/python*/$dir
|
||||
done
|
||||
|
||||
rm -rf $INSTALL/usr/lib/python*/config
|
||||
rm -rf $INSTALL/usr/bin/2to3
|
||||
rm -rf $INSTALL/usr/bin/idle
|
||||
rm -rf $INSTALL/usr/bin/pydoc
|
||||
rm -rf $INSTALL/usr/bin/smtpd.py
|
||||
rm -rf $INSTALL/usr/bin/python*-config
|
||||
|
||||
cd $INSTALL/usr/lib/python2.7
|
||||
$TOOLCHAIN/bin/python -Wi -t -B $PKG_BUILD/Lib/compileall.py -d /usr/lib/$PKG_PYTHON_VERSION -f .
|
||||
find $INSTALL/usr/lib/python2.7 -name "*.py" -exec rm -f {} \; &>/dev/null
|
||||
|
||||
# strip
|
||||
chmod u+w $INSTALL/usr/lib/libpython*.so.*
|
||||
debug_strip $INSTALL/usr
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index bcd83bf..5e54a0d 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -461,6 +463,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt
|
||||
esac; \
|
||||
$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
|
||||
_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
|
||||
+ PYTHONXCPREFIX='$(DESTDIR)$(prefix)' \
|
||||
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
|
||||
|
||||
# Build static library
|
||||
@@ -1142,7 +1145,9 @@ libainstall: all python-config
|
||||
# Install the dynamically loadable modules
|
||||
# This goes into $(exec_prefix)
|
||||
sharedinstall: sharedmods
|
||||
+ CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
|
||||
$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
|
||||
+ --skip-build \
|
||||
--prefix=$(prefix) \
|
||||
--install-scripts=$(BINDIR) \
|
||||
--install-platlib=$(DESTSHARED) \
|
||||
diff --git a/setup.py b/setup.py
|
||||
index a46bf35..528e9df 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -17,7 +17,7 @@
|
||||
from distutils.command.install_lib import install_lib
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
-cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
|
||||
+cross_compiling = ("_PYTHON_HOST_PLATFORM" in os.environ) or ('PYTHONXCPREFIX' in os.environ)
|
||||
|
||||
def get_platform():
|
||||
# cross build
|
||||
@@ -292,6 +292,14 @@ class PyBuildExt(build_ext):
|
||||
(ext.name, sys.exc_info()[1]))
|
||||
self.failed.append(ext.name)
|
||||
return
|
||||
+
|
||||
+ # Inport check will not work when cross-compiling.
|
||||
+ if os.environ.has_key('PYTHONXCPREFIX'):
|
||||
+ self.announce(
|
||||
+ 'WARNING: skipping inport check for cross-compiled: "%s"' %
|
||||
+ ext.name)
|
||||
+ return
|
||||
+
|
||||
# Workaround for Mac OS X: The Carbon-based modules cannot be
|
||||
# reliably imported into a command-line Python
|
||||
if 'Carbon' in ext.extra_link_args:
|
@ -0,0 +1,49 @@
|
||||
diff --git a/setup.py b/setup.py
|
||||
index d6ef5be..7a0d8f2 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -439,13 +439,19 @@ class PyBuildExt(build_ext):
|
||||
os.unlink(tmpfile)
|
||||
|
||||
def detect_modules(self):
|
||||
- # Ensure that /usr/local is always used
|
||||
- if not cross_compiling:
|
||||
- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
|
||||
- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
||||
- if cross_compiling:
|
||||
- self.add_gcc_paths()
|
||||
- self.add_multiarch_paths()
|
||||
+ try:
|
||||
+ modules_include_dirs = os.environ["PYTHON_MODULES_INCLUDE"].split()
|
||||
+ except KeyError:
|
||||
+ modules_include_dirs = ['/usr/include']
|
||||
+ try:
|
||||
+ modules_lib_dirs = os.environ["PYTHON_MODULES_LIB"].split()
|
||||
+ except KeyError:
|
||||
+ modules_lib_dirs = ['/usr/lib']
|
||||
+ self.add_multiarch_paths()
|
||||
+ for dir in modules_include_dirs:
|
||||
+ add_dir_to_list(self.compiler.include_dirs, dir)
|
||||
+ for dir in modules_lib_dirs:
|
||||
+ add_dir_to_list(self.compiler.library_dirs, dir)
|
||||
|
||||
# Add paths specified in the environment variables LDFLAGS and
|
||||
# CPPFLAGS for header and library files.
|
||||
@@ -481,17 +487,6 @@ class PyBuildExt(build_ext):
|
||||
for directory in reversed(options.dirs):
|
||||
add_dir_to_list(dir_list, directory)
|
||||
|
||||
- if os.path.normpath(sys.prefix) != '/usr' \
|
||||
- and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
|
||||
- # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
|
||||
- # (PYTHONFRAMEWORK is set) to avoid # linking problems when
|
||||
- # building a framework with different architectures than
|
||||
- # the one that is currently installed (issue #7473)
|
||||
- add_dir_to_list(self.compiler.library_dirs,
|
||||
- sysconfig.get_config_var("LIBDIR"))
|
||||
- add_dir_to_list(self.compiler.include_dirs,
|
||||
- sysconfig.get_config_var("INCLUDEDIR"))
|
||||
-
|
||||
try:
|
||||
have_unicode = unicode
|
||||
except NameError:
|
@ -0,0 +1,16 @@
|
||||
diff --git a/setup.py b/setup.py
|
||||
index a46bf35..d6ef5be 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -33,7 +33,10 @@ host_platform = get_platform()
|
||||
COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
|
||||
|
||||
# This global variable is used to hold the list of modules to be disabled.
|
||||
-disabled_module_list = []
|
||||
+try:
|
||||
+ disabled_module_list = os.environ["PYTHON_DISABLE_MODULES"].split()
|
||||
+except KeyError:
|
||||
+ disabled_module_list = []
|
||||
|
||||
def add_dir_to_list(dirlist, dir):
|
||||
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
|
@ -0,0 +1,24 @@
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 07af0b6..6426b22 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -2030,10 +2030,18 @@ class PyBuildExt(build_ext):
|
||||
if not self.verbose:
|
||||
config_args.append("-q")
|
||||
|
||||
+
|
||||
+ #NOTE: best solution is to add to configure script
|
||||
+ # as config subdirectory and to exclude darwin
|
||||
+ # (see configure_ctypes_darwin).
|
||||
+ #FIXME: lets for now pass all top configure arguments
|
||||
+ #and do not modify configure script.
|
||||
+ config_args = sysconfig.get_config_var("CONFIG_ARGS")
|
||||
+
|
||||
# Pass empty CFLAGS because we'll just append the resulting
|
||||
# CFLAGS to Python's; -g or -O2 is to be avoided.
|
||||
cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
|
||||
- % (ffi_builddir, ffi_srcdir, " ".join(config_args))
|
||||
+ % (ffi_builddir, ffi_srcdir, config_args)
|
||||
|
||||
res = os.system(cmd)
|
||||
if res or not os.path.exists(ffi_configfile):
|
@ -0,0 +1,29 @@
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index 918f210..c82366c 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -1011,24 +1011,6 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
|
||||
$(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
|
||||
$(DESTDIR)$(LIBDEST)/distutils/tests ; \
|
||||
fi
|
||||
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
- $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
- -d $(LIBDEST) -f \
|
||||
- -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
|
||||
- $(DESTDIR)$(LIBDEST)
|
||||
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
- $(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
- -d $(LIBDEST) -f \
|
||||
- -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
|
||||
- $(DESTDIR)$(LIBDEST)
|
||||
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
- $(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
- -d $(LIBDEST)/site-packages -f \
|
||||
- -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
|
||||
- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
- $(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
- -d $(LIBDEST)/site-packages -f \
|
||||
- -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
|
||||
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
|
||||
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
@ -0,0 +1,12 @@
|
||||
diff -Naur Python-2.7.10.orig/configure Python-2.7.10/configure
|
||||
--- Python-2.7.10.orig/configure 2015-08-18 12:24:03.016649265 -0700
|
||||
+++ Python-2.7.10/configure 2015-08-18 12:23:41.716695873 -0700
|
||||
@@ -14215,7 +14215,7 @@
|
||||
|
||||
# first curses configure check
|
||||
ac_save_cppflags="$CPPFLAGS"
|
||||
-CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
|
||||
+CPPFLAGS="$CPPFLAGS -I${prefix}/usr/include/ncursesw"
|
||||
|
||||
for ac_header in curses.h ncurses.h
|
||||
do :
|
@ -0,0 +1,54 @@
|
||||
Adjust library/header paths for cross-compilation
|
||||
|
||||
When cross-compiling third-party extensions, the get_python_inc() or
|
||||
get_python_lib() can be called, to return the path to headers or
|
||||
libraries. However, they use the sys.prefix of the host Python, which
|
||||
returns incorrect paths when cross-compiling (paths pointing to host
|
||||
headers and libraries).
|
||||
|
||||
In order to fix this, we introduce the _python_sysroot, _python_prefix
|
||||
and _python_exec_prefix variables, that allow to override these
|
||||
values, and get correct header/library paths when cross-compiling
|
||||
third-party Python modules.
|
||||
|
||||
The _python_sysroot variable is also used to prefix the LIBDIR value
|
||||
taken from the sysconfigdata module.
|
||||
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
|
||||
Index: b/Lib/distutils/sysconfig.py
|
||||
===================================================================
|
||||
--- a/Lib/distutils/sysconfig.py
|
||||
+++ b/Lib/distutils/sysconfig.py
|
||||
@@ -19,8 +19,13 @@
|
||||
from distutils.errors import DistutilsPlatformError
|
||||
|
||||
# These are needed in a couple of spots, so just compute them once.
|
||||
-PREFIX = os.path.normpath(sys.prefix)
|
||||
-EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
|
||||
+if "_python_sysroot" in os.environ:
|
||||
+ _sysroot=os.environ.get('_python_sysroot')
|
||||
+ PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_prefix'))
|
||||
+ EXEC_PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_exec_prefix'))
|
||||
+else:
|
||||
+ PREFIX = os.path.normpath(sys.prefix)
|
||||
+ EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
|
||||
|
||||
# Path to the base directory of the project. On Windows the binary may
|
||||
# live in project/PCBuild9. If we're dealing with an x64 Windows build,
|
||||
Index: b/Lib/distutils/command/build_ext.py
|
||||
===================================================================
|
||||
--- a/Lib/distutils/command/build_ext.py
|
||||
+++ b/Lib/distutils/command/build_ext.py
|
||||
@@ -237,7 +237,10 @@
|
||||
if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
|
||||
if not sysconfig.python_build:
|
||||
# building third party extensions
|
||||
- self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
|
||||
+ libdir = sysconfig.get_config_var('LIBDIR')
|
||||
+ if "_python_sysroot" in os.environ:
|
||||
+ libdir = os.environ.get("_python_sysroot") + libdir
|
||||
+ self.library_dirs.append(libdir)
|
||||
else:
|
||||
# building python standard extensions
|
||||
self.library_dirs.append('.')
|
@ -0,0 +1,34 @@
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index bf3aed7..7ff5c79 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -464,6 +464,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt
|
||||
$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
|
||||
_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
|
||||
PYTHONXCPREFIX='$(DESTDIR)$(prefix)' \
|
||||
+ CONFIG_ARGS="$(CONFIG_ARGS)" \
|
||||
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
|
||||
|
||||
libpython$(VERSION).so: $(LIBRARY_OBJS)
|
||||
@@ -1104,6 +1105,7 @@ libainstall: all python-config
|
||||
# This goes into $(exec_prefix)
|
||||
sharedinstall: sharedmods
|
||||
CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
|
||||
+ CONFIG_ARGS="$(CONFIG_ARGS)" \
|
||||
$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
|
||||
--skip-build \
|
||||
--prefix=$(prefix) \
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 6426b22..d2776dd 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -32,6 +32,9 @@ host_platform = get_platform()
|
||||
# Were we compiled --with-pydebug or with #define Py_DEBUG?
|
||||
COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
|
||||
|
||||
+sysconfig.get_config_vars()
|
||||
+sysconfig._CONFIG_VARS.update(os.environ)
|
||||
+
|
||||
# This global variable is used to hold the list of modules to be disabled.
|
||||
try:
|
||||
disabled_module_list = os.environ["PYTHON_DISABLE_MODULES"].split()
|
@ -0,0 +1,21 @@
|
||||
diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
|
||||
index 2aa1cb1..529e2d4 100644
|
||||
--- a/Lib/distutils/unixccompiler.py
|
||||
+++ b/Lib/distutils/unixccompiler.py
|
||||
@@ -83,6 +83,16 @@ class UnixCCompiler(CCompiler):
|
||||
if sys.platform == "cygwin":
|
||||
exe_extension = ".exe"
|
||||
|
||||
+ def _fix_lib_args(self, libraries, library_dirs, runtime_library_dirs):
|
||||
+ """Remove standard library path from rpath"""
|
||||
+ libraries, library_dirs, runtime_library_dirs = \
|
||||
+ CCompiler._fix_lib_args(self, libraries, library_dirs,
|
||||
+ runtime_library_dirs)
|
||||
+ libdir = sysconfig.get_config_var('LIBDIR')
|
||||
+ if runtime_library_dirs and (libdir in runtime_library_dirs):
|
||||
+ runtime_library_dirs.remove(libdir)
|
||||
+ return libraries, library_dirs, runtime_library_dirs
|
||||
+
|
||||
def preprocess(self, source,
|
||||
output_file=None, macros=None, include_dirs=None,
|
||||
extra_preargs=None, extra_postargs=None):
|
@ -0,0 +1,208 @@
|
||||
Add a backport of http://bugs.python.org/issue16235 so we can use
|
||||
python-config for cross builds.
|
||||
This basically replaces the python version of python-config with a pure-shell
|
||||
version that's already preprocessed when installed and doesn't depend
|
||||
on the sysconfig import that usually leads to bad data/results.
|
||||
|
||||
Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
|
||||
|
||||
Index: b/configure.ac
|
||||
===================================================================
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -885,6 +885,7 @@
|
||||
|
||||
# Other platforms follow
|
||||
if test $enable_shared = "yes"; then
|
||||
+ PY_ENABLE_SHARED=1
|
||||
AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
|
||||
case $ac_sys_system in
|
||||
BeOS*)
|
||||
@@ -945,6 +946,7 @@
|
||||
|
||||
esac
|
||||
else # shared is disabled
|
||||
+ PY_ENABLE_SHARED=0
|
||||
case $ac_sys_system in
|
||||
CYGWIN*)
|
||||
BLDLIBRARY='$(LIBRARY)'
|
||||
@@ -1921,6 +1923,9 @@
|
||||
AC_SUBST(BLDSHARED)
|
||||
AC_SUBST(CCSHARED)
|
||||
AC_SUBST(LINKFORSHARED)
|
||||
+AC_SUBST(PY_ENABLE_SHARED)
|
||||
+LIBPL="${prefix}/lib/python${VERSION}/config"
|
||||
+AC_SUBST(LIBPL)
|
||||
# SO is the extension of shared libraries `(including the dot!)
|
||||
# -- usually .so, .sl on HP-UX, .dll on Cygwin
|
||||
AC_MSG_CHECKING(SO)
|
||||
@@ -4588,7 +4593,7 @@
|
||||
AC_SUBST(ENSUREPIP)
|
||||
|
||||
# generate output files
|
||||
-AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
|
||||
+AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh)
|
||||
AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
|
||||
AC_OUTPUT
|
||||
|
||||
Index: b/Makefile.pre.in
|
||||
===================================================================
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -166,7 +166,7 @@
|
||||
SUBDIRSTOO= Include Lib Misc Demo
|
||||
|
||||
# Files and directories to be distributed
|
||||
-CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
|
||||
+CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in Misc/python-config.sh
|
||||
DISTFILES= README ChangeLog $(CONFIGFILES)
|
||||
DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
|
||||
DIST= $(DISTFILES) $(DISTDIRS)
|
||||
@@ -410,7 +410,7 @@
|
||||
|
||||
# Default target
|
||||
all: @DEF_MAKE_ALL_RULE@
|
||||
-build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
|
||||
+build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks python-config
|
||||
|
||||
# Compile a binary with gcc profile guided optimization.
|
||||
profile-opt:
|
||||
@@ -1101,10 +1101,12 @@
|
||||
fi; \
|
||||
cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
|
||||
|
||||
-python-config: $(srcdir)/Misc/python-config.in
|
||||
+python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
|
||||
# Substitution happens here, as the completely-expanded BINDIR
|
||||
# is not available in configure
|
||||
- sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
|
||||
+ sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
|
||||
+ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
|
||||
+ sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' Misc/python-config.sh >python-config
|
||||
|
||||
# Install the include files
|
||||
INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
|
||||
@@ -1163,7 +1165,7 @@
|
||||
$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
|
||||
$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
|
||||
$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
|
||||
- rm python-config
|
||||
+ $(INSTALL_SCRIPT) python-config.py $(DESTDIR)$(LIBPL)/python-config.py
|
||||
@if [ -s Modules/python.exp -a \
|
||||
"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
|
||||
echo; echo "Installing support files for building shared extension modules on AIX:"; \
|
||||
@@ -1345,6 +1347,7 @@
|
||||
config.cache config.log pyconfig.h Modules/config.c
|
||||
-rm -rf build platform
|
||||
-rm -rf $(PYTHONFRAMEWORKDIR)
|
||||
+ -rm -f python-config.py python-config
|
||||
|
||||
# Make things extra clean, before making a distribution:
|
||||
# remove all generated files, even Makefile[.pre]
|
||||
Index: b/Misc/python-config.sh.in
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ b/Misc/python-config.sh.in
|
||||
@@ -0,0 +1,102 @@
|
||||
+#!/bin/sh
|
||||
+
|
||||
+exit_with_usage ()
|
||||
+{
|
||||
+ echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--configdir"
|
||||
+ exit $1
|
||||
+}
|
||||
+
|
||||
+if [ "$1" = "" ] ; then
|
||||
+ exit_with_usage 1
|
||||
+fi
|
||||
+
|
||||
+# Returns the actual prefix where this script was installed to.
|
||||
+installed_prefix ()
|
||||
+{
|
||||
+ RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
|
||||
+ if which readlink >/dev/null 2>&1 ; then
|
||||
+ RESULT=$(readlink -f "$RESULT")
|
||||
+ fi
|
||||
+ echo $RESULT
|
||||
+}
|
||||
+
|
||||
+prefix_build="@prefix@"
|
||||
+prefix_real=$(installed_prefix "$0")
|
||||
+
|
||||
+# Use sed to fix paths from their built to locations to their installed to locations.
|
||||
+prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#")
|
||||
+exec_prefix_build="@exec_prefix@"
|
||||
+exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#")
|
||||
+includedir=$(echo "@includedir@")
|
||||
+libdir=$(echo "@libdir@")
|
||||
+CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#")
|
||||
+VERSION="@VERSION@"
|
||||
+LIBM="@LIBM@"
|
||||
+LIBC="@LIBC@"
|
||||
+SYSLIBS="$LIBM $LIBC"
|
||||
+LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}"
|
||||
+BASECFLAGS="@BASECFLAGS@"
|
||||
+LDLIBRARY="@LDLIBRARY@"
|
||||
+LINKFORSHARED="@LINKFORSHARED@"
|
||||
+OPT="@OPT@"
|
||||
+PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
|
||||
+LDVERSION="@LDVERSION@"
|
||||
+LIBDEST=${prefix}/lib/python${VERSION}
|
||||
+LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#")
|
||||
+SO="@SO@"
|
||||
+PYTHONFRAMEWORK="@PYTHONFRAMEWORK@"
|
||||
+INCDIR="-I$includedir/python${VERSION}"
|
||||
+PLATINCDIR="-I$includedir/python${VERSION}"
|
||||
+
|
||||
+# Scan for --help or unknown argument.
|
||||
+for ARG in $*
|
||||
+do
|
||||
+ case $ARG in
|
||||
+ --help)
|
||||
+ exit_with_usage 0
|
||||
+ ;;
|
||||
+ --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
|
||||
+ ;;
|
||||
+ *)
|
||||
+ exit_with_usage 1
|
||||
+ ;;
|
||||
+esac
|
||||
+done
|
||||
+
|
||||
+for ARG in "$@"
|
||||
+do
|
||||
+ case "$ARG" in
|
||||
+ --prefix)
|
||||
+ echo "$prefix"
|
||||
+ ;;
|
||||
+ --exec-prefix)
|
||||
+ echo "$exec_prefix"
|
||||
+ ;;
|
||||
+ --includes)
|
||||
+ echo "$INCDIR $PLATINCDIR"
|
||||
+ ;;
|
||||
+ --cflags)
|
||||
+ echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
|
||||
+ ;;
|
||||
+ --libs)
|
||||
+ echo "$LIBS"
|
||||
+ ;;
|
||||
+ --ldflags)
|
||||
+ LINKFORSHAREDUSED=
|
||||
+ if [ -z "$PYTHONFRAMEWORK" ] ; then
|
||||
+ LINKFORSHAREDUSED=$LINKFORSHARED
|
||||
+ fi
|
||||
+ LIBPLUSED=
|
||||
+ if [ "$PY_ENABLE_SHARED" = "0" ] ; then
|
||||
+ LIBPLUSED="-L$LIBPL"
|
||||
+ fi
|
||||
+ echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED"
|
||||
+ ;;
|
||||
+ --extension-suffix)
|
||||
+ echo "$SO"
|
||||
+ ;;
|
||||
+ --configdir)
|
||||
+ echo "$LIBPL"
|
||||
+ ;;
|
||||
+esac
|
||||
+done
|
@ -0,0 +1,21 @@
|
||||
Abort on failed module build
|
||||
|
||||
When building a Python module fails, the setup.py script currently
|
||||
doesn't exit with an error, and simply continues. This is not a really
|
||||
nice behavior, so this patch changes setup.py to abort with an error,
|
||||
so that the build issue is clearly noticeable.
|
||||
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
||||
|
||||
Index: b/setup.py
|
||||
===================================================================
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -283,6 +283,7 @@
|
||||
print "Failed to build these modules:"
|
||||
print_three_column(failed)
|
||||
print
|
||||
+ sys.exit(1)
|
||||
|
||||
def build_extension(self, ext):
|
||||
|
@ -0,0 +1,51 @@
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index 918f210..eb9ee6b 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -438,7 +438,7 @@ coverage:
|
||||
|
||||
|
||||
# Build the interpreter
|
||||
-$(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
|
||||
+$(BUILDPYTHON): Modules/python.o $(LDLIBRARY)
|
||||
$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
|
||||
Modules/python.o \
|
||||
$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
|
||||
@@ -465,18 +465,6 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt
|
||||
_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
|
||||
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
|
||||
|
||||
-# Build static library
|
||||
-# avoid long command lines, same as LIBRARY_OBJS
|
||||
-$(LIBRARY): $(LIBRARY_OBJS)
|
||||
- -rm -f $@
|
||||
- $(AR) $(ARFLAGS) $@ Modules/getbuildinfo.o
|
||||
- $(AR) $(ARFLAGS) $@ $(PARSER_OBJS)
|
||||
- $(AR) $(ARFLAGS) $@ $(OBJECT_OBJS)
|
||||
- $(AR) $(ARFLAGS) $@ $(PYTHON_OBJS)
|
||||
- $(AR) $(ARFLAGS) $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
|
||||
- $(AR) $(ARFLAGS) $@ $(MODOBJS)
|
||||
- $(RANLIB) $@
|
||||
-
|
||||
libpython$(VERSION).so: $(LIBRARY_OBJS)
|
||||
if test $(INSTSONAME) != $(LDLIBRARY); then \
|
||||
$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
|
||||
@@ -1090,18 +1078,6 @@ libainstall: all python-config
|
||||
else true; \
|
||||
fi; \
|
||||
done
|
||||
- @if test -d $(LIBRARY); then :; else \
|
||||
- if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
|
||||
- if test "$(SO)" = .dll; then \
|
||||
- $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
|
||||
- else \
|
||||
- $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
|
||||
- $(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
|
||||
- fi; \
|
||||
- else \
|
||||
- echo Skip install of $(LIBRARY) - use make frameworkinstall; \
|
||||
- fi; \
|
||||
- fi
|
||||
$(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
|
||||
$(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
|
||||
$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
|
@ -0,0 +1,13 @@
|
||||
diff --git a/Python/compile.c b/Python/compile.c
|
||||
index 1cf53f9..25665b5 100644
|
||||
--- a/Python/compile.c
|
||||
+++ b/Python/compile.c
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "symtable.h"
|
||||
#include "opcode.h"
|
||||
|
||||
-int Py_OptimizeFlag = 0;
|
||||
+int Py_OptimizeFlag = 1;
|
||||
|
||||
#define DEFAULT_BLOCK_SIZE 16
|
||||
#define DEFAULT_BLOCKS 8
|
@ -0,0 +1,12 @@
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 69b76e7..7a50cc3 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -2315,7 +2315,6 @@ def main():
|
||||
|
||||
# Scripts to install
|
||||
scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
|
||||
- 'Tools/scripts/2to3',
|
||||
'Lib/smtpd.py']
|
||||
)
|
||||
|
@ -0,0 +1,13 @@
|
||||
diff -Naur Python-2.7.13.orig/Lib/platform.py Python-2.7.13/Lib/platform.py
|
||||
--- Python-2.7.13.orig/Lib/platform.py 2017-01-08 11:57:36.615886244 +0100
|
||||
+++ Python-2.7.13/Lib/platform.py 2017-01-08 12:12:44.567848271 +0100
|
||||
@@ -1250,6 +1250,9 @@
|
||||
system = 'Windows'
|
||||
release = 'Vista'
|
||||
|
||||
+ if machine == 'aarch64' and architecture()[0] == '32bit':
|
||||
+ machine = 'armv7l'
|
||||
+
|
||||
_uname_cache = system,node,release,version,machine,processor
|
||||
return _uname_cache
|
||||
|
216
projects/L4T/devices/Switch/packages/ffmpeg/package.mk
Normal file
216
projects/L4T/devices/Switch/packages/ffmpeg/package.mk
Normal file
@ -0,0 +1,216 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
|
||||
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
PKG_NAME="ffmpeg"
|
||||
# Current branch is: release/4.0-kodi
|
||||
PKG_VERSION="4.0.4-Leia-18.4"
|
||||
PKG_SHA256="e11e7594af35f36ab2711252c3d6bb106908f26605498aef4a9be2d7bc001db2"
|
||||
PKG_LICENSE="LGPLv2.1+"
|
||||
PKG_SITE="https://ffmpeg.org"
|
||||
PKG_URL="https://github.com/xbmc/FFmpeg/archive/${PKG_VERSION}.tar.gz"
|
||||
PKG_DEPENDS_TARGET="toolchain zlib bzip2 openssl speex"
|
||||
PKG_LONGDESC="FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video."
|
||||
PKG_BUILD_FLAGS="-gold"
|
||||
|
||||
# Dependencies
|
||||
get_graphicdrivers
|
||||
|
||||
if [ "$DISTRO" = "Lakka" ]; then
|
||||
VAAPI_SUPPORT=no
|
||||
fi
|
||||
|
||||
if [ "$V4L2_SUPPORT" = "yes" ]; then
|
||||
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET libdrm"
|
||||
PKG_FFMPEG_V4L2="--enable-v4l2_m2m --enable-libdrm"
|
||||
else
|
||||
PKG_FFMPEG_V4L2="--disable-v4l2_m2m"
|
||||
fi
|
||||
|
||||
if [ "$VAAPI_SUPPORT" = "yes" ]; then
|
||||
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET libva"
|
||||
PKG_FFMPEG_VAAPI="--enable-vaapi"
|
||||
else
|
||||
PKG_FFMPEG_VAAPI="--disable-vaapi"
|
||||
fi
|
||||
|
||||
if [ "$VDPAU_SUPPORT" = "yes" -a "$DISPLAYSERVER" = "x11" ]; then
|
||||
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET libvdpau"
|
||||
PKG_FFMPEG_VDPAU="--enable-vdpau"
|
||||
else
|
||||
PKG_FFMPEG_VDPAU="--disable-vdpau"
|
||||
fi
|
||||
|
||||
if [ "$PROJECT" = "Rockchip" ]; then
|
||||
PKG_PATCH_DIRS+=" rkmpp"
|
||||
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET rkmpp"
|
||||
PKG_FFMPEG_RKMPP="--enable-rkmpp --enable-libdrm --enable-version3"
|
||||
else
|
||||
PKG_FFMPEG_RKMPP="--disable-rkmpp"
|
||||
fi
|
||||
|
||||
if [ "$PROJECT" = "Allwinner" ]; then
|
||||
PKG_PATCH_DIRS+=" v4l2-request-api"
|
||||
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET libdrm systemd" # systemd is needed for libudev
|
||||
PKG_FFMPEG_V4L2_REQUEST="--enable-v4l2-request --enable-libudev --enable-libdrm"
|
||||
fi
|
||||
|
||||
if build_with_debug; then
|
||||
PKG_FFMPEG_DEBUG="--enable-debug --disable-stripping"
|
||||
else
|
||||
PKG_FFMPEG_DEBUG="--disable-debug --enable-stripping"
|
||||
fi
|
||||
|
||||
if [ "$PROJECT" = "RPi" ] && [ "$ARCH" = "arm" ]; then
|
||||
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET bcm2835-driver"
|
||||
if [ "${DEVICE:0:4}" = "RPi4" ]; then
|
||||
PKG_PATCH_DIRS+=" rpi4-hevc"
|
||||
else
|
||||
PKG_PATCH_DIRS+=" rpi-hevc"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$PROJECT" = "L4T" ]; then
|
||||
PKG_DEPENDS_TARGET+=" jetson-ffmpeg"
|
||||
PKG_PATCH_DIRS+=" L4T"
|
||||
PKG_FFMPEG_NVMPI="--enable-nvmpi"
|
||||
fi
|
||||
|
||||
if target_has_feature neon; then
|
||||
PKG_FFMPEG_FPU="--enable-neon"
|
||||
else
|
||||
PKG_FFMPEG_FPU="--disable-neon"
|
||||
fi
|
||||
|
||||
if [ "$TARGET_ARCH" = "x86_64" -o "$TARGET_ARCH" = "i386" ]; then
|
||||
PKG_DEPENDS_TARGET+=" nasm:host"
|
||||
fi
|
||||
|
||||
if target_has_feature "(neon|sse)"; then
|
||||
PKG_DEPENDS_TARGET+=" dav1d"
|
||||
PKG_FFMPEG_AV1="--enable-libdav1d"
|
||||
fi
|
||||
|
||||
pre_configure_target() {
|
||||
cd $PKG_BUILD
|
||||
rm -rf .$TARGET_NAME
|
||||
|
||||
if [ "$PROJECT" = "RPi" ] && [ "$ARCH" = "arm" ]; then
|
||||
PKG_FFMPEG_LIBS="-lbcm_host -lvcos -lvchiq_arm -lmmal -lmmal_core -lmmal_util -lvcsm"
|
||||
PKG_FFMPEG_RPI="--enable-rpi"
|
||||
fi
|
||||
}
|
||||
|
||||
configure_target() {
|
||||
./configure --prefix="/usr" \
|
||||
--cpu="$TARGET_CPU" \
|
||||
--arch="$TARGET_ARCH" \
|
||||
--enable-cross-compile \
|
||||
--cross-prefix="$TARGET_PREFIX" \
|
||||
--sysroot="$SYSROOT_PREFIX" \
|
||||
--sysinclude="$SYSROOT_PREFIX/usr/include" \
|
||||
--target-os="linux" \
|
||||
--nm="$NM" \
|
||||
--ar="$AR" \
|
||||
--as="$CC" \
|
||||
--cc="$CC" \
|
||||
--ld="$CC" \
|
||||
--host-cc="$HOST_CC" \
|
||||
--host-cflags="$HOST_CFLAGS" \
|
||||
--host-ldflags="$HOST_LDFLAGS" \
|
||||
--extra-cflags="$CFLAGS" \
|
||||
--extra-ldflags="$LDFLAGS" \
|
||||
--extra-libs="$PKG_FFMPEG_LIBS" \
|
||||
--disable-static \
|
||||
--enable-shared \
|
||||
--enable-gpl \
|
||||
--disable-version3 \
|
||||
--enable-nonfree \
|
||||
--enable-logging \
|
||||
--disable-doc \
|
||||
$PKG_FFMPEG_DEBUG \
|
||||
--enable-pic \
|
||||
--pkg-config="$TOOLCHAIN/bin/pkg-config" \
|
||||
--enable-optimizations \
|
||||
--disable-extra-warnings \
|
||||
--disable-programs \
|
||||
--enable-avdevice \
|
||||
--enable-avcodec \
|
||||
--enable-avformat \
|
||||
--enable-swscale \
|
||||
--enable-postproc \
|
||||
--enable-avfilter \
|
||||
--disable-devices \
|
||||
--enable-pthreads \
|
||||
--enable-network \
|
||||
--disable-gnutls --enable-openssl \
|
||||
--disable-gray \
|
||||
--enable-swscale-alpha \
|
||||
--disable-small \
|
||||
--enable-dct \
|
||||
--enable-fft \
|
||||
--enable-mdct \
|
||||
--enable-rdft \
|
||||
--disable-crystalhd \
|
||||
$PKG_FFMPEG_V4L2 \
|
||||
$PKG_FFMPEG_VAAPI \
|
||||
$PKG_FFMPEG_VDPAU \
|
||||
$PKG_FFMPEG_RPI \
|
||||
$PKG_FFMPEG_RKMPP \
|
||||
$PKG_FFMPEG_V4L2_REQUEST \
|
||||
--enable-runtime-cpudetect \
|
||||
--disable-hardcoded-tables \
|
||||
--disable-encoders \
|
||||
--enable-encoder=ac3 \
|
||||
--enable-encoder=aac \
|
||||
--enable-encoder=wmav2 \
|
||||
--enable-encoder=mjpeg \
|
||||
--enable-encoder=png \
|
||||
--enable-hwaccels \
|
||||
--disable-muxers \
|
||||
--enable-muxer=spdif \
|
||||
--enable-muxer=adts \
|
||||
--enable-muxer=asf \
|
||||
--enable-muxer=ipod \
|
||||
--enable-muxer=mpegts \
|
||||
--enable-demuxers \
|
||||
--enable-parsers \
|
||||
--enable-bsfs \
|
||||
--enable-protocol=http \
|
||||
--disable-indevs \
|
||||
--disable-outdevs \
|
||||
--enable-filters \
|
||||
--disable-avisynth \
|
||||
--enable-bzlib \
|
||||
--disable-lzma \
|
||||
--disable-alsa \
|
||||
--disable-frei0r \
|
||||
--disable-libopencore-amrnb \
|
||||
--disable-libopencore-amrwb \
|
||||
--disable-libopencv \
|
||||
--disable-libdc1394 \
|
||||
--disable-libfreetype \
|
||||
--disable-libgsm \
|
||||
--disable-libmp3lame \
|
||||
--disable-libopenjpeg \
|
||||
--disable-librtmp \
|
||||
$PKG_FFMPEG_AV1 \
|
||||
--enable-libspeex \
|
||||
--disable-libtheora \
|
||||
--disable-libvo-amrwbenc \
|
||||
--disable-libvorbis \
|
||||
--disable-libvpx \
|
||||
--disable-libx264 \
|
||||
--disable-libxavs \
|
||||
--disable-libxvid \
|
||||
--enable-zlib \
|
||||
--enable-asm \
|
||||
--disable-altivec \
|
||||
$PKG_FFMPEG_FPU \
|
||||
--disable-symver \
|
||||
$PKG_FFMPEG_NVMPI
|
||||
}
|
||||
|
||||
post_makeinstall_target() {
|
||||
rm -rf $INSTALL/usr/share/ffmpeg/examples
|
||||
}
|
@ -0,0 +1,634 @@
|
||||
diff -Naur ffmpeg-4.0.4-Leia-18.4/configure ffmpeg-4.0.4-Leia-18.4-2/configure
|
||||
--- ffmpeg-4.0.4-Leia-18.4/configure 2021-06-09 15:11:11.531186112 -0700
|
||||
+++ ffmpeg-4.0.4-Leia-18.4-2/configure 2021-06-10 13:19:32.034991974 -0700
|
||||
@@ -328,6 +328,7 @@
|
||||
--disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect]
|
||||
--disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect]
|
||||
--disable-videotoolbox disable VideoToolbox code [autodetect]
|
||||
+ --enable-nvmpi enable nvmpi code
|
||||
|
||||
Toolchain options:
|
||||
--arch=ARCH select architecture [$arch]
|
||||
@@ -1784,6 +1785,7 @@
|
||||
mmal
|
||||
omx
|
||||
opencl
|
||||
+ nvmpi
|
||||
"
|
||||
|
||||
DOCUMENT_LIST="
|
||||
@@ -2922,11 +2924,14 @@
|
||||
h264_mediacodec_decoder_select="h264_mp4toannexb_bsf h264_parser"
|
||||
h264_mmal_decoder_deps="mmal"
|
||||
h264_nvenc_encoder_deps="nvenc"
|
||||
+h264_nvmpi_encoder_deps="nvmpi"
|
||||
h264_omx_encoder_deps="omx"
|
||||
h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec"
|
||||
h264_qsv_encoder_select="qsvenc"
|
||||
h264_rkmpp_decoder_deps="rkmpp"
|
||||
h264_rkmpp_decoder_select="h264_mp4toannexb_bsf"
|
||||
+h264_nvmpi_decoder_deps="nvmpi"
|
||||
+h264_nvmpi_decoder_select="h264_mp4toannexb_bsf"
|
||||
h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264"
|
||||
h264_vaapi_encoder_select="cbs_h264 vaapi_encode"
|
||||
h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m"
|
||||
@@ -2937,10 +2942,13 @@
|
||||
hevc_mediacodec_decoder_deps="mediacodec"
|
||||
hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser"
|
||||
hevc_nvenc_encoder_deps="nvenc"
|
||||
+hevc_nvmpi_encoder_deps="nvmpi"
|
||||
hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec"
|
||||
hevc_qsv_encoder_select="hevcparse qsvenc"
|
||||
hevc_rkmpp_decoder_deps="rkmpp"
|
||||
hevc_rkmpp_decoder_select="hevc_mp4toannexb_bsf"
|
||||
+hevc_nvmpi_decoder_deps="nvmpi"
|
||||
+hevc_nvmpi_decoder_select="hevc_mp4toannexb_bsf"
|
||||
hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
|
||||
hevc_vaapi_encoder_select="cbs_h265 vaapi_encode"
|
||||
hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
|
||||
@@ -2954,6 +2962,7 @@
|
||||
mpeg1_v4l2m2m_decoder_deps="v4l2_m2m mpeg1_v4l2_m2m"
|
||||
mpeg2_crystalhd_decoder_select="crystalhd"
|
||||
mpeg2_cuvid_decoder_deps="cuvid"
|
||||
+mpeg2_nvmpi_decoder_deps="nvmpi"
|
||||
mpeg2_mmal_decoder_deps="mmal"
|
||||
mpeg2_mediacodec_decoder_deps="mediacodec"
|
||||
mpeg2_qsv_decoder_select="qsvdec mpegvideo_parser"
|
||||
@@ -2963,6 +2972,7 @@
|
||||
mpeg2_v4l2m2m_decoder_deps="v4l2_m2m mpeg2_v4l2_m2m"
|
||||
mpeg4_crystalhd_decoder_select="crystalhd"
|
||||
mpeg4_cuvid_decoder_deps="cuvid"
|
||||
+mpeg4_nvmpi_decoder_deps="nvmpi"
|
||||
mpeg4_mediacodec_decoder_deps="mediacodec"
|
||||
mpeg4_mmal_decoder_deps="mmal"
|
||||
mpeg4_omx_encoder_deps="omx"
|
||||
@@ -2977,6 +2987,7 @@
|
||||
vc1_qsv_decoder_select="qsvdec vc1_parser"
|
||||
vc1_v4l2m2m_decoder_deps="v4l2_m2m vc1_v4l2_m2m"
|
||||
vp8_cuvid_decoder_deps="cuvid"
|
||||
+vp8_nvmpi_decoder_deps="nvmpi"
|
||||
vp8_mediacodec_decoder_deps="mediacodec"
|
||||
vp8_qsv_decoder_select="qsvdec vp8_parser"
|
||||
vp8_rkmpp_decoder_deps="rkmpp"
|
||||
@@ -2985,6 +2996,7 @@
|
||||
vp8_v4l2m2m_decoder_deps="v4l2_m2m vp8_v4l2_m2m"
|
||||
vp8_v4l2m2m_encoder_deps="v4l2_m2m vp8_v4l2_m2m"
|
||||
vp9_cuvid_decoder_deps="cuvid"
|
||||
+vp9_nvmpi_decoder_deps="nvmpi"
|
||||
vp9_mediacodec_decoder_deps="mediacodec"
|
||||
vp9_rkmpp_decoder_deps="rkmpp"
|
||||
vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9"
|
||||
@@ -6157,6 +6169,7 @@
|
||||
{ enabled libdrm ||
|
||||
die "ERROR: rkmpp requires --enable-libdrm"; }
|
||||
}
|
||||
+enabled nvmpi && require_pkg_config nvmpi nvmpi nvmpi.h nvmpi_create_decoder
|
||||
|
||||
if enabled gcrypt; then
|
||||
GCRYPT_CONFIG="${cross_prefix}libgcrypt-config"
|
||||
|
||||
diff -Naur ffmpeg-4.0.4-Leia-18.4/libavcodec/allcodecs.c ffmpeg-4.0.4-Leia-18.4-2/libavcodec/allcodecs.c
|
||||
--- ffmpeg-4.0.4-Leia-18.4/libavcodec/allcodecs.c 2021-06-09 15:11:11.567850545 -0700
|
||||
+++ ffmpeg-4.0.4-Leia-18.4-2/libavcodec/allcodecs.c 2021-06-10 13:16:30.192931556 -0700
|
||||
@@ -140,11 +140,15 @@
|
||||
extern AVCodec ff_h264_mmal_decoder;
|
||||
extern AVCodec ff_h264_qsv_decoder;
|
||||
extern AVCodec ff_h264_rkmpp_decoder;
|
||||
+extern AVCodec ff_h264_nvmpi_decoder;
|
||||
+extern AVCodec ff_h264_nvmpi_encoder;
|
||||
extern AVCodec ff_hap_encoder;
|
||||
extern AVCodec ff_hap_decoder;
|
||||
extern AVCodec ff_hevc_decoder;
|
||||
extern AVCodec ff_hevc_qsv_decoder;
|
||||
extern AVCodec ff_hevc_rkmpp_decoder;
|
||||
+extern AVCodec ff_hevc_nvmpi_decoder;
|
||||
+extern AVCodec ff_hevc_nvmpi_encoder;
|
||||
extern AVCodec ff_hevc_v4l2m2m_decoder;
|
||||
extern AVCodec ff_hnm4_video_decoder;
|
||||
extern AVCodec ff_hq_hqa_decoder;
|
||||
@@ -747,18 +751,22 @@
|
||||
extern AVCodec ff_mjpeg_vaapi_encoder;
|
||||
extern AVCodec ff_mpeg1_cuvid_decoder;
|
||||
extern AVCodec ff_mpeg2_cuvid_decoder;
|
||||
+extern AVCodec ff_mpeg2_nvmpi_decoder;
|
||||
extern AVCodec ff_mpeg2_qsv_encoder;
|
||||
extern AVCodec ff_mpeg2_vaapi_encoder;
|
||||
extern AVCodec ff_mpeg4_cuvid_decoder;
|
||||
+extern AVCodec ff_mpeg4_nvmpi_decoder;
|
||||
extern AVCodec ff_mpeg4_mediacodec_decoder;
|
||||
extern AVCodec ff_mpeg4_v4l2m2m_encoder;
|
||||
extern AVCodec ff_vc1_cuvid_decoder;
|
||||
extern AVCodec ff_vp8_cuvid_decoder;
|
||||
+extern AVCodec ff_vp8_nvmpi_decoder;
|
||||
extern AVCodec ff_vp8_mediacodec_decoder;
|
||||
extern AVCodec ff_vp8_qsv_decoder;
|
||||
extern AVCodec ff_vp8_v4l2m2m_encoder;
|
||||
extern AVCodec ff_vp8_vaapi_encoder;
|
||||
extern AVCodec ff_vp9_cuvid_decoder;
|
||||
+extern AVCodec ff_vp9_nvmpi_decoder;
|
||||
extern AVCodec ff_vp9_mediacodec_decoder;
|
||||
extern AVCodec ff_vp9_vaapi_encoder;
|
||||
|
||||
diff -Naur ffmpeg-4.0.4-Leia-18.4/libavcodec/Makefile ffmpeg-4.0.4-Leia-18.4-2/libavcodec/Makefile
|
||||
--- ffmpeg-4.0.4-Leia-18.4/libavcodec/Makefile 2021-06-09 15:11:11.581183068 -0700
|
||||
+++ ffmpeg-4.0.4-Leia-18.4-2/libavcodec/Makefile 2021-06-10 13:16:30.192931556 -0700
|
||||
@@ -347,6 +347,8 @@
|
||||
OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o
|
||||
OBJS-$(CONFIG_NVENC_ENCODER) += nvenc_h264.o
|
||||
OBJS-$(CONFIG_NVENC_H264_ENCODER) += nvenc_h264.o
|
||||
+OBJS-$(CONFIG_H264_NVMPI_DECODER) += nvmpi_dec.o
|
||||
+OBJS-$(CONFIG_H264_NVMPI_ENCODER) += nvmpi_enc.o
|
||||
OBJS-$(CONFIG_H264_OMX_ENCODER) += omx.o
|
||||
OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec_h2645.o
|
||||
OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o
|
||||
@@ -371,6 +373,8 @@
|
||||
OBJS-$(CONFIG_HEVC_RKMPP_DECODER) += rkmppdec.o
|
||||
OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o
|
||||
OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o
|
||||
+OBJS-$(CONFIG_HEVC_NVMPI_DECODER) += nvmpi_dec.o
|
||||
+OBJS-$(CONFIG_HEVC_NVMPI_ENCODER) += nvmpi_enc.o
|
||||
OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
|
||||
OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o
|
||||
OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \
|
||||
@@ -452,11 +456,13 @@
|
||||
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
|
||||
OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
|
||||
OBJS-$(CONFIG_MPEG2_CUVID_DECODER) += cuviddec.o
|
||||
+OBJS-$(CONFIG_MPEG2_NVMPI_DECODER) += nvmpi_dec.o
|
||||
OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
|
||||
OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o
|
||||
OBJS-$(CONFIG_MPEG2_V4L2M2M_DECODER) += v4l2_m2m_dec.o
|
||||
OBJS-$(CONFIG_MPEG4_DECODER) += xvididct.o
|
||||
OBJS-$(CONFIG_MPEG4_CUVID_DECODER) += cuviddec.o
|
||||
+OBJS-$(CONFIG_MPEG4_NVMPI_DECODER) += nvmpi_dec.o
|
||||
OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
|
||||
OBJS-$(CONFIG_MPEG4_OMX_ENCODER) += omx.o
|
||||
OBJS-$(CONFIG_MPEG4_V4L2M2M_DECODER) += v4l2_m2m_dec.o
|
||||
@@ -654,6 +660,7 @@
|
||||
OBJS-$(CONFIG_VP7_DECODER) += vp8.o vp56rac.o
|
||||
OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp56rac.o
|
||||
OBJS-$(CONFIG_VP8_CUVID_DECODER) += cuviddec.o
|
||||
+OBJS-$(CONFIG_VP8_NVMPI_DECODER) += nvmpi_dec.o
|
||||
OBJS-$(CONFIG_VP8_MEDIACODEC_DECODER) += mediacodecdec.o
|
||||
OBJS-$(CONFIG_VP8_QSV_DECODER) += qsvdec_other.o
|
||||
OBJS-$(CONFIG_VP8_RKMPP_DECODER) += rkmppdec.o
|
||||
@@ -664,6 +671,7 @@
|
||||
vp9block.o vp9prob.o vp9mvs.o vp56rac.o \
|
||||
vp9dsp_8bpp.o vp9dsp_10bpp.o vp9dsp_12bpp.o
|
||||
OBJS-$(CONFIG_VP9_CUVID_DECODER) += cuviddec.o
|
||||
+OBJS-$(CONFIG_VP9_NVMPI_DECODER) += nvmpi_dec.o
|
||||
OBJS-$(CONFIG_VP9_MEDIACODEC_DECODER) += mediacodecdec.o
|
||||
OBJS-$(CONFIG_VP9_RKMPP_DECODER) += rkmppdec.o
|
||||
OBJS-$(CONFIG_VP9_VAAPI_ENCODER) += vaapi_encode_vp9.o
|
||||
|
||||
diff -Naur ffmpeg-4.0.4-Leia-18.4/libavcodec/nvmpi_dec.c ffmpeg-4.0.4-Leia-18.4-2/libavcodec/nvmpi_dec.c
|
||||
--- ffmpeg-4.0.4-Leia-18.4/libavcodec/nvmpi_dec.c 1969-12-31 16:00:00.000000000 -0800
|
||||
+++ ffmpeg-4.0.4-Leia-18.4-2/libavcodec/nvmpi_dec.c 2021-06-10 13:16:30.192931556 -0700
|
||||
@@ -0,0 +1,171 @@
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <sys/time.h>
|
||||
+
|
||||
+#include <nvmpi.h>
|
||||
+#include "avcodec.h"
|
||||
+#include "decode.h"
|
||||
+#include "internal.h"
|
||||
+#include "libavutil/buffer.h"
|
||||
+#include "libavutil/common.h"
|
||||
+#include "libavutil/frame.h"
|
||||
+#include "libavutil/hwcontext.h"
|
||||
+#include "libavutil/hwcontext_drm.h"
|
||||
+#include "libavutil/imgutils.h"
|
||||
+#include "libavutil/log.h"
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+typedef struct {
|
||||
+ char eos_reached;
|
||||
+ nvmpictx* ctx;
|
||||
+ AVClass *av_class;
|
||||
+} nvmpiDecodeContext;
|
||||
+
|
||||
+static nvCodingType nvmpi_get_codingtype(AVCodecContext *avctx)
|
||||
+{
|
||||
+ switch (avctx->codec_id) {
|
||||
+ case AV_CODEC_ID_H264: return NV_VIDEO_CodingH264;
|
||||
+ case AV_CODEC_ID_HEVC: return NV_VIDEO_CodingHEVC;
|
||||
+ case AV_CODEC_ID_VP8: return NV_VIDEO_CodingVP8;
|
||||
+ case AV_CODEC_ID_VP9: return NV_VIDEO_CodingVP9;
|
||||
+ case AV_CODEC_ID_MPEG4: return NV_VIDEO_CodingMPEG4;
|
||||
+ case AV_CODEC_ID_MPEG2VIDEO: return NV_VIDEO_CodingMPEG2;
|
||||
+ default: return NV_VIDEO_CodingUnused;
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
+
|
||||
+static int nvmpi_init_decoder(AVCodecContext *avctx){
|
||||
+
|
||||
+ nvmpiDecodeContext *nvmpi_context = avctx->priv_data;
|
||||
+ nvCodingType codectype=NV_VIDEO_CodingUnused;
|
||||
+
|
||||
+ codectype =nvmpi_get_codingtype(avctx);
|
||||
+ if (codectype == NV_VIDEO_CodingUnused) {
|
||||
+ av_log(avctx, AV_LOG_ERROR, "Unknown codec type (%d).\n", avctx->codec_id);
|
||||
+ return AVERROR_UNKNOWN;
|
||||
+ }
|
||||
+
|
||||
+ //Workaround for default pix_fmt not being set, so check if it isnt set and set it,
|
||||
+ //or if it is set, but isnt set to something we can work with.
|
||||
+
|
||||
+ if(avctx->pix_fmt ==AV_PIX_FMT_NONE){
|
||||
+ avctx->pix_fmt=AV_PIX_FMT_YUV420P;
|
||||
+ }else if(avctx-> pix_fmt != AV_PIX_FMT_YUV420P){
|
||||
+ av_log(avctx, AV_LOG_ERROR, "Invalid Pix_FMT for NVMPI Only yuv420p is supported\n");
|
||||
+ return AVERROR_INVALIDDATA;
|
||||
+ }
|
||||
+
|
||||
+ nvmpi_context->ctx=nvmpi_create_decoder(codectype,NV_PIX_YUV420);
|
||||
+
|
||||
+ if(!nvmpi_context->ctx){
|
||||
+ av_log(avctx, AV_LOG_ERROR, "Failed to nvmpi_create_decoder (code = %d).\n", AVERROR_EXTERNAL);
|
||||
+ return AVERROR_EXTERNAL;
|
||||
+ }
|
||||
+ return 0;
|
||||
+
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
+static int nvmpi_close(AVCodecContext *avctx){
|
||||
+
|
||||
+ nvmpiDecodeContext *nvmpi_context = avctx->priv_data;
|
||||
+ return nvmpi_decoder_close(nvmpi_context->ctx);
|
||||
+
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
+static int nvmpi_decode(AVCodecContext *avctx,void *data,int *got_frame, AVPacket *avpkt){
|
||||
+
|
||||
+ nvmpiDecodeContext *nvmpi_context = avctx->priv_data;
|
||||
+ AVFrame *frame = data;
|
||||
+ nvFrame _nvframe={0};
|
||||
+ nvPacket packet;
|
||||
+ uint8_t* ptrs[3];
|
||||
+ int res,linesize[3];
|
||||
+
|
||||
+ if(avpkt->size){
|
||||
+ packet.payload_size=avpkt->size;
|
||||
+ packet.payload=avpkt->data;
|
||||
+ packet.pts=avpkt->pts;
|
||||
+
|
||||
+ res=nvmpi_decoder_put_packet(nvmpi_context->ctx,&packet);
|
||||
+ }
|
||||
+
|
||||
+ res=nvmpi_decoder_get_frame(nvmpi_context->ctx,&_nvframe,avctx->flags & AV_CODEC_FLAG_LOW_DELAY);
|
||||
+
|
||||
+ if(res<0)
|
||||
+ return avpkt->size;
|
||||
+
|
||||
+ if (ff_get_buffer(avctx, frame, 0) < 0) {
|
||||
+ return AVERROR(ENOMEM);
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ linesize[0]=_nvframe.linesize[0];
|
||||
+ linesize[1]=_nvframe.linesize[1];
|
||||
+ linesize[2]=_nvframe.linesize[2];
|
||||
+
|
||||
+ ptrs[0]=_nvframe.payload[0];
|
||||
+ ptrs[1]=_nvframe.payload[1];
|
||||
+ ptrs[2]=_nvframe.payload[2];
|
||||
+
|
||||
+ av_image_copy(frame->data, frame->linesize, (const uint8_t **) ptrs, linesize, avctx->pix_fmt, _nvframe.width,_nvframe.height);
|
||||
+
|
||||
+ frame->width=_nvframe.width;
|
||||
+ frame->height=_nvframe.height;
|
||||
+
|
||||
+ frame->format=AV_PIX_FMT_YUV420P;
|
||||
+ frame->pts=_nvframe.timestamp;
|
||||
+ frame->pkt_dts = AV_NOPTS_VALUE;
|
||||
+
|
||||
+ avctx->coded_width=_nvframe.width;
|
||||
+ avctx->coded_height=_nvframe.height;
|
||||
+ avctx->width=_nvframe.width;
|
||||
+ avctx->height=_nvframe.height;
|
||||
+
|
||||
+ *got_frame = 1;
|
||||
+
|
||||
+ return avpkt->size;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+#define NVMPI_DEC_CLASS(NAME) \
|
||||
+ static const AVClass nvmpi_##NAME##_dec_class = { \
|
||||
+ .class_name = "nvmpi_" #NAME "_dec", \
|
||||
+ .version = LIBAVUTIL_VERSION_INT, \
|
||||
+ };
|
||||
+
|
||||
+#define NVMPI_DEC(NAME, ID, BSFS) \
|
||||
+ NVMPI_DEC_CLASS(NAME) \
|
||||
+ AVCodec ff_##NAME##_nvmpi_decoder = { \
|
||||
+ .name = #NAME "_nvmpi", \
|
||||
+ .long_name = NULL_IF_CONFIG_SMALL(#NAME " (nvmpi)"), \
|
||||
+ .type = AVMEDIA_TYPE_VIDEO, \
|
||||
+ .id = ID, \
|
||||
+ .priv_data_size = sizeof(nvmpiDecodeContext), \
|
||||
+ .init = nvmpi_init_decoder, \
|
||||
+ .close = nvmpi_close, \
|
||||
+ .decode = nvmpi_decode, \
|
||||
+ .priv_class = &nvmpi_##NAME##_dec_class, \
|
||||
+ .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \
|
||||
+ .pix_fmts =(const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P,AV_PIX_FMT_NV12,AV_PIX_FMT_NONE},\
|
||||
+ .bsfs = BSFS, \
|
||||
+ .wrapper_name = "nvmpi", \
|
||||
+ };
|
||||
+
|
||||
+
|
||||
+
|
||||
+NVMPI_DEC(h264, AV_CODEC_ID_H264,"h264_mp4toannexb");
|
||||
+NVMPI_DEC(hevc, AV_CODEC_ID_HEVC,"hevc_mp4toannexb");
|
||||
+NVMPI_DEC(mpeg2, AV_CODEC_ID_MPEG2VIDEO,NULL);
|
||||
+NVMPI_DEC(mpeg4, AV_CODEC_ID_MPEG4,NULL);
|
||||
+NVMPI_DEC(vp9, AV_CODEC_ID_VP9,NULL);
|
||||
+NVMPI_DEC(vp8, AV_CODEC_ID_VP8,NULL);
|
||||
+
|
||||
diff -Naur ffmpeg-4.0.4-Leia-18.4/libavcodec/nvmpi_enc.c ffmpeg-4.0.4-Leia-18.4-2/libavcodec/nvmpi_enc.c
|
||||
--- ffmpeg-4.0.4-Leia-18.4/libavcodec/nvmpi_enc.c 1969-12-31 16:00:00.000000000 -0800
|
||||
+++ ffmpeg-4.0.4-Leia-18.4-2/libavcodec/nvmpi_enc.c 2021-06-10 13:16:30.192931556 -0700
|
||||
@@ -0,0 +1,272 @@
|
||||
+#include <nvmpi.h>
|
||||
+#include "avcodec.h"
|
||||
+#include "internal.h"
|
||||
+#include <stdio.h>
|
||||
+#include "libavutil/avstring.h"
|
||||
+#include "libavutil/avutil.h"
|
||||
+#include "libavutil/common.h"
|
||||
+#include "libavutil/imgutils.h"
|
||||
+#include "libavutil/log.h"
|
||||
+#include "libavutil/opt.h"
|
||||
+
|
||||
+
|
||||
+typedef struct {
|
||||
+ const AVClass *class;
|
||||
+ nvmpictx* ctx;
|
||||
+ int num_capture_buffers;
|
||||
+ int profile;
|
||||
+ int level;
|
||||
+ int rc;
|
||||
+ int preset;
|
||||
+}nvmpiEncodeContext;
|
||||
+
|
||||
+static av_cold int nvmpi_encode_init(AVCodecContext *avctx){
|
||||
+
|
||||
+ nvmpiEncodeContext * nvmpi_context = avctx->priv_data;
|
||||
+
|
||||
+ nvEncParam param={0};
|
||||
+
|
||||
+ param.width=avctx->width;
|
||||
+ param.height=avctx->height;
|
||||
+ param.bitrate=avctx->bit_rate;
|
||||
+ param.mode_vbr=0;
|
||||
+ param.idr_interval=60;
|
||||
+ param.iframe_interval=30;
|
||||
+ param.peak_bitrate=0;
|
||||
+ param.fps_n=avctx->framerate.num;
|
||||
+ param.fps_d=avctx->framerate.den;
|
||||
+ param.profile=nvmpi_context->profile& ~FF_PROFILE_H264_INTRA;
|
||||
+ param.level=nvmpi_context->level;
|
||||
+ param.capture_num=nvmpi_context->num_capture_buffers;
|
||||
+ param.hw_preset_type=nvmpi_context->preset;
|
||||
+ param.insert_spspps_idr=(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)?0:1;
|
||||
+
|
||||
+ if(nvmpi_context->rc==1){
|
||||
+ param.mode_vbr=1;
|
||||
+ }
|
||||
+
|
||||
+ if(avctx->qmin >= 0 && avctx->qmax >= 0){
|
||||
+ param.qmin=avctx->qmin;
|
||||
+ param.qmax=avctx->qmax;
|
||||
+ }
|
||||
+
|
||||
+ if (avctx->refs >= 0){
|
||||
+ param.refs=avctx->refs;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ if(avctx->max_b_frames > 0 && avctx->max_b_frames < 3){
|
||||
+ param.max_b_frames=avctx->max_b_frames;
|
||||
+ }
|
||||
+
|
||||
+ if(avctx->gop_size>0){
|
||||
+ param.idr_interval=param.iframe_interval=avctx->gop_size;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ if ((avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) && (avctx->codec->id == AV_CODEC_ID_H264)){
|
||||
+
|
||||
+ uint8_t *dst[4];
|
||||
+ int linesize[4];
|
||||
+ nvFrame _nvframe={0};
|
||||
+ nvPacket packet={0};
|
||||
+ int i;
|
||||
+ int ret;
|
||||
+ nvmpictx* _ctx;
|
||||
+ av_image_alloc(dst, linesize,avctx->width,avctx->height,avctx->pix_fmt,1);
|
||||
+
|
||||
+ _ctx=nvmpi_create_encoder(NV_VIDEO_CodingH264,¶m);
|
||||
+ i=0;
|
||||
+
|
||||
+ while(1){
|
||||
+
|
||||
+ _nvframe.payload[0]=dst[0];
|
||||
+ _nvframe.payload[1]=dst[1];
|
||||
+ _nvframe.payload[2]=dst[2];
|
||||
+ _nvframe.payload_size[0]=linesize[0]*avctx->height;
|
||||
+ _nvframe.payload_size[1]=linesize[1]*avctx->height/2;
|
||||
+ _nvframe.payload_size[2]=linesize[2]*avctx->height/2;
|
||||
+
|
||||
+ nvmpi_encoder_put_frame(_ctx,&_nvframe);
|
||||
+
|
||||
+ ret=nvmpi_encoder_get_packet(_ctx,&packet);
|
||||
+
|
||||
+ if(ret<0)
|
||||
+ continue;
|
||||
+
|
||||
+ //find idr index 0x0000000165
|
||||
+ while((packet.payload[i]!=0||packet.payload[i+1]!=0||packet.payload[i+2]!=0||packet.payload[i+3]!=0x01||packet.payload[i+4]!=0x65)){
|
||||
+ i++;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ avctx->extradata_size=i;
|
||||
+ avctx->extradata = av_mallocz( avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE );
|
||||
+ memcpy( avctx->extradata, packet.payload,avctx->extradata_size);
|
||||
+ memset( avctx->extradata + avctx->extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE );
|
||||
+
|
||||
+ break;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ nvmpi_encoder_close(_ctx);
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ if(avctx->codec->id == AV_CODEC_ID_H264)
|
||||
+ nvmpi_context->ctx=nvmpi_create_encoder(NV_VIDEO_CodingH264,¶m);
|
||||
+ else if(avctx->codec->id == AV_CODEC_ID_HEVC){
|
||||
+ nvmpi_context->ctx=nvmpi_create_encoder(NV_VIDEO_CodingHEVC,¶m);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int nvmpi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,const AVFrame *frame, int *got_packet){
|
||||
+
|
||||
+ nvmpiEncodeContext * nvmpi_context = avctx->priv_data;
|
||||
+ nvFrame _nvframe={0};
|
||||
+ nvPacket packet={0};
|
||||
+ int res;
|
||||
+
|
||||
+ if(frame){
|
||||
+
|
||||
+ _nvframe.payload[0]=frame->data[0];
|
||||
+ _nvframe.payload[1]=frame->data[1];
|
||||
+ _nvframe.payload[2]=frame->data[2];
|
||||
+
|
||||
+ _nvframe.payload_size[0]=frame->linesize[0]*frame->height;
|
||||
+ _nvframe.payload_size[1]=frame->linesize[1]*frame->height/2;
|
||||
+ _nvframe.payload_size[2]=frame->linesize[2]*frame->height/2;
|
||||
+
|
||||
+ _nvframe.linesize[0]=frame->linesize[0];
|
||||
+ _nvframe.linesize[1]=frame->linesize[1];
|
||||
+ _nvframe.linesize[2]=frame->linesize[2];
|
||||
+
|
||||
+ _nvframe.timestamp=frame->pts;
|
||||
+
|
||||
+ res=nvmpi_encoder_put_frame(nvmpi_context->ctx,&_nvframe);
|
||||
+
|
||||
+ if(res<0)
|
||||
+ return res;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ if(nvmpi_encoder_get_packet(nvmpi_context->ctx,&packet)<0)
|
||||
+ return 0;
|
||||
+
|
||||
+
|
||||
+ ff_alloc_packet2(avctx,pkt,packet.payload_size,packet.payload_size);
|
||||
+
|
||||
+ memcpy(pkt->data,packet.payload,packet.payload_size);
|
||||
+ pkt->dts=pkt->pts=packet.pts;
|
||||
+
|
||||
+ if(packet.flags& AV_PKT_FLAG_KEY)
|
||||
+ pkt->flags = AV_PKT_FLAG_KEY;
|
||||
+
|
||||
+
|
||||
+ *got_packet = 1;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static av_cold int nvmpi_encode_close(AVCodecContext *avctx){
|
||||
+
|
||||
+ nvmpiEncodeContext *nvmpi_context = avctx->priv_data;
|
||||
+ nvmpi_encoder_close(nvmpi_context->ctx);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const AVCodecDefault defaults[] = {
|
||||
+ { "b", "2M" },
|
||||
+ { "qmin", "-1" },
|
||||
+ { "qmax", "-1" },
|
||||
+ { "qdiff", "-1" },
|
||||
+ { "qblur", "-1" },
|
||||
+ { "qcomp", "-1" },
|
||||
+ { "g", "50" },
|
||||
+ { "bf", "0" },
|
||||
+ { "refs", "0" },
|
||||
+ { NULL },
|
||||
+};
|
||||
+
|
||||
+
|
||||
+#define OFFSET(x) offsetof(nvmpiEncodeContext, x)
|
||||
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
||||
+
|
||||
+static const AVOption options[] = {
|
||||
+ { "num_capture_buffers", "Number of buffers in the capture context", OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 10 }, 1, 32, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
|
||||
+ /// Profile,
|
||||
+
|
||||
+ { "profile", "Set the encoding profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, FF_PROFILE_H264_HIGH, VE, "profile" },
|
||||
+ { "baseline", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_BASELINE }, 0, 0, VE, "profile" },
|
||||
+ { "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_MAIN }, 0, 0, VE, "profile" },
|
||||
+ { "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_H264_HIGH }, 0, 0, VE, "profile" },
|
||||
+
|
||||
+ /// Profile Level
|
||||
+ { "level", "Profile Level", OFFSET(level), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 62, VE, "level" },
|
||||
+ { "auto", "", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "level" },
|
||||
+ { "1.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 10 }, 0, 0, VE, "level" },
|
||||
+ { "1.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 11 }, 0, 0, VE, "level" },
|
||||
+ { "1.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = 12 }, 0, 0, VE, "level" },
|
||||
+ { "1.3", "", 0, AV_OPT_TYPE_CONST, { .i64 = 13 }, 0, 0, VE, "level" },
|
||||
+ { "2.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 20 }, 0, 0, VE, "level" },
|
||||
+ { "2.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 21 }, 0, 0, VE, "level" },
|
||||
+ { "2.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = 22 }, 0, 0, VE, "level" },
|
||||
+ { "3.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 30 }, 0, 0, VE, "level" },
|
||||
+ { "3.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 31 }, 0, 0, VE, "level" },
|
||||
+ { "3.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = 32 }, 0, 0, VE, "level" },
|
||||
+ { "4.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 40 }, 0, 0, VE, "level" },
|
||||
+ { "4.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 41 }, 0, 0, VE, "level" },
|
||||
+ { "4.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = 42 }, 0, 0, VE, "level" },
|
||||
+ { "5.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = 50 }, 0, 0, VE, "level" },
|
||||
+ { "5.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = 51 }, 0, 0, VE, "level" },
|
||||
+
|
||||
+ { "rc", "Override the preset rate-control", OFFSET(rc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE, "rc" },
|
||||
+ { "cbr", "Constant bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "rc" },
|
||||
+ { "vbr", "Variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "rc" },
|
||||
+
|
||||
+ { "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = 3 }, 1, 4, VE, "preset" },
|
||||
+ { "default", "", 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, 0, 0, VE, "preset" },
|
||||
+ { "slow", "", 0, AV_OPT_TYPE_CONST, { .i64 = 4 }, 0, 0, VE, "preset" },
|
||||
+ { "medium", "", 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, 0, 0, VE, "preset" },
|
||||
+ { "fast", "", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, VE, "preset" },
|
||||
+ { "ultrafast", "", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "preset" },
|
||||
+ { NULL }
|
||||
+};
|
||||
+
|
||||
+
|
||||
+#define NVMPI_ENC_CLASS(NAME) \
|
||||
+ static const AVClass nvmpi_ ## NAME ## _enc_class = { \
|
||||
+ .class_name = #NAME "_nvmpi_encoder", \
|
||||
+ .item_name = av_default_item_name, \
|
||||
+ .option = options, \
|
||||
+ .version = LIBAVUTIL_VERSION_INT, \
|
||||
+ };
|
||||
+
|
||||
+
|
||||
+#define NVMPI_ENC(NAME, LONGNAME, CODEC) \
|
||||
+ NVMPI_ENC_CLASS(NAME) \
|
||||
+ AVCodec ff_ ## NAME ## _nvmpi_encoder = { \
|
||||
+ .name = #NAME "_nvmpi" , \
|
||||
+ .long_name = NULL_IF_CONFIG_SMALL("nvmpi " LONGNAME " encoder wrapper"), \
|
||||
+ .type = AVMEDIA_TYPE_VIDEO, \
|
||||
+ .id = CODEC , \
|
||||
+ .priv_data_size = sizeof(nvmpiEncodeContext), \
|
||||
+ .priv_class = &nvmpi_ ## NAME ##_enc_class, \
|
||||
+ .init = nvmpi_encode_init, \
|
||||
+ .encode2 = nvmpi_encode_frame, \
|
||||
+ .close = nvmpi_encode_close, \
|
||||
+ .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },\
|
||||
+ .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \
|
||||
+ .defaults = defaults,\
|
||||
+ .wrapper_name = "nvmpi", \
|
||||
+ };
|
||||
+
|
||||
+NVMPI_ENC(h264, "H.264", AV_CODEC_ID_H264);
|
||||
+NVMPI_ENC(hevc, "HEVC", AV_CODEC_ID_HEVC);
|
@ -0,0 +1,55 @@
|
||||
From 7adc8f706efab65d8d7e5f960690faca3d5c190d Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Sat, 4 Mar 2017 19:24:02 +0000
|
||||
Subject: [PATCH] ffmpeg: Call get_format to fix an issue with MMAL rendering
|
||||
|
||||
---
|
||||
libavcodec/dvdec.c | 7 +++++++
|
||||
libavcodec/rv34.c | 6 +++++-
|
||||
2 files changed, 12 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
|
||||
index 0b4c1bc..00081ef 100644
|
||||
--- a/libavcodec/dvdec.c
|
||||
+++ b/libavcodec/dvdec.c
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "internal.h"
|
||||
#include "put_bits.h"
|
||||
#include "simple_idct.h"
|
||||
+#include "thread.h"
|
||||
|
||||
typedef struct BlockInfo {
|
||||
const uint32_t *factor_table;
|
||||
@@ -196,6 +197,12 @@ static av_cold int dvvideo_decode_init(AVCodecContext *avctx)
|
||||
s->idct_put[0] = idsp.idct_put;
|
||||
s->idct_put[1] = ff_simple_idct248_put;
|
||||
|
||||
+ static const enum AVPixelFormat pix_fmts[] = {
|
||||
+ AV_PIX_FMT_YUV420P,
|
||||
+ AV_PIX_FMT_NONE
|
||||
+ };
|
||||
+ avctx->pix_fmt = ff_get_format(avctx, pix_fmts);
|
||||
+
|
||||
return ff_dvvideo_init(avctx);
|
||||
}
|
||||
|
||||
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
|
||||
index aca8382..f473f6c 100644
|
||||
--- a/libavcodec/rv34.c
|
||||
+++ b/libavcodec/rv34.c
|
||||
@@ -1493,7 +1493,11 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
|
||||
ff_mpv_decode_init(s, avctx);
|
||||
s->out_format = FMT_H263;
|
||||
|
||||
- avctx->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||
+ static const enum AVPixelFormat pix_fmts[] = {
|
||||
+ AV_PIX_FMT_YUV420P,
|
||||
+ AV_PIX_FMT_NONE
|
||||
+ };
|
||||
+ avctx->pix_fmt = ff_get_format(avctx, pix_fmts);
|
||||
avctx->has_b_frames = 1;
|
||||
s->low_delay = 0;
|
||||
|
||||
--
|
||||
2.7.4
|
||||
|
@ -0,0 +1,48 @@
|
||||
From d8bdcc8791c501921ee8961f3b0de0bd47668ebf Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Fri, 5 Jun 2015 22:48:33 +0100
|
||||
Subject: [PATCH] mpeg4video: Signal unsupported GMC with more than one warp
|
||||
point
|
||||
|
||||
---
|
||||
libavcodec/avcodec.h | 1 +
|
||||
libavcodec/mpeg4videodec.c | 4 ++++
|
||||
2 files changed, 5 insertions(+)
|
||||
|
||||
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
|
||||
index c26b6d607c..6c4b011b5c 100644
|
||||
--- a/libavcodec/avcodec.h
|
||||
+++ b/libavcodec/avcodec.h
|
||||
@@ -2965,6 +2965,7 @@ typedef struct AVCodecContext {
|
||||
#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
|
||||
#define FF_BUG_TRUNCATED 16384
|
||||
#define FF_BUG_IEDGE 32768
|
||||
+#define FF_BUG_GMC_UNSUPPORTED (1<<30)
|
||||
|
||||
/**
|
||||
* strictly follow the standard (MPEG-4, ...).
|
||||
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
|
||||
index cd39131d55..d8c8227cb4 100644
|
||||
--- a/libavcodec/mpeg4videodec.c
|
||||
+++ b/libavcodec/mpeg4videodec.c
|
||||
@@ -2250,6 +2250,9 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
|
||||
|
||||
if (ctx->divx_version >= 0)
|
||||
s->workaround_bugs |= FF_BUG_HPEL_CHROMA;
|
||||
+
|
||||
+ if (ctx->num_sprite_warping_points > 1)
|
||||
+ s->workaround_bugs |= FF_BUG_GMC_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (s->workaround_bugs & FF_BUG_STD_QPEL) {
|
||||
@@ -2274,6 +2277,7 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
|
||||
s->workaround_bugs, ctx->lavc_build, ctx->xvid_build,
|
||||
ctx->divx_version, ctx->divx_build, s->divx_packed ? "p" : "");
|
||||
|
||||
+ avctx->workaround_bugs = s->workaround_bugs;
|
||||
if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0 &&
|
||||
s->codec_id == AV_CODEC_ID_MPEG4 &&
|
||||
avctx->idct_algo == FF_IDCT_AUTO) {
|
||||
--
|
||||
2.14.1
|
||||
|
@ -0,0 +1,284 @@
|
||||
From 20af7af23a9f366476e67669f14957dfaf58f141 Mon Sep 17 00:00:00 2001
|
||||
From: Hendrik Leppkes <h.leppkes@gmail.com>
|
||||
Date: Sat, 9 Jan 2016 16:34:09 +0100
|
||||
Subject: [PATCH 1/4] avcodec: add h264_mvc codec id and profiles
|
||||
|
||||
---
|
||||
libavcodec/avcodec.h | 3 +++
|
||||
libavcodec/codec_desc.c | 7 +++++++
|
||||
libavcodec/profiles.c | 1 +
|
||||
libavformat/mpegts.c | 2 +-
|
||||
4 files changed, 12 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
|
||||
index d962b9cf0a..4c4581c895 100644
|
||||
--- a/libavcodec/avcodec.h
|
||||
+++ b/libavcodec/avcodec.h
|
||||
@@ -447,6 +447,8 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_GDV,
|
||||
AV_CODEC_ID_FITS,
|
||||
|
||||
+ AV_CODEC_ID_H264_MVC,
|
||||
+
|
||||
/* various PCM "codecs" */
|
||||
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
|
||||
AV_CODEC_ID_PCM_S16LE = 0x10000,
|
||||
@@ -2895,6 +2897,7 @@ typedef struct AVCodecContext {
|
||||
#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
|
||||
#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
|
||||
#define FF_PROFILE_H264_CAVLC_444 44
|
||||
+#define FF_PROFILE_H264_MULTIVIEW_HIGH_DEPTH 138
|
||||
|
||||
#define FF_PROFILE_VC1_SIMPLE 0
|
||||
#define FF_PROFILE_VC1_MAIN 1
|
||||
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
|
||||
index 79552a910d..b55955476c 100644
|
||||
--- a/libavcodec/codec_desc.c
|
||||
+++ b/libavcodec/codec_desc.c
|
||||
@@ -1647,6 +1647,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
|
||||
.long_name = NULL_IF_CONFIG_SMALL("FITS (Flexible Image Transport System)"),
|
||||
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
|
||||
},
|
||||
+ {
|
||||
+ .id = AV_CODEC_ID_H264_MVC,
|
||||
+ .type = AVMEDIA_TYPE_VIDEO,
|
||||
+ .name = "h264_mvc",
|
||||
+ .long_name = NULL_IF_CONFIG_SMALL("H264 MVC"),
|
||||
+ .props = AV_CODEC_PROP_LOSSY,
|
||||
+ },
|
||||
|
||||
/* various PCM "codecs" */
|
||||
{
|
||||
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
|
||||
index d7dc960f36..e4651f12f9 100644
|
||||
--- a/libavcodec/profiles.c
|
||||
+++ b/libavcodec/profiles.c
|
||||
@@ -72,6 +72,7 @@ const AVProfile ff_h264_profiles[] = {
|
||||
{ FF_PROFILE_H264_CAVLC_444, "CAVLC 4:4:4" },
|
||||
{ FF_PROFILE_H264_MULTIVIEW_HIGH, "Multiview High" },
|
||||
{ FF_PROFILE_H264_STEREO_HIGH, "Stereo High" },
|
||||
+ { FF_PROFILE_H264_MULTIVIEW_HIGH_DEPTH, "Multiview High Depth" },
|
||||
{ FF_PROFILE_UNKNOWN },
|
||||
};
|
||||
|
||||
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
|
||||
index 37a6aa8bff..52c5b659c4 100644
|
||||
--- a/libavformat/mpegts.c
|
||||
+++ b/libavformat/mpegts.c
|
||||
@@ -701,7 +701,7 @@ static const StreamType ISO_types[] = {
|
||||
#endif
|
||||
{ 0x1b, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264 },
|
||||
{ 0x1c, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AAC },
|
||||
- { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264 },
|
||||
+ { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264_MVC },
|
||||
{ 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000 },
|
||||
{ 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC },
|
||||
{ 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS },
|
||||
--
|
||||
2.17.0
|
||||
|
||||
|
||||
From 0f3fda4e348e6b12570f5d279713f6da46511846 Mon Sep 17 00:00:00 2001
|
||||
From: Hendrik Leppkes <h.leppkes@gmail.com>
|
||||
Date: Sat, 9 Jan 2016 16:34:40 +0100
|
||||
Subject: [PATCH 2/4] h264_parser: add support for parsing h264 mvc NALUs
|
||||
|
||||
---
|
||||
libavcodec/h264.h | 2 ++
|
||||
libavcodec/h264_parser.c | 34 ++++++++++++++++++++++++++++++----
|
||||
libavcodec/parser.c | 1 +
|
||||
3 files changed, 33 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
|
||||
index 650580bf3a..c44a0cbedd 100644
|
||||
--- a/libavcodec/h264.h
|
||||
+++ b/libavcodec/h264.h
|
||||
@@ -41,7 +41,9 @@ enum {
|
||||
H264_NAL_END_STREAM = 11,
|
||||
H264_NAL_FILLER_DATA = 12,
|
||||
H264_NAL_SPS_EXT = 13,
|
||||
+ H264_NAL_SPS_SUBSET = 15,
|
||||
H264_NAL_AUXILIARY_SLICE = 19,
|
||||
+ H264_NAL_SLICE_EXT = 20,
|
||||
};
|
||||
|
||||
|
||||
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
|
||||
index 1a9840a62c..be8b9db9b0 100644
|
||||
--- a/libavcodec/h264_parser.c
|
||||
+++ b/libavcodec/h264_parser.c
|
||||
@@ -62,6 +62,7 @@ typedef struct H264ParseContext {
|
||||
int parse_last_mb;
|
||||
int64_t reference_dts;
|
||||
int last_frame_num, last_picture_structure;
|
||||
+ int is_mvc;
|
||||
} H264ParseContext;
|
||||
|
||||
|
||||
@@ -109,14 +110,18 @@ static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf,
|
||||
} else if (state <= 5) {
|
||||
int nalu_type = buf[i] & 0x1F;
|
||||
if (nalu_type == H264_NAL_SEI || nalu_type == H264_NAL_SPS ||
|
||||
- nalu_type == H264_NAL_PPS || nalu_type == H264_NAL_AUD) {
|
||||
+ nalu_type == H264_NAL_PPS || nalu_type == H264_NAL_AUD ||
|
||||
+ nalu_type == H264_NAL_SPS_SUBSET) {
|
||||
if (pc->frame_start_found) {
|
||||
i++;
|
||||
goto found;
|
||||
}
|
||||
} else if (nalu_type == H264_NAL_SLICE || nalu_type == H264_NAL_DPA ||
|
||||
- nalu_type == H264_NAL_IDR_SLICE) {
|
||||
+ nalu_type == H264_NAL_IDR_SLICE || (p->is_mvc && nalu_type == H264_NAL_SLICE_EXT)) {
|
||||
state += 8;
|
||||
+
|
||||
+ if (nalu_type == H264_NAL_SLICE_EXT)
|
||||
+ i += 3; // skip mvc extension
|
||||
continue;
|
||||
}
|
||||
state = 7;
|
||||
@@ -601,7 +606,8 @@ static int h264_parse(AVCodecParserContext *s,
|
||||
}
|
||||
}
|
||||
|
||||
- parse_nal_units(s, avctx, buf, buf_size);
|
||||
+ if (!p->is_mvc)
|
||||
+ parse_nal_units(s, avctx, buf, buf_size);
|
||||
|
||||
if (avctx->framerate.num)
|
||||
avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
|
||||
@@ -658,7 +664,7 @@ static int h264_split(AVCodecContext *avctx,
|
||||
if ((state & 0xFFFFFF00) != 0x100)
|
||||
break;
|
||||
nalu_type = state & 0x1F;
|
||||
- if (nalu_type == H264_NAL_SPS) {
|
||||
+ if (nalu_type == H264_NAL_SPS || nalu_type == H264_NAL_SPS_SUBSET) {
|
||||
has_sps = 1;
|
||||
} else if (nalu_type == H264_NAL_PPS)
|
||||
has_pps = 1;
|
||||
@@ -710,3 +716,23 @@ AVCodecParser ff_h264_parser = {
|
||||
.parser_close = h264_close,
|
||||
.split = h264_split,
|
||||
};
|
||||
+
|
||||
+static av_cold int init_mvc(AVCodecParserContext *s)
|
||||
+{
|
||||
+ H264ParseContext *p = s->priv_data;
|
||||
+ int ret = init(s);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ p->is_mvc = 1;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+AVCodecParser ff_h264_mvc_parser = {
|
||||
+ .codec_ids = { AV_CODEC_ID_H264_MVC },
|
||||
+ .priv_data_size = sizeof(H264ParseContext),
|
||||
+ .parser_init = init_mvc,
|
||||
+ .parser_parse = h264_parse,
|
||||
+ .parser_close = h264_close,
|
||||
+ .split = h264_split,
|
||||
+};
|
||||
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
|
||||
index f43b197d5e..f96e005ef3 100644
|
||||
--- a/libavcodec/parser.c
|
||||
+++ b/libavcodec/parser.c
|
||||
@@ -54,6 +54,7 @@ extern AVCodecParser ff_gsm_parser;
|
||||
extern AVCodecParser ff_h261_parser;
|
||||
extern AVCodecParser ff_h263_parser;
|
||||
extern AVCodecParser ff_h264_parser;
|
||||
+extern AVCodecParser ff_h264_mvc_parser;
|
||||
extern AVCodecParser ff_hevc_parser;
|
||||
extern AVCodecParser ff_mjpeg_parser;
|
||||
extern AVCodecParser ff_mlp_parser;
|
||||
--
|
||||
2.17.0
|
||||
|
||||
|
||||
From cdd668dc436b9c78dcb31df477e329492356e7ec Mon Sep 17 00:00:00 2001
|
||||
From: Hendrik Leppkes <h.leppkes@gmail.com>
|
||||
Date: Tue, 28 Nov 2017 16:12:12 +0000
|
||||
Subject: [PATCH 3/4] h264_parser: force grabing a new timestamp until a frame
|
||||
start was found
|
||||
|
||||
---
|
||||
libavcodec/h264_parser.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
|
||||
index be8b9db9b0..81c9a1bbae 100644
|
||||
--- a/libavcodec/h264_parser.c
|
||||
+++ b/libavcodec/h264_parser.c
|
||||
@@ -594,6 +594,9 @@ static int h264_parse(AVCodecParserContext *s,
|
||||
} else {
|
||||
next = h264_find_frame_end(p, buf, buf_size, avctx);
|
||||
|
||||
+ if (next == END_NOT_FOUND && pc->frame_start_found == 0)
|
||||
+ s->fetch_timestamp = 1;
|
||||
+
|
||||
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
|
||||
*poutbuf = NULL;
|
||||
*poutbuf_size = 0;
|
||||
--
|
||||
2.17.0
|
||||
|
||||
|
||||
From fb0ec9a132d6eb8fd74348ef87b1176c7ca34a00 Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Mon, 28 May 2018 13:35:36 +0100
|
||||
Subject: [PATCH 4/4] fixup
|
||||
|
||||
---
|
||||
libavcodec/extract_extradata_bsf.c | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
|
||||
index 082b3e749b..7612749efc 100644
|
||||
--- a/libavcodec/extract_extradata_bsf.c
|
||||
+++ b/libavcodec/extract_extradata_bsf.c
|
||||
@@ -59,7 +59,7 @@ static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
|
||||
HEVC_NAL_VPS, HEVC_NAL_SPS, HEVC_NAL_PPS,
|
||||
};
|
||||
static const int extradata_nal_types_h264[] = {
|
||||
- H264_NAL_SPS, H264_NAL_PPS,
|
||||
+ H264_NAL_SPS, H264_NAL_SPS_SUBSET, H264_NAL_PPS,
|
||||
};
|
||||
|
||||
ExtractExtradataContext *s = ctx->priv_data;
|
||||
@@ -90,7 +90,7 @@ static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
|
||||
if (nal->type == HEVC_NAL_SPS) has_sps = 1;
|
||||
if (nal->type == HEVC_NAL_VPS) has_vps = 1;
|
||||
} else {
|
||||
- if (nal->type == H264_NAL_SPS) has_sps = 1;
|
||||
+ if (nal->type == H264_NAL_SPS || nal->type == H264_NAL_SPS_SUBSET) has_sps = 1;
|
||||
}
|
||||
} else if (s->remove) {
|
||||
filtered_size += nal->raw_size + 3;
|
||||
@@ -99,7 +99,7 @@ static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
|
||||
|
||||
if (extradata_size &&
|
||||
((ctx->par_in->codec_id == AV_CODEC_ID_HEVC && has_sps && has_vps) ||
|
||||
- (ctx->par_in->codec_id == AV_CODEC_ID_H264 && has_sps))) {
|
||||
+ ((ctx->par_in->codec_id == AV_CODEC_ID_H264 || ctx->par_in->codec_id == AV_CODEC_ID_H264_MVC) && has_sps))) {
|
||||
AVBufferRef *filtered_buf;
|
||||
uint8_t *extradata, *filtered_data;
|
||||
|
||||
@@ -253,6 +253,7 @@ static const struct {
|
||||
} extract_tab[] = {
|
||||
{ AV_CODEC_ID_CAVS, extract_extradata_mpeg4 },
|
||||
{ AV_CODEC_ID_H264, extract_extradata_h2645 },
|
||||
+ { AV_CODEC_ID_H264_MVC, extract_extradata_h2645 },
|
||||
{ AV_CODEC_ID_HEVC, extract_extradata_h2645 },
|
||||
{ AV_CODEC_ID_MPEG1VIDEO, extract_extradata_mpeg12 },
|
||||
{ AV_CODEC_ID_MPEG2VIDEO, extract_extradata_mpeg12 },
|
||||
@@ -317,6 +318,7 @@ static void extract_extradata_close(AVBSFContext *ctx)
|
||||
static const enum AVCodecID codec_ids[] = {
|
||||
AV_CODEC_ID_CAVS,
|
||||
AV_CODEC_ID_H264,
|
||||
+ AV_CODEC_ID_H264_MVC,
|
||||
AV_CODEC_ID_HEVC,
|
||||
AV_CODEC_ID_MPEG1VIDEO,
|
||||
AV_CODEC_ID_MPEG2VIDEO,
|
||||
--
|
||||
2.17.0
|
||||
|
@ -0,0 +1,407 @@
|
||||
diff -Nur a/configure b/configure
|
||||
--- a/configure 2018-11-23 12:03:27.041287929 -0500
|
||||
+++ b/configure 2018-11-23 12:08:52.945786916 -0500
|
||||
@@ -226,6 +226,7 @@
|
||||
--enable-libcelt enable CELT decoding via libcelt [no]
|
||||
--enable-libcdio enable audio CD grabbing with libcdio [no]
|
||||
--enable-libcodec2 enable codec2 en/decoding using libcodec2 [no]
|
||||
+ --enable-libdav1d enable AV1 decoding via libdav1d [no]
|
||||
--enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
|
||||
and libraw1394 [no]
|
||||
--enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no]
|
||||
@@ -1700,6 +1701,7 @@
|
||||
libcaca
|
||||
libcelt
|
||||
libcodec2
|
||||
+ libdav1d
|
||||
libdc1394
|
||||
libdrm
|
||||
libflite
|
||||
@@ -3062,6 +3064,7 @@
|
||||
libcelt_decoder_deps="libcelt"
|
||||
libcodec2_decoder_deps="libcodec2"
|
||||
libcodec2_encoder_deps="libcodec2"
|
||||
+libdav1d_decoder_deps="libdav1d"
|
||||
libfdk_aac_decoder_deps="libfdk_aac"
|
||||
libfdk_aac_encoder_deps="libfdk_aac"
|
||||
libfdk_aac_encoder_select="audio_frame_queue"
|
||||
@@ -6003,6 +6006,7 @@
|
||||
die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
|
||||
enabled libcaca && require_pkg_config libcaca caca caca.h caca_create_canvas
|
||||
enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create -lcodec2
|
||||
+enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.0.1" "dav1d/dav1d.h" dav1d_version
|
||||
enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
|
||||
enabled libdrm && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
|
||||
enabled libfdk_aac && { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
|
||||
diff -Nur a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
|
||||
--- a/libavcodec/allcodecs.c 2018-11-23 12:03:27.041287929 -0500
|
||||
+++ b/libavcodec/allcodecs.c 2018-11-23 12:11:08.584268221 -0500
|
||||
@@ -670,6 +670,7 @@
|
||||
extern AVCodec ff_libcelt_decoder;
|
||||
extern AVCodec ff_libcodec2_encoder;
|
||||
extern AVCodec ff_libcodec2_decoder;
|
||||
+extern AVCodec ff_libdav1d_decoder;
|
||||
extern AVCodec ff_libfdk_aac_encoder;
|
||||
extern AVCodec ff_libfdk_aac_decoder;
|
||||
extern AVCodec ff_libgsm_encoder;
|
||||
diff -Nur a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
|
||||
--- a/libavcodec/libdav1d.c 1969-12-31 19:00:00.000000000 -0500
|
||||
+++ b/libavcodec/libdav1d.c 2018-11-23 12:33:35.820468086 -0500
|
||||
@@ -0,0 +1,346 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2018 Ronald S. Bultje <rsbultje gmail com>
|
||||
+ * Copyright (c) 2018 James Almer <jamrial gmail com>
|
||||
+ *
|
||||
+ * 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 <dav1d/dav1d.h>
|
||||
+
|
||||
+#include "libavutil/avassert.h"
|
||||
+#include "libavutil/mastering_display_metadata.h"
|
||||
+#include "libavutil/imgutils.h"
|
||||
+#include "libavutil/opt.h"
|
||||
+
|
||||
+#include "avcodec.h"
|
||||
+#include "decode.h"
|
||||
+#include "internal.h"
|
||||
+
|
||||
+typedef struct Libdav1dContext {
|
||||
+ AVClass *class;
|
||||
+ Dav1dContext *c;
|
||||
+ AVBufferPool *pool;
|
||||
+ int pool_size;
|
||||
+
|
||||
+ Dav1dData data;
|
||||
+ int tile_threads;
|
||||
+ int apply_grain;
|
||||
+} Libdav1dContext;
|
||||
+
|
||||
+static const enum AVPixelFormat pix_fmt[][3] = {
|
||||
+ [DAV1D_PIXEL_LAYOUT_I400] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12 },
|
||||
+ [DAV1D_PIXEL_LAYOUT_I420] = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV420P12 },
|
||||
+ [DAV1D_PIXEL_LAYOUT_I422] = { AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P12 },
|
||||
+ [DAV1D_PIXEL_LAYOUT_I444] = { AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV444P12 },
|
||||
+};
|
||||
+
|
||||
+static void libdav1d_log_callback(void *opaque, const char *fmt, va_list vl)
|
||||
+{
|
||||
+ AVCodecContext *c = opaque;
|
||||
+
|
||||
+ av_vlog(c, AV_LOG_ERROR, fmt, vl);
|
||||
+}
|
||||
+
|
||||
+static int libdav1d_picture_allocator(Dav1dPicture *p, void *cookie)
|
||||
+{
|
||||
+ Libdav1dContext *dav1d = cookie;
|
||||
+ enum AVPixelFormat format = pix_fmt[p->p.layout][p->seq_hdr->hbd];
|
||||
+ int ret, linesize[4], h = FFALIGN(p->p.h, 128);
|
||||
+ uint8_t *aligned_ptr, *data[4];
|
||||
+ AVBufferRef *buf;
|
||||
+
|
||||
+ ret = av_image_fill_arrays(data, linesize, NULL, format, FFALIGN(p->p.w, 128),
|
||||
+ h, DAV1D_PICTURE_ALIGNMENT);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ if (ret != dav1d->pool_size) {
|
||||
+ av_buffer_pool_uninit(&dav1d->pool);
|
||||
+ // Use twice the amount of required padding bytes for aligned_ptr below.
|
||||
+ dav1d->pool = av_buffer_pool_init(ret + DAV1D_PICTURE_ALIGNMENT * 2, NULL);
|
||||
+ if (!dav1d->pool) {
|
||||
+ dav1d->pool_size = 0;
|
||||
+ return AVERROR(ENOMEM);
|
||||
+ }
|
||||
+ dav1d->pool_size = ret;
|
||||
+ }
|
||||
+ buf = av_buffer_pool_get(dav1d->pool);
|
||||
+ if (!buf)
|
||||
+ return AVERROR(ENOMEM);
|
||||
+
|
||||
+ // libdav1d requires DAV1D_PICTURE_ALIGNMENT aligned buffers, which av_malloc()
|
||||
+ // doesn't guarantee for example when AVX is disabled at configure time.
|
||||
+ // Use the extra DAV1D_PICTURE_ALIGNMENT padding bytes in the buffer to align it
|
||||
+ // if required.
|
||||
+ aligned_ptr = (uint8_t *)FFALIGN((uintptr_t)buf->data, DAV1D_PICTURE_ALIGNMENT);
|
||||
+ ret = av_image_fill_pointers(data, format, h, aligned_ptr, linesize);
|
||||
+ if (ret < 0) {
|
||||
+ av_buffer_unref(&buf);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ p->data[0] = data[0];
|
||||
+ p->data[1] = data[1];
|
||||
+ p->data[2] = data[2];
|
||||
+ p->stride[0] = linesize[0];
|
||||
+ p->stride[1] = linesize[1];
|
||||
+ p->allocator_data = buf;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void libdav1d_picture_release(Dav1dPicture *p, void *cookie)
|
||||
+{
|
||||
+ AVBufferRef *buf = p->allocator_data;
|
||||
+
|
||||
+ av_buffer_unref(&buf);
|
||||
+}
|
||||
+
|
||||
+static av_cold int libdav1d_init(AVCodecContext *c)
|
||||
+{
|
||||
+ Libdav1dContext *dav1d = c->priv_data;
|
||||
+ Dav1dSettings s;
|
||||
+ int res;
|
||||
+
|
||||
+ av_log(c, AV_LOG_INFO, "libdav1d %s\n", dav1d_version());
|
||||
+
|
||||
+ dav1d_default_settings(&s);
|
||||
+ s.logger.cookie = c;
|
||||
+ s.logger.callback = libdav1d_log_callback;
|
||||
+ s.allocator.cookie = dav1d;
|
||||
+ s.allocator.alloc_picture_callback = libdav1d_picture_allocator;
|
||||
+ s.allocator.release_picture_callback = libdav1d_picture_release;
|
||||
+ s.n_tile_threads = dav1d->tile_threads;
|
||||
+ s.apply_grain = dav1d->apply_grain;
|
||||
+ s.n_frame_threads = FFMIN(c->thread_count ? c->thread_count : av_cpu_count(), DAV1D_MAX_FRAME_THREADS);
|
||||
+
|
||||
+ res = dav1d_open(&dav1d->c, &s);
|
||||
+ if (res < 0)
|
||||
+ return AVERROR(ENOMEM);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void libdav1d_flush(AVCodecContext *c)
|
||||
+{
|
||||
+ Libdav1dContext *dav1d = c->priv_data;
|
||||
+
|
||||
+ dav1d_data_unref(&dav1d->data);
|
||||
+ dav1d_flush(dav1d->c);
|
||||
+}
|
||||
+
|
||||
+static void libdav1d_data_free(const uint8_t *data, void *opaque) {
|
||||
+ AVBufferRef *buf = opaque;
|
||||
+
|
||||
+ av_buffer_unref(&buf);
|
||||
+}
|
||||
+
|
||||
+static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
|
||||
+{
|
||||
+ Libdav1dContext *dav1d = c->priv_data;
|
||||
+ Dav1dData *data = &dav1d->data;
|
||||
+ Dav1dPicture pic = { 0 }, *p = &pic;
|
||||
+ int res;
|
||||
+
|
||||
+ if (!data->sz) {
|
||||
+ AVPacket pkt = { 0 };
|
||||
+
|
||||
+ res = ff_decode_get_packet(c, &pkt);
|
||||
+ if (res < 0 && res != AVERROR_EOF)
|
||||
+ return res;
|
||||
+
|
||||
+ if (pkt.size) {
|
||||
+ res = dav1d_data_wrap(data, pkt.data, pkt.size, libdav1d_data_free, pkt.buf);
|
||||
+ if (res < 0) {
|
||||
+ av_packet_unref(&pkt);
|
||||
+ return res;
|
||||
+ }
|
||||
+
|
||||
+ data->m.timestamp = pkt.pts;
|
||||
+ data->m.offset = pkt.pos;
|
||||
+ data->m.duration = pkt.duration;
|
||||
+
|
||||
+ pkt.buf = NULL;
|
||||
+ av_packet_unref(&pkt);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ res = dav1d_send_data(dav1d->c, data);
|
||||
+ if (res < 0) {
|
||||
+ if (res == AVERROR(EINVAL))
|
||||
+ res = AVERROR_INVALIDDATA;
|
||||
+ if (res != AVERROR(EAGAIN))
|
||||
+ return res;
|
||||
+ }
|
||||
+
|
||||
+ res = dav1d_get_picture(dav1d->c, p);
|
||||
+ if (res < 0) {
|
||||
+ if (res == AVERROR(EINVAL))
|
||||
+ res = AVERROR_INVALIDDATA;
|
||||
+ else if (res == AVERROR(EAGAIN) && c->internal->draining)
|
||||
+ res = AVERROR_EOF;
|
||||
+
|
||||
+ return res;
|
||||
+ }
|
||||
+
|
||||
+ av_assert0(p->data[0] != NULL);
|
||||
+
|
||||
+ // This requires the custom allocator above
|
||||
+ frame->buf[0] = av_buffer_ref(p->allocator_data);
|
||||
+ if (!frame->buf[0]) {
|
||||
+ dav1d_picture_unref(p);
|
||||
+ return AVERROR(ENOMEM);
|
||||
+ }
|
||||
+
|
||||
+ frame->data[0] = p->data[0];
|
||||
+ frame->data[1] = p->data[1];
|
||||
+ frame->data[2] = p->data[2];
|
||||
+ frame->linesize[0] = p->stride[0];
|
||||
+ frame->linesize[1] = p->stride[1];
|
||||
+ frame->linesize[2] = p->stride[1];
|
||||
+
|
||||
+ c->profile = p->seq_hdr->profile;
|
||||
+ frame->format = c->pix_fmt = pix_fmt[p->p.layout][p->seq_hdr->hbd];
|
||||
+ frame->width = p->p.w;
|
||||
+ frame->height = p->p.h;
|
||||
+ if (c->width != p->p.w || c->height != p->p.h) {
|
||||
+ res = ff_set_dimensions(c, p->p.w, p->p.h);
|
||||
+ if (res < 0)
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ switch (p->seq_hdr->chr) {
|
||||
+ case DAV1D_CHR_VERTICAL:
|
||||
+ frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_LEFT;
|
||||
+ break;
|
||||
+ case DAV1D_CHR_COLOCATED:
|
||||
+ frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
|
||||
+ break;
|
||||
+ }
|
||||
+ frame->colorspace = c->colorspace = (enum AVColorSpace) p->seq_hdr->mtrx;
|
||||
+ frame->color_primaries = c->color_primaries = (enum AVColorPrimaries) p->seq_hdr->pri;
|
||||
+ frame->color_trc = c->color_trc = (enum AVColorTransferCharacteristic) p->seq_hdr->trc;
|
||||
+ frame->color_range = c->color_range = p->seq_hdr->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
|
||||
+
|
||||
+ // match timestamps and packet size
|
||||
+ frame->pts = frame->best_effort_timestamp = p->m.timestamp;
|
||||
+#if FF_API_PKT_PTS
|
||||
+FF_DISABLE_DEPRECATION_WARNINGS
|
||||
+ frame->pkt_pts = p->m.timestamp;
|
||||
+FF_ENABLE_DEPRECATION_WARNINGS
|
||||
+#endif
|
||||
+ frame->pkt_dts = p->m.timestamp;
|
||||
+ frame->pkt_pos = p->m.offset;
|
||||
+ frame->pkt_size = p->m.size;
|
||||
+ frame->pkt_duration = p->m.duration;
|
||||
+ frame->key_frame = p->frame_hdr->frame_type == DAV1D_FRAME_TYPE_KEY;
|
||||
+
|
||||
+ switch (p->frame_hdr->frame_type) {
|
||||
+ case DAV1D_FRAME_TYPE_KEY:
|
||||
+ case DAV1D_FRAME_TYPE_INTRA:
|
||||
+ frame->pict_type = AV_PICTURE_TYPE_I;
|
||||
+ break;
|
||||
+ case DAV1D_FRAME_TYPE_INTER:
|
||||
+ frame->pict_type = AV_PICTURE_TYPE_P;
|
||||
+ break;
|
||||
+ case DAV1D_FRAME_TYPE_SWITCH:
|
||||
+ frame->pict_type = AV_PICTURE_TYPE_SP;
|
||||
+ break;
|
||||
+ default:
|
||||
+ res = AVERROR_INVALIDDATA;
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ if (p->mastering_display) {
|
||||
+ AVMasteringDisplayMetadata *mastering = av_mastering_display_metadata_create_side_data(frame);
|
||||
+ if (!mastering) {
|
||||
+ res = AVERROR(ENOMEM);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < 3; i++) {
|
||||
+ mastering->display_primaries[i][0] = av_make_q(p->mastering_display->primaries[i][0], 1 << 16);
|
||||
+ mastering->display_primaries[i][1] = av_make_q(p->mastering_display->primaries[i][1], 1 << 16);
|
||||
+ }
|
||||
+ mastering->white_point[0] = av_make_q(p->mastering_display->white_point[0], 1 << 16);
|
||||
+ mastering->white_point[1] = av_make_q(p->mastering_display->white_point[1], 1 << 16);
|
||||
+
|
||||
+ mastering->max_luminance = av_make_q(p->mastering_display->max_luminance, 1 << 8);
|
||||
+ mastering->min_luminance = av_make_q(p->mastering_display->min_luminance, 1 << 14);
|
||||
+
|
||||
+ mastering->has_primaries = 1;
|
||||
+ mastering->has_luminance = 1;
|
||||
+ }
|
||||
+ if (p->content_light) {
|
||||
+ AVContentLightMetadata *light = av_content_light_metadata_create_side_data(frame);
|
||||
+ if (!light) {
|
||||
+ res = AVERROR(ENOMEM);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+ light->MaxCLL = p->content_light->max_content_light_level;
|
||||
+ light->MaxFALL = p->content_light->max_frame_average_light_level;
|
||||
+ }
|
||||
+
|
||||
+ res = 0;
|
||||
+fail:
|
||||
+ dav1d_picture_unref(p);
|
||||
+ if (res < 0)
|
||||
+ av_frame_unref(frame);
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+static av_cold int libdav1d_close(AVCodecContext *c)
|
||||
+{
|
||||
+ Libdav1dContext *dav1d = c->priv_data;
|
||||
+
|
||||
+ av_buffer_pool_uninit(&dav1d->pool);
|
||||
+ dav1d_data_unref(&dav1d->data);
|
||||
+ dav1d_close(&dav1d->c);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#define OFFSET(x) offsetof(Libdav1dContext, x)
|
||||
+#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
|
||||
+static const AVOption libdav1d_options[] = {
|
||||
+ { "tilethreads", "Tile threads", OFFSET(tile_threads), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, DAV1D_MAX_TILE_THREADS, VD },
|
||||
+ { "filmgrain", "Apply Film Grain", OFFSET(apply_grain), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VD },
|
||||
+ { NULL }
|
||||
+};
|
||||
+
|
||||
+static const AVClass libdav1d_class = {
|
||||
+ .class_name = "libdav1d decoder",
|
||||
+ .item_name = av_default_item_name,
|
||||
+ .option = libdav1d_options,
|
||||
+ .version = LIBAVUTIL_VERSION_INT,
|
||||
+};
|
||||
+
|
||||
+AVCodec ff_libdav1d_decoder = {
|
||||
+ .name = "libdav1d",
|
||||
+ .long_name = NULL_IF_CONFIG_SMALL("dav1d AV1 decoder by VideoLAN"),
|
||||
+ .type = AVMEDIA_TYPE_VIDEO,
|
||||
+ .id = AV_CODEC_ID_AV1,
|
||||
+ .priv_data_size = sizeof(Libdav1dContext),
|
||||
+ .init = libdav1d_init,
|
||||
+ .close = libdav1d_close,
|
||||
+ .flush = libdav1d_flush,
|
||||
+ .receive_frame = libdav1d_receive_frame,
|
||||
+ .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
|
||||
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_SETS_PKT_DTS,
|
||||
+ .priv_class = &libdav1d_class,
|
||||
+ .wrapper_name = "libdav1d",
|
||||
+};
|
||||
diff -Nur a/libavcodec/Makefile b/libavcodec/Makefile
|
||||
--- a/libavcodec/Makefile 2018-11-23 12:03:27.041287929 -0500
|
||||
+++ b/libavcodec/Makefile 2018-11-23 12:10:28.676717867 -0500
|
||||
@@ -954,6 +954,7 @@
|
||||
OBJS-$(CONFIG_LIBCELT_DECODER) += libcelt_dec.o
|
||||
OBJS-$(CONFIG_LIBCODEC2_DECODER) += libcodec2.o codec2utils.o
|
||||
OBJS-$(CONFIG_LIBCODEC2_ENCODER) += libcodec2.o codec2utils.o
|
||||
+OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o
|
||||
OBJS-$(CONFIG_LIBFDK_AAC_DECODER) += libfdk-aacdec.o
|
||||
OBJS-$(CONFIG_LIBFDK_AAC_ENCODER) += libfdk-aacenc.o
|
||||
OBJS-$(CONFIG_LIBGSM_DECODER) += libgsmdec.o
|
@ -0,0 +1,60 @@
|
||||
From 0ae5ba3567a896af2b272e3a52ca574b7f41ec5a Mon Sep 17 00:00:00 2001
|
||||
From: Lukas Rusak <lorusak@gmail.com>
|
||||
Date: Wed, 10 Apr 2019 13:40:07 -0700
|
||||
Subject: [PATCH 0/1] *** SUBJECT HERE ***
|
||||
|
||||
*** BLURB HERE ***
|
||||
|
||||
Lukas Rusak (1):
|
||||
libavcodec/libdav1d: add libdav1d_get_format method in order to call
|
||||
ff_get_format
|
||||
|
||||
libavcodec/libdav1d.c | 12 +++++++++++-
|
||||
1 file changed, 11 insertions(+), 1 deletion(-)
|
||||
|
||||
--
|
||||
2.20.1
|
||||
|
||||
From 0ae5ba3567a896af2b272e3a52ca574b7f41ec5a Mon Sep 17 00:00:00 2001
|
||||
From: Lukas Rusak <lorusak@gmail.com>
|
||||
Date: Wed, 10 Apr 2019 13:39:21 -0700
|
||||
Subject: [PATCH 1/1] libavcodec/libdav1d: add libdav1d_get_format method in
|
||||
order to call ff_get_format
|
||||
|
||||
---
|
||||
libavcodec/libdav1d.c | 12 +++++++++++-
|
||||
1 file changed, 11 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
|
||||
index 30c6eccfef..fa71834543 100644
|
||||
--- a/libavcodec/libdav1d.c
|
||||
+++ b/libavcodec/libdav1d.c
|
||||
@@ -48,6 +48,16 @@ static const enum AVPixelFormat pix_fmt[][3] = {
|
||||
[DAV1D_PIXEL_LAYOUT_I444] = { AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV444P12 },
|
||||
};
|
||||
|
||||
+static enum AVPixelFormat libdav1d_get_format(AVCodecContext *avctx, const Dav1dPicture *p)
|
||||
+{
|
||||
+ enum AVPixelFormat pix_fmts[2], *fmt = pix_fmts;
|
||||
+
|
||||
+ *fmt++ = pix_fmt[p->p.layout][p->seq_hdr->hbd];
|
||||
+ *fmt = AV_PIX_FMT_NONE;
|
||||
+
|
||||
+ return ff_get_format(avctx, pix_fmts);
|
||||
+}
|
||||
+
|
||||
static void libdav1d_log_callback(void *opaque, const char *fmt, va_list vl)
|
||||
{
|
||||
AVCodecContext *c = opaque;
|
||||
@@ -214,7 +224,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
|
||||
frame->linesize[2] = p->stride[1];
|
||||
|
||||
c->profile = p->seq_hdr->profile;
|
||||
- frame->format = c->pix_fmt = pix_fmt[p->p.layout][p->seq_hdr->hbd];
|
||||
+ frame->format = c->pix_fmt = libdav1d_get_format(c, p);
|
||||
frame->width = p->p.w;
|
||||
frame->height = p->p.h;
|
||||
if (c->width != p->p.w || c->height != p->p.h) {
|
||||
--
|
||||
2.20.1
|
||||
|
@ -0,0 +1,22 @@
|
||||
From 39f9392e40cc6fb1492f51d2f2b4c87d1503ca39 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Fri, 31 Aug 2018 21:17:27 +0200
|
||||
Subject: [PATCH] rkmppdec: Kodi need more buffers
|
||||
|
||||
---
|
||||
libavcodec/rkmppdec.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
|
||||
index 143d05bd51..c00f08c70b 100644
|
||||
--- a/libavcodec/rkmppdec.c
|
||||
+++ b/libavcodec/rkmppdec.c
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "libavutil/log.h"
|
||||
|
||||
#define RECEIVE_FRAME_TIMEOUT 100
|
||||
-#define FRAMEGROUP_MAX_FRAMES 16
|
||||
+#define FRAMEGROUP_MAX_FRAMES 24
|
||||
#define INPUT_MAX_PACKETS 4
|
||||
|
||||
typedef struct {
|
@ -0,0 +1,44 @@
|
||||
From ca3c0a0b70373da243949b7b72bbbf8bb47f01d5 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Sun, 9 Sep 2018 12:37:29 +0200
|
||||
Subject: [PATCH] rkmppdec: continue on errinfo frame
|
||||
|
||||
---
|
||||
libavcodec/rkmppdec.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
|
||||
index c00f08c70b..72be832141 100644
|
||||
--- a/libavcodec/rkmppdec.c
|
||||
+++ b/libavcodec/rkmppdec.c
|
||||
@@ -49,6 +49,7 @@ typedef struct {
|
||||
|
||||
char first_packet;
|
||||
char eos_reached;
|
||||
+ int errors;
|
||||
|
||||
AVBufferRef *frames_ref;
|
||||
AVBufferRef *device_ref;
|
||||
@@ -386,12 +387,13 @@ static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
|
||||
goto fail;
|
||||
} else if (mpp_frame_get_errinfo(mppframe)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Received a errinfo frame.\n");
|
||||
- ret = AVERROR_UNKNOWN;
|
||||
+ ret = (decoder->errors++ > 100) ? AVERROR_UNKNOWN : AVERROR(EAGAIN);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// here we should have a valid frame
|
||||
av_log(avctx, AV_LOG_DEBUG, "Received a frame.\n");
|
||||
+ decoder->errors = 0;
|
||||
|
||||
// setup general frame fields
|
||||
frame->format = AV_PIX_FMT_DRM_PRIME;
|
||||
@@ -544,6 +546,7 @@ static void rkmpp_flush(AVCodecContext *avctx)
|
||||
ret = decoder->mpi->reset(decoder->ctx);
|
||||
if (ret == MPP_OK) {
|
||||
decoder->first_packet = 1;
|
||||
+ decoder->errors = 0;
|
||||
} else
|
||||
av_log(avctx, AV_LOG_ERROR, "Failed to reset MPI (code = %d)\n", ret);
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
From 5062ff7504a92a144b32e20b6b4d5627240f81c8 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Wed, 12 Sep 2018 22:29:22 +0200
|
||||
Subject: [PATCH] rkmppdec: enable mpeg2
|
||||
|
||||
---
|
||||
configure | 1 +
|
||||
libavcodec/Makefile | 1 +
|
||||
libavcodec/allcodecs.c | 1 +
|
||||
libavcodec/rkmppdec.c | 8 ++++++++
|
||||
4 files changed, 11 insertions(+)
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 15e6c321b1..c17252f883 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -2954,6 +2954,7 @@ mpeg2_crystalhd_decoder_select="crystalhd"
|
||||
mpeg2_cuvid_decoder_deps="cuvid"
|
||||
mpeg2_mmal_decoder_deps="mmal"
|
||||
mpeg2_mediacodec_decoder_deps="mediacodec"
|
||||
+mpeg2_rkmpp_decoder_deps="rkmpp"
|
||||
mpeg2_qsv_decoder_select="qsvdec mpegvideo_parser"
|
||||
mpeg2_qsv_encoder_select="qsvenc"
|
||||
mpeg2_vaapi_encoder_deps="VAEncPictureParameterBufferMPEG2"
|
||||
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
|
||||
index 4b8ad121db..f1580bb10b 100644
|
||||
--- a/libavcodec/Makefile
|
||||
+++ b/libavcodec/Makefile
|
||||
@@ -447,6 +447,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
|
||||
OBJS-$(CONFIG_MPEG1_CUVID_DECODER) += cuviddec.o
|
||||
OBJS-$(CONFIG_MPEG1_V4L2M2M_DECODER) += v4l2_m2m_dec.o
|
||||
OBJS-$(CONFIG_MPEG2_MMAL_DECODER) += mmaldec.o
|
||||
+OBJS-$(CONFIG_MPEG2_RKMPP_DECODER) += rkmppdec.o
|
||||
OBJS-$(CONFIG_MPEG2_QSV_DECODER) += qsvdec_other.o
|
||||
OBJS-$(CONFIG_MPEG2_QSV_ENCODER) += qsvenc_mpeg2.o
|
||||
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
|
||||
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
|
||||
index 4d4ef530e4..07e1216333 100644
|
||||
--- a/libavcodec/allcodecs.c
|
||||
+++ b/libavcodec/allcodecs.c
|
||||
@@ -192,6 +192,7 @@ extern AVCodec ff_mpeg1_v4l2m2m_decoder;
|
||||
extern AVCodec ff_mpeg2_mmal_decoder;
|
||||
extern AVCodec ff_mpeg2_crystalhd_decoder;
|
||||
extern AVCodec ff_mpeg2_v4l2m2m_decoder;
|
||||
+extern AVCodec ff_mpeg2_rkmpp_decoder;
|
||||
extern AVCodec ff_mpeg2_qsv_decoder;
|
||||
extern AVCodec ff_mpeg2_mediacodec_decoder;
|
||||
extern AVCodec ff_msa1_decoder;
|
||||
diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
|
||||
index 72be832141..48016bc681 100644
|
||||
--- a/libavcodec/rkmppdec.c
|
||||
+++ b/libavcodec/rkmppdec.c
|
||||
@@ -70,6 +70,7 @@ static MppCodingType rkmpp_get_codingtype(AVCodecContext *avctx)
|
||||
switch (avctx->codec_id) {
|
||||
case AV_CODEC_ID_H264: return MPP_VIDEO_CodingAVC;
|
||||
case AV_CODEC_ID_HEVC: return MPP_VIDEO_CodingHEVC;
|
||||
+ case AV_CODEC_ID_MPEG2VIDEO: return MPP_VIDEO_CodingMPEG2;
|
||||
case AV_CODEC_ID_VP8: return MPP_VIDEO_CodingVP8;
|
||||
case AV_CODEC_ID_VP9: return MPP_VIDEO_CodingVP9;
|
||||
default: return MPP_VIDEO_CodingUnused;
|
||||
@@ -405,6 +406,12 @@ static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
|
||||
frame->color_trc = mpp_frame_get_color_trc(mppframe);
|
||||
frame->colorspace = mpp_frame_get_colorspace(mppframe);
|
||||
|
||||
+ if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
|
||||
+ MppFrameRational dar = mpp_frame_get_sar(mppframe);
|
||||
+ frame->sample_aspect_ratio = av_div_q((AVRational) { dar.num, dar.den },
|
||||
+ (AVRational) { frame->width, frame->height });
|
||||
+ }
|
||||
+
|
||||
mode = mpp_frame_get_mode(mppframe);
|
||||
frame->interlaced_frame = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_DEINTERLACED);
|
||||
frame->top_field_first = ((mode & MPP_FRAME_FLAG_FIELD_ORDER_MASK) == MPP_FRAME_FLAG_TOP_FIRST);
|
||||
@@ -585,5 +592,6 @@ static const AVCodecHWConfigInternal *rkmpp_hw_configs[] = {
|
||||
|
||||
RKMPP_DEC(h264, AV_CODEC_ID_H264, "h264_mp4toannexb")
|
||||
RKMPP_DEC(hevc, AV_CODEC_ID_HEVC, "hevc_mp4toannexb")
|
||||
+RKMPP_DEC(mpeg2, AV_CODEC_ID_MPEG2VIDEO, NULL)
|
||||
RKMPP_DEC(vp8, AV_CODEC_ID_VP8, NULL)
|
||||
RKMPP_DEC(vp9, AV_CODEC_ID_VP9, NULL)
|
@ -0,0 +1,105 @@
|
||||
From 6d97fb902d7e69a9b706664223bf53ab3b2f9054 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Sat, 22 Jun 2019 16:08:25 +0000
|
||||
Subject: [PATCH] rkmppdec: set mastering display and content light side data
|
||||
|
||||
---
|
||||
libavcodec/rkmppdec.c | 64 +++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 64 insertions(+)
|
||||
|
||||
diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
|
||||
index 48016bc681..faae23c064 100644
|
||||
--- a/libavcodec/rkmppdec.c
|
||||
+++ b/libavcodec/rkmppdec.c
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "libavutil/frame.h"
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include "libavutil/hwcontext_drm.h"
|
||||
+#include "libavutil/mastering_display_metadata.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "libavutil/log.h"
|
||||
|
||||
@@ -319,6 +320,61 @@ static void rkmpp_release_frame(void *opaque, uint8_t *data)
|
||||
av_free(desc);
|
||||
}
|
||||
|
||||
+static int rkmpp_hevc_mastering_display(AVFrame *frame, MppFrameMasteringDisplayMetadata mastering_display)
|
||||
+{
|
||||
+ // HEVC uses a g,b,r ordering, which we convert to a more natural r,g,b
|
||||
+ AVMasteringDisplayMetadata *metadata;
|
||||
+ const int mapping[3] = {2, 0, 1};
|
||||
+ const int chroma_den = 50000;
|
||||
+ const int luma_den = 10000;
|
||||
+ int i;
|
||||
+
|
||||
+ AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
|
||||
+ if (sd)
|
||||
+ metadata = (AVMasteringDisplayMetadata *)sd->data;
|
||||
+ else
|
||||
+ metadata = av_mastering_display_metadata_create_side_data(frame);
|
||||
+ if (!metadata)
|
||||
+ return AVERROR(ENOMEM);
|
||||
+
|
||||
+ for (i = 0; i < 3; i++) {
|
||||
+ const int j = mapping[i];
|
||||
+ metadata->display_primaries[i][0].num = mastering_display.display_primaries[j][0];
|
||||
+ metadata->display_primaries[i][0].den = chroma_den;
|
||||
+ metadata->display_primaries[i][1].num = mastering_display.display_primaries[j][1];
|
||||
+ metadata->display_primaries[i][1].den = chroma_den;
|
||||
+ }
|
||||
+ metadata->white_point[0].num = mastering_display.white_point[0];
|
||||
+ metadata->white_point[0].den = chroma_den;
|
||||
+ metadata->white_point[1].num = mastering_display.white_point[1];
|
||||
+ metadata->white_point[1].den = chroma_den;
|
||||
+
|
||||
+ metadata->max_luminance.num = mastering_display.max_luminance;
|
||||
+ metadata->max_luminance.den = luma_den;
|
||||
+ metadata->min_luminance.num = mastering_display.min_luminance;
|
||||
+ metadata->min_luminance.den = luma_den;
|
||||
+ metadata->has_luminance = 1;
|
||||
+ metadata->has_primaries = 1;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int rkmpp_hevc_content_light(AVFrame *frame, MppFrameContentLightMetadata content_light)
|
||||
+{
|
||||
+ AVContentLightMetadata *metadata;
|
||||
+
|
||||
+ AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
|
||||
+ if (sd)
|
||||
+ metadata = (AVContentLightMetadata *)sd->data;
|
||||
+ else
|
||||
+ metadata = av_content_light_metadata_create_side_data(frame);
|
||||
+ if (!metadata)
|
||||
+ return AVERROR(ENOMEM);
|
||||
+
|
||||
+ metadata->MaxCLL = content_light.MaxCLL;
|
||||
+ metadata->MaxFALL = content_light.MaxFALL;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
|
||||
{
|
||||
RKMPPDecodeContext *rk_context = avctx->priv_data;
|
||||
@@ -352,6 +408,11 @@ static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
|
||||
avctx->width = mpp_frame_get_width(mppframe);
|
||||
avctx->height = mpp_frame_get_height(mppframe);
|
||||
|
||||
+ avctx->color_range = mpp_frame_get_color_range(mppframe);
|
||||
+ avctx->color_primaries = mpp_frame_get_color_primaries(mppframe);
|
||||
+ avctx->color_trc = mpp_frame_get_color_trc(mppframe);
|
||||
+ avctx->colorspace = mpp_frame_get_colorspace(mppframe);
|
||||
+
|
||||
decoder->mpi->control(decoder->ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL);
|
||||
|
||||
av_buffer_unref(&decoder->frames_ref);
|
||||
@@ -410,6 +471,9 @@ static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
|
||||
MppFrameRational dar = mpp_frame_get_sar(mppframe);
|
||||
frame->sample_aspect_ratio = av_div_q((AVRational) { dar.num, dar.den },
|
||||
(AVRational) { frame->width, frame->height });
|
||||
+ } else if (avctx->codec_id == AV_CODEC_ID_HEVC && frame->color_trc > AVCOL_TRC_UNSPECIFIED) {
|
||||
+ rkmpp_hevc_mastering_display(frame, mpp_frame_get_mastering_display(mppframe));
|
||||
+ rkmpp_hevc_content_light(frame, mpp_frame_get_content_light(mppframe));
|
||||
}
|
||||
|
||||
mode = mpp_frame_get_mode(mppframe);
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,54 @@
|
||||
From 7ab07a6b9a8ac8a91213bcbba4a63dc9db03cb53 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Mon, 3 Dec 2018 23:48:04 +0100
|
||||
Subject: [PATCH 1/6] avutil: add av_buffer_pool_reclaim()
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
---
|
||||
libavutil/buffer.c | 13 +++++++++++++
|
||||
libavutil/buffer.h | 5 +++++
|
||||
2 files changed, 18 insertions(+)
|
||||
|
||||
diff --git a/libavutil/buffer.c b/libavutil/buffer.c
|
||||
index 8d1aa5fa84..9c5d530c7a 100644
|
||||
--- a/libavutil/buffer.c
|
||||
+++ b/libavutil/buffer.c
|
||||
@@ -272,6 +272,19 @@ static void buffer_pool_free(AVBufferPool *pool)
|
||||
av_freep(&pool);
|
||||
}
|
||||
|
||||
+void av_buffer_pool_reclaim(AVBufferPool *pool)
|
||||
+{
|
||||
+ ff_mutex_lock(&pool->mutex);
|
||||
+ while (pool->pool) {
|
||||
+ BufferPoolEntry *buf = pool->pool;
|
||||
+ pool->pool = buf->next;
|
||||
+
|
||||
+ buf->free(buf->opaque, buf->data);
|
||||
+ av_freep(&buf);
|
||||
+ }
|
||||
+ ff_mutex_unlock(&pool->mutex);
|
||||
+}
|
||||
+
|
||||
void av_buffer_pool_uninit(AVBufferPool **ppool)
|
||||
{
|
||||
AVBufferPool *pool;
|
||||
diff --git a/libavutil/buffer.h b/libavutil/buffer.h
|
||||
index 73b6bd0b14..fab745f853 100644
|
||||
--- a/libavutil/buffer.h
|
||||
+++ b/libavutil/buffer.h
|
||||
@@ -266,6 +266,11 @@ AVBufferPool *av_buffer_pool_init2(int size, void *opaque,
|
||||
AVBufferRef* (*alloc)(void *opaque, int size),
|
||||
void (*pool_free)(void *opaque));
|
||||
|
||||
+/**
|
||||
+ * Free all available buffers in a buffer pool.
|
||||
+ */
|
||||
+ void av_buffer_pool_reclaim(AVBufferPool *pool);
|
||||
+
|
||||
/**
|
||||
* Mark the pool as being available for freeing. It will actually be freed only
|
||||
* once all the allocated buffers associated with the pool are released. Thus it
|
||||
--
|
||||
2.21.0
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,247 @@
|
||||
From f4f6c74953b0bfaadec93b01d855a15f08c558a2 Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Karlman <jonas@kwiboo.se>
|
||||
Date: Sat, 15 Dec 2018 22:32:16 +0100
|
||||
Subject: [PATCH 3/6] Add V4L2 request API mpeg2 hwaccel
|
||||
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
---
|
||||
configure | 3 +
|
||||
libavcodec/Makefile | 1 +
|
||||
libavcodec/hwaccels.h | 1 +
|
||||
libavcodec/mpeg12dec.c | 6 ++
|
||||
libavcodec/v4l2_request_mpeg2.c | 154 ++++++++++++++++++++++++++++++++
|
||||
5 files changed, 165 insertions(+)
|
||||
create mode 100644 libavcodec/v4l2_request_mpeg2.c
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 6401cae9e7..b163ed8dbe 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -2846,6 +2846,8 @@ mpeg2_dxva2_hwaccel_deps="dxva2"
|
||||
mpeg2_dxva2_hwaccel_select="mpeg2video_decoder"
|
||||
mpeg2_nvdec_hwaccel_deps="nvdec"
|
||||
mpeg2_nvdec_hwaccel_select="mpeg2video_decoder"
|
||||
+mpeg2_v4l2request_hwaccel_deps="v4l2_request mpeg2_v4l2_request"
|
||||
+mpeg2_v4l2request_hwaccel_select="mpeg2video_decoder"
|
||||
mpeg2_vaapi_hwaccel_deps="vaapi"
|
||||
mpeg2_vaapi_hwaccel_select="mpeg2video_decoder"
|
||||
mpeg2_vdpau_hwaccel_deps="vdpau"
|
||||
@@ -6241,6 +6243,7 @@ check_cc vp8_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;"
|
||||
check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;"
|
||||
|
||||
check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns
|
||||
+check_cc mpeg2_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2_SLICE;"
|
||||
|
||||
check_header sys/videoio.h
|
||||
test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
|
||||
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
|
||||
index 48f6e06545..9b945e3f64 100644
|
||||
--- a/libavcodec/Makefile
|
||||
+++ b/libavcodec/Makefile
|
||||
@@ -871,6 +871,7 @@ OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o
|
||||
OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o
|
||||
OBJS-$(CONFIG_MPEG2_NVDEC_HWACCEL) += nvdec_mpeg12.o
|
||||
OBJS-$(CONFIG_MPEG2_QSV_HWACCEL) += qsvdec_other.o
|
||||
+OBJS-$(CONFIG_MPEG2_V4L2REQUEST_HWACCEL) += v4l2_request_mpeg2.o
|
||||
OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o
|
||||
OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL) += vdpau_mpeg12.o
|
||||
OBJS-$(CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
|
||||
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
|
||||
index 7d73da8676..ef54de2a3b 100644
|
||||
--- a/libavcodec/hwaccels.h
|
||||
+++ b/libavcodec/hwaccels.h
|
||||
@@ -47,6 +47,7 @@ extern const AVHWAccel ff_mpeg2_d3d11va_hwaccel;
|
||||
extern const AVHWAccel ff_mpeg2_d3d11va2_hwaccel;
|
||||
extern const AVHWAccel ff_mpeg2_nvdec_hwaccel;
|
||||
extern const AVHWAccel ff_mpeg2_dxva2_hwaccel;
|
||||
+extern const AVHWAccel ff_mpeg2_v4l2request_hwaccel;
|
||||
extern const AVHWAccel ff_mpeg2_vaapi_hwaccel;
|
||||
extern const AVHWAccel ff_mpeg2_vdpau_hwaccel;
|
||||
extern const AVHWAccel ff_mpeg2_videotoolbox_hwaccel;
|
||||
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
|
||||
index 83e537884b..305127bc94 100644
|
||||
--- a/libavcodec/mpeg12dec.c
|
||||
+++ b/libavcodec/mpeg12dec.c
|
||||
@@ -1156,6 +1156,9 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = {
|
||||
#endif
|
||||
#if CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL
|
||||
AV_PIX_FMT_VIDEOTOOLBOX,
|
||||
+#endif
|
||||
+#if CONFIG_MPEG2_V4L2REQUEST_HWACCEL
|
||||
+ AV_PIX_FMT_DRM_PRIME,
|
||||
#endif
|
||||
AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_NONE
|
||||
@@ -2941,6 +2944,9 @@ AVCodec ff_mpeg2video_decoder = {
|
||||
#endif
|
||||
#if CONFIG_MPEG2_XVMC_HWACCEL
|
||||
HWACCEL_XVMC(mpeg2),
|
||||
+#endif
|
||||
+#if CONFIG_MPEG2_V4L2REQUEST_HWACCEL
|
||||
+ HWACCEL_V4L2REQUEST(mpeg2),
|
||||
#endif
|
||||
NULL
|
||||
},
|
||||
diff --git a/libavcodec/v4l2_request_mpeg2.c b/libavcodec/v4l2_request_mpeg2.c
|
||||
new file mode 100644
|
||||
index 0000000000..782b9c2471
|
||||
--- /dev/null
|
||||
+++ b/libavcodec/v4l2_request_mpeg2.c
|
||||
@@ -0,0 +1,154 @@
|
||||
+/*
|
||||
+ * 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 "hwaccel.h"
|
||||
+#include "mpegvideo.h"
|
||||
+#include "v4l2_request.h"
|
||||
+
|
||||
+typedef struct V4L2RequestControlsMPEG2 {
|
||||
+ struct v4l2_ctrl_mpeg2_slice_params slice_params;
|
||||
+ struct v4l2_ctrl_mpeg2_quantization quantization;
|
||||
+} V4L2RequestControlsMPEG2;
|
||||
+
|
||||
+static int v4l2_request_mpeg2_start_frame(AVCodecContext *avctx,
|
||||
+ av_unused const uint8_t *buffer,
|
||||
+ av_unused uint32_t size)
|
||||
+{
|
||||
+ const MpegEncContext *s = avctx->priv_data;
|
||||
+ V4L2RequestControlsMPEG2 *controls = s->current_picture_ptr->hwaccel_picture_private;
|
||||
+ V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)s->current_picture_ptr->f->data[0];
|
||||
+
|
||||
+ controls->slice_params = (struct v4l2_ctrl_mpeg2_slice_params) {
|
||||
+ .bit_size = 0,
|
||||
+ .data_bit_offset = 0,
|
||||
+
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Slice */
|
||||
+ .quantiser_scale_code = s->qscale >> 1,
|
||||
+
|
||||
+ .sequence = {
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence header */
|
||||
+ .horizontal_size = s->width,
|
||||
+ .vertical_size = s->height,
|
||||
+ .vbv_buffer_size = req->output.size,
|
||||
+
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */
|
||||
+ .profile_and_level_indication = 0,
|
||||
+ .progressive_sequence = s->progressive_sequence,
|
||||
+ .chroma_format = s->chroma_format,
|
||||
+ },
|
||||
+
|
||||
+ .picture = {
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture header */
|
||||
+ .picture_coding_type = s->pict_type,
|
||||
+
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture coding extension */
|
||||
+ .f_code[0][0] = s->mpeg_f_code[0][0],
|
||||
+ .f_code[0][1] = s->mpeg_f_code[0][1],
|
||||
+ .f_code[1][0] = s->mpeg_f_code[1][0],
|
||||
+ .f_code[1][1] = s->mpeg_f_code[1][1],
|
||||
+ .intra_dc_precision = s->intra_dc_precision,
|
||||
+ .picture_structure = s->picture_structure,
|
||||
+ .top_field_first = s->top_field_first,
|
||||
+ .frame_pred_frame_dct = s->frame_pred_frame_dct,
|
||||
+ .concealment_motion_vectors = s->concealment_motion_vectors,
|
||||
+ .q_scale_type = s->q_scale_type,
|
||||
+ .intra_vlc_format = s->intra_vlc_format,
|
||||
+ .alternate_scan = s->alternate_scan,
|
||||
+ .repeat_first_field = s->repeat_first_field,
|
||||
+ .progressive_frame = s->progressive_frame,
|
||||
+ },
|
||||
+ };
|
||||
+
|
||||
+ switch (s->pict_type) {
|
||||
+ case AV_PICTURE_TYPE_B:
|
||||
+ controls->slice_params.backward_ref_ts = ff_v4l2_request_get_capture_timestamp(s->next_picture.f);
|
||||
+ // fall-through
|
||||
+ case AV_PICTURE_TYPE_P:
|
||||
+ controls->slice_params.forward_ref_ts = ff_v4l2_request_get_capture_timestamp(s->last_picture.f);
|
||||
+ }
|
||||
+
|
||||
+ controls->quantization = (struct v4l2_ctrl_mpeg2_quantization) {
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Quant matrix extension */
|
||||
+ .load_intra_quantiser_matrix = 1,
|
||||
+ .load_non_intra_quantiser_matrix = 1,
|
||||
+ .load_chroma_intra_quantiser_matrix = 1,
|
||||
+ .load_chroma_non_intra_quantiser_matrix = 1,
|
||||
+ };
|
||||
+
|
||||
+ for (int i = 0; i < 64; i++) {
|
||||
+ int n = s->idsp.idct_permutation[ff_zigzag_direct[i]];
|
||||
+ controls->quantization.intra_quantiser_matrix[i] = s->intra_matrix[n];
|
||||
+ controls->quantization.non_intra_quantiser_matrix[i] = s->inter_matrix[n];
|
||||
+ controls->quantization.chroma_intra_quantiser_matrix[i] = s->chroma_intra_matrix[n];
|
||||
+ controls->quantization.chroma_non_intra_quantiser_matrix[i] = s->chroma_inter_matrix[n];
|
||||
+ }
|
||||
+
|
||||
+ return ff_v4l2_request_reset_frame(avctx, s->current_picture_ptr->f);
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
|
||||
+{
|
||||
+ const MpegEncContext *s = avctx->priv_data;
|
||||
+
|
||||
+ return ff_v4l2_request_append_output_buffer(avctx, s->current_picture_ptr->f, buffer, size);
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_mpeg2_end_frame(AVCodecContext *avctx)
|
||||
+{
|
||||
+ const MpegEncContext *s = avctx->priv_data;
|
||||
+ V4L2RequestControlsMPEG2 *controls = s->current_picture_ptr->hwaccel_picture_private;
|
||||
+ V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)s->current_picture_ptr->f->data[0];
|
||||
+
|
||||
+ struct v4l2_ext_control control[] = {
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS,
|
||||
+ .ptr = &controls->slice_params,
|
||||
+ .size = sizeof(controls->slice_params),
|
||||
+ },
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION,
|
||||
+ .ptr = &controls->quantization,
|
||||
+ .size = sizeof(controls->quantization),
|
||||
+ },
|
||||
+ };
|
||||
+
|
||||
+ controls->slice_params.bit_size = req->output.used * 8;
|
||||
+
|
||||
+ return ff_v4l2_request_decode_frame(avctx, s->current_picture_ptr->f, control, FF_ARRAY_ELEMS(control));
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_mpeg2_init(AVCodecContext *avctx)
|
||||
+{
|
||||
+ return ff_v4l2_request_init(avctx, V4L2_PIX_FMT_MPEG2_SLICE, 1024 * 1024, NULL, 0);
|
||||
+}
|
||||
+
|
||||
+const AVHWAccel ff_mpeg2_v4l2request_hwaccel = {
|
||||
+ .name = "mpeg2_v4l2request",
|
||||
+ .type = AVMEDIA_TYPE_VIDEO,
|
||||
+ .id = AV_CODEC_ID_MPEG2VIDEO,
|
||||
+ .pix_fmt = AV_PIX_FMT_DRM_PRIME,
|
||||
+ .start_frame = v4l2_request_mpeg2_start_frame,
|
||||
+ .decode_slice = v4l2_request_mpeg2_decode_slice,
|
||||
+ .end_frame = v4l2_request_mpeg2_end_frame,
|
||||
+ .frame_priv_data_size = sizeof(V4L2RequestControlsMPEG2),
|
||||
+ .init = v4l2_request_mpeg2_init,
|
||||
+ .uninit = ff_v4l2_request_uninit,
|
||||
+ .priv_data_size = sizeof(V4L2RequestContext),
|
||||
+ .frame_params = ff_v4l2_request_frame_params,
|
||||
+ .caps_internal = HWACCEL_CAP_ASYNC_SAFE,
|
||||
+};
|
||||
--
|
||||
2.21.0
|
||||
|
@ -0,0 +1,474 @@
|
||||
From 250fab0e761f4956c009a6333c6799f63440b091 Mon Sep 17 00:00:00 2001
|
||||
From: Jernej Skrabec <jernej.skrabec@siol.net>
|
||||
Date: Sat, 15 Dec 2018 22:32:16 +0100
|
||||
Subject: [PATCH 4/6] Add V4L2 request API h264 hwaccel
|
||||
|
||||
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
---
|
||||
configure | 3 +
|
||||
libavcodec/Makefile | 1 +
|
||||
libavcodec/h264_slice.c | 4 +
|
||||
libavcodec/h264dec.c | 3 +
|
||||
libavcodec/hwaccels.h | 1 +
|
||||
libavcodec/v4l2_request_h264.c | 367 +++++++++++++++++++++++++++++++++
|
||||
6 files changed, 379 insertions(+)
|
||||
create mode 100644 libavcodec/v4l2_request_h264.c
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index b163ed8dbe..698a91d5dc 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -2804,6 +2804,8 @@ h264_dxva2_hwaccel_deps="dxva2"
|
||||
h264_dxva2_hwaccel_select="h264_decoder"
|
||||
h264_nvdec_hwaccel_deps="nvdec"
|
||||
h264_nvdec_hwaccel_select="h264_decoder"
|
||||
+h264_v4l2request_hwaccel_deps="v4l2_request h264_v4l2_request"
|
||||
+h264_v4l2request_hwaccel_select="h264_decoder"
|
||||
h264_vaapi_hwaccel_deps="vaapi"
|
||||
h264_vaapi_hwaccel_select="h264_decoder"
|
||||
h264_vdpau_hwaccel_deps="vdpau"
|
||||
@@ -6243,6 +6245,7 @@ check_cc vp8_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;"
|
||||
check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;"
|
||||
|
||||
check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns
|
||||
+check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE_RAW;"
|
||||
check_cc mpeg2_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2_SLICE;"
|
||||
|
||||
check_header sys/videoio.h
|
||||
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
|
||||
index 9b945e3f64..2bdfaabb5f 100644
|
||||
--- a/libavcodec/Makefile
|
||||
+++ b/libavcodec/Makefile
|
||||
@@ -852,6 +852,7 @@ OBJS-$(CONFIG_H264_D3D11VA_HWACCEL) += dxva2_h264.o
|
||||
OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o
|
||||
OBJS-$(CONFIG_H264_NVDEC_HWACCEL) += nvdec_h264.o
|
||||
OBJS-$(CONFIG_H264_QSV_HWACCEL) += qsvdec_h2645.o
|
||||
+OBJS-$(CONFIG_H264_V4L2REQUEST_HWACCEL) += v4l2_request_h264.o
|
||||
OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
|
||||
OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o
|
||||
OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
|
||||
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
|
||||
index f78f9f87b0..688d6c4ac2 100644
|
||||
--- a/libavcodec/h264_slice.c
|
||||
+++ b/libavcodec/h264_slice.c
|
||||
@@ -758,6 +758,7 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
|
||||
#define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \
|
||||
(CONFIG_H264_D3D11VA_HWACCEL * 2) + \
|
||||
CONFIG_H264_NVDEC_HWACCEL + \
|
||||
+ CONFIG_H264_V4L2REQUEST_HWACCEL + \
|
||||
CONFIG_H264_VAAPI_HWACCEL + \
|
||||
CONFIG_H264_VIDEOTOOLBOX_HWACCEL + \
|
||||
CONFIG_H264_VDPAU_HWACCEL)
|
||||
@@ -842,6 +843,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
|
||||
#endif
|
||||
#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
|
||||
*fmt++ = AV_PIX_FMT_VIDEOTOOLBOX;
|
||||
+#endif
|
||||
+#if CONFIG_H264_V4L2REQUEST_HWACCEL
|
||||
+ *fmt++ = AV_PIX_FMT_DRM_PRIME;
|
||||
#endif
|
||||
if (h->avctx->codec->pix_fmts)
|
||||
choices = h->avctx->codec->pix_fmts;
|
||||
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
|
||||
index 33e1056d87..3ccfa60621 100644
|
||||
--- a/libavcodec/h264dec.c
|
||||
+++ b/libavcodec/h264dec.c
|
||||
@@ -1078,6 +1078,9 @@ AVCodec ff_h264_decoder = {
|
||||
#endif
|
||||
#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
|
||||
HWACCEL_VIDEOTOOLBOX(h264),
|
||||
+#endif
|
||||
+#if CONFIG_H264_V4L2REQUEST_HWACCEL
|
||||
+ HWACCEL_V4L2REQUEST(h264),
|
||||
#endif
|
||||
NULL
|
||||
},
|
||||
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
|
||||
index ef54de2a3b..003200edea 100644
|
||||
--- a/libavcodec/hwaccels.h
|
||||
+++ b/libavcodec/hwaccels.h
|
||||
@@ -27,6 +27,7 @@ extern const AVHWAccel ff_h264_d3d11va_hwaccel;
|
||||
extern const AVHWAccel ff_h264_d3d11va2_hwaccel;
|
||||
extern const AVHWAccel ff_h264_dxva2_hwaccel;
|
||||
extern const AVHWAccel ff_h264_nvdec_hwaccel;
|
||||
+extern const AVHWAccel ff_h264_v4l2request_hwaccel;
|
||||
extern const AVHWAccel ff_h264_vaapi_hwaccel;
|
||||
extern const AVHWAccel ff_h264_vdpau_hwaccel;
|
||||
extern const AVHWAccel ff_h264_videotoolbox_hwaccel;
|
||||
diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c
|
||||
new file mode 100644
|
||||
index 0000000000..3687325fad
|
||||
--- /dev/null
|
||||
+++ b/libavcodec/v4l2_request_h264.c
|
||||
@@ -0,0 +1,367 @@
|
||||
+/*
|
||||
+ * 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 "h264dec.h"
|
||||
+#include "hwaccel.h"
|
||||
+#include "v4l2_request.h"
|
||||
+
|
||||
+typedef struct V4L2RequestControlsH264 {
|
||||
+ struct v4l2_ctrl_h264_sps sps;
|
||||
+ struct v4l2_ctrl_h264_pps pps;
|
||||
+ struct v4l2_ctrl_h264_scaling_matrix scaling_matrix;
|
||||
+ struct v4l2_ctrl_h264_decode_params decode_params;
|
||||
+ struct v4l2_ctrl_h264_slice_params slice_params;
|
||||
+} V4L2RequestControlsH264;
|
||||
+
|
||||
+static void fill_weight_factors(struct v4l2_h264_weight_factors *factors, int list, const H264SliceContext *sl)
|
||||
+{
|
||||
+ for (int i = 0; i < sl->ref_count[list]; i++) {
|
||||
+ if (sl->pwt.luma_weight_flag[list]) {
|
||||
+ factors->luma_weight[i] = sl->pwt.luma_weight[i][list][0];
|
||||
+ factors->luma_offset[i] = sl->pwt.luma_weight[i][list][1];
|
||||
+ } else {
|
||||
+ factors->luma_weight[i] = 1 << sl->pwt.luma_log2_weight_denom;
|
||||
+ factors->luma_offset[i] = 0;
|
||||
+ }
|
||||
+ for (int j = 0; j < 2; j++) {
|
||||
+ if (sl->pwt.chroma_weight_flag[list]) {
|
||||
+ factors->chroma_weight[i][j] = sl->pwt.chroma_weight[i][list][j][0];
|
||||
+ factors->chroma_offset[i][j] = sl->pwt.chroma_weight[i][list][j][1];
|
||||
+ } else {
|
||||
+ factors->chroma_weight[i][j] = 1 << sl->pwt.chroma_log2_weight_denom;
|
||||
+ factors->chroma_offset[i][j] = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void fill_dpb_entry(struct v4l2_h264_dpb_entry *entry, const H264Picture *pic)
|
||||
+{
|
||||
+ entry->reference_ts = ff_v4l2_request_get_capture_timestamp(pic->f);
|
||||
+ entry->frame_num = pic->frame_num;
|
||||
+ entry->pic_num = pic->pic_id;
|
||||
+ entry->flags = V4L2_H264_DPB_ENTRY_FLAG_VALID;
|
||||
+ if (pic->reference)
|
||||
+ entry->flags |= V4L2_H264_DPB_ENTRY_FLAG_ACTIVE;
|
||||
+ if (pic->long_ref)
|
||||
+ entry->flags |= V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM;
|
||||
+ if (pic->field_poc[0] != INT_MAX)
|
||||
+ entry->top_field_order_cnt = pic->field_poc[0];
|
||||
+ if (pic->field_poc[1] != INT_MAX)
|
||||
+ entry->bottom_field_order_cnt = pic->field_poc[1];
|
||||
+}
|
||||
+
|
||||
+static void fill_dpb(struct v4l2_ctrl_h264_decode_params *decode, const H264Context *h)
|
||||
+{
|
||||
+ int entries = 0;
|
||||
+
|
||||
+ for (int i = 0; i < h->short_ref_count; i++) {
|
||||
+ const H264Picture *pic = h->short_ref[i];
|
||||
+ if (pic && (pic->field_poc[0] != INT_MAX || pic->field_poc[1] != INT_MAX))
|
||||
+ fill_dpb_entry(&decode->dpb[entries++], pic);
|
||||
+ }
|
||||
+
|
||||
+ if (!h->long_ref_count)
|
||||
+ return;
|
||||
+
|
||||
+ for (int i = 0; i < FF_ARRAY_ELEMS(h->long_ref); i++) {
|
||||
+ const H264Picture *pic = h->long_ref[i];
|
||||
+ if (pic && (pic->field_poc[0] != INT_MAX || pic->field_poc[1] != INT_MAX))
|
||||
+ fill_dpb_entry(&decode->dpb[entries++], pic);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static uint8_t get_dpb_index(struct v4l2_ctrl_h264_decode_params *decode, const H264Ref *ref)
|
||||
+{
|
||||
+ uint64_t timestamp;
|
||||
+
|
||||
+ if (!ref->parent)
|
||||
+ return 0;
|
||||
+
|
||||
+ timestamp = ff_v4l2_request_get_capture_timestamp(ref->parent->f);
|
||||
+
|
||||
+ for (uint8_t i = 0; i < FF_ARRAY_ELEMS(decode->dpb); i++) {
|
||||
+ struct v4l2_h264_dpb_entry *entry = &decode->dpb[i];
|
||||
+ if ((entry->flags & V4L2_H264_DPB_ENTRY_FLAG_VALID) &&
|
||||
+ entry->reference_ts == timestamp)
|
||||
+ // TODO: signal reference type, possible using top 2 bits
|
||||
+ return i | ((ref->reference & 3) << 6);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void fill_sps(struct v4l2_ctrl_h264_sps *ctrl, const H264Context *h)
|
||||
+{
|
||||
+ const SPS *sps = h->ps.sps;
|
||||
+
|
||||
+ *ctrl = (struct v4l2_ctrl_h264_sps) {
|
||||
+ .profile_idc = sps->profile_idc,
|
||||
+ .constraint_set_flags = sps->constraint_set_flags,
|
||||
+ .level_idc = sps->level_idc,
|
||||
+ .seq_parameter_set_id = sps->sps_id,
|
||||
+ .chroma_format_idc = sps->chroma_format_idc,
|
||||
+ .bit_depth_luma_minus8 = sps->bit_depth_luma - 8,
|
||||
+ .bit_depth_chroma_minus8 = sps->bit_depth_chroma - 8,
|
||||
+ .log2_max_frame_num_minus4 = sps->log2_max_frame_num - 4,
|
||||
+ .pic_order_cnt_type = sps->poc_type,
|
||||
+ .log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4,
|
||||
+ .max_num_ref_frames = sps->ref_frame_count,
|
||||
+ .num_ref_frames_in_pic_order_cnt_cycle = sps->poc_cycle_length,
|
||||
+ //.offset_for_ref_frame[255] - not required? not set by libva-v4l2-request - copy sps->offset_for_ref_frame
|
||||
+ .offset_for_non_ref_pic = sps->offset_for_non_ref_pic,
|
||||
+ .offset_for_top_to_bottom_field = sps->offset_for_top_to_bottom_field,
|
||||
+ .pic_width_in_mbs_minus1 = h->mb_width - 1,
|
||||
+ .pic_height_in_map_units_minus1 = sps->frame_mbs_only_flag ? h->mb_height - 1 : h->mb_height / 2 - 1,
|
||||
+ };
|
||||
+
|
||||
+ if (sps->residual_color_transform_flag)
|
||||
+ ctrl->flags |= V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE;
|
||||
+ if (sps->transform_bypass)
|
||||
+ ctrl->flags |= V4L2_H264_SPS_FLAG_QPPRIME_Y_ZERO_TRANSFORM_BYPASS;
|
||||
+ if (sps->delta_pic_order_always_zero_flag)
|
||||
+ ctrl->flags |= V4L2_H264_SPS_FLAG_DELTA_PIC_ORDER_ALWAYS_ZERO;
|
||||
+ if (sps->gaps_in_frame_num_allowed_flag)
|
||||
+ ctrl->flags |= V4L2_H264_SPS_FLAG_GAPS_IN_FRAME_NUM_VALUE_ALLOWED;
|
||||
+ if (sps->frame_mbs_only_flag)
|
||||
+ ctrl->flags |= V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY;
|
||||
+ if (sps->mb_aff)
|
||||
+ ctrl->flags |= V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD;
|
||||
+ if (sps->direct_8x8_inference_flag)
|
||||
+ ctrl->flags |= V4L2_H264_SPS_FLAG_DIRECT_8X8_INFERENCE;
|
||||
+}
|
||||
+
|
||||
+static void fill_pps(struct v4l2_ctrl_h264_pps *ctrl, const H264Context *h)
|
||||
+{
|
||||
+ const PPS *pps = h->ps.pps;
|
||||
+ const H264SliceContext *sl = &h->slice_ctx[0];
|
||||
+
|
||||
+ *ctrl = (struct v4l2_ctrl_h264_pps) {
|
||||
+ .pic_parameter_set_id = sl->pps_id,
|
||||
+ .seq_parameter_set_id = pps->sps_id,
|
||||
+ .num_slice_groups_minus1 = pps->slice_group_count - 1,
|
||||
+ .num_ref_idx_l0_default_active_minus1 = pps->ref_count[0] - 1,
|
||||
+ .num_ref_idx_l1_default_active_minus1 = pps->ref_count[1] - 1,
|
||||
+ .weighted_bipred_idc = pps->weighted_bipred_idc,
|
||||
+ .pic_init_qp_minus26 = pps->init_qp - 26,
|
||||
+ .pic_init_qs_minus26 = pps->init_qs - 26,
|
||||
+ .chroma_qp_index_offset = pps->chroma_qp_index_offset[0],
|
||||
+ .second_chroma_qp_index_offset = pps->chroma_qp_index_offset[1],
|
||||
+ };
|
||||
+
|
||||
+ if (pps->cabac)
|
||||
+ ctrl->flags |= V4L2_H264_PPS_FLAG_ENTROPY_CODING_MODE;
|
||||
+ if (pps->pic_order_present)
|
||||
+ ctrl->flags |= V4L2_H264_PPS_FLAG_BOTTOM_FIELD_PIC_ORDER_IN_FRAME_PRESENT;
|
||||
+ if (pps->weighted_pred)
|
||||
+ ctrl->flags |= V4L2_H264_PPS_FLAG_WEIGHTED_PRED;
|
||||
+ if (pps->deblocking_filter_parameters_present)
|
||||
+ ctrl->flags |= V4L2_H264_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT;
|
||||
+ if (pps->constrained_intra_pred)
|
||||
+ ctrl->flags |= V4L2_H264_PPS_FLAG_CONSTRAINED_INTRA_PRED;
|
||||
+ if (pps->redundant_pic_cnt_present)
|
||||
+ ctrl->flags |= V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT;
|
||||
+ if (pps->transform_8x8_mode)
|
||||
+ ctrl->flags |= V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE;
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_h264_start_frame(AVCodecContext *avctx,
|
||||
+ av_unused const uint8_t *buffer,
|
||||
+ av_unused uint32_t size)
|
||||
+{
|
||||
+ const H264Context *h = avctx->priv_data;
|
||||
+ const PPS *pps = h->ps.pps;
|
||||
+ V4L2RequestControlsH264 *controls = h->cur_pic_ptr->hwaccel_picture_private;
|
||||
+
|
||||
+ fill_sps(&controls->sps, h);
|
||||
+ fill_pps(&controls->pps, h);
|
||||
+
|
||||
+ memcpy(controls->scaling_matrix.scaling_list_4x4, pps->scaling_matrix4, sizeof(controls->scaling_matrix.scaling_list_4x4));
|
||||
+ memcpy(controls->scaling_matrix.scaling_list_8x8, pps->scaling_matrix8, sizeof(controls->scaling_matrix.scaling_list_8x8));
|
||||
+
|
||||
+ controls->decode_params = (struct v4l2_ctrl_h264_decode_params) {
|
||||
+ .num_slices = 0,
|
||||
+ .nal_ref_idc = h->nal_ref_idc,
|
||||
+ .top_field_order_cnt = h->cur_pic_ptr->field_poc[0] != INT_MAX ? h->cur_pic_ptr->field_poc[0] : 0,
|
||||
+ .bottom_field_order_cnt = h->cur_pic_ptr->field_poc[1] != INT_MAX ? h->cur_pic_ptr->field_poc[1] : 0,
|
||||
+ };
|
||||
+
|
||||
+ if (h->picture_idr)
|
||||
+ controls->decode_params.flags |= V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC;
|
||||
+
|
||||
+ fill_dpb(&controls->decode_params, h);
|
||||
+
|
||||
+ return ff_v4l2_request_reset_frame(avctx, h->cur_pic_ptr->f);
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_h264_end_frame(AVCodecContext *avctx)
|
||||
+{
|
||||
+ const H264Context *h = avctx->priv_data;
|
||||
+ V4L2RequestControlsH264 *controls = h->cur_pic_ptr->hwaccel_picture_private;
|
||||
+ V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)h->cur_pic_ptr->f->data[0];
|
||||
+
|
||||
+ struct v4l2_ext_control control[] = {
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_H264_SPS,
|
||||
+ .ptr = &controls->sps,
|
||||
+ .size = sizeof(controls->sps),
|
||||
+ },
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_H264_PPS,
|
||||
+ .ptr = &controls->pps,
|
||||
+ .size = sizeof(controls->pps),
|
||||
+ },
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX,
|
||||
+ .ptr = &controls->scaling_matrix,
|
||||
+ .size = sizeof(controls->scaling_matrix),
|
||||
+ },
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS,
|
||||
+ .ptr = &controls->slice_params,
|
||||
+ .size = sizeof(controls->slice_params),
|
||||
+ },
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS,
|
||||
+ .ptr = &controls->decode_params,
|
||||
+ .size = sizeof(controls->decode_params),
|
||||
+ },
|
||||
+ };
|
||||
+
|
||||
+ controls->slice_params.size = req->output.used;
|
||||
+
|
||||
+ return ff_v4l2_request_decode_frame(avctx, h->cur_pic_ptr->f, control, FF_ARRAY_ELEMS(control));
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
|
||||
+{
|
||||
+ const H264Context *h = avctx->priv_data;
|
||||
+ const PPS *pps = h->ps.pps;
|
||||
+ const H264SliceContext *sl = &h->slice_ctx[0];
|
||||
+ V4L2RequestControlsH264 *controls = h->cur_pic_ptr->hwaccel_picture_private;
|
||||
+ V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)h->cur_pic_ptr->f->data[0];
|
||||
+ int i, count;
|
||||
+
|
||||
+ // HACK: trigger decode per slice
|
||||
+ if (req->output.used) {
|
||||
+ v4l2_request_h264_end_frame(avctx);
|
||||
+ ff_v4l2_request_reset_frame(avctx, h->cur_pic_ptr->f);
|
||||
+ }
|
||||
+
|
||||
+ controls->decode_params.num_slices++;
|
||||
+
|
||||
+ controls->slice_params = (struct v4l2_ctrl_h264_slice_params) {
|
||||
+ /* Size in bytes, including header */
|
||||
+ .size = 0,
|
||||
+ /* Offset in bits to slice_data() from the beginning of this slice. */
|
||||
+ .header_bit_size = get_bits_count(&sl->gb),
|
||||
+
|
||||
+ .first_mb_in_slice = sl->first_mb_addr,
|
||||
+ .slice_type = ff_h264_get_slice_type(sl),
|
||||
+ .pic_parameter_set_id = sl->pps_id,
|
||||
+ .colour_plane_id = 0, /* what is this? */
|
||||
+ .frame_num = h->poc.frame_num,
|
||||
+ .idr_pic_id = 0, /* what is this? */
|
||||
+ .pic_order_cnt_lsb = sl->poc_lsb,
|
||||
+ .delta_pic_order_cnt_bottom = sl->delta_poc_bottom,
|
||||
+ .delta_pic_order_cnt0 = sl->delta_poc[0],
|
||||
+ .delta_pic_order_cnt1 = sl->delta_poc[1],
|
||||
+ .redundant_pic_cnt = sl->redundant_pic_count,
|
||||
+
|
||||
+ /* Size in bits of dec_ref_pic_marking() syntax element. */
|
||||
+ .dec_ref_pic_marking_bit_size = 0,
|
||||
+ /* Size in bits of pic order count syntax. */
|
||||
+ .pic_order_cnt_bit_size = 0,
|
||||
+
|
||||
+ .cabac_init_idc = sl->cabac_init_idc,
|
||||
+ .slice_qp_delta = sl->qscale - pps->init_qp,
|
||||
+ .slice_qs_delta = 0, /* XXX not implemented by FFmpeg */
|
||||
+ .disable_deblocking_filter_idc = sl->deblocking_filter < 2 ? !sl->deblocking_filter : sl->deblocking_filter,
|
||||
+ .slice_alpha_c0_offset_div2 = sl->slice_alpha_c0_offset / 2,
|
||||
+ .slice_beta_offset_div2 = sl->slice_beta_offset / 2,
|
||||
+ .slice_group_change_cycle = 0, /* what is this? */
|
||||
+
|
||||
+ .num_ref_idx_l0_active_minus1 = sl->list_count > 0 ? sl->ref_count[0] - 1 : 0,
|
||||
+ .num_ref_idx_l1_active_minus1 = sl->list_count > 1 ? sl->ref_count[1] - 1 : 0,
|
||||
+ };
|
||||
+
|
||||
+ if (FIELD_PICTURE(h))
|
||||
+ controls->slice_params.flags |= V4L2_H264_SLICE_FLAG_FIELD_PIC;
|
||||
+ if (h->picture_structure == PICT_BOTTOM_FIELD)
|
||||
+ controls->slice_params.flags |= V4L2_H264_SLICE_FLAG_BOTTOM_FIELD;
|
||||
+ if (sl->slice_type == AV_PICTURE_TYPE_B && sl->direct_spatial_mv_pred)
|
||||
+ controls->slice_params.flags |= V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED;
|
||||
+
|
||||
+ controls->slice_params.pred_weight_table.chroma_log2_weight_denom = sl->pwt.chroma_log2_weight_denom;
|
||||
+ controls->slice_params.pred_weight_table.luma_log2_weight_denom = sl->pwt.luma_log2_weight_denom;
|
||||
+
|
||||
+ count = sl->list_count > 0 ? sl->ref_count[0] : 0;
|
||||
+ for (i = 0; i < count; i++)
|
||||
+ controls->slice_params.ref_pic_list0[i] = get_dpb_index(&controls->decode_params, &sl->ref_list[0][i]);
|
||||
+ if (count)
|
||||
+ fill_weight_factors(&controls->slice_params.pred_weight_table.weight_factors[0], 0, sl);
|
||||
+
|
||||
+ count = sl->list_count > 1 ? sl->ref_count[1] : 0;
|
||||
+ for (i = 0; i < count; i++)
|
||||
+ controls->slice_params.ref_pic_list1[i] = get_dpb_index(&controls->decode_params, &sl->ref_list[1][i]);
|
||||
+ if (count)
|
||||
+ fill_weight_factors(&controls->slice_params.pred_weight_table.weight_factors[1], 1, sl);
|
||||
+
|
||||
+ return ff_v4l2_request_append_output_buffer(avctx, h->cur_pic_ptr->f, buffer, size);
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_h264_init(AVCodecContext *avctx)
|
||||
+{
|
||||
+ const H264Context *h = avctx->priv_data;
|
||||
+ struct v4l2_ctrl_h264_sps sps;
|
||||
+ struct v4l2_ctrl_h264_pps pps;
|
||||
+
|
||||
+ struct v4l2_ext_control control[] = {
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_H264_SPS,
|
||||
+ .ptr = &sps,
|
||||
+ .size = sizeof(sps),
|
||||
+ },
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_H264_PPS,
|
||||
+ .ptr = &pps,
|
||||
+ .size = sizeof(pps),
|
||||
+ },
|
||||
+ };
|
||||
+
|
||||
+ fill_sps(&sps, h);
|
||||
+ fill_pps(&pps, h);
|
||||
+
|
||||
+ return ff_v4l2_request_init(avctx, V4L2_PIX_FMT_H264_SLICE_RAW, 2 * 1024 * 1024, control, FF_ARRAY_ELEMS(control));
|
||||
+}
|
||||
+
|
||||
+const AVHWAccel ff_h264_v4l2request_hwaccel = {
|
||||
+ .name = "h264_v4l2request",
|
||||
+ .type = AVMEDIA_TYPE_VIDEO,
|
||||
+ .id = AV_CODEC_ID_H264,
|
||||
+ .pix_fmt = AV_PIX_FMT_DRM_PRIME,
|
||||
+ .start_frame = v4l2_request_h264_start_frame,
|
||||
+ .decode_slice = v4l2_request_h264_decode_slice,
|
||||
+ .end_frame = v4l2_request_h264_end_frame,
|
||||
+ .frame_priv_data_size = sizeof(V4L2RequestControlsH264),
|
||||
+ .init = v4l2_request_h264_init,
|
||||
+ .uninit = ff_v4l2_request_uninit,
|
||||
+ .priv_data_size = sizeof(V4L2RequestContext),
|
||||
+ .frame_params = ff_v4l2_request_frame_params,
|
||||
+ .caps_internal = HWACCEL_CAP_ASYNC_SAFE,
|
||||
+};
|
||||
--
|
||||
2.21.0
|
||||
|
@ -0,0 +1,503 @@
|
||||
From 55751072c14f2ef678489be3d527f34604bb5602 Mon Sep 17 00:00:00 2001
|
||||
From: Jernej Skrabec <jernej.skrabec@siol.net>
|
||||
Date: Sat, 15 Dec 2018 22:32:16 +0100
|
||||
Subject: [PATCH 5/6] Add V4L2 request API hevc hwaccel
|
||||
|
||||
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
|
||||
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
|
||||
---
|
||||
configure | 3 +
|
||||
libavcodec/Makefile | 1 +
|
||||
libavcodec/hevcdec.c | 10 +
|
||||
libavcodec/hwaccels.h | 1 +
|
||||
libavcodec/v4l2_request_hevc.c | 391 +++++++++++++++++++++++++++++++++
|
||||
5 files changed, 406 insertions(+)
|
||||
create mode 100644 libavcodec/v4l2_request_hevc.c
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 698a91d5dc..2d39cecbdf 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -2820,6 +2820,8 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
|
||||
hevc_dxva2_hwaccel_select="hevc_decoder"
|
||||
hevc_nvdec_hwaccel_deps="nvdec"
|
||||
hevc_nvdec_hwaccel_select="hevc_decoder"
|
||||
+hevc_v4l2request_hwaccel_deps="v4l2_request hevc_v4l2_request"
|
||||
+hevc_v4l2request_hwaccel_select="hevc_decoder"
|
||||
hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
|
||||
hevc_vaapi_hwaccel_select="hevc_decoder"
|
||||
hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
|
||||
@@ -6246,6 +6248,7 @@ check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;"
|
||||
|
||||
check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns
|
||||
check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE_RAW;"
|
||||
+check_cc hevc_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_HEVC_SLICE;"
|
||||
check_cc mpeg2_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2_SLICE;"
|
||||
|
||||
check_header sys/videoio.h
|
||||
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
|
||||
index 2bdfaabb5f..a4c959e0f5 100644
|
||||
--- a/libavcodec/Makefile
|
||||
+++ b/libavcodec/Makefile
|
||||
@@ -860,6 +860,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o
|
||||
OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
|
||||
OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
|
||||
OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec_h2645.o
|
||||
+OBJS-$(CONFIG_HEVC_V4L2REQUEST_HWACCEL) += v4l2_request_hevc.o
|
||||
OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
|
||||
OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
|
||||
OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL) += nvdec_mjpeg.o
|
||||
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
|
||||
index c8877626d2..df33433150 100644
|
||||
--- a/libavcodec/hevcdec.c
|
||||
+++ b/libavcodec/hevcdec.c
|
||||
@@ -362,6 +362,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps)
|
||||
#define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \
|
||||
CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \
|
||||
CONFIG_HEVC_NVDEC_HWACCEL + \
|
||||
+ CONFIG_HEVC_V4L2REQUEST_HWACCEL + \
|
||||
CONFIG_HEVC_VAAPI_HWACCEL + \
|
||||
CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \
|
||||
CONFIG_HEVC_VDPAU_HWACCEL)
|
||||
@@ -388,6 +389,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps)
|
||||
#endif
|
||||
#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
|
||||
*fmt++ = AV_PIX_FMT_VIDEOTOOLBOX;
|
||||
+#endif
|
||||
+#if CONFIG_HEVC_V4L2REQUEST_HWACCEL
|
||||
+ *fmt++ = AV_PIX_FMT_DRM_PRIME;
|
||||
#endif
|
||||
break;
|
||||
case AV_PIX_FMT_YUV420P10:
|
||||
@@ -406,6 +410,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps)
|
||||
#endif
|
||||
#if CONFIG_HEVC_NVDEC_HWACCEL
|
||||
*fmt++ = AV_PIX_FMT_CUDA;
|
||||
+#endif
|
||||
+#if CONFIG_HEVC_V4L2REQUEST_HWACCEL
|
||||
+ *fmt++ = AV_PIX_FMT_DRM_PRIME;
|
||||
#endif
|
||||
break;
|
||||
case AV_PIX_FMT_YUV420P12:
|
||||
@@ -3556,6 +3563,9 @@ AVCodec ff_hevc_decoder = {
|
||||
#endif
|
||||
#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL
|
||||
HWACCEL_VIDEOTOOLBOX(hevc),
|
||||
+#endif
|
||||
+#if CONFIG_HEVC_V4L2REQUEST_HWACCEL
|
||||
+ HWACCEL_V4L2REQUEST(hevc),
|
||||
#endif
|
||||
NULL
|
||||
},
|
||||
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
|
||||
index 003200edea..d183675abe 100644
|
||||
--- a/libavcodec/hwaccels.h
|
||||
+++ b/libavcodec/hwaccels.h
|
||||
@@ -35,6 +35,7 @@ extern const AVHWAccel ff_hevc_d3d11va_hwaccel;
|
||||
extern const AVHWAccel ff_hevc_d3d11va2_hwaccel;
|
||||
extern const AVHWAccel ff_hevc_dxva2_hwaccel;
|
||||
extern const AVHWAccel ff_hevc_nvdec_hwaccel;
|
||||
+extern const AVHWAccel ff_hevc_v4l2request_hwaccel;
|
||||
extern const AVHWAccel ff_hevc_vaapi_hwaccel;
|
||||
extern const AVHWAccel ff_hevc_vdpau_hwaccel;
|
||||
extern const AVHWAccel ff_hevc_videotoolbox_hwaccel;
|
||||
diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c
|
||||
new file mode 100644
|
||||
index 0000000000..38969d77fb
|
||||
--- /dev/null
|
||||
+++ b/libavcodec/v4l2_request_hevc.c
|
||||
@@ -0,0 +1,391 @@
|
||||
+/*
|
||||
+ * 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 "hevcdec.h"
|
||||
+#include "hwaccel.h"
|
||||
+#include "v4l2_request.h"
|
||||
+
|
||||
+typedef struct V4L2RequestControlsHEVC {
|
||||
+ struct v4l2_ctrl_hevc_sps sps;
|
||||
+ struct v4l2_ctrl_hevc_pps pps;
|
||||
+ struct v4l2_ctrl_hevc_scaling_matrix scaling_matrix;
|
||||
+ struct v4l2_ctrl_hevc_slice_params slice_params;
|
||||
+} V4L2RequestControlsHEVC;
|
||||
+
|
||||
+static void v4l2_request_hevc_fill_pred_table(const HEVCContext *h, struct v4l2_hevc_pred_weight_table *table)
|
||||
+{
|
||||
+ int32_t luma_weight_denom, chroma_weight_denom;
|
||||
+ const SliceHeader *sh = &h->sh;
|
||||
+
|
||||
+ if (sh->slice_type == HEVC_SLICE_I ||
|
||||
+ (sh->slice_type == HEVC_SLICE_P && !h->ps.pps->weighted_pred_flag) ||
|
||||
+ (sh->slice_type == HEVC_SLICE_B && !h->ps.pps->weighted_bipred_flag))
|
||||
+ return;
|
||||
+
|
||||
+ table->luma_log2_weight_denom = sh->luma_log2_weight_denom;
|
||||
+
|
||||
+ if (h->ps.sps->chroma_format_idc)
|
||||
+ table->delta_chroma_log2_weight_denom = sh->chroma_log2_weight_denom - sh->luma_log2_weight_denom;
|
||||
+
|
||||
+ luma_weight_denom = (1 << sh->luma_log2_weight_denom);
|
||||
+ chroma_weight_denom = (1 << sh->chroma_log2_weight_denom);
|
||||
+
|
||||
+ for (int i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
|
||||
+ table->delta_luma_weight_l0[i] = sh->luma_weight_l0[i] - luma_weight_denom;
|
||||
+ table->luma_offset_l0[i] = sh->luma_offset_l0[i];
|
||||
+ table->delta_chroma_weight_l0[i][0] = sh->chroma_weight_l0[i][0] - chroma_weight_denom;
|
||||
+ table->delta_chroma_weight_l0[i][1] = sh->chroma_weight_l0[i][1] - chroma_weight_denom;
|
||||
+ table->chroma_offset_l0[i][0] = sh->chroma_offset_l0[i][0];
|
||||
+ table->chroma_offset_l0[i][1] = sh->chroma_offset_l0[i][1];
|
||||
+ }
|
||||
+
|
||||
+ if (sh->slice_type != HEVC_SLICE_B)
|
||||
+ return;
|
||||
+
|
||||
+ for (int i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
|
||||
+ table->delta_luma_weight_l1[i] = sh->luma_weight_l1[i] - luma_weight_denom;
|
||||
+ table->luma_offset_l1[i] = sh->luma_offset_l1[i];
|
||||
+ table->delta_chroma_weight_l1[i][0] = sh->chroma_weight_l1[i][0] - chroma_weight_denom;
|
||||
+ table->delta_chroma_weight_l1[i][1] = sh->chroma_weight_l1[i][1] - chroma_weight_denom;
|
||||
+ table->chroma_offset_l1[i][0] = sh->chroma_offset_l1[i][0];
|
||||
+ table->chroma_offset_l1[i][1] = sh->chroma_offset_l1[i][1];
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int find_frame_rps_type(const HEVCContext *h, uint64_t timestamp)
|
||||
+{
|
||||
+ const HEVCFrame *frame;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < h->rps[ST_CURR_BEF].nb_refs; i++) {
|
||||
+ frame = h->rps[ST_CURR_BEF].ref[i];
|
||||
+ if (frame && timestamp == ff_v4l2_request_get_capture_timestamp(frame->frame))
|
||||
+ return V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_BEFORE;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < h->rps[ST_CURR_AFT].nb_refs; i++) {
|
||||
+ frame = h->rps[ST_CURR_AFT].ref[i];
|
||||
+ if (frame && timestamp == ff_v4l2_request_get_capture_timestamp(frame->frame))
|
||||
+ return V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_AFTER;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < h->rps[LT_CURR].nb_refs; i++) {
|
||||
+ frame = h->rps[LT_CURR].ref[i];
|
||||
+ if (frame && timestamp == ff_v4l2_request_get_capture_timestamp(frame->frame))
|
||||
+ return V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static uint8_t get_ref_pic_index(const HEVCContext *h, const HEVCFrame *frame,
|
||||
+ struct v4l2_ctrl_hevc_slice_params *slice_params)
|
||||
+{
|
||||
+ uint64_t timestamp;
|
||||
+
|
||||
+ if (!frame)
|
||||
+ return 0;
|
||||
+
|
||||
+ timestamp = ff_v4l2_request_get_capture_timestamp(frame->frame);
|
||||
+
|
||||
+ for (uint8_t i = 0; i < slice_params->num_active_dpb_entries; i++) {
|
||||
+ struct v4l2_hevc_dpb_entry *entry = &slice_params->dpb[i];
|
||||
+ if (entry->timestamp == timestamp)
|
||||
+ return i;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h,
|
||||
+ struct v4l2_ctrl_hevc_slice_params *slice_params)
|
||||
+{
|
||||
+ const HEVCFrame *pic = h->ref;
|
||||
+ const SliceHeader *sh = &h->sh;
|
||||
+ int i, entries = 0;
|
||||
+ RefPicList *rpl;
|
||||
+
|
||||
+ *slice_params = (struct v4l2_ctrl_hevc_slice_params) {
|
||||
+ .bit_size = 0,
|
||||
+ .data_bit_offset = get_bits_count(&h->HEVClc->gb),
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */
|
||||
+ .nal_unit_type = h->nal_unit_type,
|
||||
+ .nuh_temporal_id_plus1 = h->temporal_id + 1,
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
|
||||
+ .slice_type = sh->slice_type,
|
||||
+ .colour_plane_id = sh->colour_plane_id,
|
||||
+ .slice_pic_order_cnt = pic->poc,
|
||||
+ .slice_sao_luma_flag = sh->slice_sample_adaptive_offset_flag[0],
|
||||
+ .slice_sao_chroma_flag = sh->slice_sample_adaptive_offset_flag[1],
|
||||
+ .slice_temporal_mvp_enabled_flag = sh->slice_temporal_mvp_enabled_flag,
|
||||
+ .num_ref_idx_l0_active_minus1 = sh->nb_refs[L0] ? sh->nb_refs[L0] - 1 : 0,
|
||||
+ .num_ref_idx_l1_active_minus1 = sh->nb_refs[L1] ? sh->nb_refs[L1] - 1 : 0,
|
||||
+ .mvd_l1_zero_flag = sh->mvd_l1_zero_flag,
|
||||
+ .cabac_init_flag = sh->cabac_init_flag,
|
||||
+ .collocated_from_l0_flag = sh->collocated_list == L0 ? 1 : 0,
|
||||
+ .collocated_ref_idx = sh->slice_temporal_mvp_enabled_flag ? sh->collocated_ref_idx : 0,
|
||||
+ .five_minus_max_num_merge_cand = sh->slice_type == HEVC_SLICE_I ? 0 : 5 - sh->max_num_merge_cand,
|
||||
+ .use_integer_mv_flag = 0,
|
||||
+ .slice_qp_delta = sh->slice_qp_delta,
|
||||
+ .slice_cb_qp_offset = sh->slice_cb_qp_offset,
|
||||
+ .slice_cr_qp_offset = sh->slice_cr_qp_offset,
|
||||
+ .slice_act_y_qp_offset = 0,
|
||||
+ .slice_act_cb_qp_offset = 0,
|
||||
+ .slice_act_cr_qp_offset = 0,
|
||||
+ .slice_deblocking_filter_disabled_flag = sh->disable_deblocking_filter_flag,
|
||||
+ .slice_beta_offset_div2 = sh->beta_offset / 2,
|
||||
+ .slice_tc_offset_div2 = sh->tc_offset / 2,
|
||||
+ .slice_loop_filter_across_slices_enabled_flag = sh->slice_loop_filter_across_slices_enabled_flag,
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture timing SEI message */
|
||||
+ .pic_struct = h->sei.picture_timing.picture_struct,
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
|
||||
+ .num_rps_poc_st_curr_before = h->rps[ST_CURR_BEF].nb_refs,
|
||||
+ .num_rps_poc_st_curr_after = h->rps[ST_CURR_AFT].nb_refs,
|
||||
+ .num_rps_poc_lt_curr = h->rps[LT_CURR].nb_refs,
|
||||
+
|
||||
+ .slice_segment_addr = sh->slice_segment_addr,
|
||||
+ .first_slice_segment_in_pic_flag = sh->first_slice_in_pic_flag,
|
||||
+ };
|
||||
+
|
||||
+ for (i = 0; i < FF_ARRAY_ELEMS(h->DPB); i++) {
|
||||
+ const HEVCFrame *frame = &h->DPB[i];
|
||||
+ if (frame != pic && (frame->flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF))) {
|
||||
+ struct v4l2_hevc_dpb_entry *entry = &slice_params->dpb[entries++];
|
||||
+
|
||||
+ entry->timestamp = ff_v4l2_request_get_capture_timestamp(frame->frame);
|
||||
+ entry->rps = find_frame_rps_type(h, entry->timestamp);
|
||||
+ entry->field_pic = frame->frame->interlaced_frame;
|
||||
+
|
||||
+ /* TODO: Interleaved: Get the POC for each field. */
|
||||
+ entry->pic_order_cnt[0] = frame->poc;
|
||||
+ entry->pic_order_cnt[1] = frame->poc;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ slice_params->num_active_dpb_entries = entries;
|
||||
+
|
||||
+ if (sh->slice_type != HEVC_SLICE_I) {
|
||||
+ rpl = &h->ref->refPicList[0];
|
||||
+ for (i = 0; i < rpl->nb_refs; i++)
|
||||
+ slice_params->ref_idx_l0[i] = get_ref_pic_index(h, rpl->ref[i], slice_params);
|
||||
+ }
|
||||
+
|
||||
+ if (sh->slice_type == HEVC_SLICE_B) {
|
||||
+ rpl = &h->ref->refPicList[1];
|
||||
+ for (i = 0; i < rpl->nb_refs; i++)
|
||||
+ slice_params->ref_idx_l1[i] = get_ref_pic_index(h, rpl->ref[i], slice_params);
|
||||
+ }
|
||||
+
|
||||
+ v4l2_request_hevc_fill_pred_table(h, &slice_params->pred_weight_table);
|
||||
+
|
||||
+ slice_params->num_entry_point_offsets = sh->num_entry_point_offsets;
|
||||
+ if (slice_params->num_entry_point_offsets > 256) {
|
||||
+ slice_params->num_entry_point_offsets = 256;
|
||||
+ av_log(NULL, AV_LOG_ERROR, "%s: Currently only 256 entry points are supported, but slice has %d entry points.\n", __func__, sh->num_entry_point_offsets);
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < slice_params->num_entry_point_offsets; i++)
|
||||
+ slice_params->entry_point_offset_minus1[i] = sh->entry_point_offset[i] - 1;
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_hevc_start_frame(AVCodecContext *avctx,
|
||||
+ av_unused const uint8_t *buffer,
|
||||
+ av_unused uint32_t size)
|
||||
+{
|
||||
+ const HEVCContext *h = avctx->priv_data;
|
||||
+ const HEVCSPS *sps = h->ps.sps;
|
||||
+ const HEVCPPS *pps = h->ps.pps;
|
||||
+ const ScalingList *sl = pps->scaling_list_data_present_flag ?
|
||||
+ &pps->scaling_list :
|
||||
+ sps->scaling_list_enable_flag ?
|
||||
+ &sps->scaling_list : NULL;
|
||||
+ V4L2RequestControlsHEVC *controls = h->ref->hwaccel_picture_private;
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Sequence parameter set */
|
||||
+ controls->sps = (struct v4l2_ctrl_hevc_sps) {
|
||||
+ .chroma_format_idc = sps->chroma_format_idc,
|
||||
+ .separate_colour_plane_flag = sps->separate_colour_plane_flag,
|
||||
+ .pic_width_in_luma_samples = sps->width,
|
||||
+ .pic_height_in_luma_samples = sps->height,
|
||||
+ .bit_depth_luma_minus8 = sps->bit_depth - 8,
|
||||
+ .bit_depth_chroma_minus8 = sps->bit_depth - 8,
|
||||
+ .log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4,
|
||||
+ .sps_max_dec_pic_buffering_minus1 = sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering - 1,
|
||||
+ .sps_max_num_reorder_pics = sps->temporal_layer[sps->max_sub_layers - 1].num_reorder_pics,
|
||||
+ .sps_max_latency_increase_plus1 = sps->temporal_layer[sps->max_sub_layers - 1].max_latency_increase + 1,
|
||||
+ .log2_min_luma_coding_block_size_minus3 = sps->log2_min_cb_size - 3,
|
||||
+ .log2_diff_max_min_luma_coding_block_size = sps->log2_diff_max_min_coding_block_size,
|
||||
+ .log2_min_luma_transform_block_size_minus2 = sps->log2_min_tb_size - 2,
|
||||
+ .log2_diff_max_min_luma_transform_block_size = sps->log2_max_trafo_size - sps->log2_min_tb_size,
|
||||
+ .max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter,
|
||||
+ .max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra,
|
||||
+ .scaling_list_enabled_flag = sps->scaling_list_enable_flag,
|
||||
+ .amp_enabled_flag = sps->amp_enabled_flag,
|
||||
+ .sample_adaptive_offset_enabled_flag = sps->sao_enabled,
|
||||
+ .pcm_enabled_flag = sps->pcm_enabled_flag,
|
||||
+ .pcm_sample_bit_depth_luma_minus1 = sps->pcm.bit_depth - 1,
|
||||
+ .pcm_sample_bit_depth_chroma_minus1 = sps->pcm.bit_depth_chroma - 1,
|
||||
+ .log2_min_pcm_luma_coding_block_size_minus3 = sps->pcm.log2_min_pcm_cb_size - 3,
|
||||
+ .log2_diff_max_min_pcm_luma_coding_block_size = sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size,
|
||||
+ .pcm_loop_filter_disabled_flag = sps->pcm.loop_filter_disable_flag,
|
||||
+ .num_short_term_ref_pic_sets = sps->nb_st_rps,
|
||||
+ .long_term_ref_pics_present_flag = sps->long_term_ref_pics_present_flag,
|
||||
+ .num_long_term_ref_pics_sps = sps->num_long_term_ref_pics_sps,
|
||||
+ .sps_temporal_mvp_enabled_flag = sps->sps_temporal_mvp_enabled_flag,
|
||||
+ .strong_intra_smoothing_enabled_flag = sps->sps_strong_intra_smoothing_enable_flag,
|
||||
+ };
|
||||
+
|
||||
+ if (sl) {
|
||||
+ for (int i = 0; i < 6; i++) {
|
||||
+ for (int j = 0; j < 16; j++)
|
||||
+ controls->scaling_matrix.scaling_list_4x4[i][j] = sl->sl[0][i][j];
|
||||
+ for (int j = 0; j < 64; j++) {
|
||||
+ controls->scaling_matrix.scaling_list_8x8[i][j] = sl->sl[1][i][j];
|
||||
+ controls->scaling_matrix.scaling_list_16x16[i][j] = sl->sl[2][i][j];
|
||||
+ if (i < 2)
|
||||
+ controls->scaling_matrix.scaling_list_32x32[i][j] = sl->sl[3][i * 3][j];
|
||||
+ }
|
||||
+ controls->scaling_matrix.scaling_list_dc_coef_16x16[i] = sl->sl_dc[0][i];
|
||||
+ if (i < 2)
|
||||
+ controls->scaling_matrix.scaling_list_dc_coef_32x32[i] = sl->sl_dc[1][i * 3];
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture parameter set */
|
||||
+ controls->pps = (struct v4l2_ctrl_hevc_pps) {
|
||||
+ .dependent_slice_segment_flag = pps->dependent_slice_segments_enabled_flag,
|
||||
+ .output_flag_present_flag = pps->output_flag_present_flag,
|
||||
+ .num_extra_slice_header_bits = pps->num_extra_slice_header_bits,
|
||||
+ .sign_data_hiding_enabled_flag = pps->sign_data_hiding_flag,
|
||||
+ .cabac_init_present_flag = pps->cabac_init_present_flag,
|
||||
+ .init_qp_minus26 = pps->pic_init_qp_minus26,
|
||||
+ .constrained_intra_pred_flag = pps->constrained_intra_pred_flag,
|
||||
+ .transform_skip_enabled_flag = pps->transform_skip_enabled_flag,
|
||||
+ .cu_qp_delta_enabled_flag = pps->cu_qp_delta_enabled_flag,
|
||||
+ .diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth,
|
||||
+ .pps_cb_qp_offset = pps->cb_qp_offset,
|
||||
+ .pps_cr_qp_offset = pps->cr_qp_offset,
|
||||
+ .pps_slice_chroma_qp_offsets_present_flag = pps->pic_slice_level_chroma_qp_offsets_present_flag,
|
||||
+ .weighted_pred_flag = pps->weighted_pred_flag,
|
||||
+ .weighted_bipred_flag = pps->weighted_bipred_flag,
|
||||
+ .transquant_bypass_enabled_flag = pps->transquant_bypass_enable_flag,
|
||||
+ .tiles_enabled_flag = pps->tiles_enabled_flag,
|
||||
+ .entropy_coding_sync_enabled_flag = pps->entropy_coding_sync_enabled_flag,
|
||||
+ .loop_filter_across_tiles_enabled_flag = pps->loop_filter_across_tiles_enabled_flag,
|
||||
+ .pps_loop_filter_across_slices_enabled_flag = pps->seq_loop_filter_across_slices_enabled_flag,
|
||||
+ .deblocking_filter_override_enabled_flag = pps->deblocking_filter_override_enabled_flag,
|
||||
+ .pps_disable_deblocking_filter_flag = pps->disable_dbf,
|
||||
+ .pps_beta_offset_div2 = pps->beta_offset / 2,
|
||||
+ .pps_tc_offset_div2 = pps->tc_offset / 2,
|
||||
+ .lists_modification_present_flag = pps->lists_modification_present_flag,
|
||||
+ .log2_parallel_merge_level_minus2 = pps->log2_parallel_merge_level - 2,
|
||||
+ .slice_segment_header_extension_present_flag = pps->slice_header_extension_present_flag,
|
||||
+ .scaling_list_enable_flag = pps->scaling_list_data_present_flag, // pps_scaling_list_data_present_flag
|
||||
+ };
|
||||
+
|
||||
+ if (pps->tiles_enabled_flag) {
|
||||
+ controls->pps.num_tile_columns_minus1 = pps->num_tile_columns - 1;
|
||||
+ controls->pps.num_tile_rows_minus1 = pps->num_tile_rows - 1;
|
||||
+
|
||||
+ av_log(avctx, AV_LOG_DEBUG, "%s: avctx=%p tiles_enabled_flag=%d num_tile_columns=%d num_tile_rows=%d\n", __func__, avctx, pps->tiles_enabled_flag, pps->num_tile_columns, pps->num_tile_rows);
|
||||
+
|
||||
+ for (int i = 0; i < pps->num_tile_columns; i++)
|
||||
+ controls->pps.column_width_minus1[i] = pps->column_width[i] - 1;
|
||||
+
|
||||
+ for (int i = 0; i < pps->num_tile_rows; i++)
|
||||
+ controls->pps.row_height_minus1[i] = pps->row_height[i] - 1;
|
||||
+ }
|
||||
+
|
||||
+ return ff_v4l2_request_reset_frame(avctx, h->ref->frame);
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_hevc_end_frame(AVCodecContext *avctx)
|
||||
+{
|
||||
+ const HEVCContext *h = avctx->priv_data;
|
||||
+ V4L2RequestControlsHEVC *controls = h->ref->hwaccel_picture_private;
|
||||
+ V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)h->ref->frame->data[0];
|
||||
+
|
||||
+ struct v4l2_ext_control control[] = {
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_HEVC_SPS,
|
||||
+ .ptr = &controls->sps,
|
||||
+ .size = sizeof(controls->sps),
|
||||
+ },
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_HEVC_PPS,
|
||||
+ .ptr = &controls->pps,
|
||||
+ .size = sizeof(controls->pps),
|
||||
+ },
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX,
|
||||
+ .ptr = &controls->scaling_matrix,
|
||||
+ .size = sizeof(controls->scaling_matrix),
|
||||
+ },
|
||||
+ {
|
||||
+ .id = V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS,
|
||||
+ .ptr = &controls->slice_params,
|
||||
+ .size = sizeof(controls->slice_params),
|
||||
+ },
|
||||
+ };
|
||||
+
|
||||
+ controls->slice_params.bit_size = req->output.used * 8;
|
||||
+
|
||||
+ return ff_v4l2_request_decode_frame(avctx, h->ref->frame, control, FF_ARRAY_ELEMS(control));
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
|
||||
+{
|
||||
+ const HEVCContext *h = avctx->priv_data;
|
||||
+ V4L2RequestControlsHEVC *controls = h->ref->hwaccel_picture_private;
|
||||
+ V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)h->ref->frame->data[0];
|
||||
+
|
||||
+ // HACK: trigger decode per slice
|
||||
+ if (req->output.used) {
|
||||
+ v4l2_request_hevc_end_frame(avctx);
|
||||
+ ff_v4l2_request_reset_frame(avctx, h->ref->frame);
|
||||
+ }
|
||||
+
|
||||
+ v4l2_request_hevc_fill_slice_params(h, &controls->slice_params);
|
||||
+
|
||||
+ return ff_v4l2_request_append_output_buffer(avctx, h->ref->frame, buffer, size);
|
||||
+}
|
||||
+
|
||||
+static int v4l2_request_hevc_init(AVCodecContext *avctx)
|
||||
+{
|
||||
+ return ff_v4l2_request_init(avctx, V4L2_PIX_FMT_HEVC_SLICE, 3 * 1024 * 1024, NULL, 0);
|
||||
+}
|
||||
+
|
||||
+const AVHWAccel ff_hevc_v4l2request_hwaccel = {
|
||||
+ .name = "hevc_v4l2request",
|
||||
+ .type = AVMEDIA_TYPE_VIDEO,
|
||||
+ .id = AV_CODEC_ID_HEVC,
|
||||
+ .pix_fmt = AV_PIX_FMT_DRM_PRIME,
|
||||
+ .start_frame = v4l2_request_hevc_start_frame,
|
||||
+ .decode_slice = v4l2_request_hevc_decode_slice,
|
||||
+ .end_frame = v4l2_request_hevc_end_frame,
|
||||
+ .frame_priv_data_size = sizeof(V4L2RequestControlsHEVC),
|
||||
+ .init = v4l2_request_hevc_init,
|
||||
+ .uninit = ff_v4l2_request_uninit,
|
||||
+ .priv_data_size = sizeof(V4L2RequestContext),
|
||||
+ .frame_params = ff_v4l2_request_frame_params,
|
||||
+ .caps_internal = HWACCEL_CAP_ASYNC_SAFE,
|
||||
+};
|
||||
--
|
||||
2.21.0
|
||||
|
@ -0,0 +1,580 @@
|
||||
From d80cbc949372d6f19dc8c3b5f97b336864bd259c Mon Sep 17 00:00:00 2001
|
||||
From: Jernej Skrabec <jernej.skrabec@siol.net>
|
||||
Date: Thu, 14 Feb 2019 23:20:05 +0100
|
||||
Subject: [PATCH 6/6] Add and use private linux headers for V4L2 request API
|
||||
ctrls
|
||||
|
||||
---
|
||||
configure | 4 +-
|
||||
libavcodec/h264-ctrls.h | 197 +++++++++++++++++++++++++++++++
|
||||
libavcodec/hevc-ctrls.h | 203 ++++++++++++++++++++++++++++++++
|
||||
libavcodec/mpeg2-ctrls.h | 82 +++++++++++++
|
||||
libavcodec/v4l2_request_h264.c | 1 +
|
||||
libavcodec/v4l2_request_hevc.c | 1 +
|
||||
libavcodec/v4l2_request_mpeg2.c | 1 +
|
||||
7 files changed, 487 insertions(+), 2 deletions(-)
|
||||
create mode 100644 libavcodec/h264-ctrls.h
|
||||
create mode 100644 libavcodec/hevc-ctrls.h
|
||||
create mode 100644 libavcodec/mpeg2-ctrls.h
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 2d39cecbdf..23b1e57882 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -2804,7 +2804,7 @@ h264_dxva2_hwaccel_deps="dxva2"
|
||||
h264_dxva2_hwaccel_select="h264_decoder"
|
||||
h264_nvdec_hwaccel_deps="nvdec"
|
||||
h264_nvdec_hwaccel_select="h264_decoder"
|
||||
-h264_v4l2request_hwaccel_deps="v4l2_request h264_v4l2_request"
|
||||
+h264_v4l2request_hwaccel_deps="v4l2_request"
|
||||
h264_v4l2request_hwaccel_select="h264_decoder"
|
||||
h264_vaapi_hwaccel_deps="vaapi"
|
||||
h264_vaapi_hwaccel_select="h264_decoder"
|
||||
@@ -2820,7 +2820,7 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
|
||||
hevc_dxva2_hwaccel_select="hevc_decoder"
|
||||
hevc_nvdec_hwaccel_deps="nvdec"
|
||||
hevc_nvdec_hwaccel_select="hevc_decoder"
|
||||
-hevc_v4l2request_hwaccel_deps="v4l2_request hevc_v4l2_request"
|
||||
+hevc_v4l2request_hwaccel_deps="v4l2_request"
|
||||
hevc_v4l2request_hwaccel_select="hevc_decoder"
|
||||
hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
|
||||
hevc_vaapi_hwaccel_select="hevc_decoder"
|
||||
diff --git a/libavcodec/h264-ctrls.h b/libavcodec/h264-ctrls.h
|
||||
new file mode 100644
|
||||
index 0000000000..e1404d78d6
|
||||
--- /dev/null
|
||||
+++ b/libavcodec/h264-ctrls.h
|
||||
@@ -0,0 +1,197 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+/*
|
||||
+ * These are the H.264 state controls for use with stateless H.264
|
||||
+ * codec drivers.
|
||||
+ *
|
||||
+ * It turns out that these structs are not stable yet and will undergo
|
||||
+ * more changes. So keep them private until they are stable and ready to
|
||||
+ * become part of the official public API.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _H264_CTRLS_H_
|
||||
+#define _H264_CTRLS_H_
|
||||
+
|
||||
+#include <linux/videodev2.h>
|
||||
+
|
||||
+/* Our pixel format isn't stable at the moment */
|
||||
+#define V4L2_PIX_FMT_H264_SLICE_RAW v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */
|
||||
+
|
||||
+/*
|
||||
+ * This is put insanely high to avoid conflicting with controls that
|
||||
+ * would be added during the phase where those controls are not
|
||||
+ * stable. It should be fixed eventually.
|
||||
+ */
|
||||
+#define V4L2_CID_MPEG_VIDEO_H264_SPS (V4L2_CID_MPEG_BASE+1000)
|
||||
+#define V4L2_CID_MPEG_VIDEO_H264_PPS (V4L2_CID_MPEG_BASE+1001)
|
||||
+#define V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX (V4L2_CID_MPEG_BASE+1002)
|
||||
+#define V4L2_CID_MPEG_VIDEO_H264_SLICE_PARAMS (V4L2_CID_MPEG_BASE+1003)
|
||||
+#define V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS (V4L2_CID_MPEG_BASE+1004)
|
||||
+
|
||||
+/* enum v4l2_ctrl_type type values */
|
||||
+#define V4L2_CTRL_TYPE_H264_SPS 0x0110
|
||||
+#define V4L2_CTRL_TYPE_H264_PPS 0x0111
|
||||
+#define V4L2_CTRL_TYPE_H264_SCALING_MATRIX 0x0112
|
||||
+#define V4L2_CTRL_TYPE_H264_SLICE_PARAMS 0x0113
|
||||
+#define V4L2_CTRL_TYPE_H264_DECODE_PARAMS 0x0114
|
||||
+
|
||||
+#define V4L2_H264_SPS_CONSTRAINT_SET0_FLAG 0x01
|
||||
+#define V4L2_H264_SPS_CONSTRAINT_SET1_FLAG 0x02
|
||||
+#define V4L2_H264_SPS_CONSTRAINT_SET2_FLAG 0x04
|
||||
+#define V4L2_H264_SPS_CONSTRAINT_SET3_FLAG 0x08
|
||||
+#define V4L2_H264_SPS_CONSTRAINT_SET4_FLAG 0x10
|
||||
+#define V4L2_H264_SPS_CONSTRAINT_SET5_FLAG 0x20
|
||||
+
|
||||
+#define V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE 0x01
|
||||
+#define V4L2_H264_SPS_FLAG_QPPRIME_Y_ZERO_TRANSFORM_BYPASS 0x02
|
||||
+#define V4L2_H264_SPS_FLAG_DELTA_PIC_ORDER_ALWAYS_ZERO 0x04
|
||||
+#define V4L2_H264_SPS_FLAG_GAPS_IN_FRAME_NUM_VALUE_ALLOWED 0x08
|
||||
+#define V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY 0x10
|
||||
+#define V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD 0x20
|
||||
+#define V4L2_H264_SPS_FLAG_DIRECT_8X8_INFERENCE 0x40
|
||||
+
|
||||
+struct v4l2_ctrl_h264_sps {
|
||||
+ __u8 profile_idc;
|
||||
+ __u8 constraint_set_flags;
|
||||
+ __u8 level_idc;
|
||||
+ __u8 seq_parameter_set_id;
|
||||
+ __u8 chroma_format_idc;
|
||||
+ __u8 bit_depth_luma_minus8;
|
||||
+ __u8 bit_depth_chroma_minus8;
|
||||
+ __u8 log2_max_frame_num_minus4;
|
||||
+ __u8 pic_order_cnt_type;
|
||||
+ __u8 log2_max_pic_order_cnt_lsb_minus4;
|
||||
+ __u8 max_num_ref_frames;
|
||||
+ __u8 num_ref_frames_in_pic_order_cnt_cycle;
|
||||
+ __s32 offset_for_ref_frame[255];
|
||||
+ __s32 offset_for_non_ref_pic;
|
||||
+ __s32 offset_for_top_to_bottom_field;
|
||||
+ __u16 pic_width_in_mbs_minus1;
|
||||
+ __u16 pic_height_in_map_units_minus1;
|
||||
+ __u32 flags;
|
||||
+};
|
||||
+
|
||||
+#define V4L2_H264_PPS_FLAG_ENTROPY_CODING_MODE 0x0001
|
||||
+#define V4L2_H264_PPS_FLAG_BOTTOM_FIELD_PIC_ORDER_IN_FRAME_PRESENT 0x0002
|
||||
+#define V4L2_H264_PPS_FLAG_WEIGHTED_PRED 0x0004
|
||||
+#define V4L2_H264_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT 0x0008
|
||||
+#define V4L2_H264_PPS_FLAG_CONSTRAINED_INTRA_PRED 0x0010
|
||||
+#define V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT 0x0020
|
||||
+#define V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE 0x0040
|
||||
+#define V4L2_H264_PPS_FLAG_PIC_SCALING_MATRIX_PRESENT 0x0080
|
||||
+
|
||||
+struct v4l2_ctrl_h264_pps {
|
||||
+ __u8 pic_parameter_set_id;
|
||||
+ __u8 seq_parameter_set_id;
|
||||
+ __u8 num_slice_groups_minus1;
|
||||
+ __u8 num_ref_idx_l0_default_active_minus1;
|
||||
+ __u8 num_ref_idx_l1_default_active_minus1;
|
||||
+ __u8 weighted_bipred_idc;
|
||||
+ __s8 pic_init_qp_minus26;
|
||||
+ __s8 pic_init_qs_minus26;
|
||||
+ __s8 chroma_qp_index_offset;
|
||||
+ __s8 second_chroma_qp_index_offset;
|
||||
+ __u16 flags;
|
||||
+};
|
||||
+
|
||||
+struct v4l2_ctrl_h264_scaling_matrix {
|
||||
+ __u8 scaling_list_4x4[6][16];
|
||||
+ __u8 scaling_list_8x8[6][64];
|
||||
+};
|
||||
+
|
||||
+struct v4l2_h264_weight_factors {
|
||||
+ __s16 luma_weight[32];
|
||||
+ __s16 luma_offset[32];
|
||||
+ __s16 chroma_weight[32][2];
|
||||
+ __s16 chroma_offset[32][2];
|
||||
+};
|
||||
+
|
||||
+struct v4l2_h264_pred_weight_table {
|
||||
+ __u16 luma_log2_weight_denom;
|
||||
+ __u16 chroma_log2_weight_denom;
|
||||
+ struct v4l2_h264_weight_factors weight_factors[2];
|
||||
+};
|
||||
+
|
||||
+#define V4L2_H264_SLICE_TYPE_P 0
|
||||
+#define V4L2_H264_SLICE_TYPE_B 1
|
||||
+#define V4L2_H264_SLICE_TYPE_I 2
|
||||
+#define V4L2_H264_SLICE_TYPE_SP 3
|
||||
+#define V4L2_H264_SLICE_TYPE_SI 4
|
||||
+
|
||||
+#define V4L2_H264_SLICE_FLAG_FIELD_PIC 0x01
|
||||
+#define V4L2_H264_SLICE_FLAG_BOTTOM_FIELD 0x02
|
||||
+#define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED 0x04
|
||||
+#define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH 0x08
|
||||
+
|
||||
+struct v4l2_ctrl_h264_slice_params {
|
||||
+ /* Size in bytes, including header */
|
||||
+ __u32 size;
|
||||
+ /* Offset in bits to slice_data() from the beginning of this slice. */
|
||||
+ __u32 header_bit_size;
|
||||
+
|
||||
+ __u16 first_mb_in_slice;
|
||||
+ __u8 slice_type;
|
||||
+ __u8 pic_parameter_set_id;
|
||||
+ __u8 colour_plane_id;
|
||||
+ __u8 redundant_pic_cnt;
|
||||
+ __u16 frame_num;
|
||||
+ __u16 idr_pic_id;
|
||||
+ __u16 pic_order_cnt_lsb;
|
||||
+ __s32 delta_pic_order_cnt_bottom;
|
||||
+ __s32 delta_pic_order_cnt0;
|
||||
+ __s32 delta_pic_order_cnt1;
|
||||
+
|
||||
+ struct v4l2_h264_pred_weight_table pred_weight_table;
|
||||
+ /* Size in bits of dec_ref_pic_marking() syntax element. */
|
||||
+ __u32 dec_ref_pic_marking_bit_size;
|
||||
+ /* Size in bits of pic order count syntax. */
|
||||
+ __u32 pic_order_cnt_bit_size;
|
||||
+
|
||||
+ __u8 cabac_init_idc;
|
||||
+ __s8 slice_qp_delta;
|
||||
+ __s8 slice_qs_delta;
|
||||
+ __u8 disable_deblocking_filter_idc;
|
||||
+ __s8 slice_alpha_c0_offset_div2;
|
||||
+ __s8 slice_beta_offset_div2;
|
||||
+ __u8 num_ref_idx_l0_active_minus1;
|
||||
+ __u8 num_ref_idx_l1_active_minus1;
|
||||
+ __u32 slice_group_change_cycle;
|
||||
+
|
||||
+ /*
|
||||
+ * Entries on each list are indices into
|
||||
+ * v4l2_ctrl_h264_decode_params.dpb[].
|
||||
+ */
|
||||
+ __u8 ref_pic_list0[32];
|
||||
+ __u8 ref_pic_list1[32];
|
||||
+
|
||||
+ __u32 flags;
|
||||
+};
|
||||
+
|
||||
+#define V4L2_H264_DPB_ENTRY_FLAG_VALID 0x01
|
||||
+#define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x02
|
||||
+#define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x04
|
||||
+
|
||||
+struct v4l2_h264_dpb_entry {
|
||||
+ __u64 reference_ts;
|
||||
+ __u16 frame_num;
|
||||
+ __u16 pic_num;
|
||||
+ /* Note that field is indicated by v4l2_buffer.field */
|
||||
+ __s32 top_field_order_cnt;
|
||||
+ __s32 bottom_field_order_cnt;
|
||||
+ __u32 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */
|
||||
+};
|
||||
+
|
||||
+#define V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC 0x01
|
||||
+
|
||||
+struct v4l2_ctrl_h264_decode_params {
|
||||
+ struct v4l2_h264_dpb_entry dpb[16];
|
||||
+ __u16 num_slices;
|
||||
+ __u16 nal_ref_idc;
|
||||
+ __u8 ref_pic_list_p0[32];
|
||||
+ __u8 ref_pic_list_b0[32];
|
||||
+ __u8 ref_pic_list_b1[32];
|
||||
+ __s32 top_field_order_cnt;
|
||||
+ __s32 bottom_field_order_cnt;
|
||||
+ __u32 flags; /* V4L2_H264_DECODE_PARAM_FLAG_* */
|
||||
+};
|
||||
+
|
||||
+#endif
|
||||
diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h
|
||||
new file mode 100644
|
||||
index 0000000000..eee4479c7a
|
||||
--- /dev/null
|
||||
+++ b/libavcodec/hevc-ctrls.h
|
||||
@@ -0,0 +1,203 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+/*
|
||||
+ * These are the HEVC state controls for use with stateless HEVC
|
||||
+ * codec drivers.
|
||||
+ *
|
||||
+ * It turns out that these structs are not stable yet and will undergo
|
||||
+ * more changes. So keep them private until they are stable and ready to
|
||||
+ * become part of the official public API.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _HEVC_CTRLS_H_
|
||||
+#define _HEVC_CTRLS_H_
|
||||
+
|
||||
+#include <linux/videodev2.h>
|
||||
+
|
||||
+/* The pixel format isn't stable at the moment and will likely be renamed. */
|
||||
+#define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5') /* HEVC parsed slices */
|
||||
+
|
||||
+#define V4L2_CID_MPEG_VIDEO_HEVC_SPS (V4L2_CID_MPEG_BASE + 1008)
|
||||
+#define V4L2_CID_MPEG_VIDEO_HEVC_PPS (V4L2_CID_MPEG_BASE + 1009)
|
||||
+#define V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS (V4L2_CID_MPEG_BASE + 1010)
|
||||
+#define V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX (V4L2_CID_MPEG_BASE + 1011)
|
||||
+
|
||||
+/* enum v4l2_ctrl_type type values */
|
||||
+#define V4L2_CTRL_TYPE_HEVC_SPS 0x0120
|
||||
+#define V4L2_CTRL_TYPE_HEVC_PPS 0x0121
|
||||
+#define V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS 0x0122
|
||||
+#define V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX 0x0123
|
||||
+
|
||||
+#define V4L2_HEVC_SLICE_TYPE_B 0
|
||||
+#define V4L2_HEVC_SLICE_TYPE_P 1
|
||||
+#define V4L2_HEVC_SLICE_TYPE_I 2
|
||||
+
|
||||
+/* The controls are not stable at the moment and will likely be reworked. */
|
||||
+struct v4l2_ctrl_hevc_sps {
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Sequence parameter set */
|
||||
+ __u8 chroma_format_idc;
|
||||
+ __u8 separate_colour_plane_flag;
|
||||
+ __u16 pic_width_in_luma_samples;
|
||||
+ __u16 pic_height_in_luma_samples;
|
||||
+ __u8 bit_depth_luma_minus8;
|
||||
+ __u8 bit_depth_chroma_minus8;
|
||||
+ __u8 log2_max_pic_order_cnt_lsb_minus4;
|
||||
+ __u8 sps_max_dec_pic_buffering_minus1;
|
||||
+ __u8 sps_max_num_reorder_pics;
|
||||
+ __u8 sps_max_latency_increase_plus1;
|
||||
+ __u8 log2_min_luma_coding_block_size_minus3;
|
||||
+ __u8 log2_diff_max_min_luma_coding_block_size;
|
||||
+ __u8 log2_min_luma_transform_block_size_minus2;
|
||||
+ __u8 log2_diff_max_min_luma_transform_block_size;
|
||||
+ __u8 max_transform_hierarchy_depth_inter;
|
||||
+ __u8 max_transform_hierarchy_depth_intra;
|
||||
+ __u8 scaling_list_enabled_flag;
|
||||
+ __u8 amp_enabled_flag;
|
||||
+ __u8 sample_adaptive_offset_enabled_flag;
|
||||
+ __u8 pcm_enabled_flag;
|
||||
+ __u8 pcm_sample_bit_depth_luma_minus1;
|
||||
+ __u8 pcm_sample_bit_depth_chroma_minus1;
|
||||
+ __u8 log2_min_pcm_luma_coding_block_size_minus3;
|
||||
+ __u8 log2_diff_max_min_pcm_luma_coding_block_size;
|
||||
+ __u8 pcm_loop_filter_disabled_flag;
|
||||
+ __u8 num_short_term_ref_pic_sets;
|
||||
+ __u8 long_term_ref_pics_present_flag;
|
||||
+ __u8 num_long_term_ref_pics_sps;
|
||||
+ __u8 sps_temporal_mvp_enabled_flag;
|
||||
+ __u8 strong_intra_smoothing_enabled_flag;
|
||||
+};
|
||||
+
|
||||
+struct v4l2_ctrl_hevc_pps {
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture parameter set */
|
||||
+ __u8 dependent_slice_segment_flag;
|
||||
+ __u8 output_flag_present_flag;
|
||||
+ __u8 num_extra_slice_header_bits;
|
||||
+ __u8 sign_data_hiding_enabled_flag;
|
||||
+ __u8 cabac_init_present_flag;
|
||||
+ __s8 init_qp_minus26;
|
||||
+ __u8 constrained_intra_pred_flag;
|
||||
+ __u8 transform_skip_enabled_flag;
|
||||
+ __u8 cu_qp_delta_enabled_flag;
|
||||
+ __u8 diff_cu_qp_delta_depth;
|
||||
+ __s8 pps_cb_qp_offset;
|
||||
+ __s8 pps_cr_qp_offset;
|
||||
+ __u8 pps_slice_chroma_qp_offsets_present_flag;
|
||||
+ __u8 weighted_pred_flag;
|
||||
+ __u8 weighted_bipred_flag;
|
||||
+ __u8 transquant_bypass_enabled_flag;
|
||||
+ __u8 tiles_enabled_flag;
|
||||
+ __u8 entropy_coding_sync_enabled_flag;
|
||||
+ __u8 num_tile_columns_minus1;
|
||||
+ __u8 num_tile_rows_minus1;
|
||||
+ __u8 column_width_minus1[20];
|
||||
+ __u8 row_height_minus1[22];
|
||||
+ __u8 loop_filter_across_tiles_enabled_flag;
|
||||
+ __u8 pps_loop_filter_across_slices_enabled_flag;
|
||||
+ __u8 deblocking_filter_override_enabled_flag;
|
||||
+ __u8 pps_disable_deblocking_filter_flag;
|
||||
+ __s8 pps_beta_offset_div2;
|
||||
+ __s8 pps_tc_offset_div2;
|
||||
+ __u8 lists_modification_present_flag;
|
||||
+ __u8 log2_parallel_merge_level_minus2;
|
||||
+ __u8 slice_segment_header_extension_present_flag;
|
||||
+ __u8 scaling_list_enable_flag;
|
||||
+};
|
||||
+
|
||||
+#define V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_BEFORE 0x01
|
||||
+#define V4L2_HEVC_DPB_ENTRY_RPS_ST_CURR_AFTER 0x02
|
||||
+#define V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR 0x03
|
||||
+
|
||||
+#define V4L2_HEVC_DPB_ENTRIES_NUM_MAX 16
|
||||
+
|
||||
+struct v4l2_hevc_dpb_entry {
|
||||
+ __u64 timestamp;
|
||||
+ __u8 rps;
|
||||
+ __u8 field_pic;
|
||||
+ __u16 pic_order_cnt[2];
|
||||
+ __u8 padding[2];
|
||||
+};
|
||||
+
|
||||
+struct v4l2_hevc_pred_weight_table {
|
||||
+ __u8 luma_log2_weight_denom;
|
||||
+ __s8 delta_chroma_log2_weight_denom;
|
||||
+
|
||||
+ __s8 delta_luma_weight_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
|
||||
+ __s8 luma_offset_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
|
||||
+ __s8 delta_chroma_weight_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
|
||||
+ __s8 chroma_offset_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
|
||||
+
|
||||
+ __s8 delta_luma_weight_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
|
||||
+ __s8 luma_offset_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
|
||||
+ __s8 delta_chroma_weight_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
|
||||
+ __s8 chroma_offset_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
|
||||
+
|
||||
+ __u8 padding[2];
|
||||
+};
|
||||
+
|
||||
+struct v4l2_ctrl_hevc_slice_params {
|
||||
+ __u32 bit_size;
|
||||
+ __u32 data_bit_offset;
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */
|
||||
+ __u8 nal_unit_type;
|
||||
+ __u8 nuh_temporal_id_plus1;
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
|
||||
+ __u8 slice_type;
|
||||
+ __u8 colour_plane_id;
|
||||
+ __u16 slice_pic_order_cnt;
|
||||
+ __u8 slice_sao_luma_flag;
|
||||
+ __u8 slice_sao_chroma_flag;
|
||||
+ __u8 slice_temporal_mvp_enabled_flag;
|
||||
+ __u8 num_ref_idx_l0_active_minus1;
|
||||
+ __u8 num_ref_idx_l1_active_minus1;
|
||||
+ __u8 mvd_l1_zero_flag;
|
||||
+ __u8 cabac_init_flag;
|
||||
+ __u8 collocated_from_l0_flag;
|
||||
+ __u8 collocated_ref_idx;
|
||||
+ __u8 five_minus_max_num_merge_cand;
|
||||
+ __u8 use_integer_mv_flag;
|
||||
+ __s8 slice_qp_delta;
|
||||
+ __s8 slice_cb_qp_offset;
|
||||
+ __s8 slice_cr_qp_offset;
|
||||
+ __s8 slice_act_y_qp_offset;
|
||||
+ __s8 slice_act_cb_qp_offset;
|
||||
+ __s8 slice_act_cr_qp_offset;
|
||||
+ __u8 slice_deblocking_filter_disabled_flag;
|
||||
+ __s8 slice_beta_offset_div2;
|
||||
+ __s8 slice_tc_offset_div2;
|
||||
+ __u8 slice_loop_filter_across_slices_enabled_flag;
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture timing SEI message */
|
||||
+ __u8 pic_struct;
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
|
||||
+ struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
|
||||
+ __u8 num_active_dpb_entries;
|
||||
+ __u8 ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
|
||||
+ __u8 ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
|
||||
+
|
||||
+ __u8 num_rps_poc_st_curr_before;
|
||||
+ __u8 num_rps_poc_st_curr_after;
|
||||
+ __u8 num_rps_poc_lt_curr;
|
||||
+
|
||||
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Weighted prediction parameter */
|
||||
+ struct v4l2_hevc_pred_weight_table pred_weight_table;
|
||||
+
|
||||
+ __u32 slice_segment_addr;
|
||||
+ __u32 num_entry_point_offsets;
|
||||
+ __u32 entry_point_offset_minus1[256];
|
||||
+ __u8 first_slice_segment_in_pic_flag;
|
||||
+
|
||||
+ __u8 padding;
|
||||
+};
|
||||
+
|
||||
+struct v4l2_ctrl_hevc_scaling_matrix {
|
||||
+ __u8 scaling_list_4x4[6][16];
|
||||
+ __u8 scaling_list_8x8[6][64];
|
||||
+ __u8 scaling_list_16x16[6][64];
|
||||
+ __u8 scaling_list_32x32[2][64];
|
||||
+ __u8 scaling_list_dc_coef_16x16[6];
|
||||
+ __u8 scaling_list_dc_coef_32x32[2];
|
||||
+};
|
||||
+
|
||||
+#endif
|
||||
diff --git a/libavcodec/mpeg2-ctrls.h b/libavcodec/mpeg2-ctrls.h
|
||||
new file mode 100644
|
||||
index 0000000000..6601455b3d
|
||||
--- /dev/null
|
||||
+++ b/libavcodec/mpeg2-ctrls.h
|
||||
@@ -0,0 +1,82 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+/*
|
||||
+ * These are the MPEG2 state controls for use with stateless MPEG-2
|
||||
+ * codec drivers.
|
||||
+ *
|
||||
+ * It turns out that these structs are not stable yet and will undergo
|
||||
+ * more changes. So keep them private until they are stable and ready to
|
||||
+ * become part of the official public API.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _MPEG2_CTRLS_H_
|
||||
+#define _MPEG2_CTRLS_H_
|
||||
+
|
||||
+#define V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS (V4L2_CID_MPEG_BASE+250)
|
||||
+#define V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION (V4L2_CID_MPEG_BASE+251)
|
||||
+
|
||||
+/* enum v4l2_ctrl_type type values */
|
||||
+#define V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS 0x0103
|
||||
+#define V4L2_CTRL_TYPE_MPEG2_QUANTIZATION 0x0104
|
||||
+
|
||||
+#define V4L2_MPEG2_PICTURE_CODING_TYPE_I 1
|
||||
+#define V4L2_MPEG2_PICTURE_CODING_TYPE_P 2
|
||||
+#define V4L2_MPEG2_PICTURE_CODING_TYPE_B 3
|
||||
+#define V4L2_MPEG2_PICTURE_CODING_TYPE_D 4
|
||||
+
|
||||
+struct v4l2_mpeg2_sequence {
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence header */
|
||||
+ __u16 horizontal_size;
|
||||
+ __u16 vertical_size;
|
||||
+ __u32 vbv_buffer_size;
|
||||
+
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */
|
||||
+ __u16 profile_and_level_indication;
|
||||
+ __u8 progressive_sequence;
|
||||
+ __u8 chroma_format;
|
||||
+};
|
||||
+
|
||||
+struct v4l2_mpeg2_picture {
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture header */
|
||||
+ __u8 picture_coding_type;
|
||||
+
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Picture coding extension */
|
||||
+ __u8 f_code[2][2];
|
||||
+ __u8 intra_dc_precision;
|
||||
+ __u8 picture_structure;
|
||||
+ __u8 top_field_first;
|
||||
+ __u8 frame_pred_frame_dct;
|
||||
+ __u8 concealment_motion_vectors;
|
||||
+ __u8 q_scale_type;
|
||||
+ __u8 intra_vlc_format;
|
||||
+ __u8 alternate_scan;
|
||||
+ __u8 repeat_first_field;
|
||||
+ __u16 progressive_frame;
|
||||
+};
|
||||
+
|
||||
+struct v4l2_ctrl_mpeg2_slice_params {
|
||||
+ __u32 bit_size;
|
||||
+ __u32 data_bit_offset;
|
||||
+ __u64 backward_ref_ts;
|
||||
+ __u64 forward_ref_ts;
|
||||
+
|
||||
+ struct v4l2_mpeg2_sequence sequence;
|
||||
+ struct v4l2_mpeg2_picture picture;
|
||||
+
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Slice */
|
||||
+ __u32 quantiser_scale_code;
|
||||
+};
|
||||
+
|
||||
+struct v4l2_ctrl_mpeg2_quantization {
|
||||
+ /* ISO/IEC 13818-2, ITU-T Rec. H.262: Quant matrix extension */
|
||||
+ __u8 load_intra_quantiser_matrix;
|
||||
+ __u8 load_non_intra_quantiser_matrix;
|
||||
+ __u8 load_chroma_intra_quantiser_matrix;
|
||||
+ __u8 load_chroma_non_intra_quantiser_matrix;
|
||||
+
|
||||
+ __u8 intra_quantiser_matrix[64];
|
||||
+ __u8 non_intra_quantiser_matrix[64];
|
||||
+ __u8 chroma_intra_quantiser_matrix[64];
|
||||
+ __u8 chroma_non_intra_quantiser_matrix[64];
|
||||
+};
|
||||
+
|
||||
+#endif
|
||||
diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c
|
||||
index 3687325fad..2145a974eb 100644
|
||||
--- a/libavcodec/v4l2_request_h264.c
|
||||
+++ b/libavcodec/v4l2_request_h264.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "h264dec.h"
|
||||
#include "hwaccel.h"
|
||||
#include "v4l2_request.h"
|
||||
+#include "h264-ctrls.h"
|
||||
|
||||
typedef struct V4L2RequestControlsH264 {
|
||||
struct v4l2_ctrl_h264_sps sps;
|
||||
diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c
|
||||
index 38969d77fb..b73eb2ab03 100644
|
||||
--- a/libavcodec/v4l2_request_hevc.c
|
||||
+++ b/libavcodec/v4l2_request_hevc.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "hevcdec.h"
|
||||
#include "hwaccel.h"
|
||||
#include "v4l2_request.h"
|
||||
+#include "hevc-ctrls.h"
|
||||
|
||||
typedef struct V4L2RequestControlsHEVC {
|
||||
struct v4l2_ctrl_hevc_sps sps;
|
||||
diff --git a/libavcodec/v4l2_request_mpeg2.c b/libavcodec/v4l2_request_mpeg2.c
|
||||
index 782b9c2471..37a4eae62c 100644
|
||||
--- a/libavcodec/v4l2_request_mpeg2.c
|
||||
+++ b/libavcodec/v4l2_request_mpeg2.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "hwaccel.h"
|
||||
#include "mpegvideo.h"
|
||||
#include "v4l2_request.h"
|
||||
+#include "mpeg2-ctrls.h"
|
||||
|
||||
typedef struct V4L2RequestControlsMPEG2 {
|
||||
struct v4l2_ctrl_mpeg2_slice_params slice_params;
|
||||
--
|
||||
2.21.0
|
||||
|
@ -0,0 +1,44 @@
|
||||
################################################################################
|
||||
# This file is part of LibreELEC - https://libreelec.tv
|
||||
# Copyright (C) 2016 Team LibreELEC
|
||||
#
|
||||
# LibreELEC is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# LibreELEC 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||
################################################################################
|
||||
|
||||
PKG_NAME="gcc-linaro-aarch64-linux-gnu"
|
||||
PKG_VERSION="6.4.1-2018.05"
|
||||
PKG_VERSION_SHORT="6.4-2018.05"
|
||||
PKG_REV="1"
|
||||
PKG_ARCH="any"
|
||||
PKG_LICENSE="GPL"
|
||||
PKG_SITE=""
|
||||
PKG_URL="https://releases.linaro.org/components/toolchain/binaries/${PKG_VERSION_SHORT}/aarch64-linux-gnu/gcc-linaro-${PKG_VERSION}-x86_64_aarch64-linux-gnu.tar.xz"
|
||||
PKG_SOURCE_DIR="gcc-linaro-${PKG_VERSION}-x86_64_aarch64-linux-gnu"
|
||||
PKG_PRIORITY="optional"
|
||||
PKG_SECTION="lang"
|
||||
PKG_SHORTDESC=""
|
||||
PKG_LONGDESC=""
|
||||
PKG_TOOLCHAIN="make"
|
||||
|
||||
PKG_IS_ADDON="no"
|
||||
PKG_AUTORECONF="no"
|
||||
|
||||
make_host() {
|
||||
:
|
||||
}
|
||||
|
||||
makeinstall_host() {
|
||||
mkdir -p ${TOOLCHAIN}/lib/gcc-linaro-aarch64-linux-gnu/
|
||||
cp -a * ${TOOLCHAIN}/lib/gcc-linaro-aarch64-linux-gnu
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
################################################################################
|
||||
# This file is part of LibreELEC - https://libreelec.tv
|
||||
# Copyright (C) 2016 Team LibreELEC
|
||||
#
|
||||
# LibreELEC is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# LibreELEC 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||
################################################################################
|
||||
|
||||
PKG_NAME="gcc-linaro-arm-linux-gnueabi"
|
||||
PKG_VERSION="6.4.1-2018.05"
|
||||
PKG_VERSION_SHORT="6.4-2018.05"
|
||||
PKG_REV="1"
|
||||
PKG_ARCH="any"
|
||||
PKG_LICENSE="GPL"
|
||||
PKG_SITE=""
|
||||
PKG_URL="https://releases.linaro.org/components/toolchain/binaries/${PKG_VERSION_SHORT}/arm-linux-gnueabi/gcc-linaro-${PKG_VERSION}-x86_64_arm-linux-gnueabi.tar.xz"
|
||||
PKG_SOURCE_DIR="gcc-linaro-${PKG_VERSION}-x86_64_arm-linux-gnueabi"
|
||||
PKG_PRIORITY="optional"
|
||||
PKG_SECTION="lang"
|
||||
PKG_SHORTDESC=""
|
||||
PKG_LONGDESC=""
|
||||
PKG_TOOLCHAIN="make"
|
||||
|
||||
PKG_IS_ADDON="no"
|
||||
PKG_AUTORECONF="no"
|
||||
|
||||
make_host() {
|
||||
:
|
||||
}
|
||||
|
||||
makeinstall_host() {
|
||||
mkdir -p ${TOOLCHAIN}/lib/gcc-linaro-arm-linux-gnueabi/
|
||||
cp -a * ${TOOLCHAIN}/lib/gcc-linaro-arm-linux-gnueabi
|
||||
}
|
32
projects/L4T/devices/Switch/packages/libxcb/package.mk
Normal file
32
projects/L4T/devices/Switch/packages/libxcb/package.mk
Normal file
@ -0,0 +1,32 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
|
||||
|
||||
PKG_NAME="libxcb"
|
||||
PKG_VERSION="1.13"
|
||||
PKG_SHA256="188c8752193c50ff2dbe89db4554c63df2e26a2e47b0fa415a70918b5b851daa"
|
||||
PKG_LICENSE="OSS"
|
||||
PKG_SITE="http://xcb.freedesktop.org"
|
||||
#PKG_URL="https://xorg.freedesktop.org/archive/individual/lib/$PKG_NAME-$PKG_VERSION.tar.gz"
|
||||
PKG_URL="http://xcb.freedesktop.org/dist/$PKG_NAME-$PKG_VERSION.tar.bz2"
|
||||
PKG_DEPENDS_TARGET="toolchain util-macros Python2:host xcb-proto libpthread-stubs libXau"
|
||||
PKG_LONGDESC="X C-language Bindings library."
|
||||
PKG_BUILD_FLAGS="+pic"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="--enable-static \
|
||||
--enable-shared \
|
||||
--disable-screensaver \
|
||||
--disable-xprint \
|
||||
--disable-selinux \
|
||||
--disable-xvmc"
|
||||
|
||||
pre_configure_target() {
|
||||
if [ ${PROJECT} = "L4T" ]; then
|
||||
PYTHON_LIBDIR=$SYSROOT_PREFIX/usr/lib/python2.7
|
||||
else
|
||||
PYTHON_LIBDIR=$SYSROOT_PREFIX/usr/lib/$PKG_PYTHON_VERSION
|
||||
fi
|
||||
PYTHON_TOOLCHAIN_PATH=$PYTHON_LIBDIR/site-packages
|
||||
echo $PYTHON_TOOLCHAIN_PATH
|
||||
PKG_CONFIG="$PKG_CONFIG --define-variable=pythondir=$PYTHON_TOOLCHAIN_PATH"
|
||||
PKG_CONFIG="$PKG_CONFIG --define-variable=xcbincludedir=$SYSROOT_PREFIX/usr/share/xcb"
|
||||
}
|
28
projects/L4T/devices/Switch/packages/mergerfs/package.mk
Normal file
28
projects/L4T/devices/Switch/packages/mergerfs/package.mk
Normal file
@ -0,0 +1,28 @@
|
||||
################################################################################
|
||||
# This file is part of LibreELEC - https://libreelec.tv
|
||||
# Copyright (C) 2016-present Team LibreELEC
|
||||
#
|
||||
# LibreELEC is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# LibreELEC 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||
################################################################################
|
||||
|
||||
PKG_NAME="mergerfs"
|
||||
PKG_VERSION="2.24.0"
|
||||
PKG_ARCH="any"
|
||||
PKG_SITE="https://github.com/trapexit/mergerfs"
|
||||
PKG_URL="$PKG_SITE/releases/download/$PKG_VERSION/$PKG_NAME-$PKG_VERSION.tar.gz"
|
||||
PKG_DEPENDS_TARGET="toolchain fuse"
|
||||
PKG_SECTION="tools"
|
||||
PKG_SHORTDESC="a featureful union filesystem "
|
||||
PKG_MAKE_OPTS_TARGET="XATTR_AVAILABLE=0"
|
||||
PKG_MAKEINSTALL_OPTS_TARGET="PREFIX=/usr"
|
@ -0,0 +1,112 @@
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 0137632..617fa4d 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -12,6 +12,7 @@
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
+PKGCONFIG = $(shell which pkg-config)
|
||||
GIT = $(shell which git)
|
||||
TAR = $(shell which tar)
|
||||
MKDIR = $(shell which mkdir)
|
||||
@@ -27,7 +28,10 @@ PANDOC = $(shell which pandoc)
|
||||
SED = $(shell which sed)
|
||||
GZIP = $(shell which gzip)
|
||||
RPMBUILD = $(shell which rpmbuild)
|
||||
-GIT2DEBCL = ./tools/git2debcl
|
||||
+
|
||||
+ifeq ($(PKGCONFIG),"")
|
||||
+$(error "pkg-config not installed")
|
||||
+endif
|
||||
|
||||
GIT_REPO = 0
|
||||
ifneq ($(GIT),)
|
||||
@@ -42,6 +46,16 @@ endif
|
||||
|
||||
XATTR_AVAILABLE = $(shell test ! -e /usr/include/attr/xattr.h; echo $$?)
|
||||
|
||||
+FUSE_AVAILABLE = $(shell ! pkg-config --exists fuse; echo $$?)
|
||||
+
|
||||
+ifeq ($(FUSE_AVAILABLE),0)
|
||||
+FUSE_AVAILABLE = $(shell test ! -e /usr/include/fuse.h; echo $$?)
|
||||
+endif
|
||||
+
|
||||
+ifeq ($(FUSE_AVAILABLE),0)
|
||||
+$(error "FUSE development package doesn't appear available")
|
||||
+endif
|
||||
+
|
||||
UGID_USE_RWLOCK = 0
|
||||
|
||||
OPTS = -O2
|
||||
@@ -50,7 +64,7 @@ OBJ = $(SRC:src/%.cpp=obj/%.o)
|
||||
DEPS = $(OBJ:obj/%.o=obj/%.d)
|
||||
TARGET = mergerfs
|
||||
MANPAGE = $(TARGET).1
|
||||
-FUSE_CFLAGS = -D_FILE_OFFSET_BITS=64 -Ilibfuse/include
|
||||
+FUSE_CFLAGS = -D_FILE_OFFSET_BITS=64 $(shell $(PKGCONFIG) --cflags fuse)
|
||||
CFLAGS = -g -Wall \
|
||||
$(OPTS) \
|
||||
-Wno-unused-result \
|
||||
@@ -58,7 +72,7 @@ CFLAGS = -g -Wall \
|
||||
-DFUSE_USE_VERSION=29 \
|
||||
-MMD \
|
||||
-DUGID_USE_RWLOCK=$(UGID_USE_RWLOCK)
|
||||
-LDFLAGS = -pthread -lrt
|
||||
+LDFLAGS = $(shell $(PKGCONFIG) fuse --libs)
|
||||
|
||||
PREFIX = /usr/local
|
||||
EXEC_PREFIX = $(PREFIX)
|
||||
@@ -84,9 +98,8 @@ help:
|
||||
@echo "usage: make"
|
||||
@echo "make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)"
|
||||
|
||||
-$(TARGET): version obj/obj-stamp libfuse/lib/.libs/libfuse.a $(OBJ)
|
||||
- cd libfuse && make
|
||||
- $(CXX) $(CFLAGS) $(OBJ) -o $@ libfuse/lib/.libs/libfuse.a -ldl $(LDFLAGS)
|
||||
+$(TARGET): src/version.hpp obj/obj-stamp $(OBJ)
|
||||
+ $(CXX) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
|
||||
|
||||
mount.mergerfs: $(TARGET)
|
||||
$(LN) -fs "$<" "$@"
|
||||
@@ -111,15 +124,13 @@ obj/obj-stamp:
|
||||
obj/%.o: src/%.cpp
|
||||
$(CXX) $(CFLAGS) -c $< -o $@
|
||||
|
||||
-clean: rpm-clean libfuse_Makefile
|
||||
+clean: rpm-clean
|
||||
$(RM) -f src/version.hpp
|
||||
$(RM) -rf obj
|
||||
$(RM) -f "$(TARGET)" mount.mergerfs
|
||||
$(FIND) . -name "*~" -delete
|
||||
- cd libfuse && $(MAKE) clean
|
||||
|
||||
-distclean: clean libfuse_Makefile
|
||||
- cd libfuse && $(MAKE) distclean
|
||||
+distclean: clean
|
||||
ifeq ($(GIT_REPO),1)
|
||||
$(GIT) clean -fd
|
||||
endif
|
||||
@@ -208,19 +219,6 @@ else ifeq ($(shell test -e /usr/bin/yum; echo $$?),0)
|
||||
yum -y install git rpm-build libattr-devel gcc-c++ make which python automake libtool gettext-devel
|
||||
endif
|
||||
|
||||
-unexport CFLAGS LDFLAGS
|
||||
-.PHONY: libfuse_Makefile
|
||||
-libfuse_Makefile:
|
||||
-ifeq ($(shell test -e libfuse/Makefile; echo $$?),1)
|
||||
- cd libfuse && \
|
||||
- $(MKDIR) -p m4 && \
|
||||
- autoreconf --force --install && \
|
||||
- ./configure --enable-lib --disable-util --disable-example
|
||||
-endif
|
||||
-
|
||||
-libfuse/lib/.libs/libfuse.a: libfuse_Makefile
|
||||
- cd libfuse && $(MAKE)
|
||||
-
|
||||
.PHONY: all clean install help version
|
||||
|
||||
-include $(DEPS)
|
||||
--
|
||||
2.7.4
|
||||
|
@ -0,0 +1,20 @@
|
||||
# Software Information
|
||||
display_name = "Moonlight"
|
||||
authors = "Rock88"
|
||||
supported_extensions = ""
|
||||
corename = "Moonlight"
|
||||
categories = "Streaming client"
|
||||
license = "GPLv3"
|
||||
permissions = ""
|
||||
display_version = "1.0"
|
||||
|
||||
# Hardware Information
|
||||
systemname = "moonlight"
|
||||
manufacturer = "nVidia"
|
||||
|
||||
# Libretro Features
|
||||
supports_no_game = "true"
|
||||
hw_render = "true"
|
||||
is_experimental = "true"
|
||||
|
||||
description = "A port of the nVidia streaming client Moonlight. Currently only tested using Lakka running on Nintendo Switch."
|
@ -0,0 +1,43 @@
|
||||
################################################################################
|
||||
# This file is part of OpenELEC - http://www.openelec.tv
|
||||
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
|
||||
#
|
||||
# This Program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This Program 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with OpenELEC.tv; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
|
||||
# http://www.gnu.org/copyleft/gpl.html
|
||||
################################################################################
|
||||
|
||||
PKG_NAME="moonlight-libretro"
|
||||
PKG_VERSION="20d2d77"
|
||||
PKG_ARCH="any"
|
||||
PKG_LICENSE="GPLv2"
|
||||
PKG_SITE="https://github.com/rock88/moonlight-libretro"
|
||||
PKG_URL="$PKG_SITE.git"
|
||||
PKG_DEPENDS_TARGET="toolchain ffmpeg opus cairo"
|
||||
PKG_SECTION="libretro"
|
||||
PKG_SHORTDESC="Moonlight-libretro is a port of Moonlight Game Streaming Project for RetroArch platform."
|
||||
PKG_LONGDESC="Moonlight-libretro is a port of Moonlight Game Streaming Project for RetroArch platform."
|
||||
|
||||
PKG_IS_ADDON="no"
|
||||
PKG_AUTORECONF="no"
|
||||
|
||||
make_target() {
|
||||
make platform=lakka-switch TOOLCHAIN=${TOOLCHAIN}
|
||||
}
|
||||
|
||||
makeinstall_target() {
|
||||
mkdir -p $INSTALL/usr/lib/libretro
|
||||
cp moonlight_libretro.so $INSTALL/usr/lib/libretro/
|
||||
cp $PKG_DIR/assets/moonlight_libretro.info $INSTALL/usr/lib/libretro/
|
||||
}
|
@ -0,0 +1,217 @@
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 757c3bc..c0e21dd 100755
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -61,10 +61,8 @@ else ifeq ($(platform), lakka-switch)
|
||||
DEFINES += -mcpu=cortex-a57+crypto+crc+fp+simd -mabi=lp64 -Wno-psabi -mtune=cortex-a57 \
|
||||
-march=armv8-a+crypto+crc+fp+simd -fomit-frame-pointer -Wall -pipe -fPIC -pthread \
|
||||
-D__LAKKA_SWITCH__
|
||||
- INCLUDES += -Ithird_party/opus/include -Ithird_party/ffmpeg/include \
|
||||
- -I$(TOOLCHAIN)/aarch64-libreelec-linux-gnueabi/sysroot/usr/include -I$(TOOLCHAIN)/include
|
||||
- LIBS += -Lthird_party/opus/lib -Lthird_party/ffmpeg/lib \
|
||||
- -lpthread -lGL -luuid -lvdpau -lX11
|
||||
+ INCLUDES += -I$(TOOLCHAIN)/aarch64-libreelec-linux-gnueabi/sysroot/usr/include -I$(TOOLCHAIN)/include
|
||||
+ LIBS += -lpthread -lGL -luuid -lvdpau -lX11
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
else
|
||||
CC = gcc
|
||||
diff --git a/src/ui/LoadingOverlay.cpp b/src/ui/LoadingOverlay.cpp
|
||||
index 97ffc8e..fb5c5bb 100644
|
||||
--- a/src/ui/LoadingOverlay.cpp
|
||||
+++ b/src/ui/LoadingOverlay.cpp
|
||||
@@ -17,7 +17,13 @@ void LoadingOverlay::draw(NVGcontext *ctx) {
|
||||
nvgSave(ctx);
|
||||
|
||||
// Draw bg
|
||||
- nvgFillColor(ctx, Color(0, 0, 0, 100));
|
||||
+ NVGcolor bgColor;
|
||||
+ bgColor.r = 0 / 255.0;
|
||||
+ bgColor.g = 0 / 255.0;
|
||||
+ bgColor.b = 0 / 255.0;
|
||||
+ bgColor.a = 100 / 255.0;
|
||||
+ nvgFillColor(ctx, bgColor);
|
||||
+
|
||||
nvgBeginPath(ctx);
|
||||
nvgRect(ctx, 0, 0, width(), height());
|
||||
nvgFill(ctx);
|
||||
@@ -29,7 +35,13 @@ void LoadingOverlay::draw(NVGcontext *ctx) {
|
||||
nvgTranslate(ctx, width() / 2, height() / 2);
|
||||
nvgRotate(ctx, r);
|
||||
|
||||
- nvgFillColor(ctx, Color(255, 255, 255, 255));
|
||||
+ NVGcolor spinnerColor;
|
||||
+ spinnerColor.r = 255 / 255.0;
|
||||
+ spinnerColor.g = 255 / 255.0;
|
||||
+ spinnerColor.b = 255 / 255.0;
|
||||
+ spinnerColor.a = 255 / 255.0;
|
||||
+ nvgFillColor(ctx, spinnerColor);
|
||||
+
|
||||
nvgFontSize(ctx, 40);
|
||||
nvgFontFace(ctx, "icons");
|
||||
nvgTextAlign(ctx, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);
|
||||
diff --git a/src/ui/buttons/AddHostButton.cpp b/src/ui/buttons/AddHostButton.cpp
|
||||
index 6bc91d3..678e23f 100644
|
||||
--- a/src/ui/buttons/AddHostButton.cpp
|
||||
+++ b/src/ui/buttons/AddHostButton.cpp
|
||||
@@ -18,7 +18,14 @@ void AddHostButton::draw(NVGcontext *ctx) {
|
||||
nvgReset(ctx);
|
||||
|
||||
nvgTranslate(ctx, absolute_position().x(), absolute_position().y());
|
||||
- nvgFillColor(ctx, Color(255, 255, 255, 255));
|
||||
+
|
||||
+ NVGcolor fillColor;
|
||||
+ fillColor.r = 255 / 255.0;
|
||||
+ fillColor.g = 255 / 255.0;
|
||||
+ fillColor.b = 255 / 255.0;
|
||||
+ fillColor.a = 255 / 255.0;
|
||||
+ nvgFillColor(ctx, fillColor);
|
||||
+
|
||||
nvgFontSize(ctx, 130);
|
||||
nvgFontFace(ctx, "icons");
|
||||
nvgTextAlign(ctx, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);
|
||||
diff --git a/src/ui/buttons/AppButton.cpp b/src/ui/buttons/AppButton.cpp
|
||||
index bde7e7f..4310434 100644
|
||||
--- a/src/ui/buttons/AppButton.cpp
|
||||
+++ b/src/ui/buttons/AppButton.cpp
|
||||
@@ -74,7 +74,14 @@ void AppButton::draw(NVGcontext *ctx) {
|
||||
|
||||
if (m_label->visible()) {
|
||||
nvgSave(ctx);
|
||||
- nvgFillColor(ctx, Color(0, 0, 0, 100));
|
||||
+
|
||||
+ NVGcolor fillColor;
|
||||
+ fillColor.r = 0 / 255.0;
|
||||
+ fillColor.g = 0 / 255.0;
|
||||
+ fillColor.b = 0 / 255.0;
|
||||
+ fillColor.a = 100 / 255.0;
|
||||
+ nvgFillColor(ctx, fillColor);
|
||||
+
|
||||
nvgBeginPath(ctx);
|
||||
nvgRect(ctx, m_pos.x(), m_pos.y(), m_label->width(), m_label->height());
|
||||
nvgFill(ctx);
|
||||
diff --git a/src/ui/buttons/HostButton.cpp b/src/ui/buttons/HostButton.cpp
|
||||
index 8e2222b..92f2aef 100644
|
||||
--- a/src/ui/buttons/HostButton.cpp
|
||||
+++ b/src/ui/buttons/HostButton.cpp
|
||||
@@ -42,7 +42,14 @@ void HostButton::draw(NVGcontext *ctx) {
|
||||
nvgReset(ctx);
|
||||
|
||||
nvgTranslate(ctx, absolute_position().x(), absolute_position().y());
|
||||
- nvgFillColor(ctx, Color(255, 255, 255, 255));
|
||||
+
|
||||
+ NVGcolor fillColor;
|
||||
+ fillColor.r = 255 / 255.0;
|
||||
+ fillColor.g = 255 / 255.0;
|
||||
+ fillColor.b = 255 / 255.0;
|
||||
+ fillColor.a = 255 / 255.0;
|
||||
+ nvgFillColor(ctx, fillColor);
|
||||
+
|
||||
nvgFontSize(ctx, 130);
|
||||
nvgFontFace(ctx, "icons");
|
||||
nvgTextAlign(ctx, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);
|
||||
diff --git a/src/ui/windows/ContentWindow.cpp b/src/ui/windows/ContentWindow.cpp
|
||||
index a708250..c6c15b8 100644
|
||||
--- a/src/ui/windows/ContentWindow.cpp
|
||||
+++ b/src/ui/windows/ContentWindow.cpp
|
||||
@@ -32,20 +32,44 @@ void ContentWindow::draw(NVGcontext *ctx) {
|
||||
nvgSave(ctx);
|
||||
|
||||
// Draw bg
|
||||
- nvgFillColor(ctx, Color(48, 48, 48, 255));
|
||||
+ NVGcolor bgColor;
|
||||
+ bgColor.r = 48 / 255.0;
|
||||
+ bgColor.g = 48 / 255.0;
|
||||
+ bgColor.b = 48 / 255.0;
|
||||
+ bgColor.a = 255 / 255.0;
|
||||
+ nvgFillColor(ctx, bgColor);
|
||||
+
|
||||
nvgBeginPath(ctx);
|
||||
nvgRect(ctx, 0, 0, width(), height());
|
||||
nvgFill(ctx);
|
||||
|
||||
// Draw header
|
||||
- nvgFillColor(ctx, Color(62, 78, 184, 255));
|
||||
+ NVGcolor headerColor;
|
||||
+ headerColor.r = 62 / 255.0;
|
||||
+ headerColor.g = 78 / 255.0;
|
||||
+ headerColor.b = 184 / 255.0;
|
||||
+ headerColor.a = 255 / 255.0;
|
||||
+ nvgFillColor(ctx, headerColor);
|
||||
+
|
||||
nvgBeginPath(ctx);
|
||||
nvgRect(ctx, 0, 0, width(), 80);
|
||||
nvgFill(ctx);
|
||||
|
||||
// Draw separator
|
||||
+ NVGcolor greyColor;
|
||||
+ headerColor.r = 0 / 255.0;
|
||||
+ headerColor.g = 0 / 255.0;
|
||||
+ headerColor.b = 0 / 255.0;
|
||||
+ headerColor.a = 100 / 255.0;
|
||||
+
|
||||
+ NVGcolor blackColor;
|
||||
+ blackColor.r = 0 / 255.0;
|
||||
+ blackColor.g = 0 / 255.0;
|
||||
+ blackColor.b = 0 / 255.0;
|
||||
+ blackColor.a = 0 / 255.0;
|
||||
+
|
||||
nvgBeginPath(ctx);
|
||||
- NVGpaint gradient = nvgLinearGradient(ctx, 0, 80, 0, 84, Color(0, 0, 0, 100), Color(0, 0, 0, 0));
|
||||
+ NVGpaint gradient = nvgLinearGradient(ctx, 0, 80, 0, 84, greyColor, blackColor);
|
||||
nvgFillPaint(ctx, gradient);
|
||||
nvgRect(ctx, 0, 80, width(), 4);
|
||||
nvgFill(ctx);
|
||||
diff --git a/src/ui/windows/MainWindow.cpp b/src/ui/windows/MainWindow.cpp
|
||||
index 3bf0a84..3adbaf3 100644
|
||||
--- a/src/ui/windows/MainWindow.cpp
|
||||
+++ b/src/ui/windows/MainWindow.cpp
|
||||
@@ -66,7 +66,13 @@ void MainWindow::draw(NVGcontext *ctx) {
|
||||
|
||||
nvgSave(ctx);
|
||||
|
||||
- nvgFillColor(ctx, Color(255, 255, 255, 200));
|
||||
+ NVGcolor bgColor;
|
||||
+ bgColor.r = 255 / 255.0;
|
||||
+ bgColor.g = 255 / 255.0;
|
||||
+ bgColor.b = 255 / 255.0;
|
||||
+ bgColor.a = 200 / 255.0;
|
||||
+ nvgFillColor(ctx, bgColor);
|
||||
+
|
||||
nvgFontSize(ctx, 20);
|
||||
nvgFontFace(ctx, "sans");
|
||||
nvgText(ctx, width() - 40, height() - 8, MOONLIGHT_LIBRETRO_VERSION, NULL);
|
||||
diff --git a/src/ui/windows/StreamWindow.cpp b/src/ui/windows/StreamWindow.cpp
|
||||
index 385df3a..90001a8 100644
|
||||
--- a/src/ui/windows/StreamWindow.cpp
|
||||
+++ b/src/ui/windows/StreamWindow.cpp
|
||||
@@ -54,7 +54,13 @@ void StreamWindow::draw(NVGcontext *ctx) {
|
||||
nvgRestore(ctx);
|
||||
|
||||
if (m_session->connection_status_is_poor()) {
|
||||
- nvgFillColor(ctx, Color(255, 255, 255, 200));
|
||||
+ NVGcolor warnColor;
|
||||
+ warnColor.r = 255 / 255.0;
|
||||
+ warnColor.g = 255 / 255.0;
|
||||
+ warnColor.b = 255 / 255.0;
|
||||
+ warnColor.a = 200 / 255.0;
|
||||
+ nvgFillColor(ctx, warnColor);
|
||||
+
|
||||
nvgFontSize(ctx, 20);
|
||||
nvgFontFace(ctx, "icons");
|
||||
nvgTextAlign(ctx, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
|
||||
@@ -91,7 +97,13 @@ void StreamWindow::draw(NVGcontext *ctx) {
|
||||
(float)stats->video_decode_stats.total_decode_time / stats->video_decode_stats.decoded_frames,
|
||||
(float)stats->video_render_stats.total_render_time / stats->video_render_stats.rendered_frames);
|
||||
|
||||
- nvgFillColor(ctx, Color(0, 255, 0, 255));
|
||||
+ NVGcolor statsColor;
|
||||
+ statsColor.r = 0 / 255.0;
|
||||
+ statsColor.g = 255 / 255.0;
|
||||
+ statsColor.b = 0 / 255.0;
|
||||
+ statsColor.a = 255 / 255.0;
|
||||
+ nvgFillColor(ctx, statsColor);
|
||||
+
|
||||
nvgFontFace(ctx, "sans-bold");
|
||||
nvgFontSize(ctx, 20);
|
||||
nvgTextAlign(ctx, NVG_ALIGN_LEFT | NVG_ALIGN_BOTTOM);
|
||||
|
@ -0,0 +1,16 @@
|
||||
diff -Naur moonlight-20d2d77/src/streaming/ffmpeg/FFmpegVideoDecoder.cpp moonlight-20d2d77-2/src/streaming/ffmpeg/FFmpegVideoDecoder.cpp
|
||||
--- moonlight-20d2d77/src/streaming/ffmpeg/FFmpegVideoDecoder.cpp 2021-06-11 00:23:20.472732135 +0000
|
||||
+++ moonlight-20d2d77-2/src/streaming/ffmpeg/FFmpegVideoDecoder.cpp 2021-06-11 00:26:21.582274704 +0000
|
||||
@@ -36,10 +36,10 @@
|
||||
|
||||
switch (video_format) {
|
||||
case VIDEO_FORMAT_H264:
|
||||
- m_decoder = avcodec_find_decoder_by_name("h264");
|
||||
+ m_decoder = avcodec_find_decoder_by_name("h264_nvmpi");
|
||||
break;
|
||||
case VIDEO_FORMAT_H265:
|
||||
- m_decoder = avcodec_find_decoder_by_name("hevc");
|
||||
+ m_decoder = avcodec_find_decoder_by_name("hevc_nvmpi");
|
||||
break;
|
||||
}
|
||||
|
59
projects/L4T/devices/Switch/packages/openssh/package.mk
Normal file
59
projects/L4T/devices/Switch/packages/openssh/package.mk
Normal file
@ -0,0 +1,59 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
|
||||
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
PKG_NAME="openssh"
|
||||
PKG_VERSION="8.0p1"
|
||||
PKG_SHA256="bd943879e69498e8031eb6b7f44d08cdc37d59a7ab689aa0b437320c3481fd68"
|
||||
PKG_LICENSE="OSS"
|
||||
PKG_SITE="https://www.openssh.com/"
|
||||
PKG_URL="https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/$PKG_NAME-$PKG_VERSION.tar.gz"
|
||||
PKG_DEPENDS_TARGET="toolchain openssl zlib"
|
||||
PKG_LONGDESC="An open re-implementation of the SSH package."
|
||||
PKG_TOOLCHAIN="autotools"
|
||||
PKG_BUILD_FLAGS="+lto"
|
||||
|
||||
PKG_CONFIGURE_OPTS_TARGET="ac_cv_header_rpc_types_h=no \
|
||||
--sysconfdir=/etc/ssh \
|
||||
--libexecdir=/usr/lib/openssh \
|
||||
--disable-strip \
|
||||
--disable-lastlog \
|
||||
--with-sandbox=no \
|
||||
--disable-utmp \
|
||||
--disable-utmpx \
|
||||
--disable-wtmp \
|
||||
--disable-wtmpx \
|
||||
--without-rpath \
|
||||
--with-ssl-engine \
|
||||
--with-privsep-user=nobody \
|
||||
--disable-pututline \
|
||||
--disable-pututxline \
|
||||
--disable-etc-default-login \
|
||||
--with-keydir=/storage/.cache/ssh \
|
||||
--without-pam"
|
||||
|
||||
pre_configure_target() {
|
||||
export LD="$CC"
|
||||
export LDFLAGS="$TARGET_CFLAGS $TARGET_LDFLAGS"
|
||||
}
|
||||
|
||||
post_makeinstall_target() {
|
||||
rm -rf $INSTALL/usr/lib/openssh/ssh-keysign
|
||||
rm -rf $INSTALL/usr/lib/openssh/ssh-pkcs11-helper
|
||||
if [ ! $SFTP_SERVER = "yes" ]; then
|
||||
rm -rf $INSTALL/usr/lib/openssh/sftp-server
|
||||
fi
|
||||
rm -rf $INSTALL/usr/bin/ssh-add
|
||||
rm -rf $INSTALL/usr/bin/ssh-agent
|
||||
rm -rf $INSTALL/usr/bin/ssh-keyscan
|
||||
|
||||
sed -e "s|^#PermitRootLogin.*|PermitRootLogin yes|g" \
|
||||
-e "s|^#StrictModes.*|StrictModes no|g" \
|
||||
-i $INSTALL/etc/ssh/sshd_config
|
||||
|
||||
debug_strip $INSTALL/usr
|
||||
}
|
||||
|
||||
post_install() {
|
||||
enable_service sshd.service
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
diff -u a/configure.ac b/configure.ac
|
||||
--- a/configure.ac 2018-10-16 20:01:20.000000000 -0400
|
||||
+++ b/configure.ac 2018-12-06 04:08:42.718993760 -0500
|
||||
@@ -4903,6 +4903,19 @@
|
||||
)
|
||||
|
||||
|
||||
+# Set keydir
|
||||
+AC_ARG_WITH([keydir],
|
||||
+ [ --with-keydir= Specify different path for storing keys],
|
||||
+ [
|
||||
+ if test -n "$withval" && test "x$withval" != "xno" && \
|
||||
+ test "x${withval}" != "xyes"; then
|
||||
+ KEYDIR=$withval
|
||||
+ fi
|
||||
+ ]
|
||||
+)
|
||||
+AC_SUBST([KEYDIR])
|
||||
+
|
||||
+
|
||||
AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
|
||||
IPV4_IN6_HACK_MSG="no"
|
||||
AC_ARG_WITH(4in6,
|
||||
@@ -5277,6 +5290,7 @@
|
||||
H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
|
||||
I=`eval echo ${user_path}` ; I=`eval echo ${I}`
|
||||
J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
|
||||
+K=`eval echo ${KEYDIR}` ; K=`eval echo ${K}`
|
||||
|
||||
echo ""
|
||||
echo "OpenSSH has been configured with the following options:"
|
||||
@@ -5300,6 +5314,9 @@
|
||||
if test ! -z "$superuser_path" ; then
|
||||
echo " sshd superuser user PATH: $J"
|
||||
fi
|
||||
+if test ! -z "$KEYDIR" ; then
|
||||
+echo " sshd keydir: $K"
|
||||
+fi
|
||||
echo " Manpage format: $MANTYPE"
|
||||
echo " PAM support: $PAM_MSG"
|
||||
echo " OSF SIA support: $SIA_MSG"
|
||||
Common subdirectories: a/contrib and b/contrib
|
||||
diff -u a/Makefile.in b/Makefile.in
|
||||
--- a/Makefile.in 2018-10-16 20:01:20.000000000 -0400
|
||||
+++ b/Makefile.in 2018-12-06 04:00:04.301968236 -0500
|
||||
@@ -28,8 +28,10 @@
|
||||
SSH_PRIVSEP_USER=@SSH_PRIVSEP_USER@
|
||||
STRIP_OPT=@STRIP_OPT@
|
||||
TEST_SHELL=@TEST_SHELL@
|
||||
+KEYDIR=@KEYDIR@
|
||||
|
||||
PATHS= -DSSHDIR=\"$(sysconfdir)\" \
|
||||
+ -DKEYDIR=\"$(KEYDIR)\" \
|
||||
-D_PATH_SSH_PROGRAM=\"$(SSH_PROGRAM)\" \
|
||||
-D_PATH_SSH_ASKPASS_DEFAULT=\"$(ASKPASS_PROGRAM)\" \
|
||||
-D_PATH_SFTP_SERVER=\"$(SFTP_SERVER)\" \
|
||||
@@ -133,11 +135,11 @@
|
||||
-e 's|/etc/ssh/sshd_config|$(sysconfdir)/sshd_config|g' \
|
||||
-e 's|/usr/libexec|$(libexecdir)|g' \
|
||||
-e 's|/etc/shosts.equiv|$(sysconfdir)/shosts.equiv|g' \
|
||||
- -e 's|/etc/ssh/ssh_host_key|$(sysconfdir)/ssh_host_key|g' \
|
||||
- -e 's|/etc/ssh/ssh_host_ecdsa_key|$(sysconfdir)/ssh_host_ecdsa_key|g' \
|
||||
- -e 's|/etc/ssh/ssh_host_dsa_key|$(sysconfdir)/ssh_host_dsa_key|g' \
|
||||
- -e 's|/etc/ssh/ssh_host_rsa_key|$(sysconfdir)/ssh_host_rsa_key|g' \
|
||||
- -e 's|/etc/ssh/ssh_host_ed25519_key|$(sysconfdir)/ssh_host_ed25519_key|g' \
|
||||
+ -e 's|/etc/ssh/ssh_host_key|$(KEYDIR)/ssh_host_key|g' \
|
||||
+ -e 's|/etc/ssh/ssh_host_ecdsa_key|$(KEYDIR)/ssh_host_ecdsa_key|g' \
|
||||
+ -e 's|/etc/ssh/ssh_host_dsa_key|$(KEYDIR)/ssh_host_dsa_key|g' \
|
||||
+ -e 's|/etc/ssh/ssh_host_rsa_key|$(KEYDIR)/ssh_host_rsa_key|g' \
|
||||
+ -e 's|/etc/ssh/ssh_host_ed25519_key|$(KEYDIR)/ssh_host_ed25519_key|g' \
|
||||
-e 's|/var/run/sshd.pid|$(piddir)/sshd.pid|g' \
|
||||
-e 's|/etc/moduli|$(sysconfdir)/moduli|g' \
|
||||
-e 's|/etc/ssh/moduli|$(sysconfdir)/moduli|g' \
|
||||
Common subdirectories: a/openbsd-compat and b/openbsd-compat
|
||||
diff -u a/pathnames.h b/pathnames.h
|
||||
--- a/pathnames.h 2018-10-16 20:01:20.000000000 -0400
|
||||
+++ b/pathnames.h 2018-12-06 04:15:01.286012398 -0500
|
||||
@@ -18,6 +18,10 @@
|
||||
#define SSHDIR ETCDIR "/ssh"
|
||||
#endif
|
||||
|
||||
+#ifndef KEYDIR
|
||||
+#define KEYDIR SSHDIR
|
||||
+#endif
|
||||
+
|
||||
#ifndef _PATH_SSH_PIDDIR
|
||||
#define _PATH_SSH_PIDDIR "/var/run"
|
||||
#endif
|
||||
@@ -26,9 +30,9 @@
|
||||
* System-wide file containing host keys of known hosts. This file should be
|
||||
* world-readable.
|
||||
*/
|
||||
-#define _PATH_SSH_SYSTEM_HOSTFILE SSHDIR "/ssh_known_hosts"
|
||||
+#define _PATH_SSH_SYSTEM_HOSTFILE KEYDIR "/ssh_known_hosts"
|
||||
/* backward compat for protocol 2 */
|
||||
-#define _PATH_SSH_SYSTEM_HOSTFILE2 SSHDIR "/ssh_known_hosts2"
|
||||
+#define _PATH_SSH_SYSTEM_HOSTFILE2 KEYDIR "/ssh_known_hosts2"
|
||||
|
||||
/*
|
||||
* Of these, ssh_host_key must be readable only by root, whereas ssh_config
|
||||
@@ -36,11 +40,11 @@
|
||||
*/
|
||||
#define _PATH_SERVER_CONFIG_FILE SSHDIR "/sshd_config"
|
||||
#define _PATH_HOST_CONFIG_FILE SSHDIR "/ssh_config"
|
||||
-#define _PATH_HOST_DSA_KEY_FILE SSHDIR "/ssh_host_dsa_key"
|
||||
-#define _PATH_HOST_ECDSA_KEY_FILE SSHDIR "/ssh_host_ecdsa_key"
|
||||
-#define _PATH_HOST_ED25519_KEY_FILE SSHDIR "/ssh_host_ed25519_key"
|
||||
-#define _PATH_HOST_XMSS_KEY_FILE SSHDIR "/ssh_host_xmss_key"
|
||||
-#define _PATH_HOST_RSA_KEY_FILE SSHDIR "/ssh_host_rsa_key"
|
||||
-#define _PATH_DH_MODULI SSHDIR "/moduli"
|
||||
+#define _PATH_HOST_DSA_KEY_FILE KEYDIR "/ssh_host_dsa_key"
|
||||
+#define _PATH_HOST_ECDSA_KEY_FILE KEYDIR "/ssh_host_ecdsa_key"
|
||||
+#define _PATH_HOST_ED25519_KEY_FILE KEYDIR "/ssh_host_ed25519_key"
|
||||
+#define _PATH_HOST_XMSS_KEY_FILE KEYDIR "/ssh_host_xmss_key"
|
||||
+#define _PATH_HOST_RSA_KEY_FILE KEYDIR "/ssh_host_rsa_key"
|
||||
+#define _PATH_DH_MODULI KEYDIR "/moduli"
|
||||
|
||||
#ifndef _PATH_SSH_PROGRAM
|
||||
#define _PATH_SSH_PROGRAM "/usr/bin/ssh"
|
@ -0,0 +1,31 @@
|
||||
--- a/authfile.c 2016-07-28 00:54:27.000000000 +0200
|
||||
+++ b/authfile.c 2018-07-03 19:13:08.496275544 +0200
|
||||
@@ -169,28 +169,6 @@
|
||||
int
|
||||
sshkey_perm_ok(int fd, const char *filename)
|
||||
{
|
||||
- struct stat st;
|
||||
-
|
||||
- if (fstat(fd, &st) < 0)
|
||||
- return SSH_ERR_SYSTEM_ERROR;
|
||||
- /*
|
||||
- * if a key owned by the user is accessed, then we check the
|
||||
- * permissions of the file. if the key owned by a different user,
|
||||
- * then we don't care.
|
||||
- */
|
||||
-#ifdef HAVE_CYGWIN
|
||||
- if (check_ntsec(filename))
|
||||
-#endif
|
||||
- if ((st.st_uid == getuid()) && (st.st_mode & 077) != 0) {
|
||||
- error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
|
||||
- error("@ WARNING: UNPROTECTED PRIVATE KEY FILE! @");
|
||||
- error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
|
||||
- error("Permissions 0%3.3o for '%s' are too open.",
|
||||
- (u_int)st.st_mode & 0777, filename);
|
||||
- error("It is required that your private key files are NOT accessible by others.");
|
||||
- error("This private key will be ignored.");
|
||||
- return SSH_ERR_KEY_BAD_PERMISSIONS;
|
||||
- }
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
diff --git a/sshconnect2.c b/sshconnect2.c
|
||||
index d6af0b9..22c0aa6 100644
|
||||
--- a/sshconnect2.c
|
||||
+++ b/sshconnect2.c
|
||||
@@ -1320,8 +1320,7 @@ load_identity_file(char *filename, int userprovided)
|
||||
struct stat st;
|
||||
|
||||
if (stat(id->filename, &st) < 0) {
|
||||
- (id->userprovided ? logit : debug3)("no such identity: %s: %s",
|
||||
- id->filename, strerror(errno));
|
||||
+ debug3("no such identity: %s", id->filename);
|
||||
return NULL;
|
||||
}
|
||||
private = key_load_private_type(KEY_UNSPEC, filename, "", NULL, &perm_ok);
|
@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=OpenSSH server daemon
|
||||
ConditionKernelCommandLine=|ssh
|
||||
ConditionPathExists=|/storage/.cache/services/sshd.conf
|
||||
|
||||
[Service]
|
||||
Restart=on-failure
|
||||
EnvironmentFile=-/storage/.cache/services/sshd.conf
|
||||
ExecStartPre=/usr/bin/ssh-keygen -A
|
||||
ExecStart=/usr/sbin/sshd -D $SSH_ARGS
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
TimeoutStopSec=1s
|
||||
RestartSec=2
|
||||
StartLimitInterval=0
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
||||
|
||||
d /var/empty 0600 root root - -
|
||||
d /storage/.cache/ssh 0755 root root - -
|
||||
d /storage/.ssh 0700 root root - -
|
@ -0,0 +1,21 @@
|
||||
[Unit]
|
||||
Description=Retroarch
|
||||
After=graphical.target
|
||||
ConditionKernelCommandLine=!retroarch=0
|
||||
Requires=graphical.target
|
||||
|
||||
[Service]
|
||||
Environment=HOME=/storage DISPLAY=:0
|
||||
EnvironmentFile=-/run/libreelec/retroarch.conf
|
||||
EnvironmentFile=-/storage/.cache/services/retroarch.conf
|
||||
ExecStartPre=-/usr/lib/retroarch/retroarch-config
|
||||
ExecStart=/usr/bin/retroarch
|
||||
# keep KillMode=process unless there is no good reason to switch to cgroup
|
||||
KillMode=process
|
||||
TimeoutStopSec=300
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
StartLimitInterval=0
|
||||
|
||||
[Install]
|
||||
WantedBy=retroarch.target
|
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Assets directory
|
||||
Before=retroarch.service umount.target
|
||||
Conflicts=umount.target
|
||||
After=systemd-tmpfiles-setup.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Mount]
|
||||
What=/storage/assets:/usr/share/retroarch-assets
|
||||
Where=/tmp/assets
|
||||
Type=mergerfs
|
||||
Options=defaults,allow_other,use_ino
|
||||
|
||||
[Install]
|
||||
WantedBy=retroarch.target
|
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Cores directory
|
||||
Before=retroarch.service umount.target
|
||||
Conflicts=umount.target
|
||||
After=systemd-tmpfiles-setup.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Mount]
|
||||
What=/storage/cores:/usr/lib/libretro
|
||||
Where=/tmp/cores
|
||||
Type=mergerfs
|
||||
Options=defaults,allow_other,use_ino
|
||||
|
||||
[Install]
|
||||
WantedBy=retroarch.target
|
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Database directory
|
||||
Before=retroarch.service umount.target
|
||||
Conflicts=umount.target
|
||||
After=systemd-tmpfiles-setup.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Mount]
|
||||
What=/storage/database:/usr/share/libretro-database
|
||||
Where=/tmp/database
|
||||
Type=mergerfs
|
||||
Options=defaults,allow_other,use_ino
|
||||
|
||||
[Install]
|
||||
WantedBy=retroarch.target
|
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Joypad configs directory
|
||||
Before=retroarch.service umount.target
|
||||
Conflicts=umount.target
|
||||
After=systemd-tmpfiles-setup.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Mount]
|
||||
What=/storage/joypads:/etc/retroarch-joypad-autoconfig
|
||||
Where=/tmp/joypads
|
||||
Type=mergerfs
|
||||
Options=defaults,allow_other,use_ino
|
||||
|
||||
[Install]
|
||||
WantedBy=retroarch.target
|
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Overlays directory
|
||||
Before=retroarch.service umount.target
|
||||
Conflicts=umount.target
|
||||
After=systemd-tmpfiles-setup.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Mount]
|
||||
What=/storage/overlays:/usr/share/retroarch-overlays
|
||||
Where=/tmp/overlays
|
||||
Type=mergerfs
|
||||
Options=defaults,allow_other,use_ino
|
||||
|
||||
[Install]
|
||||
WantedBy=retroarch.target
|
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Shaders directory RetroArch
|
||||
Before=retroarch.service umount.target
|
||||
Conflicts=umount.target
|
||||
After=systemd-tmpfiles-setup.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Mount]
|
||||
What=/storage/shaders:/usr/share/common-shaders
|
||||
Where=/tmp/shaders
|
||||
Type=mergerfs
|
||||
Options=defaults,allow_other,use_ino
|
||||
|
||||
[Install]
|
||||
WantedBy=retroarch.target
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user