mirror of
https://github.com/libretro/Lakka-LibreELEC.git
synced 2024-11-28 01:34:40 +00:00
66e50e96b9
* L4T: Fix/Enable NVV4l2 decoder in libreelec builds. * L4T: LibreELEC: Allow Kodi to run as root * L4T: Small Tree Cleanup * Bluez: Switch: LibreELEC: Fix fast connect on all switch builds, not just lakka. * L4T: Finish ffmpeg 6.0 patchset * L4T: Fix building newer libcec for switch * L4T: switch-bsp: Update dock hotplug to check distro stuff, before integrating CEC and bump version.
223 lines
9.0 KiB
Diff
223 lines
9.0 KiB
Diff
From a3ee3863be6268abaf331af6a12892feeb8797c6 Mon Sep 17 00:00:00 2001
|
|
From: CTCaer <ctcaer@gmail.com>
|
|
Date: Sun, 2 Jul 2023 03:18:28 +0000
|
|
Subject: [PATCH 29/39] fftools: improve nvv4l2 enforcing Now non-supported
|
|
pixel formats are properly handled. Additionally, all edge cases are handled
|
|
even if the codec is forced by user.
|
|
|
|
---
|
|
fftools/ffmpeg_demux.c | 92 ++++++++++++++++++++++++++++++------------
|
|
fftools/ffplay.c | 74 +++++++++++++++++++++++++--------
|
|
2 files changed, 124 insertions(+), 42 deletions(-)
|
|
|
|
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
|
|
index 938ec09e3d..3b58c18f3d 100644
|
|
--- a/fftools/ffmpeg_demux.c
|
|
+++ b/fftools/ffmpeg_demux.c
|
|
@@ -500,40 +500,80 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s
|
|
|
|
{
|
|
char *codec_name = NULL;
|
|
+#if CONFIG_NVV4L2
|
|
+ int nvv4l2_pix_fmt_ok;
|
|
+#endif
|
|
|
|
MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
|
|
- if (codec_name) {
|
|
- const AVCodec *codec = find_codec_or_die(NULL, codec_name, st->codecpar->codec_type, 0);
|
|
- st->codecpar->codec_id = codec->id;
|
|
- if (recast_media && st->codecpar->codec_type != codec->type)
|
|
- st->codecpar->codec_type = codec->type;
|
|
- return codec;
|
|
- } else {
|
|
- if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
|
|
- hwaccel_id == HWACCEL_GENERIC &&
|
|
- hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
|
|
- const AVCodec *c;
|
|
- void *i = NULL;
|
|
-
|
|
- while ((c = av_codec_iterate(&i))) {
|
|
- const AVCodecHWConfig *config;
|
|
|
|
- if (c->id != st->codecpar->codec_id ||
|
|
- !av_codec_is_decoder(c))
|
|
- continue;
|
|
+#if CONFIG_NVV4L2
|
|
+ nvv4l2_pix_fmt_ok = st->codecpar->format == AV_PIX_FMT_NONE ||
|
|
+ st->codecpar->format == AV_PIX_FMT_NV12 ||
|
|
+ st->codecpar->format == AV_PIX_FMT_YUV420P;
|
|
|
|
- for (int j = 0; config = avcodec_get_hw_config(c, j); j++) {
|
|
- if (config->device_type == hwaccel_device_type) {
|
|
- av_log(NULL, AV_LOG_VERBOSE, "Selecting decoder '%s' because of requested hwaccel method %s\n",
|
|
- c->name, av_hwdevice_get_type_name(hwaccel_device_type));
|
|
- return c;
|
|
- }
|
|
- }
|
|
- }
|
|
+ /* Force software decoding if codec name not defined and pixel format not supported. */
|
|
+ if (!codec_name && !nvv4l2_pix_fmt_ok) {
|
|
+ switch (st->codecpar->codec_id) {
|
|
+ case AV_CODEC_ID_H264:
|
|
+ codec_name = (char *)"h264";
|
|
+ break;
|
|
+ case AV_CODEC_ID_HEVC:
|
|
+ codec_name = (char *)"hevc";
|
|
+ break;
|
|
+ case AV_CODEC_ID_MPEG2VIDEO:
|
|
+ codec_name = (char *)"mpeg2video";
|
|
+ break;
|
|
+ case AV_CODEC_ID_MPEG4:
|
|
+ codec_name = (char *)"mpeg4";
|
|
+ break;
|
|
+ case AV_CODEC_ID_VP8:
|
|
+ codec_name = (char *)"vp8";
|
|
+ break;
|
|
+ case AV_CODEC_ID_VP9:
|
|
+ codec_name = (char *)"vp9";
|
|
+ break;
|
|
}
|
|
+ }
|
|
+#endif
|
|
|
|
+ if (!codec_name)
|
|
return avcodec_find_decoder(st->codecpar->codec_id);
|
|
+
|
|
+#if CONFIG_NVV4L2
|
|
+ if (nvv4l2_pix_fmt_ok) {
|
|
+ /* Force hardware decoding if pixel format supported. */
|
|
+ if (strcmp(codec_name, "h264") == 0)
|
|
+ return avcodec_find_decoder(st->codecpar->codec_id);
|
|
+ else if (strcmp(codec_name, "hevc") == 0)
|
|
+ return avcodec_find_decoder(st->codecpar->codec_id);
|
|
+ else if (strcmp(codec_name, "mpeg2video") == 0)
|
|
+ return avcodec_find_decoder(st->codecpar->codec_id);
|
|
+ else if (strcmp(codec_name, "mpeg4") == 0)
|
|
+ return avcodec_find_decoder(st->codecpar->codec_id);
|
|
+ else if (strcmp(codec_name, "vp8") == 0)
|
|
+ return avcodec_find_decoder(st->codecpar->codec_id);
|
|
+ else if (strcmp(codec_name, "vp9") == 0)
|
|
+ return avcodec_find_decoder(st->codecpar->codec_id);
|
|
+ } else {
|
|
+ /* Force software decoding if pixel format not supported. */
|
|
+ if (strcmp(codec_name, "h264_nvv4l2") == 0)
|
|
+ codec_name = (char *)"h264";
|
|
+ else if (strcmp(codec_name, "hevc_nvv4l2") == 0)
|
|
+ codec_name = (char *)"hevc";
|
|
+ else if (strcmp(codec_name, "mpeg2video_nvv4l2") == 0)
|
|
+ codec_name = (char *)"mpeg2video";
|
|
+ else if (strcmp(codec_name, "mpeg4_nvv4l2") == 0)
|
|
+ codec_name = (char *)"mpeg4";
|
|
+ else if (strcmp(codec_name, "vp8_nvv4l2") == 0)
|
|
+ codec_name = (char *)"vp8";
|
|
+ else if (strcmp(codec_name, "vp9_nvv4l2") == 0)
|
|
+ codec_name = (char *)"vp9";
|
|
}
|
|
+#endif
|
|
+
|
|
+ const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
|
|
+ st->codecpar->codec_id = codec->id;
|
|
+ return codec;
|
|
}
|
|
|
|
static int guess_input_channel_layout(InputStream *ist)
|
|
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
|
|
index 86f8425a15..a02f2a06a7 100644
|
|
--- a/fftools/ffplay.c
|
|
+++ b/fftools/ffplay.c
|
|
@@ -2570,6 +2570,9 @@ static int stream_component_open(VideoState *is, int stream_index)
|
|
AVChannelLayout ch_layout = { 0 };
|
|
int ret = 0;
|
|
int stream_lowres = lowres;
|
|
+#if CONFIG_NVV4L2
|
|
+ int nvv4l2_pix_fmt_ok;
|
|
+#endif
|
|
|
|
if (stream_index < 0 || stream_index >= ic->nb_streams)
|
|
return -1;
|
|
@@ -2593,26 +2596,65 @@ static int stream_component_open(VideoState *is, int stream_index)
|
|
|
|
#if CONFIG_NVV4L2
|
|
/* Reset requested decoder in order to enforce NVV4L2 if possible. */
|
|
+ nvv4l2_pix_fmt_ok = avctx->pix_fmt == AV_PIX_FMT_NONE ||
|
|
+ avctx->pix_fmt == AV_PIX_FMT_NV12 ||
|
|
+ avctx->pix_fmt == AV_PIX_FMT_YUV420P;
|
|
+
|
|
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && forced_codec_name) {
|
|
- if (strcmp(forced_codec_name, "h264") == 0)
|
|
- forced_codec_name = NULL;
|
|
- else if (strcmp(forced_codec_name, "hevc") == 0)
|
|
- forced_codec_name = NULL;
|
|
- else if (strcmp(forced_codec_name, "mpeg2video") == 0)
|
|
- forced_codec_name = NULL;
|
|
- else if (strcmp(forced_codec_name, "mpeg4") == 0)
|
|
- forced_codec_name = NULL;
|
|
- else if (strcmp(forced_codec_name, "vp8") == 0)
|
|
- forced_codec_name = NULL;
|
|
- else if (strcmp(forced_codec_name, "vp9") == 0 &&
|
|
- avctx->pix_fmt != AV_PIX_FMT_YUV420P10) {
|
|
- forced_codec_name = NULL;
|
|
+ if (nvv4l2_pix_fmt_ok) {
|
|
+ /* Force hardware decoding if pixel format supported. */
|
|
+ if (strcmp(forced_codec_name, "h264") == 0)
|
|
+ forced_codec_name = NULL;
|
|
+ else if (strcmp(forced_codec_name, "hevc") == 0)
|
|
+ forced_codec_name = NULL;
|
|
+ else if (strcmp(forced_codec_name, "mpeg2video") == 0)
|
|
+ forced_codec_name = NULL;
|
|
+ else if (strcmp(forced_codec_name, "mpeg4") == 0)
|
|
+ forced_codec_name = NULL;
|
|
+ else if (strcmp(forced_codec_name, "vp8") == 0)
|
|
+ forced_codec_name = NULL;
|
|
+ else if (strcmp(forced_codec_name, "vp9") == 0)
|
|
+ forced_codec_name = NULL;
|
|
+ } else {
|
|
+ /* Force software decoding if pixel format not supported. */
|
|
+ if (strcmp(forced_codec_name, "h264_nvv4l2") == 0)
|
|
+ forced_codec_name = (char *)"h264";
|
|
+ else if (strcmp(forced_codec_name, "hevc_nvv4l2") == 0)
|
|
+ forced_codec_name = (char *)"hevc";
|
|
+ else if (strcmp(forced_codec_name, "mpeg2video_nvv4l2") == 0)
|
|
+ forced_codec_name = (char *)"mpeg2video";
|
|
+ else if (strcmp(forced_codec_name, "mpeg4_nvv4l2") == 0)
|
|
+ forced_codec_name = (char *)"mpeg4";
|
|
+ else if (strcmp(forced_codec_name, "vp8_nvv4l2") == 0)
|
|
+ forced_codec_name = (char *)"vp8";
|
|
+ else if (strcmp(forced_codec_name, "vp9_nvv4l2") == 0)
|
|
+ forced_codec_name = (char *)"vp9";
|
|
}
|
|
}
|
|
|
|
- /* NVV4L2 does not support VP9 with YUV420P10. */
|
|
- if (!forced_codec_name && avctx->pix_fmt == AV_PIX_FMT_YUV420P10)
|
|
- forced_codec_name = "vp9";
|
|
+ /* Force software decoding if codec name not defined and pixel format not supported. */
|
|
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !forced_codec_name && !nvv4l2_pix_fmt_ok) {
|
|
+ switch (avctx->codec_id) {
|
|
+ case AV_CODEC_ID_H264:
|
|
+ forced_codec_name = (char *)"h264";
|
|
+ break;
|
|
+ case AV_CODEC_ID_HEVC:
|
|
+ forced_codec_name = (char *)"hevc";
|
|
+ break;
|
|
+ case AV_CODEC_ID_MPEG2VIDEO:
|
|
+ forced_codec_name = (char *)"mpeg2video";
|
|
+ break;
|
|
+ case AV_CODEC_ID_MPEG4:
|
|
+ forced_codec_name = (char *)"mpeg4";
|
|
+ break;
|
|
+ case AV_CODEC_ID_VP8:
|
|
+ forced_codec_name = (char *)"vp8";
|
|
+ break;
|
|
+ case AV_CODEC_ID_VP9:
|
|
+ forced_codec_name = (char *)"vp9";
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
#endif
|
|
|
|
if (forced_codec_name)
|
|
--
|
|
2.25.1
|
|
|