2013-02-20, 20:26
Here are some findings (for review) regarding the patches for the old ffmpeg 0.10.2 package that was included in the frodo release. Looking forward to get some feedback.
Interesting enough it seems that a lot of the custom made patches were submitted to ffmpeg.org/libav thanks to Joakim Plate & co. Some patches were later rejected, sometimes for some quite silly reasons and some were accepted but never committed into the main line. I don't know why, but maybe they just fell through the cracks during the quite stormy days of the ffmpeg/libav controversy.
I think it's worth trying to (re)submitted them to ffmpeg for review, especially patches that seems to solve general problems (i.e not only related to xbmc). If we are lucky we may be able to remove at least some of the custom patches.
Anyhow, I'll try to apply all the patches marked "XBMC custom patch" although some will probably fail because the target has been refactored (thus we probably need to perform some refactoring work on our patches as well). This is also an important reason why you want to avoid customized patches as far as possible in the future.
XBMC add on patches for ffmpeg, brief summary:
Down below you find more details regarding the current status of the xbmc add on patches. The text may be somewhat hard to read because of the formatting, but you can use this link (to a published google doc) for a better read experience: "FFmpeg 1.1 XBMC Patches". (I'm sorry but the current formatting capabilities in MyBB really sucks! )
Details and current status of the XBMC add on patches for ffmpeg:
Interesting enough it seems that a lot of the custom made patches were submitted to ffmpeg.org/libav thanks to Joakim Plate & co. Some patches were later rejected, sometimes for some quite silly reasons and some were accepted but never committed into the main line. I don't know why, but maybe they just fell through the cracks during the quite stormy days of the ffmpeg/libav controversy.
I think it's worth trying to (re)submitted them to ffmpeg for review, especially patches that seems to solve general problems (i.e not only related to xbmc). If we are lucky we may be able to remove at least some of the custom patches.
Anyhow, I'll try to apply all the patches marked "XBMC custom patch" although some will probably fail because the target has been refactored (thus we probably need to perform some refactoring work on our patches as well). This is also an important reason why you want to avoid customized patches as far as possible in the future.
XBMC add on patches for ffmpeg, brief summary:
Code:
Patch Origin
----- ------
0001-Support-raw-dvdsub-palette-as-stored-on-normal-dvd-s.patch FFmpeg 1.1
0002-Change-fallthrough-logic-for-read_seek-to-be-based-o.patch XBMC - Possible obsolete
0003-matroska-Check-return-value-of-avio_seek-and-avoid-m.patch XBMC - Possible obsolete
0004-asf-hacks.patch XBMC - Possible obsolete
0005-if-av_read_packet-returns-AVERROR_IO-we-are-done.-ff.patch XBMC - Possible obsolete
0006-added-Ticket-7187-TV-Teletext-support-for-DVB-EBU-Te.patch XBMC - Refactoring needed
0007-Don-t-accept-mpegts-PMT-that-isn-t-current.patch XBMC - Refactoring needed
0008-Don-t-reparse-PMT-unless-it-s-version-has-changed.patch XBMC - Commit lost in space
0009-fixed-compile-with-VDPAU-header-versions-without-MPE.patch XBMC - Patch lost in space
0010-Read-PID-timestamps-as-well-as-PCR-timestamps-to-fin.patch XBMC - Obsolete
0011-Get-stream-durations-using-read_timestamp.patch XBMC - Possible obsolete
0012-include-stdint.h.patch XBMC - Obsolete
0013-aacenc-add-recognized-profiles-array.patch XBMC - Refactoring needed
0014-changed-allow-4-second-skew-between-streams-in-mov-b.patch XBMC - Submit upstreams
0015-fixed-memleak-in-mpegts-demuxer-on-some-malformed-mp.patch XBMC - Submit upstreams
0016-Speed-up-mpegts-av_find_stream_info.patch XBMC - Submit upstreams
0017-allow-customizing-shared-library-soname-name-with-ma.patch XBMC - Hack fits not here
0018-dxva-mpeg2-Allocate-slices-array-dynamically-fixes-v.patch XBMC - Submit upstreams
0019-dxva-mpeg2-speed-up-slice-allocation.patch XBMC - Submit upstreams
0020-dxva-vc1-Take-BI-into-account-for-forward-and-backwa.patch XBMC - Submit upstreams
0021-dxva-vc1-Pass-overlapping-transforms-hint.patch XBMC - Submit upstreams
0022-dxva-h264-Fix-dxva-playback-of-streams-that-don-t-st.patch XBMC - Possible obsolete
0023-Changed-format-string-td-not-supported-by-our-MingW-.patch XBMC - Possible obsolete
0024-add-public-version-of-ff_read_frame_flush.patch XBMC - Obsolete
0025-dvb-subtitle-decoding-when-display-segment-is-mi.patch FFmpeg 1.1
0026-Handle-return-value-of-BeginFrame-better.patch XBMC - Submit upstreams
0027-threads-Perform-the-generic-progress-cleanup-more-ca.patch FFmpeg 1.1
0028-added-support-for-OTF-fonts.patch FFmpeg 1.1
0028-fixed-dvd-still-frames-ended-up-in-internal-lavf.patch XBMC - possible obsolete
0029-stop-forcing-gas-preprocessor-for-darwin.patch XBMC - possible obsolete
0030-ARM-generate-position-independent-code-to-access-dat.patch FFmpeg 1.1
0031-ARM-vp56-allow-inline-asm-to-build-with-clang.patch FFmpeg 1.1
0032-PGS-use-the-PTS-from-the-presentation-segment.patch FFmpeg 1.1
0033-ARM-ac3-fix-ac3_bit_alloc_calc_bap_armv6.patch FFmpeg 1.1
0034-ARM-fix-h264-chroma-mc-overrides.patch FFmpeg 1.1
0035-ffmpeg-fixed-missing-S_DVBSUB-subtitles.patch FFmpeg 1.1
Down below you find more details regarding the current status of the xbmc add on patches. The text may be somewhat hard to read because of the formatting, but you can use this link (to a published google doc) for a better read experience: "FFmpeg 1.1 XBMC Patches". (I'm sorry but the current formatting capabilities in MyBB really sucks! )
Details and current status of the XBMC add on patches for ffmpeg:
Code:
Status Patch
==============================================================================================================
Patch Ref: 0001-Support-raw-dvdsub-palette-as-stored-on-normal-dvd-s.patch
Included in FFmpeg 1.1. http://ffmpeg.org/pipermail/ffmpeg-devel/2011-September/114709.html
"Suppose this is not especially interesting since it would be hard to test. It's nothing
xbmc require either since we normally uses another decoder for dvd's overlays/
subtitles."
Note: this patch seems slightly refactored in 1.1 but I can't locate the actual commit.
==============================================================================================================
Patch Ref: 0002-Change-fallthrough-logic-for-read_seek-to-be-based-o.patch
XBMC Custom patch. "This changes the logic for read_seek to only use generic seek routines if the return
Obsolete ?? value is AVERROR(ENOSYS) to avoid retrying seeks if the demuxer already realized it
wasn't possible."
This patch was sent to ffmpeg as a RFC but never became an acctual patch request AFAIK:
http://ffmpeg.org/pipermail/ffmpeg-devel/2011-September/114772.html
Note: not sure if this behavior is still needed in v1.1, will check with ffmpeg.org.
==============================================================================================================
Patch Ref: 0003-matroska-Check-return-value-of-avio_seek-and-avoid-m.patch
XBMC Custom patch. "The code still modifies state if the timestamp is not found. Not sure exactly how to
Obsolete ?? avoid that."
Note: This patch seems to be accepted by the ffmpeg community but no changes were
committed, maybe they found another solution:. There are similar patches made for other
demuxes e.g. mxfdec.c so we need to check with ffmpeg.org why the patch wasn't commited.
Check: http://ffmpeg.org/pipermail/ffmpeg-devel/2011-October/116033.html
==============================================================================================================
Patch Ref: 0004-asf-hacks.patch
XBMC Custom patch. "this is a hack since av_gen_search searches the entire file …"
Obsolete ??
Note: Not sure this concerns ffmpeg 1.1. It may need some further investigation but
hopefully this patch is now obsolete. Thisis what Michael Niedermayer said about it:
http://ffmpeg.org/pipermail/ffmpeg-devel/2010-July/088318.html.
==============================================================================================================
Patch Ref: 0005-if-av_read_packet-returns-AVERROR_IO-we-are-done.-ff.patch
XBMC Custom patch. "if av_read_packet returns AVERROR_IO, we are done. FFmpeg's codecs might or might not
Obsolete ?? handle returning any completed demuxed packets correctly"
http://ffmpeg.org/pipermail/ffmpeg-devel/2010-June/092763.html
Note: it this patch solves a still existing problem it will be resubmitted to ffmpeg.org.
==============================================================================================================
Patch Ref: 0006-added-Ticket-7187-TV-Teletext-support-for-DVB-EBU-Te.patch
XBMC Custom patch. Note: Although this patch needs some refactoring, it solves a general issue and will be
Submitted to ffmpeg.org.
==============================================================================================================
Patch Ref: 0007-Don-t-accept-mpegts-PMT-that-isn-t-current.patch
XBMC Custom patch. Note: Although this patch needs some refactoring, it solves a general issue and will be
Obsolete ?? submitted to ffmpeg.org.
==============================================================================================================
Patch Ref: 0008-Don-t-reparse-PMT-unless-it-s-version-has-changed.patch
XBMC Custom patch. http://ffmpeg.org/pipermail/ffmpeg-devel/2010-July/088279.html
Obsolete ?? http://ffmpeg.org/pipermail/ffmpeg-devel/2010-June/092769.html
Note: this patch was submitted and accepted but there is no trace of a commit...
==============================================================================================================
Patch Ref: 0009-fixed-compile-with-VDPAU-header-versions-without-MPE.patch (VDPAU without MPEG4 support)
XBMC Custom patch. https://lists.libav.org/pipermail/ffmpeg-devel/2010-June/091837.html
Submitted to FFmpeg: http://repo.or.cz/w/FFMpeg-mirror/mplayer-patches.git/commitdiff/136c16af11076153717d3de31c9d84360644e006
Commit info unavail:
Note: Unable to figure out the reason to leave out mpeg4 from vdpau but the patch was
Anyway submitted to ffmpeg but seems rejected because of some minor (and silly) issue
with a "#ifdef".
==============================================================================================================
Patch Ref: 0010-Read-PID-timestamps-as-well-as-PCR-timestamps-to-fin.patch
XBMC Custom patch. Note: Patch is probably obsolete since "mpegts_get_pcr" is declared unused ("static
Obsolete ?? av_unused int64_t mpegts_get_pcr") in libavformat/mpegts.c and there are no references
to it. My need some further work to make sure...
==============================================================================================================
Patch Ref: 0011-Get-stream-durations-using-read_timestamp.patch
XBMC Custom patch. "[FFmpeg-devel][RFC] mpegts: Provide a monotonic timestamp to the outside world"
Patch still necessary? http://ffmpeg.org/pipermail/ffmpeg-devel/2012-October/132836.html
Note: We need to examine whether this patch is still necessary with the current version
of ffmpeg. If "av_estimate_timings_from_pts2" still produces a more accurate estimate
from the PTSes, then we should hand over the patch to ffmpeg.org.
==============================================================================================================
Patch Ref: 0012-include-stdint.h.patch
OBSOLETE Custom patch. Note: this patch is obsolete as stdint.h should only be included whenever necessary in
ffmpeg 1.1.
==============================================================================================================
Patch Ref: 0013-aacenc-add-recognized-profiles-array.patch
XBMC Custom patch. http://ffmpeg.org/pipermail/ffmpeg-devel/2011-January/106853.html
Note: Patch sumbitted to ffmpeg.org but unable to locate commit info. Regardless of
that, it seems like libavcodec/aacenc.c has been refactored thus we need to perform
some refactoring on the patch as well.
==============================================================================================================
Patch Ref: 0014-changed-allow-4-second-skew-between-streams-in-mov-b.patch
XBMC Custom patch. "changed: allow 4 second skew between streams in mov before attempting to seek"
Note: this patch solves a general problem and will be submitted to ffmpeg.org.
Patch Ref: 0015-fixed-memleak-in-mpegts-demuxer-on-some-malformed-mp.patch
XBMC Custom patch. "fixed: memleak in mpegts demuxer on some malformed (??) mpegts files with too large
packets."
Note: this patch solves a general problem and will be submitted to ffmpeg.org.
==============================================================================================================
Patch Ref: 0016-Speed-up-mpegts-av_find_stream_info.patch
XBMC Custom patch. "Speed up mpegts av_find_stream_info"
Note: this patch solves a general problem and will be submitted to ffmpeg.org.
==============================================================================================================
Patch Ref: 0017-allow-customizing-shared-library-soname-name-with-ma.patch
XBMC Custom patch. "This is a hack! Allow customizing shared library soname (name with major)"
Note: This hack doesn’t motivate a custom patch and should probably be solved elsewhere.
==============================================================================================================
Patch Ref: 0018-dxva-mpeg2-Allocate-slices-array-dynamically-fixes-v.patch
XBMC Custom patch: "Allocate slices array dynamically - fixes videos with > 175 slices. They used to result
in images with a black bottom. Inspired by the vaapi code to reallocate the slices
array for each new slice. Could be more efficient if the array could be preserved for
all frames and freed only at the end of the video, but there doesn't seem to be anywhere
appropriate to free the memory at the end.Alternative is to allocate the proper size
straight away for a new frame, instead of realloc'ing for each slice."
Note: this patch solves a general problem and will be submitted to ffmpeg.org.
==============================================================================================================
Patch Ref: 0019-dxva-mpeg2-speed-up-slice-allocation.patch
XBMC Custom patch. "The number of slices is not very likely to change from frame to frame, so at the
beginning of a new frame, allocate memory for the amount of slices of the previous
frame. Saves a lot of reallocation, for some TV capture samples there are over 200
slices. There wasn't anywhere really appropriate to store last_slice_count (needs to
live from first frame to last frame), so this is likely to cause discussion to merge
upstream. Adding members to dxva_context breaks ABI, which we don't care too much about
since on Windows we don't support external ffmpeg. dxva mpeg2 code also has access to
MpegEncContext, but adding there would likely break ABI as well."
Note: this patch solves a general problem and will be submitted to ffmpeg.org.
==============================================================================================================
Patch Ref: 0020-dxva-vc1-Take-BI-into-account-for-forward-and-backwa.patch
XBMC Custom patch. "Fix for some DXVA WMV-VC1 playback - The FFMPEG lib for WMV VC1 advanced profile
('WMV9') is buggy, both on ATI as NVIDIA. This patch solves the bugs and extends
support. (http://trac.xbmc.org/ticket/11643)
Note: this patch solves a general problem and will be submitted to ffmpeg.org.
==============================================================================================================
Patch Ref: 0021-dxva-vc1-Pass-overlapping-transforms-hint.patch
XBMC Custom patch. "The FFMPEG lib for WMV VC1 advanced profile ('WMV9') is buggy, both on ATI as NVIDIA.
This patch solves the bugs and extends support." (http://trac.xbmc.org/ticket/11643)
Note: this patch solves a general problem and will be submitted to ffmpeg.org.
==============================================================================================================
Patch Ref: 0022-dxva-h264-Fix-dxva-playback-of-streams-that-don-t-st.patch
XBMC Custom patch. "GPUs with ATI UVDa and UVD+ have trouble when decoding doesn't start on an I-Frame,
and they don't recover on later I-Frames. The variable to track the first I-Frame is
in H264Context so that it can be reset by code in h264 when initializing the context
or flushing."
Note: this patch solves a general problem and will be submitted to ffmpeg.org.
==============================================================================================================
Patch Ref: 0023-Changed-format-string-td-not-supported-by-our-MinGW-.patch (MinGW-64 on win only)
http://ffmpeg.org/pipermail/ffmpeg-devel/2011-January/107099.html
XBMC Custom patch. http://web.archiveorange.com/archive/v/yR2T4T1iKbtsVRTrHj9s
Note: This patch resolves the issue with the format warnings only in a single place for
MinGW-64. There are still many other files in FFmpeg that needs to be fixed with the same
problem. See the link above. It is not a problem on mingw32 because you can use –
D__USE_MINGW_ANSI_STDIO=1 to force conformance but this is not yet implemented for
sscanf in Mingw-w64.
Note: not sure how important the MinGW-64 environment is that motivates a custom patch
in relation to general maintenance issues of the FFmpeg libraries?
Note: This patch was submitted to ffmpeg.org but status is unknown or silently rejected.
==============================================================================================================
Patch Ref: 0024-add-public-version-of-ff_read_frame_flush.patch
XBMC Custom patch. "We need this since we sometimes seek on the input stream behind ffmpeg's back. After
this all data need to be flushed completely."
Note: total unnecessary custom patch that used to enable a wrapper for the deprecated
"av_read_frame_flush" to the internal "ff_read_frame_flush". Fix: we now call
ff_read_frame_flush directly from lib/DllAvFormat.h: "virtual void av_read_frame_flush
-> ::ff_read_frame_flush"
Note: obsolete patch, all gone now!
==============================================================================================================
Patch Ref: 0025-dvb-subtitle-decoding-when-display-segment-is-mi.patch
Included in FFmpeg 1.1. https://lists.ffmpeg.org/pipermail/ffmpeg-cvslog/2012-January/046523.html
Commmit info: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7df9937fcc6a91ce4763dfa1ea6fc331f7e77295
==============================================================================================================
Patch Ref: 0026-Handle-return-value-of-BeginFrame-better.patch
XBMC Custom patch. "nVidia cards sometimes return E_PENDING and need time before they can start decoding a
new frame. Helps nVidia cards with blocky pictures/pixellation artifacts after skip or
when CPU is busy."
Note: this patch solves a general problem and will be submitted to ffmpeg.org
==============================================================================================================
Patch Ref: 0027-threads-Perform-the-generic-progress-cleanup-more-ca.patch
Included in FFmpeg 1.1. https://lists.ffmpeg.org/pipermail/ffmpeg-cvslog/2012-February/047015.html
Commit info: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=18a7f7465e7e6b9c3688ffc23230ae7a0639a771
==============================================================================================================
Patch Ref: 0028-added-support-for-OTF-fonts.patch
Included in FFmpeg 1.1. http://ffmpeg.org/pipermail/ffmpeg-cvslog/2012-September/054431.html
Commit info: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e14725cecc1941f5b87209b8846dbea34b64a3c1
==============================================================================================================
Patch Ref: 0028-fixed-dvd-still-frames-ended-up-in-internal-lavf.patch
XBMC Custom patch. Type: workaround in libavformat/utils.c:
- if((st->codec->codec_id != CODEC_ID_NONE && score > AVPROBE_SCORE_MAX/4)
+ if((st->codec->codec_id != CODEC_ID_NONE && score > AVPROBE_SCORE_MAX/4-1)
"This is very hackish, but it's the old solution we had for dvd still frames. The
problem is that the demuxer asks for probing of the codec in the mpeg stream. This
causes lavf to read the whole menu structure into internal buffers. After which, it
won't read from input stream anymore and no events triggers. - The only proper fix to
avoid this is to allow this situation in our navigator. This needs further work so that
we can process HOP/ACTIVATION events in libdvdnav without advancing stream."
Note: Not sure if this patch solves a general issue, i.e if it should be sent to
ffmpeg.org or not?
==============================================================================================================
Patch Ref: 0029-stop-forcing-gas-preprocessor-for-darwin.patch
XBMC Custom patch. Type: configure - Disables gas-preprocessor.pl (#gas="gas-preprocessor.pl $cc") in
configure.
From: /Users/Shared/xbmc-depends/toolchain/bin/gas-preprocessor.pl
# Apple's gas is ancient and doesn't support modern preprocessing features like
# .rept and has ugly macro syntax, among other things. Thus, this script
# implements the subset of the gas preprocessor used by x264 and ffmpeg
# that isn't supported by Apple's gas.
Still valid, i.e. why is "gas- preprocessor.pl" still around if Xcode does the tric?
Note: Xcode 3 only issue? If this patch solves a general problem it will be submitted
to ffmpeg.org.
==============================================================================================================
Patch Ref: 0030-ARM-generate-position-independent-code-to-access-data-symbols.patch
Included in FFmpeg 1.1. https://lists.ffmpeg.org/pipermail/ffmpeg-cvslog/2012-July/052123.html
Commit info: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62634158b7cd39ad1e330a87153a97bf3dc6f8de
==============================================================================================================
Patch Ref: 0031-ARM-vp56-allow-inline-asm-to-build-with-clang.patch
Included in FFmpeg 1.1. http://ffmpeg.org/pipermail/ffmpeg-cvslog/2012-August/053273.html
Commit info: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9829a81bcd3e9ef26c4bbc2959bfb65159dbd314
==============================================================================================================
Patch Ref: 0032-PGS-use-the-PTS-from-the-presentation-segment.patch
Included in FFmpeg 1.1. http://ffmpeg.org/pipermail/ffmpeg-cvslog/2012-September/054610.html
Commit info: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=37bbc9eb8bdae43d38a6fb7cc1356d1ce7d41e1c
==============================================================================================================
Patch Ref: 0033-ARM-ac3-fix-ac3_bit_alloc_calc_bap_armv6.patch
Included in FFmpeg 1.1. https://lists.ffmpeg.org/pipermail/ffmpeg-cvslog/2012-February/046718.html
Commit info: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d77294c5e404c8a214da0e74f7836390b48b2dba
==============================================================================================================
Patch Ref: 0034-ARM-fix-h264-chroma-mc-overrides.patch
Included in FFmpeg 1.1. http://ffmpeg.org/pipermail/ffmpeg-cvslog/2012-October/055982.html
Commit info: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=04c6ecb7da677049cd52efe2a980e586167e9e5d
==============================================================================================================
Patch Ref: 0035-ffmpeg-fixed-missing-S_DVBSUB-subtitles.patch
Included in FFmpeg 1.1. https://lists.ffmpeg.org/pipermail/ffmpeg-cvslog/2013-February/060202.html
Commit info: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4789c25d83c4a90e8ef81d2cc05be6d2f12dfa68
==============================================================================================================