ffmpeg: remove rkmpp support

This commit is contained in:
Jonas Karlman 2019-12-31 09:09:33 +00:00
parent 30d63b56a0
commit 406fb9ad7d
5 changed files with 0 additions and 261 deletions

View File

@ -41,15 +41,6 @@ else
PKG_FFMPEG_VDPAU="--disable-vdpau"
fi
if [ "${PROJECT}" = "Rockchip" -a "${LINUX}" = "rockchip-4.4" ]; then
PKG_DEPENDS_TARGET+=" rkmpp"
PKG_NEED_UNPACK+=" $(get_pkg_directory rkmpp)"
PKG_PATCH_DIRS+=" rkmpp"
PKG_FFMPEG_RKMPP="--enable-rkmpp --enable-libdrm --enable-version3"
else
PKG_FFMPEG_RKMPP="--disable-rkmpp"
fi
if [ "${PROJECT}" = "Allwinner" -o "${PROJECT}" = "Rockchip" ]; then
PKG_DEPENDS_TARGET+=" libdrm systemd" # systemd is needed for libudev
PKG_NEED_UNPACK+=" $(get_pkg_directory libdrm) $(get_pkg_directory systemd)"
@ -153,7 +144,6 @@ configure_target() {
${PKG_FFMPEG_VAAPI} \
${PKG_FFMPEG_VDPAU} \
${PKG_FFMPEG_RPI} \
${PKG_FFMPEG_RKMPP} \
${PKG_FFMPEG_V4L2_REQUEST} \
--enable-runtime-cpudetect \
--disable-hardcoded-tables \

View File

@ -1,22 +0,0 @@
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 {

View File

@ -1,44 +0,0 @@
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);
}

View File

@ -1,80 +0,0 @@
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)

View File

@ -1,105 +0,0 @@
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);