forked from jellyfin/jellyfin-ffmpeg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jellyfin#28 from nyanmisaka/amfupdate
Update AMF encoder to support Linux
- Loading branch information
Showing
4 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
jellyfin-ffmpeg (4.2.1-6) unstable; urgency=medium | ||
|
||
* Update AMD AMF files to support Linux | ||
|
||
-- nyanmisaka <[email protected]> Tue, 25 Feb 2020 17:33:28 +0800 | ||
|
||
jellyfin-ffmpeg (4.2.1-5) unstable; urgency=medium | ||
|
||
* Add support for Debian Bullseye (testing) | ||
|
100 changes: 100 additions & 0 deletions
100
debian/patches/0002-Update-AMF-files-to-support-Linux.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
Index: jellyfin-ffmpeg/libavcodec/amfenc.c | ||
=================================================================== | ||
--- jellyfin-ffmpeg.orig/libavcodec/amfenc.c | ||
+++ jellyfin-ffmpeg/libavcodec/amfenc.c | ||
@@ -213,6 +213,7 @@ static int amf_init_from_dxva2_device(AV | ||
static int amf_init_context(AVCodecContext *avctx) | ||
{ | ||
AmfContext *ctx = avctx->priv_data; | ||
+ AMFContext1 *context1 = NULL; | ||
AMF_RESULT res; | ||
av_unused int ret; | ||
|
||
@@ -311,8 +312,20 @@ static int amf_init_context(AVCodecConte | ||
if (res == AMF_OK) { | ||
av_log(avctx, AV_LOG_VERBOSE, "AMF initialisation succeeded via D3D9.\n"); | ||
} else { | ||
- av_log(avctx, AV_LOG_ERROR, "AMF initialisation failed via D3D9: error %d.\n", res); | ||
- return AVERROR(ENOSYS); | ||
+ AMFGuid guid = IID_AMFContext1(); | ||
+ res = ctx->context->pVtbl->QueryInterface(ctx->context, &guid, (void**)&context1); | ||
+ AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, "CreateContext1() failed with error %d\n", res); | ||
+ | ||
+ res = context1->pVtbl->InitVulkan(context1, NULL); | ||
+ context1->pVtbl->Release(context1); | ||
+ if (res != AMF_OK) { | ||
+ if (res == AMF_NOT_SUPPORTED) | ||
+ av_log(avctx, AV_LOG_ERROR, "AMF via Vulkan is not supported on the given device.\n"); | ||
+ else | ||
+ av_log(avctx, AV_LOG_ERROR, "AMF failed to initialise on the given Vulkan device: %d.\n", res); | ||
+ return AVERROR(ENOSYS); | ||
+ } | ||
+ av_log(avctx, AV_LOG_VERBOSE, "AMF initialisation succeeded via Vulkan.\n"); | ||
} | ||
} | ||
} | ||
@@ -438,7 +451,7 @@ static int amf_copy_buffer(AVCodecContex | ||
int64_t timestamp = AV_NOPTS_VALUE; | ||
int64_t size = buffer->pVtbl->GetSize(buffer); | ||
|
||
- if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0) { | ||
+ if ((ret = av_new_packet(pkt, size)) < 0) { | ||
return ret; | ||
} | ||
memcpy(pkt->data, buffer->pVtbl->GetNative(buffer), size); | ||
Index: jellyfin-ffmpeg/libavcodec/amfenc_h264.c | ||
=================================================================== | ||
--- jellyfin-ffmpeg.orig/libavcodec/amfenc_h264.c | ||
+++ jellyfin-ffmpeg/libavcodec/amfenc_h264.c | ||
@@ -366,6 +366,7 @@ static const AVCodecDefault defaults[] = | ||
{ "b", "2M" }, | ||
{ "g", "250" }, | ||
{ "slices", "1" }, | ||
+ { "flags", "+loop"}, | ||
{ NULL }, | ||
}; | ||
|
||
Index: jellyfin-ffmpeg/libavcodec/amfenc_hevc.c | ||
=================================================================== | ||
--- jellyfin-ffmpeg.orig/libavcodec/amfenc_hevc.c | ||
+++ jellyfin-ffmpeg/libavcodec/amfenc_hevc.c | ||
@@ -69,7 +69,7 @@ static const AVOption options[] = { | ||
{ "gop", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_GOP_ALIGNED }, 0, 0, VE, "hdrmode" }, | ||
{ "idr", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_HEADER_INSERTION_MODE_IDR_ALIGNED }, 0, 0, VE, "hdrmode" }, | ||
|
||
- { "gops_per_idr", "GOPs per IDR 0-no IDR will be inserted", OFFSET(gops_per_idr), AV_OPT_TYPE_INT, { .i64 = 60 }, 0, INT_MAX, VE }, | ||
+ { "gops_per_idr", "GOPs per IDR 0-no IDR will be inserted", OFFSET(gops_per_idr), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, VE }, | ||
{ "preanalysis", "Enable preanalysis", OFFSET(preanalysis), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, | ||
{ "vbaq", "Enable VBAQ", OFFSET(enable_vbaq), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, | ||
{ "enforce_hrd", "Enforce HRD", OFFSET(enforce_hrd), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, | ||
@@ -136,7 +136,7 @@ static av_cold int amf_encode_init_hevc( | ||
AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_TIER, ctx->tier); | ||
|
||
profile_level = avctx->level; | ||
- if (profile_level == 0) { | ||
+ if (profile_level == FF_LEVEL_UNKNOWN) { | ||
profile_level = ctx->level; | ||
} | ||
if (profile_level != 0) { | ||
@@ -144,7 +144,7 @@ static av_cold int amf_encode_init_hevc( | ||
} | ||
AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET, ctx->quality); | ||
// Maximum Reference Frames | ||
- if (avctx->refs != 0) { | ||
+ if (avctx->refs != -1) { | ||
AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MAX_NUM_REFRAMES, avctx->refs); | ||
} | ||
// Aspect Ratio | ||
@@ -254,10 +254,10 @@ static av_cold int amf_encode_init_hevc( | ||
} | ||
|
||
if (ctx->qp_p != -1) { | ||
- AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QP_I, ctx->qp_p); | ||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QP_P, ctx->qp_p); | ||
} | ||
if (ctx->qp_i != -1) { | ||
- AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QP_P, ctx->qp_i); | ||
+ AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_QP_I, ctx->qp_i); | ||
} | ||
AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_SKIP_FRAME_ENABLE, ctx->skip_frame); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
0001_fix-segment-muxer.patch | ||
0002-Update-AMF-files-to-support-Linux.patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters