mirror of
https://github.com/jellyfin/jellyfin-ffmpeg.git
synced 2026-09-03 05:09:58 +03:00
Avoid amfenc assertion due to filter chain reset
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
This commit is contained in:
@@ -77,7 +77,17 @@ Index: FFmpeg/libavcodec/amfenc.c
|
||||
AMF_RETURN_IF_FALSE(ctx, can_read > 0, AVERROR_UNKNOWN,
|
||||
"timestamp_list is empty while max_b_frames = %d\n", avctx->max_b_frames);
|
||||
av_fifo_peek(ctx->timestamp_list, ×tamp_last, 1, can_read - 1);
|
||||
@@ -766,11 +751,50 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
@@ -690,9 +675,6 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
ID3D11Texture2D *texture = (ID3D11Texture2D*)frame->data[0]; // actual texture
|
||||
int index = (intptr_t)frame->data[1]; // index is a slice in texture array is - set to tell AMF which slice to use
|
||||
|
||||
- av_assert0(frame->hw_frames_ctx && ctx->hw_frames_ctx &&
|
||||
- frame->hw_frames_ctx->data == ctx->hw_frames_ctx->data);
|
||||
-
|
||||
texture->lpVtbl->SetPrivateData(texture, &AMFTextureArrayIndexGUID, sizeof(index), &index);
|
||||
|
||||
res = ctx->context->pVtbl->CreateSurfaceFromDX11Native(ctx->context, texture, &surface, NULL); // wrap to AMF surface
|
||||
@@ -766,11 +748,50 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
switch (avctx->codec->id) {
|
||||
case AV_CODEC_ID_H264:
|
||||
AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_INSERT_AUD, !!ctx->aud);
|
||||
@@ -129,7 +139,7 @@ Index: FFmpeg/libavcodec/amfenc.c
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -787,6 +811,13 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
@@ -787,6 +808,13 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
|
||||
av_frame_unref(frame);
|
||||
ret = av_fifo_write(ctx->timestamp_list, &pts, 1);
|
||||
@@ -143,7 +153,7 @@ Index: FFmpeg/libavcodec/amfenc.c
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
@@ -796,7 +827,7 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
@@ -796,7 +824,7 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
do {
|
||||
block_and_wait = 0;
|
||||
// poll data
|
||||
@@ -152,7 +162,7 @@ Index: FFmpeg/libavcodec/amfenc.c
|
||||
res_query = ctx->encoder->pVtbl->QueryOutput(ctx->encoder, &data);
|
||||
if (data) {
|
||||
// copy data to packet
|
||||
@@ -806,6 +837,7 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
@@ -806,6 +834,7 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
data->pVtbl->QueryInterface(data, &guid, (void**)&buffer); // query for buffer interface
|
||||
ret = amf_copy_buffer(avctx, avpkt, buffer);
|
||||
|
||||
@@ -160,7 +170,7 @@ Index: FFmpeg/libavcodec/amfenc.c
|
||||
buffer->pVtbl->Release(buffer);
|
||||
|
||||
if (data->pVtbl->HasProperty(data, L"av_frame_ref")) {
|
||||
@@ -845,6 +877,7 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
@@ -845,6 +874,7 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
av_frame_unref(ctx->delayed_frame);
|
||||
AMF_RETURN_IF_FALSE(ctx, res_resubmit == AMF_OK, AVERROR_UNKNOWN, "Repeated SubmitInput() failed with error %d\n", res_resubmit);
|
||||
|
||||
@@ -168,7 +178,7 @@ Index: FFmpeg/libavcodec/amfenc.c
|
||||
ret = av_fifo_write(ctx->timestamp_list, &pts, 1);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@@ -863,7 +896,12 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
@@ -863,7 +893,12 @@ int ff_amf_receive_packet(AVCodecContext
|
||||
if (query_output_data_flag == 0) {
|
||||
if (res_resubmit == AMF_INPUT_FULL || ctx->delayed_drain || (ctx->eof && res_query != AMF_EOF) || (ctx->hwsurfaces_in_queue >= ctx->hwsurfaces_in_queue_max)) {
|
||||
block_and_wait = 1;
|
||||
|
||||
Reference in New Issue
Block a user