From f0b471c6697824f0120c08b35592059dd0c68b20 Mon Sep 17 00:00:00 2001 From: marc Date: Mon, 18 Feb 2013 17:18:18 +0000 Subject: [PATCH 1/8] dxva-h264: Fix an AMD driver issue with playback of streams that don't start with an I-Frame --- libavcodec/dxva2_h264.c | 8 ++++++++ libavcodec/h264_slice.c | 1 + libavcodec/h264dec.c | 1 + libavcodec/h264dec.h | 2 ++ 4 files changed, 12 insertions(+) diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c index 5b23b28f1202b..c0a8d80f3b1c0 100644 --- a/libavcodec/dxva2_h264.c +++ b/libavcodec/dxva2_h264.c @@ -504,6 +504,14 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx) 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), diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 713953778ae1e..db8363e4cc988 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -928,6 +928,7 @@ static int h264_slice_header_init(H264Context *h) h->first_field = 0; h->prev_interlaced_frame = 1; + h->got_first_iframe = 0; init_scan_tables(h); ret = ff_h264_alloc_tables(h); diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 6270ea80dff09..5eedeb3c275de 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -467,6 +467,7 @@ void ff_h264_flush_change(H264Context *h) h->next_outputed_poc = INT_MIN; h->prev_interlaced_frame = 1; + h->got_first_iframe = 0; idr(h); h->poc.prev_frame_num = -1; diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 29c4d4e42c1e3..a419615124b20 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -539,6 +539,8 @@ typedef struct H264Context { * 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 From 02642caa2a577c6a8f3a66851b618f52c4f3c7ac Mon Sep 17 00:00:00 2001 From: Rechi Date: Tue, 21 Nov 2017 08:16:53 +0100 Subject: [PATCH 2/8] use Kodi as extra version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 45a22b0cb3c89..76454245bb2f1 100644 --- a/Makefile +++ b/Makefile @@ -120,7 +120,7 @@ GIT_LOG = $(SRC_PATH)/.git/logs/HEAD .version: M=@ libavutil/ffversion.h .version: - $(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION) + $(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h Kodi $(Q)touch .version # force version.sh to run whenever version might have changed From 32d4754a4c08f5f74292f9b857bc3a1aad83b90e Mon Sep 17 00:00:00 2001 From: Rechi Date: Tue, 21 Nov 2017 08:16:53 +0100 Subject: [PATCH 3/8] common.mak: never ignore an error if strip doesn't succeed --- ffbuild/common.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffbuild/common.mak b/ffbuild/common.mak index a60d27c9bd365..9efe74108688d 100644 --- a/ffbuild/common.mak +++ b/ffbuild/common.mak @@ -79,7 +79,7 @@ COMPILE_NVCC = $(call COMPILE,NVCC) %.o: %.asm $(COMPILE_X86ASM) - -$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@) + $(if $(STRIP), $(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)) %.o: %.rc $(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $< From e01f7698314dc07f9ab14c4d8a9778c726acc392 Mon Sep 17 00:00:00 2001 From: wsnipex Date: Tue, 21 Nov 2017 08:16:53 +0100 Subject: [PATCH 4/8] only check for a git rev if the src tree is in a git repo fixes the version string when building from the kodi depends src tree --- ffbuild/version.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ffbuild/version.sh b/ffbuild/version.sh index edc4dd33c5420..239a138ca77d8 100755 --- a/ffbuild/version.sh +++ b/ffbuild/version.sh @@ -2,6 +2,7 @@ # Usage: version.sh +if [ -d $1/.git ]; then # only check for a git rev, if the src tree is in a git repo # check for git short hash if ! test "$revision"; then if (cd "$1" && grep git RELEASE 2> /dev/null >/dev/null) ; then @@ -27,6 +28,7 @@ if [ -z "$revision" ]; then git_hash="${srcdir##*-}";; esac fi +fi # no revision number found test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null) From 8a7b4627e4485a1f649daf33a6630a144f478a17 Mon Sep 17 00:00:00 2001 From: Anton Fedchin Date: Fri, 11 Jan 2019 10:47:43 +0100 Subject: [PATCH 5/8] after 153b36f there is a possibility to crash when trying to get index of a surface which points to nirvana. it may occurs when a stream starts with non i-frame. --- libavcodec/dxva2.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 32416112bfd9c..dfae50044488f 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -771,16 +771,18 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, #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 From 5a1e9dc3e20b4b3b296683ac499c2baca71eed4c Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sat, 26 Jan 2019 19:48:35 +0100 Subject: [PATCH 6/8] avcodec/vaapi_h264: skip decode if pic has no slices This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368. It was hit frequently when watching h264 channels received via DVB-X. Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704 --- libavcodec/vaapi_h264.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c index 9332aa6f3106a..d4494beebf8a8 100644 --- a/libavcodec/vaapi_h264.c +++ b/libavcodec/vaapi_h264.c @@ -314,6 +314,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx) 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; From 922f5eed9a810b56cfca16de3a38a86c15a158e8 Mon Sep 17 00:00:00 2001 From: phunkyfish Date: Tue, 14 Jul 2020 18:12:09 +0100 Subject: [PATCH 7/8] Disable EIT EPG stream as it ends the stream during seek if available --- libavformat/mpegts.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index c6fd3e1cef631..089ace9f366af 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2562,6 +2562,10 @@ static void eit_cb(MpegTSFilter *filter, const uint8_t *section, int section_len const uint8_t *p, *p_end; SectionHeader h1, *h = &h1; + // Something in kodi breaks with seeking when EIT EPG data is included in the stream + // As we figure this out lets just skip any EIT data. + return; + /* * Sometimes we receive EPG packets but SDT table do not have * eit_pres_following or eit_sched turned on, so we open EPG From e198aa38ddbcc7eb8c114200232ff87b8cb5d878 Mon Sep 17 00:00:00 2001 From: Sylvain CECCHETTO Date: Tue, 1 Sep 2020 08:34:14 +0200 Subject: [PATCH 8/8] [VideoToolbox] Force SW decoder for interlaced h264 videos on iOS/tvOS devices See https://patchwork.ffmpeg.org/project/ffmpeg/patch/20170926003631.55571-3-ffmpeg@tmm1.net/#16694 --- libavcodec/videotoolbox.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 8773de3393057..1931b54afde23 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -743,11 +743,18 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec if (data) CFDictionarySetValue(avc_info, CFSTR("esds"), data); break; - case kCMVideoCodecType_H264 : + case kCMVideoCodecType_H264 : { + H264Context *h = avctx->priv_data; + if (TARGET_OS_IPHONE && h->ps.sps->frame_mbs_only_flag == 0) { + av_log(avctx, AV_LOG_ERROR, "VideoToolbox cannot decode interlaced fields on iOS\n"); + CFRelease(avc_info); + goto fail; + } data = ff_videotoolbox_avcc_extradata_create(avctx); if (data) CFDictionarySetValue(avc_info, CFSTR("avcC"), data); break; + } case kCMVideoCodecType_HEVC : data = ff_videotoolbox_hvcc_extradata_create(avctx); if (data) @@ -766,6 +773,10 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec CFRelease(avc_info); return config_info; + +fail: + CFRelease(config_info); + return NULL; } static int videotoolbox_start(AVCodecContext *avctx)