diff --git a/make/target-ffmpeg.mk b/make/target-ffmpeg.mk index 6895f98b..586cf3cd 100644 --- a/make/target-ffmpeg.mk +++ b/make/target-ffmpeg.mk @@ -3,7 +3,7 @@ # # ----------------------------------------------------------------------------- -FFMPEG_VER = 4.2.2 +FFMPEG_VER = 4.3 FFMPEG_TMP = ffmpeg-$(FFMPEG_VER) FFMPEG_SOURCE = ffmpeg-$(FFMPEG_VER).tar.xz FFMPEG_SITE = http://www.ffmpeg.org/releases @@ -11,15 +11,6 @@ FFMPEG_SITE = http://www.ffmpeg.org/releases $(ARCHIVE)/$(FFMPEG_SOURCE): $(DOWNLOAD) $(FFMPEG_SITE)/$(FFMPEG_SOURCE) -FFMPEG_PATCH = ffmpeg-02-fix_mpegts.patch -FFMPEG_PATCH += ffmpeg-03-allow_to_choose_rtmp_impl_at_runtime.patch -FFMPEG_PATCH += ffmpeg-04-hls_replace_key_uri.patch -FFMPEG_PATCH += ffmpeg-06-optimize_aac.patch -FFMPEG_PATCH += ffmpeg-07-increase_buffer_size.patch -FFMPEG_PATCH += ffmpeg-08-recheck_discard_flags.patch -FFMPEG_PATCH += ffmpeg-09-fix_edit_list_parsing.patch -FFMPEG_PATCH += ffmpeg-mips64_cpu_detection.patch - FFMPEG_UNPATCHED := no # ----------------------------------------------------------------------------- @@ -356,7 +347,7 @@ ffmpeg: $(FFMPEG_DEPS) $(ARCHIVE)/$(FFMPEG_SOURCE) | $(TARGET_DIR) $(UNTAR)/$(FFMPEG_SOURCE) ifneq ($(FFMPEG_UNPATCHED), yes) $(CHDIR)/$(FFMPEG_TMP); \ - $(call apply_patches, $(addprefix $(@F)/,$(FFMPEG_PATCH))) + $(APPLY_PATCHES) endif $(CHDIR)/$(FFMPEG_TMP); \ ./configure \ diff --git a/patches/ffmpeg/ffmpeg-02-fix_mpegts.patch b/patches/ffmpeg/4_02_fix_mpegts.patch similarity index 83% rename from patches/ffmpeg/ffmpeg-02-fix_mpegts.patch rename to patches/ffmpeg/4_02_fix_mpegts.patch index 83c7feba..a9610767 100644 --- a/patches/ffmpeg/ffmpeg-02-fix_mpegts.patch +++ b/patches/ffmpeg/4_02_fix_mpegts.patch @@ -1,6 +1,6 @@ --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c -@@ -1014,10 +1014,12 @@ static int new_pes_packet(PESContext *pes, AVPacket *pkt) +@@ -1015,10 +1015,12 @@ static int new_pes_packet(PESContext *pes, AVPacket *pkt) pes->buffer = NULL; reset_pes_packet_state(pes); diff --git a/patches/ffmpeg/ffmpeg-03-allow_to_choose_rtmp_impl_at_runtime.patch b/patches/ffmpeg/4_03_allow_to_choose_rtmp_impl_at_runtime.patch similarity index 92% rename from patches/ffmpeg/ffmpeg-03-allow_to_choose_rtmp_impl_at_runtime.patch rename to patches/ffmpeg/4_03_allow_to_choose_rtmp_impl_at_runtime.patch index dd9192b3..ea218c8e 100644 --- a/patches/ffmpeg/ffmpeg-03-allow_to_choose_rtmp_impl_at_runtime.patch +++ b/patches/ffmpeg/4_03_allow_to_choose_rtmp_impl_at_runtime.patch @@ -1,6 +1,6 @@ --- a/configure +++ b/configure -@@ -3353,10 +3353,8 @@ xv_outdev_deps="xlib" +@@ -3411,10 +3411,8 @@ xv_outdev_deps="xlib" # protocols async_protocol_deps="threads" bluray_protocol_deps="libbluray" @@ -11,7 +11,7 @@ ffrtmphttp_protocol_select="http_protocol" ftp_protocol_select="tcp_protocol" gopher_protocol_select="network" -@@ -3369,20 +3367,18 @@ https_protocol_suggest="zlib" +@@ -3427,20 +3425,18 @@ https_protocol_suggest="zlib" icecast_protocol_select="http_protocol" mmsh_protocol_select="http_protocol" mmst_protocol_select="network" @@ -46,7 +46,7 @@ sctp_protocol_deps="struct_sctp_event_subscribe struct_msghdr_msg_flags" --- a/libavformat/Makefile +++ b/libavformat/Makefile -@@ -599,12 +599,12 @@ OBJS-$(CONFIG_MMSH_PROTOCOL) += mmsh.o mms.o asf.o +@@ -609,12 +609,12 @@ OBJS-$(CONFIG_MMSH_PROTOCOL) += mmsh.o mms.o asf.o OBJS-$(CONFIG_MMST_PROTOCOL) += mmst.o mms.o asf.o OBJS-$(CONFIG_PIPE_PROTOCOL) += file.o OBJS-$(CONFIG_PROMPEG_PROTOCOL) += prompeg.o @@ -88,7 +88,7 @@ extern const URLProtocol ff_srtp_protocol; --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c -@@ -2592,7 +2592,7 @@ static int inject_fake_duration_metadata(RTMPContext *rt) +@@ -2591,7 +2591,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags, AVDictionary **opts) { RTMPContext *rt = s->priv_data; @@ -97,7 +97,7 @@ char *old_app, *qmark, *n, fname_buffer[1024]; uint8_t buf[2048]; int port; -@@ -2603,7 +2603,9 @@ static int rtmp_open(URLContext *s, const char *uri, int flags, AVDictionary **o +@@ -2602,7 +2602,9 @@ rt->is_input = !(flags & AVIO_FLAG_WRITE); @@ -108,7 +108,7 @@ hostname, sizeof(hostname), &port, path, sizeof(path), s->filename); -@@ -3137,9 +3139,9 @@ const URLProtocol ff_##flavor##_protocol = { \ +@@ -3141,9 +3143,9 @@ }; diff --git a/patches/ffmpeg/ffmpeg-04-hls_replace_key_uri.patch b/patches/ffmpeg/4_04_hls_replace_key_uri.patch similarity index 72% rename from patches/ffmpeg/ffmpeg-04-hls_replace_key_uri.patch rename to patches/ffmpeg/4_04_hls_replace_key_uri.patch index f5e1101b..3b105d4d 100644 --- a/patches/ffmpeg/ffmpeg-04-hls_replace_key_uri.patch +++ b/patches/ffmpeg/4_04_hls_replace_key_uri.patch @@ -1,15 +1,15 @@ --- a/libavformat/hls.c +++ b/libavformat/hls.c -@@ -207,6 +207,8 @@ typedef struct HLSContext { +@@ -209,6 +209,8 @@ + AVDictionary *avio_opts; + char *allowed_extensions; int max_reload; - int http_persistent; - int http_multiple; + char *key_uri_replace_old; + char *key_uri_replace_new; - AVIOContext *playlist_pb; - } HLSContext; - -@@ -1205,8 +1207,16 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg, + int http_persistent; + int http_multiple; + int http_seekable; +@@ -1243,8 +1245,16 @@ } else if (seg->key_type == KEY_AES_128) { char iv[33], key[33], url[MAX_URL_SIZE]; if (strcmp(seg->key, pls->key_url)) { @@ -27,7 +27,7 @@ ret = avio_read(pb, pls->key, sizeof(pls->key)); if (ret != sizeof(pls->key)) { av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s\n", -@@ -1218,6 +1228,8 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg, +@@ -1256,6 +1266,8 @@ seg->key); } av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url)); @@ -36,12 +36,12 @@ } ff_data_to_hex(iv, seg->iv, sizeof(seg->iv), 0); ff_data_to_hex(key, pls->key, sizeof(pls->key), 0); -@@ -2319,6 +2331,8 @@ static const AVOption hls_options[] = { - OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS }, - {"http_multiple", "Use multiple HTTP connections for fetching segments", - OFFSET(http_multiple), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, FLAGS}, +@@ -2367,6 +2379,8 @@ + INT_MIN, INT_MAX, FLAGS}, + {"max_reload", "Maximum number of times a insufficient list is attempted to be reloaded", + OFFSET(max_reload), AV_OPT_TYPE_INT, {.i64 = 1000}, 0, INT_MAX, FLAGS}, + { "key_uri_old", "allow to replace part of AES key uri - old", OFFSET(key_uri_replace_old), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, FLAGS }, + { "key_uri_new", "allow to replace part of AES key uri - new", OFFSET(key_uri_replace_new), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, FLAGS }, - {NULL} - }; - + {"m3u8_hold_counters", "The maximum number of times to load m3u8 when it refreshes without new segments", + OFFSET(m3u8_hold_counters), AV_OPT_TYPE_INT, {.i64 = 1000}, 0, INT_MAX, FLAGS}, + {"http_persistent", "Use persistent HTTP connections", diff --git a/patches/ffmpeg/ffmpeg-06-optimize_aac.patch b/patches/ffmpeg/4_06_optimize_aac.patch similarity index 100% rename from patches/ffmpeg/ffmpeg-06-optimize_aac.patch rename to patches/ffmpeg/4_06_optimize_aac.patch diff --git a/patches/ffmpeg/ffmpeg-07-increase_buffer_size.patch b/patches/ffmpeg/4_07_increase_buffer_size.patch similarity index 78% rename from patches/ffmpeg/ffmpeg-07-increase_buffer_size.patch rename to patches/ffmpeg/4_07_increase_buffer_size.patch index 824dfbc0..0ce6f9d6 100644 --- a/patches/ffmpeg/ffmpeg-07-increase_buffer_size.patch +++ b/patches/ffmpeg/4_07_increase_buffer_size.patch @@ -1,6 +1,6 @@ --- a/libavformat/avio.h +++ b/libavformat/avio.h -@@ -290,13 +290,6 @@ typedef struct AVIOContext { +@@ -290,12 +290,6 @@ typedef struct AVIOContext { */ int writeout_count; @@ -10,10 +10,9 @@ - * This field is internal to libavformat and access from outside is not allowed. - */ - int orig_buffer_size; -- + /** * Threshold to favor readahead over seek. - * This is current internal only, do not use from outside. --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -33,7 +33,7 @@ @@ -25,7 +24,7 @@ /** * Do seeks within this distance ahead of the current buffer by skipping -@@ -90,7 +90,6 @@ int ffio_init_context(AVIOContext *s, +@@ -85,7 +85,6 @@ int ffio_init_context(AVIOContext *s, memset(s, 0, sizeof(AVIOContext)); s->buffer = buffer; @@ -33,7 +32,7 @@ s->buffer_size = buffer_size; s->buf_ptr = buffer; s->buf_ptr_max = buffer; -@@ -570,15 +569,16 @@ static void fill_buffer(AVIOContext *s) +@@ -548,15 +547,15 @@ } /* make buffer smaller in case it ended up large after probing */ @@ -48,12 +47,11 @@ s->checksum_ptr = dst = s->buffer; } - len = s->orig_buffer_size; -+ av_assert0(len >= max_buffer_size); + len = max_buffer_size; } len = read_packet_wrapper(s, dst, len); -@@ -1086,7 +1086,6 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size) +@@ -1017,7 +1016,6 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size) av_free(s->buffer); s->buffer = buffer; @@ -61,9 +59,19 @@ s->buffer_size = buf_size; s->buf_ptr = s->buf_ptr_max = buffer; url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ); +@@ -1044,7 +1044,6 @@ + memcpy(buffer, s->write_flag ? s->buffer : s->buf_ptr, data_size); + av_free(s->buffer); + s->buffer = buffer; +- s->orig_buffer_size = buf_size; + s->buffer_size = buf_size; + s->buf_ptr = s->write_flag ? (s->buffer + data_size) : s->buffer; + if (s->write_flag) +diff --git a/libavformat/utils.c b/libavformat/utils.c +index c25eab4..02ce5e2 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c -@@ -138,6 +138,25 @@ FF_ENABLE_DEPRECATION_WARNINGS +@@ -133,6 +133,25 @@ FF_ENABLE_DEPRECATION_WARNINGS #endif #endif diff --git a/patches/ffmpeg/ffmpeg-08-recheck_discard_flags.patch b/patches/ffmpeg/4_08_recheck_discard_flags.patch similarity index 94% rename from patches/ffmpeg/ffmpeg-08-recheck_discard_flags.patch rename to patches/ffmpeg/4_08_recheck_discard_flags.patch index ee134fae..85079d5c 100644 --- a/patches/ffmpeg/ffmpeg-08-recheck_discard_flags.patch +++ b/patches/ffmpeg/4_08_recheck_discard_flags.patch @@ -1,6 +1,6 @@ --- a/libavformat/hls.c +++ b/libavformat/hls.c -@@ -2080,8 +2080,10 @@ +@@ -2140,8 +2140,10 @@ HLSContext *c = s->priv_data; int ret, i, minplaylist = -1; diff --git a/patches/ffmpeg/ffmpeg-09-fix_edit_list_parsing.patch b/patches/ffmpeg/4_09_ffmpeg_fix_edit_list_parsing.patch similarity index 88% rename from patches/ffmpeg/ffmpeg-09-fix_edit_list_parsing.patch rename to patches/ffmpeg/4_09_ffmpeg_fix_edit_list_parsing.patch index a1824011..b5631ee4 100644 --- a/patches/ffmpeg/ffmpeg-09-fix_edit_list_parsing.patch +++ b/patches/ffmpeg/4_09_ffmpeg_fix_edit_list_parsing.patch @@ -1,6 +1,6 @@ --- a/libavformat/mov.c +++ b/libavformat/mov.c -@@ -3558,8 +3558,10 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) +@@ -3615,8 +3615,10 @@ if (ctts_data_old && ctts_index_old < ctts_count_old) { curr_ctts = ctts_data_old[ctts_index_old].duration; diff --git a/patches/ffmpeg/4_10_rtsp_patch b/patches/ffmpeg/4_10_rtsp_patch new file mode 100644 index 00000000..9ee24cf3 --- /dev/null +++ b/patches/ffmpeg/4_10_rtsp_patch @@ -0,0 +1,54 @@ +--- a/libavformat/rtsp.c ++++ b/libavformat/rtsp.c +@@ -2338,7 +2338,9 @@ + RTSPStream *rtsp_st; + int size, i, err; + char *content; ++ const char *p, *sp="", *sources="", *sp2, *sources2; + char url[1024]; ++ char sources_buf[1024]; + + if (!ff_network_init()) + return AVERROR(EIO); +@@ -2364,6 +2366,16 @@ + av_freep(&content); + if (err) goto fail; + ++ /* Search for sources= tag in original URL for rtp protocol only */ ++ if (strncmp(s->url, "rtp://", 6) == 0) { ++ p = strchr(s->url, '?'); ++ if (p && av_find_info_tag(sources_buf, sizeof(sources_buf), "sources", p)) { ++ /* av_log(s, AV_LOG_VERBOSE, "sdp_read_header found sources %s\n", sources_buf); */ ++ sp = sources_buf; ++ sources = "&sources="; ++ } ++ } ++ + /* open each RTP stream */ + for (i = 0; i < rt->nb_rtsp_streams; i++) { + char namebuf[50]; +@@ -2381,12 +2393,22 @@ + av_dict_free(&opts); + goto fail; + } ++ ++ /* Prepare to add sources to the url to be opened. ++ Otherwise the join to the source specific muliticast will be missing */ ++ sources2 = sources; ++ sp2 = sp; ++ /* ignore sources from original URL, when sources are already set in rtsp_st */ ++ if (rtsp_st->nb_include_source_addrs > 0) ++ sources2 = sp2 = ""; ++ + ff_url_join(url, sizeof(url), "rtp", NULL, + namebuf, rtsp_st->sdp_port, +- "?localport=%d&ttl=%d&connect=%d&write_to_source=%d", ++ "?localport=%d&ttl=%d&connect=%d&write_to_source=%d%s%s", + rtsp_st->sdp_port, rtsp_st->sdp_ttl, + rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0, +- rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0); ++ rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0, ++ sources2, sp2); + + append_source_addrs(url, sizeof(url), "sources", + rtsp_st->nb_include_source_addrs, diff --git a/patches/ffmpeg/4_11_dxva2_patch b/patches/ffmpeg/4_11_dxva2_patch new file mode 100644 index 00000000..434cd27f --- /dev/null +++ b/patches/ffmpeg/4_11_dxva2_patch @@ -0,0 +1,108 @@ +--- a/libavcodec/dxva2.c ++++ b/libavcodec/dxva2.c +@@ -771,16 +771,18 @@ + #if CONFIG_D3D11VA + if (avctx->pix_fmt == AV_PIX_FMT_D3D11) + return (intptr_t)frame->data[1]; +- if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { ++ if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && surface) { + D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; + ID3D11VideoDecoderOutputView_GetDesc((ID3D11VideoDecoderOutputView*) surface, &viewDesc); + return viewDesc.Texture2D.ArraySlice; + } + #endif + #if CONFIG_DXVA2 +- for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { +- if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface) +- return i; ++ if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { ++ for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { ++ if (ctx->dxva2.surface[i] == surface) ++ return i; ++ } + } + #endif + +--- a/libavcodec/dxva2_h264.c ++++ b/libavcodec/dxva2_h264.c +@@ -504,6 +504,14 @@ + + if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0) + return -1; ++ ++ // Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs ++ if (!h->got_first_iframe) { ++ if (!(ctx_pic->pp.wBitFields & (1 << 15))) ++ return -1; ++ h->got_first_iframe = 1; ++ } ++ + ret = ff_dxva2_common_end_frame(avctx, h->cur_pic_ptr->f, + &ctx_pic->pp, sizeof(ctx_pic->pp), + &ctx_pic->qm, sizeof(ctx_pic->qm), +--- a/libavcodec/h264_slice.c ++++ b/libavcodec/h264_slice.c +@@ -928,6 +928,7 @@ + + h->first_field = 0; + h->prev_interlaced_frame = 1; ++ h->got_first_iframe = 0; + + init_scan_tables(h); + ret = ff_h264_alloc_tables(h); +--- a/libavcodec/h264dec.c ++++ b/libavcodec/h264dec.c +@@ -467,6 +467,7 @@ + + h->next_outputed_poc = INT_MIN; + h->prev_interlaced_frame = 1; ++ h->got_first_iframe = 0; + idr(h); + + h->poc.prev_frame_num = -1; +--- a/libavcodec/h264dec.h ++++ b/libavcodec/h264dec.h +@@ -539,6 +539,8 @@ + * slices) anymore */ + int setup_finished; + ++ int got_first_iframe; ++ + int cur_chroma_format_idc; + int cur_bit_depth_luma; + int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low +--- a/libavcodec/vaapi_h264.c ++++ b/libavcodec/vaapi_h264.c +@@ -314,6 +314,11 @@ + H264SliceContext *sl = &h->slice_ctx[0]; + int ret; + ++ if (pic->nb_slices == 0) { ++ ret = AVERROR_INVALIDDATA; ++ goto finish; ++ } ++ + ret = ff_vaapi_decode_issue(avctx, pic); + if (ret < 0) + goto finish; +--- a/libavformat/bintext.c ++++ b/libavformat/bintext.c +@@ -149,7 +149,7 @@ + return AVPROBE_SCORE_EXTENSION + 1; + + predict_width(&par, p->buf_size, got_width); +- if (par.width < 8) ++ if (par.width <= 0) + return 0; + calculate_height(&par, p->buf_size); + if (par.height <= 0) +@@ -195,8 +195,6 @@ + next_tag_read(s, &bin->fsize); + if (!bin->width) { + predict_width(st->codecpar, bin->fsize, got_width); +- if (st->codecpar->width < 8) +- return AVERROR_INVALIDDATA; + calculate_height(st->codecpar, bin->fsize); + } + avio_seek(pb, 0, SEEK_SET); + diff --git a/patches/ffmpeg/4_A02-corrupt-h264-frames.patch b/patches/ffmpeg/4_A02-corrupt-h264-frames.patch new file mode 100644 index 00000000..73b73157 --- /dev/null +++ b/patches/ffmpeg/4_A02-corrupt-h264-frames.patch @@ -0,0 +1,14 @@ +--- a/libavcodec/h264_slice.c ++++ b/libavcodec/h264_slice.c +@@ -1460,6 +1460,11 @@ + h->avctx->has_b_frames = sps->num_reorder_frames; + } + ++ if (sps && sps->bitstream_restriction_flag && ++ h->avctx->has_b_frames < sps->num_reorder_frames) { ++ h->avctx->has_b_frames = FFMAX(h->avctx->has_b_frames, sps->num_reorder_frames); ++ } ++ + last_pic_droppable = h->droppable; + last_pic_structure = h->picture_structure; + h->droppable = (nal->ref_idc == 0); diff --git a/patches/ffmpeg/4_A11-FFmpeg-devel-amfenc-Add-support-for-pict_type-field.patch b/patches/ffmpeg/4_A11-FFmpeg-devel-amfenc-Add-support-for-pict_type-field.patch new file mode 100644 index 00000000..631efd3a --- /dev/null +++ b/patches/ffmpeg/4_A11-FFmpeg-devel-amfenc-Add-support-for-pict_type-field.patch @@ -0,0 +1,78 @@ +From patchwork Mon Jan 14 19:02:20 2019 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: [FFmpeg-devel] amfenc: Add support for pict_type field +From: Michael Fabian 'Xaymar' Dirks +X-Patchwork-Id: 11748 +Message-Id: <20190114190220.16236-1-info@xaymar.com> +To: ffmpeg-devel@ffmpeg.org +Cc: Michael Fabian 'Xaymar' Dirks +Date: Mon, 14 Jan 2019 20:02:20 +0100 + +Adds support for the pict_type field in AVFrame to amf_h264 and amf_h265 simultaneously. This field is needed in cases where the application wishes to override the frame type with another one, such as forcefully inserting a key frame for chapter markers or similar. + +Additionally this abuses AV_PICTURE_TYPE_S for marking Skip frames, a special type of frame in AVC, SVC and HEVC which is a flag for the decoder to repeat the last frame. + +Signed-off-by: Michael Fabian 'Xaymar' Dirks +--- + libavcodec/amfenc.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 46 insertions(+) + +diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c +index 384d8efc92..eb4b65e4f2 100644 +--- a/libavcodec/amfenc.c ++++ b/libavcodec/amfenc.c +@@ -693,6 +693,52 @@ int ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame) + break; + } + ++ // Override Picture Type for Frame ++ if (avctx->codec->id == AV_CODEC_ID_H264) { ++ switch (frame->pict_type) { ++ case AV_PICTURE_TYPE_I: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_I); ++ break; ++ case AV_PICTURE_TYPE_P: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_P); ++ break; ++ case AV_PICTURE_TYPE_B: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_B); ++ break; ++ case AV_PICTURE_TYPE_S: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_SKIP); ++ break; ++ default: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_NONE); ++ break; ++ } ++ // Keyframe overrides previous assignment. ++ if (frame->key_frame) { ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_PICTURE_TYPE_IDR); ++ } ++ } else if (avctx->codec->id == AV_CODEC_ID_HEVC) { ++ switch (frame->pict_type) { ++ case AV_PICTURE_TYPE_I: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_I); ++ break; ++ case AV_PICTURE_TYPE_P: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_P); ++ break; ++ case AV_PICTURE_TYPE_B: ++ av_log(ctx, AV_LOG_WARNING, "Ignoring B-Frame, unsupported by AMD AMF H.265 Encoder."); ++ break; ++ case AV_PICTURE_TYPE_S: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_SKIP); ++ break; ++ default: ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_NONE); ++ break; ++ } ++ // Keyframe overrides previous assignment. ++ if (frame->key_frame) { ++ AMF_ASSIGN_PROPERTY_INT64(res, surface, AMF_VIDEO_ENCODER_HEVC_FORCE_PICTURE_TYPE, AMF_VIDEO_ENCODER_HEVC_PICTURE_TYPE_IDR); ++ } ++ } + + // submit surface + res = ctx->encoder->pVtbl->SubmitInput(ctx->encoder, (AMFData*)surface); diff --git a/patches/ffmpeg/ffmpeg-mips64_cpu_detection.patch b/patches/ffmpeg/4_mips64_cpu_detection.patch similarity index 96% rename from patches/ffmpeg/ffmpeg-mips64_cpu_detection.patch rename to patches/ffmpeg/4_mips64_cpu_detection.patch index 5a78cb44..4470689c 100644 --- a/patches/ffmpeg/ffmpeg-mips64_cpu_detection.patch +++ b/patches/ffmpeg/4_mips64_cpu_detection.patch @@ -15,7 +15,7 @@ Upstream-Status: Inappropriate [OE-Specific] --- a/configure +++ b/configure -@@ -5758,12 +5758,9 @@ elif enabled mips; then +@@ -5847,12 +5847,9 @@ elif enabled mips; then # Enable minimum ISA based on selected options if enabled mips64; then