[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#930162: unblock: vlc/3.0.7-1



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package vlc. The update is the latest bug fix release of
the 3.0.x branch. As with jessie and stretch, we intend to keep vlc
update to date with the latest bug fix release for security support.

This release includes bug fixes for 20 low and 20 medium security issues
including integer overflows, heap overflows, NULL dereferences,
use-after-free issues and more. See
http://www.jbkempf.com/blog/post/2019/VLC-3.0.7-and-security for some
details. Besides fixes for the security issues, the release also
includes update of the translations and some other non-security bug
fixes.

Thea attached debdiff was filtered to remove the following changes:

 Makefile.in                                        |    40 +-
 configure                                          |    30 +-
 configure.ac                                       |    10 +-
 contrib/bootstrap                                  |    20 +-
 contrib/src/aom/rules.mak                          |     2 +-
 contrib/src/ass/rules.mak                          |     2 +-
 ...01-Implement-dl_get_path-for-darwin-macOS.patch |    62 -
 ...h-menuless-user-selected-streams-between-.patch |    51 -
 ...ibrary-paths-Explicitly-add-usr-local-lib.patch |    34 -
 contrib/src/bluray/SHA512SUMS                      |     2 +-
 contrib/src/bluray/rules.mak                       |     5 +-
 contrib/src/d3d11/rules.mak                        |    18 +-
 contrib/src/d3d9/rules.mak                         |     6 +-
 ...quence-header-corresponding-to-the-pictur.patch |    94 -
 contrib/src/dav1d/SHA512SUMS                       |     2 +-
 contrib/src/dav1d/rules.mak                        |     5 +-
 contrib/src/directx/rules.mak                      |     2 +-
 contrib/src/dshow/rules.mak                        |     2 +-
 contrib/src/dvdread/SHA512SUMS                     |     2 +-
 contrib/src/dvdread/rules.mak                      |     4 +-
 contrib/src/faad2/faad2-fix-overflows.patch        |    25 +
 contrib/src/faad2/rules.mak                        |     1 +
 ...memset-size-on-ctts_data-in-mov_read_trun.patch |    68 +
 contrib/src/ffmpeg/ffmpeg-mkv-overshoot.patch      |    21 +
 contrib/src/ffmpeg/rules.mak                       |     4 +-
 contrib/src/gnutls/rules.mak                       |     1 +
 .../gnutls/vasnprintf-android-no-percent-n.patch   |    11 +
 contrib/src/iconv/rules.mak                        |     6 +
 contrib/src/live555/rules.mak                      |     2 +-
 contrib/src/lua/rules.mak                          |     2 +-
 contrib/src/main.mak                               |    31 +-
 ...-not-attempt-to-use-laced-sizes-that-are-.patch |    54 +
 ...on-t-reset-potentially-unallocated-memory.patch |    29 +
 contrib/src/matroska/rules.mak                     |     2 +
 contrib/src/png/SHA512SUMS                         |     2 +-
 contrib/src/png/rules.mak                          |     2 +-
 contrib/src/x264/rules.mak                         |     4 +-
 contrib/src/x265/rules.mak                         |     2 +-
 doc/ChangeLog-2017                                 |     6 +
 extras/package/macosx/package.mak                  |     2 +-
 .../project.pbxproj                                |     0
 .../package/win32/NSIS/languages/AlbanianExtra.nsh |     2 +
 .../package/win32/NSIS/languages/ArabicExtra.nsh   |    79 +
 .../package/win32/NSIS/languages/BengaliExtra.nsh  |    55 -
 .../package/win32/NSIS/languages/BosnianExtra.nsh  |    77 +
 .../package/win32/NSIS/languages/BretonExtra.nsh   |    79 +
 extras/package/win32/NSIS/languages/CzechExtra.nsh |    79 +
 .../package/win32/NSIS/languages/DanishExtra.nsh   |     4 +-
 extras/package/win32/NSIS/languages/GreekExtra.nsh |    77 +
 .../win32/NSIS/languages/IndonesianExtra.nsh       |    18 +-
 .../package/win32/NSIS/languages/KoreanExtra.nsh   |    79 +
 .../package/win32/NSIS/languages/LatvianExtra.nsh  |    16 +-
 extras/package/win32/NSIS/languages/MalayExtra.nsh |    79 +
 .../win32/NSIS/languages/NorwegianExtra.nsh        |    79 +
 .../win32/NSIS/languages/NorwegianNynorskExtra.nsh |    79 +
 .../package/win32/NSIS/languages/OccitanExtra.nsh  |    62 -
 .../win32/NSIS/languages/PortugueseBRExtra.nsh     |     2 +
 .../win32/NSIS/languages/PortugueseExtra.nsh       |    79 +
 .../package/win32/NSIS/languages/PunjabiExtra.nsh  |    75 -
 .../package/win32/NSIS/languages/RomanianExtra.nsh |     2 +
 .../win32/NSIS/languages/ScotsGaelicExtra.nsh      |    77 +
 .../package/win32/NSIS/languages/SerbianExtra.nsh  |    79 +
 .../win32/NSIS/languages/SlovenianExtra.nsh        |     2 +
 .../package/win32/NSIS/languages/SoraniExtra.nsh   |    53 -
 extras/package/win32/NSIS/languages/ThaiExtra.nsh  |    79 +
 .../win32/NSIS/languages/TradChineseExtra.nsh      |    79 +
 .../package/win32/NSIS/languages/TurkishExtra.nsh  |    79 +
 .../win32/NSIS/languages/UkrainianExtra.nsh        |    79 +
 extras/package/win32/NSIS/languages/UzbekExtra.nsh |    77 +
 extras/package/win32/NSIS/languages/WelshExtra.nsh |    77 +
 extras/package/win32/NSIS/vlc.win32.nsi.in         |    19 +-
 extras/package/win32/package.mak                   |    38 +-
 extras/tools/bootstrap                             |     2 +-
 extras/tools/tools.mak                             |     6 +-
 modules/Makefile.in                                |   324 +-
 src/misc/update_crypto.c                           |     5 +-
 share/Info.plist.in                                |     2 +-

autotools change, Windows and OS X packaging and contrib which are not
used in Debian.

 modules/access/decklink.cpp                        |     9 +-
 modules/gui/macosx/VLCHelpWindowController.m       |     4 +-
 modules/gui/macosx/VLCMain+OldPrefs.m              |     7 +-
 modules/gui/macosx/VLCMain.m                       |     6 +-
 modules/gui/macosx/VLCMainMenu.m                   |    10 +-
 modules/gui/macosx/VLCOpenWindowController.m       |     9 +-
 modules/gui/macosx/VLCSimplePrefsController.m      |    29 +-
 modules/video_chroma/d3d11_fmt.c                   |     4 +-
 modules/video_chroma/dxgi_fmt.c                    |     1 +
 modules/video_output/decklink.cpp                  |    42 +-
 modules/video_output/ios.m                         |    55 +-
 modules/video_output/macosx.m                      |    10 +-
 modules/video_output/win32/d3d11_shaders.c         |    19 +-
 modules/video_output/win32/direct3d11.c            |    10 +-

Windows and OS X specific code. decklink is not used in Debian.

 po/LINGUAS                                         |    14 +-
 po/ach.gmo                                         |   Bin 47982 -> 47982 bytes
 po/ach.po                                          |   669 +-
 po/af.gmo                                          |   Bin 105230 -> 105230 bytes
 po/af.po                                           |   669 +-
 po/am.gmo                                          |   Bin 62226 -> 62226 bytes
 po/am.po                                           |   669 +-
 po/am_ET.gmo                                       |   Bin 0 -> 80664 bytes
 po/{or.po => am_ET.po}                             |  3845 +--
 po/an.gmo                                          |   Bin 407014 -> 407014 bytes
 po/an.po                                           |   669 +-
 po/ar.gmo                                          |   Bin 348650 -> 348650 bytes
 po/ar.po                                           |   672 +-
 po/as_IN.gmo                                       |   Bin 813787 -> 813787 bytes
 po/as_IN.po                                        |   669 +-
 po/ast.gmo                                         |   Bin 405605 -> 405605 bytes
 po/ast.po                                          |   669 +-
 po/az.gmo                                          |   Bin 8862 -> 0 bytes
 po/az.po                                           | 27861 ------------------
 po/be.gmo                                          |   Bin 643212 -> 643212 bytes
 po/be.po                                           |   676 +-
 po/bg.gmo                                          |   Bin 541449 -> 541449 bytes
 po/bg.po                                           |   672 +-
 po/bn.gmo                                          |   Bin 572047 -> 572047 bytes
 po/bn.po                                           |   669 +-
 po/bn_IN.gmo                                       |   Bin 688738 -> 688738 bytes
 po/bn_IN.po                                        |   669 +-
 po/br.gmo                                          |   Bin 132815 -> 135705 bytes
 po/br.po                                           |   919 +-
 po/brx.gmo                                         |   Bin 810372 -> 810372 bytes
 po/brx.po                                          |   669 +-
 po/bs.gmo                                          |   Bin 164828 -> 164828 bytes
 po/bs.po                                           |   671 +-
 po/ca.gmo                                          |   Bin 545398 -> 545398 bytes
 po/ca.po                                           |   671 +-
 po/ca@valencia.gmo                                 |   Bin 0 -> 534990 bytes
 po/{tet.po => ca@valencia.po}                      | 17479 ++++++------
 po/cgg.gmo                                         |   Bin 34589 -> 34589 bytes
 po/cgg.po                                          |   671 +-
 po/co.gmo                                          |   Bin 194458 -> 194458 bytes
 po/co.po                                           |   670 +-
 po/cs.gmo                                          |   Bin 292867 -> 295492 bytes
 po/cs.po                                           |   710 +-
 po/cy.gmo                                          |   Bin 274570 -> 274601 bytes
 po/cy.po                                           |   689 +-
 po/da.gmo                                          |   Bin 538315 -> 544946 bytes
 po/da.po                                           |  1325 +-
 po/de.gmo                                          |   Bin 614907 -> 615100 bytes
 po/de.po                                           |   741 +-
 po/el.gmo                                          |   Bin 760877 -> 761631 bytes
 po/el.po                                           |   699 +-
 po/en_GB.gmo                                       |   Bin 53655 -> 53655 bytes
 po/en_GB.po                                        |   671 +-
 po/es.gmo                                          |   Bin 617456 -> 617491 bytes
 po/es.po                                           |   710 +-
 po/es_MX.gmo                                       |   Bin 0 -> 535874 bytes
 po/{tl.po => es_MX.po}                             | 17515 ++++++------
 po/et.gmo                                          |   Bin 406912 -> 407090 bytes
 po/et.po                                           |   936 +-
 po/eu.gmo                                          |   Bin 622184 -> 622245 bytes
 po/eu.po                                           |   675 +-
 po/fa.gmo                                          |   Bin 163181 -> 163181 bytes
 po/fa.po                                           |   680 +-
 po/ff.gmo                                          |   Bin 73914 -> 73914 bytes
 po/ff.po                                           |   669 +-
 po/fi.gmo                                          |   Bin 497233 -> 497233 bytes
 po/fi.po                                           |   669 +-
 po/fr.gmo                                          |   Bin 618020 -> 618020 bytes
 po/fr.po                                           |  2039 +-
 po/fur.gmo                                         |   Bin 34958 -> 34958 bytes
 po/fur.po                                          |   669 +-
 po/fy.gmo                                          |   Bin 537236 -> 537236 bytes
 po/fy.po                                           |   671 +-
 po/ga.gmo                                          |   Bin 161860 -> 161862 bytes
 po/ga.po                                           |   677 +-
 po/gd.gmo                                          |   Bin 172505 -> 172528 bytes
 po/gd.po                                           |   672 +-
 po/gl.gmo                                          |   Bin 605959 -> 612068 bytes
 po/gl.po                                           |   794 +-
 po/gu.gmo                                          |   Bin 789273 -> 789273 bytes
 po/gu.po                                           |   669 +-
 po/he.gmo                                          |   Bin 273742 -> 302081 bytes
 po/he.po                                           |  1268 +-
 po/hi.gmo                                          |   Bin 128584 -> 128584 bytes
 po/hi.po                                           |   669 +-
 po/hr.gmo                                          |   Bin 483760 -> 483760 bytes
 po/hr.po                                           |   669 +-
 po/hu.gmo                                          |   Bin 619934 -> 626767 bytes
 po/hu.po                                           |   819 +-
 po/hy.gmo                                          |   Bin 125414 -> 125414 bytes
 po/hy.po                                           |   669 +-
 po/ia.gmo                                          |   Bin 10904 -> 0 bytes
 po/ia.po                                           | 27882 -------------------
 po/id.gmo                                          |   Bin 374803 -> 428526 bytes
 po/id.po                                           |  2801 +-
 po/is.gmo                                          |   Bin 301590 -> 307025 bytes
 po/is.po                                           |   826 +-
 po/it.gmo                                          |   Bin 611077 -> 611479 bytes
 po/it.po                                           |   702 +-
 po/ja.gmo                                          |   Bin 680803 -> 680883 bytes
 po/ja.po                                           |   679 +-
 po/ka.gmo                                          |   Bin 53176 -> 53176 bytes
 po/ka.po                                           |   669 +-
 po/kab.gmo                                         |   Bin 0 -> 494848 bytes
 po/{ckb.po => kab.po}                              | 16842 +++++------
 po/kk.gmo                                          |   Bin 230136 -> 230136 bytes
 po/kk.po                                           |   669 +-
 po/km.gmo                                          |   Bin 864813 -> 864813 bytes
 po/km.po                                           |   669 +-
 po/kn.gmo                                          |   Bin 717493 -> 717493 bytes
 po/kn.po                                           |   669 +-
 po/ko.gmo                                          |   Bin 623179 -> 623180 bytes
 po/ko.po                                           |   672 +-
 po/ks_IN.gmo                                       |   Bin 679328 -> 679535 bytes
 po/ks_IN.po                                        |   677 +-
 po/{ckb.gmo => ku_IQ.gmo}                          |   Bin 79322 -> 79399 bytes
 po/{my.po => ku_IQ.po}                             |  3848 ++-
 po/ky.gmo                                          |   Bin 37089 -> 37089 bytes
 po/ky.po                                           |   669 +-
 po/lg.gmo                                          |   Bin 47089 -> 47089 bytes
 po/lg.po                                           |   671 +-
 po/lt.gmo                                          |   Bin 314661 -> 314661 bytes
 po/lt.po                                           |   669 +-
 po/lv.gmo                                          |   Bin 619472 -> 619574 bytes
 po/lv.po                                           |  1025 +-
 po/mai.gmo                                         |   Bin 802559 -> 802559 bytes
 po/mai.po                                          |   669 +-
 po/mk.gmo                                          |   Bin 10245 -> 0 bytes
 po/ml.gmo                                          |   Bin 980767 -> 980766 bytes
 po/ml.po                                           |   676 +-
 po/mn.gmo                                          |   Bin 95365 -> 95365 bytes
 po/mn.po                                           |   669 +-
 po/mr.gmo                                          |   Bin 874560 -> 875070 bytes
 po/mr.po                                           |   679 +-
 po/ms.gmo                                          |   Bin 583935 -> 584028 bytes
 po/ms.po                                           |   745 +-
 po/my.gmo                                          |   Bin 14808 -> 0 bytes
 po/nb.gmo                                          |   Bin 539159 -> 542540 bytes
 po/nb.po                                           |   821 +-
 po/ne.gmo                                          |   Bin 360764 -> 360764 bytes
 po/ne.po                                           |   676 +-
 po/nl.gmo                                          |   Bin 599934 -> 600043 bytes
 po/nl.po                                           |   697 +-
 po/nn.gmo                                          |   Bin 228560 -> 230911 bytes
 po/nn.po                                           |   799 +-
 po/oc.gmo                                          |   Bin 538955 -> 538955 bytes
 po/oc.po                                           |   669 +-
 po/or.gmo                                          |   Bin 24785 -> 0 bytes
 po/pa.gmo                                          |   Bin 273987 -> 274742 bytes
 po/pa.po                                           |   697 +-
 po/pl.gmo                                          |   Bin 612711 -> 612771 bytes
 po/pl.po                                           |   675 +-
 po/ps.gmo                                          |   Bin 38869 -> 38869 bytes
 po/ps.po                                           |   669 +-
 po/pt_BR.gmo                                       |   Bin 618336 -> 618804 bytes
 po/pt_BR.po                                        |   691 +-
 po/pt_PT.gmo                                       |   Bin 558476 -> 624071 bytes
 po/pt_PT.po                                        |  5785 ++--
 po/ro.gmo                                          |   Bin 413066 -> 413775 bytes
 po/ro.po                                           |   692 +-
 po/ru.gmo                                          |   Bin 780839 -> 780937 bytes
 po/ru.po                                           |   679 +-
 po/si.gmo                                          |   Bin 265713 -> 265713 bytes
 po/si.po                                           |   669 +-
 po/sk.gmo                                          |   Bin 635106 -> 635181 bytes
 po/sk.po                                           |   677 +-
 po/sl.gmo                                          |   Bin 595001 -> 595032 bytes
 po/sl.po                                           |   687 +-
 po/sq.gmo                                          |   Bin 63707 -> 63707 bytes
 po/sq.po                                           |   669 +-
 po/sr.gmo                                          |   Bin 329298 -> 331458 bytes
 po/sr.po                                           |   725 +-
 po/sv.gmo                                          |   Bin 479646 -> 482570 bytes
 po/sv.po                                           |   723 +-
 po/ta.gmo                                          |   Bin 143448 -> 143448 bytes
 po/ta.po                                           |   669 +-
 po/te.gmo                                          |   Bin 137919 -> 137889 bytes
 po/te.po                                           |   671 +-
 po/tet.gmo                                         |   Bin 449 -> 0 bytes
 po/th.gmo                                          |   Bin 418881 -> 418881 bytes
 po/th.po                                           |   676 +-
 po/tl.gmo                                          |   Bin 426 -> 0 bytes
 po/tr.gmo                                          |   Bin 623325 -> 624420 bytes
 po/tr.po                                           |  1932 +-
 po/tt.gmo                                          |   Bin 0 -> 85546 bytes
 po/{mk.po => tt.po}                                |  2762 +-
 po/ug.gmo                                          |   Bin 54985 -> 54985 bytes
 po/ug.po                                           |   669 +-
 po/uk.gmo                                          |   Bin 788464 -> 788573 bytes
 po/uk.po                                           |   674 +-
 po/uz.gmo                                          |   Bin 54756 -> 54756 bytes
 po/uz.po                                           |   669 +-
 po/vi.gmo                                          |   Bin 489962 -> 489962 bytes
 po/vi.po                                           |   670 +-
 po/vlc.pot                                         |   662 +-
 po/wa.gmo                                          |   Bin 256774 -> 256774 bytes
 po/wa.po                                           |   669 +-
 po/zh_CN.gmo                                       |   Bin 557317 -> 557364 bytes
 po/zh_CN.po                                        |   675 +-
 po/zh_TW.gmo                                       |   Bin 287133 -> 292090 bytes
 po/zh_TW.po                                        |   801 +-
 po/zu.gmo                                          |   Bin 52348 -> 52348 bytes
 po/zu.po                                           |   669 +-
 share/vlc.desktop.in                               |    23 +-

Translation updates.

unblock vlc/3.0.7-1

Cheer
-- 
Sebastian Ramacher
diff --git a/NEWS b/NEWS
index 996898f4b1..de940b64c9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,65 @@
+Changes between 3.0.6 and 3.0.7:
+--------------------------------
+
+Access:
+ * Improve Blu-ray support
+ * Fix sftp module build with libssh >= 1.8.1
+
+Audio output:
+ * Fix pass-through on Android-23
+ * Fix DirectSound drain
+
+Demux:
+ * Improve MP4 support
+
+Video Output:
+ * Fix 12 bits sources playback with Direct3D11
+ * Fix crash on iOS
+ * Fix midstream aspect-ratio changes when Windows hardware decoding is on
+ * Fix HLG display with Direct3D11
+
+Stream Output:
+ * Improve Chromecast support with new ChromeCast apps
+
+macOS:
+ * Fix UPNP service discovery, services are discovered on the highest priority
+   active network interface now
+ * Fix video distortion on macOS Mojave
+
+Misc:
+ * Update Youtube, Dailymotion, Vimeo, Soundcloud scripts
+ * Work around busy looping when playing an invalid item with loop enabled
+
+Translations:
+ * Update of most translations
+
+Security:
+ * Fix multiple buffer overflows in the ps demuxer
+ * Fix a buffer overflow when copying a biplanar YUV image
+ * Fix multiple buffer overflows in the faad decoder
+ * Fix buffer overflow in the svcdsub decoder
+ * Fix buffer overflows in the ogg muxer & demuxer
+ * Fix buffer overflows in libavformat demuxer
+ * Fix multiple buffer overflows in the MKV demuxer
+ * Fix a buffer overflow in the MP4 demuxer
+ * Fix a buffer overflow in the textst decoder
+ * Fix a buffer overflow in the webvtt decoder
+ * Fix a buffer overflow in the ASF demux
+ * Fix a buffer overflow in the UPNP SD
+ * Fix use after free in the ogg demuxer
+ * Fix multiple use after free in the MKV demuxer
+ * Fix multiple use after free in the DMO decoder
+ * Fix integer underflow in the MKV demuxer
+ * Fix an updater NULL pointer dereference on invalid signing keys
+ * Fix NULL pointer dereference in the MKV demuxer
+ * Fix an integer overflow in the spudec decoder
+ * Fix an integer overflow in the nsc demuxer
+ * Fix an integer overflow in the avi demuxer
+ * Fix reads of uninitialized pointers in the MKV demuxer
+ * Fix a floating point exception in the MKV demuxer
+ * Fix an infinite loop in the flac packetizer
+ 
+
 Changes between 3.0.5 and 3.0.6:
 --------------------------------
 
@@ -8,6 +70,7 @@ Codec:
  * Add support for 12 bits decoding of AV1
  * Fix HDR support in AV1 when the container provides the metadata
 
+
 Changes between 3.0.4 and 3.0.5:
 --------------------------------
 
diff --git a/debian/changelog b/debian/changelog
index 5f2de04764..9a6e105638 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
+vlc (3.0.7-1) unstable; urgency=high
+
+  * New upstream release.
+    - Fix multiple integer overflows.
+    - Fix multiple buffer overflows.
+    - Fix use-after-free issue.
+    - Fix NULL pointer dereference.
+    - Fix other memory access bugs and infinite loops.
+  * debian/rules: Be explicit about --enable-debug/disable-debug.
+
+ -- Sebastian Ramacher <sramacher@debian.org>  Fri, 07 Jun 2019 01:08:14 +0200
+
 vlc (3.0.6-1) unstable; urgency=medium
 
   * New upstream release.
diff --git a/debian/rules b/debian/rules
index dd934e2b70..6b386dd425 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,8 +7,14 @@ include /usr/share/dpkg/architecture.mk
 include /usr/share/dpkg/pkg-info.mk
 include /usr/share/dpkg/vendor.mk
 
+# custom build option: debug
+# VLC enables assertions if --enable-debug is passed to the configure script. To debug issues, it
+# might be useful to have them enabled. In that case, rebuilding the package with
+# DEB_BUILD_OPTIONS=debug produces a build with the assertions enabled.
 ifneq (,$(filter debug,$(DEB_BUILD_OPTIONS)))
 confflags += --enable-debug
+else
+confflags += --disable-debug
 endif
 
 # configure flags
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index f260e9543b..f00a59701b 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -2,7 +2,7 @@
  * libvlc_media_player.h:  libvlc_media_player external API
  *****************************************************************************
  * Copyright (C) 1998-2015 VLC authors and VideoLAN
- * $Id: 4336df9442b5bae28ec93d540f2ee5907f34e077 $
+ * $Id: c431c235e92ced9e6e7d7712eb7ff0e73dc4f933 $
  *
  * Authors: Clément Stenac <zorglub@videolan.org>
  *          Jean-Paul Saman <jpsaman@videolan.org>
@@ -766,7 +766,7 @@ void libvlc_audio_set_format_callbacks( libvlc_media_player_t *mp,
  *
  * \param mp the media player
  * \param format a four-characters string identifying the sample format
- *               (e.g. "S16N" or "FL32")
+ *               (e.g. "S16N" or "f32l")
  * \param rate sample rate (expressed in Hz)
  * \param channels channels count
  * \version LibVLC 2.0.0 or later
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 09d8d1075b..68b13c2248 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -162,6 +162,9 @@ struct  demux_sys_t
     unsigned int        i_longest_title;
     input_title_t       **pp_title;
 
+    /* Events */
+    DECL_ARRAY(BD_EVENT) events_delayed;
+
     vlc_mutex_t             pl_info_lock;
     BLURAY_TITLE_INFO      *p_pl_info;
     const BLURAY_CLIP_INFO *p_clip_info;
@@ -782,6 +785,7 @@ static int blurayOpen(vlc_object_t *object)
 
     TAB_INIT(p_sys->i_title, p_sys->pp_title);
     TAB_INIT(p_sys->i_attachments, p_sys->attachments);
+    ARRAY_INIT(p_sys->events_delayed);
 
     vlc_mutex_init(&p_sys->pl_info_lock);
     vlc_mutex_init(&p_sys->bdj_overlay_lock);
@@ -1027,6 +1031,8 @@ static void blurayClose(vlc_object_t *object)
       vlc_input_attachment_Delete(p_sys->attachments[i]);
     TAB_CLEAN(p_sys->i_attachments, p_sys->attachments);
 
+    ARRAY_RESET(p_sys->events_delayed);
+
     vlc_mutex_destroy(&p_sys->pl_info_lock);
     vlc_mutex_destroy(&p_sys->bdj_overlay_lock);
     vlc_mutex_destroy(&p_sys->read_block_lock);
@@ -1960,6 +1966,7 @@ static void bluraySendOverlayToVout(demux_t *p_demux, bluray_overlay_t *p_ov)
 static bool blurayTitleIsRepeating(BLURAY_TITLE_INFO *title_info,
                                    unsigned repeats, unsigned ratio)
 {
+#if BLURAY_VERSION >= BLURAY_VERSION_CODE(1, 0, 0)
     const BLURAY_CLIP_INFO *prev = NULL;
     unsigned maxrepeats = 0;
     unsigned sequence = 0;
@@ -1992,6 +1999,9 @@ static bool blurayTitleIsRepeating(BLURAY_TITLE_INFO *title_info,
     }
     return (maxrepeats > repeats &&
             (100 * maxrepeats / title_info->chapter_count) >= ratio);
+#else
+    return false;
+#endif
 }
 
 static void blurayUpdateTitleInfo(input_title_t *t, BLURAY_TITLE_INFO *title_info)
@@ -2139,8 +2149,9 @@ static int bluraySetTitle(demux_t *p_demux, int i_title)
 #  define BLURAY_AUDIO_STREAM 0
 #endif
 
-static void blurayOnUserStreamSelection(demux_sys_t *p_sys, int i_pid)
+static void blurayOnUserStreamSelection(demux_t *p_demux, int i_pid)
 {
+    demux_sys_t *p_sys = p_demux->p_sys;
     vlc_mutex_lock(&p_sys->pl_info_lock);
 
     if(i_pid == -AUDIO_ES)
@@ -2149,19 +2160,30 @@ static void blurayOnUserStreamSelection(demux_sys_t *p_sys, int i_pid)
         bd_select_stream(p_sys->bluray, BLURAY_PG_TEXTST_STREAM, 0, 0);
     else if (p_sys->p_clip_info)
     {
-
         if ((i_pid & 0xff00) == 0x1100) {
+            bool b_in_playlist = false;
             // audio
             for (int i_id = 0; i_id < p_sys->p_clip_info->audio_stream_count; i_id++) {
                 if (i_pid == p_sys->p_clip_info->audio_streams[i_id].pid) {
                     bd_select_stream(p_sys->bluray, BLURAY_AUDIO_STREAM, i_id + 1, 1);
+
                     if(!p_sys->b_menu)
                         bd_set_player_setting_str(p_sys->bluray, BLURAY_PLAYER_SETTING_AUDIO_LANG,
                                   (const char *) p_sys->p_clip_info->audio_streams[i_id].lang);
+                    b_in_playlist = true;
                     break;
                 }
             }
-        } else if ((i_pid & 0xff00) == 0x1400 || i_pid == 0x1800) {
+            if(!b_in_playlist && !p_sys->b_menu)
+            {
+                /* Without menu, the selected playlist might not be correct and only
+                   exposing a subset of PID, although same length */
+                msg_Warn(p_demux, "Incorrect playlist for menuless track, forcing");
+                es_out_Control(p_sys->p_out, BLURAY_ES_OUT_CONTROL_SET_ES_BY_PID,
+                               BD_EVENT_AUDIO_STREAM, i_pid);
+            }
+        } else if ((i_pid & 0xff00) == 0x1200 || i_pid == 0x1800) {
+            bool b_in_playlist = false;
             // subtitle
             for (int i_id = 0; i_id < p_sys->p_clip_info->pg_stream_count; i_id++) {
                 if (i_pid == p_sys->p_clip_info->pg_streams[i_id].pid) {
@@ -2169,9 +2191,16 @@ static void blurayOnUserStreamSelection(demux_sys_t *p_sys, int i_pid)
                     if(!p_sys->b_menu)
                         bd_set_player_setting_str(p_sys->bluray, BLURAY_PLAYER_SETTING_PG_LANG,
                                    (const char *) p_sys->p_clip_info->pg_streams[i_id].lang);
+                    b_in_playlist = true;
                     break;
                 }
             }
+            if(!b_in_playlist && !p_sys->b_menu)
+            {
+                msg_Warn(p_demux, "Incorrect playlist for menuless track, forcing");
+                es_out_Control(p_sys->p_out, BLURAY_ES_OUT_CONTROL_SET_ES_BY_PID,
+                               BD_EVENT_PG_TEXTST_STREAM, i_pid);
+            }
         }
     }
 
@@ -2213,7 +2242,7 @@ static int blurayControl(demux_t *p_demux, int query, va_list args)
     case DEMUX_SET_ES:
     {
         int i_id = va_arg(args, int);
-        blurayOnUserStreamSelection(p_sys, i_id);
+        blurayOnUserStreamSelection(p_demux, i_id);
         break;
     }
     case DEMUX_SET_TITLE:
@@ -2665,7 +2694,7 @@ static void blurayOnClipUpdate(demux_t *p_demux, uint32_t clip)
     blurayResetStillImage(p_demux);
 }
 
-static void blurayHandleEvent(demux_t *p_demux, const BD_EVENT *e)
+static void blurayHandleEvent(demux_t *p_demux, const BD_EVENT *e, bool b_delayed)
 {
     demux_sys_t *p_sys = p_demux->p_sys;
 
@@ -2753,7 +2782,10 @@ static void blurayHandleEvent(demux_t *p_demux, const BD_EVENT *e)
         break;
     case BD_EVENT_AUDIO_STREAM:
     case BD_EVENT_PG_TEXTST_STREAM:
-        blurayOnStreamSelectedEvent(p_demux, e->event, e->param);
+         if(b_delayed)
+             blurayOnStreamSelectedEvent(p_demux, e->event, e->param);
+         else
+             ARRAY_APPEND(p_sys->events_delayed, *e);
         break;
     case BD_EVENT_IG_STREAM:
     case BD_EVENT_SECONDARY_AUDIO:
@@ -2909,15 +2941,20 @@ static int blurayDemux(demux_t *p_demux)
     if (p_sys->b_menu == false) {
         nread = bd_read(p_sys->bluray, p_block->p_buffer, BD_READ_SIZE);
         while (bd_get_event(p_sys->bluray, &e))
-            blurayHandleEvent(p_demux, &e);
+            blurayHandleEvent(p_demux, &e, false);
     } else {
         nread = bd_read_ext(p_sys->bluray, p_block->p_buffer, BD_READ_SIZE, &e);
         while (e.event != BD_EVENT_NONE) {
-            blurayHandleEvent(p_demux, &e);
+            blurayHandleEvent(p_demux, &e, false);
             bd_get_event(p_sys->bluray, &e);
         }
     }
 
+    /* Process delayed selections events */
+    for(int i=0; i<p_sys->events_delayed.i_size; i++)
+        blurayHandleEvent(p_demux, &p_sys->events_delayed.p_elems[i], true);
+    p_sys->events_delayed.i_size = 0;
+
     blurayHandleOverlays(p_demux, nread);
 
     if (nread <= 0) {
diff --git a/modules/access/http/access.c b/modules/access/http/access.c
index ab72107a04..7eb9f0cc37 100644
--- a/modules/access/http/access.c
+++ b/modules/access/http/access.c
@@ -295,7 +295,6 @@ vlc_module_begin()
 
     add_bool("http-continuous", false, N_("Continuous stream"),
              N_("Keep reading a resource that keeps being updated."), true)
-        change_safe()
         change_volatile()
     add_bool("http-forward-cookies", true, N_("Cookies forwarding"),
              N_("Forward cookies across HTTP redirections."), true)
diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index b6480a83d9..36fed226b9 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -2,7 +2,7 @@
  * live555.cpp : LIVE555 Streaming Media support.
  *****************************************************************************
  * Copyright (C) 2003-2007 VLC authors and VideoLAN
- * $Id: d59a633d3cb90a0d2e56aae63ac4241071d8d92c $
+ * $Id: 26db2d6f24955ddc482009285c0c7b0e8392821c $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Derk-Jan Hartman <hartman at videolan. org>
@@ -2353,7 +2353,7 @@ static unsigned char* parseH264ConfigStr( char const* configStr,
         }
     }
 
-    size_t configMax = 5*strlen(dup);
+    size_t configMax = 4*i_records+strlen(configStr);
     unsigned char *cfg = new unsigned char[configMax];
     psz = dup;
     for( size_t i = 0; i < i_records; ++i )
diff --git a/modules/access/rdp.c b/modules/access/rdp.c
index 2992090219..3e09047b6c 100644
--- a/modules/access/rdp.c
+++ b/modules/access/rdp.c
@@ -457,7 +457,11 @@ static int Open( vlc_object_t *p_this )
 
     /* Parse uri params for pre-connect */
     vlc_url_t url;
-    vlc_UrlParse( &url, p_demux->psz_location );
+    char *psz_url;
+    if ( asprintf( &psz_url, "%s://%s", p_demux->psz_access, p_demux->psz_location ) == -1 )
+        goto error;
+    vlc_UrlParse( &url, psz_url );
+    free(psz_url);
 
     if ( !EMPTY_STR(url.psz_host) )
         p_sys->psz_hostname = strdup( url.psz_host );
diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index 80fd0c59cb..4a6eef81a7 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -2,7 +2,7 @@
  * sftp.c: SFTP input module
  *****************************************************************************
  * Copyright (C) 2009 VLC authors and VideoLAN
- * $Id: 5bc054d310b67f514f04b3ef5ddcfc188f6d81c3 $
+ * $Id: 6ea58654ed4c158f005861b87edffba22582ec78 $
  *
  * Authors: Rémi Duraffort <ivoire@videolan.org>
  *          Petri Hintukainen <phintuka@gmail.com>
@@ -306,7 +306,7 @@ static int Open( vlc_object_t* p_this )
         case LIBSSH2_HOSTKEY_TYPE_DSS:
             knownhost_fingerprint_algo = LIBSSH2_KNOWNHOST_KEY_SSHDSS;
             break;
-#if LIBSSH2_VERSION_NUM >= 0x010801
+#if LIBSSH2_VERSION_NUM >= 0x010900
         case LIBSSH2_HOSTKEY_TYPE_ECDSA_256:
             knownhost_fingerprint_algo = LIBSSH2_KNOWNHOST_KEY_ECDSA_256;
             break;
diff --git a/modules/access/vnc.c b/modules/access/vnc.c
index 3cd4ab642b..1d067c584c 100644
--- a/modules/access/vnc.c
+++ b/modules/access/vnc.c
@@ -439,7 +439,11 @@ static int Open( vlc_object_t *p_this )
 
     /* Parse uri params */
     vlc_url_t url;
-    vlc_UrlParse( &url, p_demux->psz_location );
+    char *psz_url;
+    if ( asprintf( &psz_url, "%s://%s", p_demux->psz_access, p_demux->psz_location ) == -1 )
+        return VLC_ENOMEM;
+    vlc_UrlParse( &url, psz_url );
+    free(psz_url);
 
     if ( !EMPTY_STR(url.psz_host) )
         p_sys->p_client->serverHost = strdup( url.psz_host );
diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index a6a8a78d74..23becdc718 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -1011,6 +1011,11 @@ StartPassthrough( JNIEnv *env, audio_output_t *p_aout )
                     return VLC_EGENERIC;
                 i_at_format = jfields.AudioFormat.ENCODING_AC3;
                 break;
+            case VLC_CODEC_EAC3:
+                if( !jfields.AudioFormat.has_ENCODING_E_AC3 )
+                    return VLC_EGENERIC;
+                i_at_format = jfields.AudioFormat.ENCODING_E_AC3;
+                break;
             case VLC_CODEC_DTS:
                 if( !jfields.AudioFormat.has_ENCODING_DTS )
                     return VLC_EGENERIC;
@@ -1729,6 +1734,46 @@ AudioTrack_Thread( void *p_data )
     return NULL;
 }
 
+static int
+ConvertFromIEC61937( audio_output_t *p_aout, block_t *p_buffer )
+{
+    /* This function is only used for Android API 23 when AudioTrack is
+     * configured with ENCODING_ AC3/E_AC3/DTS. In that case, only the codec
+     * data is needed (without the IEC61937 encapsulation). This function
+     * recovers the codec data from an EC61937 frame. It is the opposite of the
+     * code found in converter/tospdif.c. We could also request VLC core to
+     * send us the codec data directly, but in that case, we wouldn't benefit
+     * from the eac3 block merger of tospdif.c. */
+
+    VLC_UNUSED( p_aout );
+    uint8_t i_length_mul;
+
+    switch( GetWBE( &p_buffer->p_buffer[4] ) & 0xFF )
+    {
+        case 0x01: /* IEC61937_AC3 */
+            i_length_mul = 8;
+            break;
+        case 0x15: /* IEC61937_EAC3 */
+            i_length_mul = 1;
+            break;
+        case 0x0B: /* IEC61937_DTS1 */
+        case 0x0C: /* IEC61937_DTS2 */
+        case 0x0D: /* IEC61937_DTS3 */
+        case 0x11: /* IEC61937_DTSHD */
+            i_length_mul = 8;
+            break;
+        default:
+            vlc_assert_unreachable();
+    }
+    uint16_t i_length = GetWBE( &p_buffer->p_buffer[6] );
+    if( i_length == 0 )
+        return -1;
+    p_buffer->p_buffer += 8; /* SPDIF_HEADER_SIZE */
+    p_buffer->i_buffer = i_length / i_length_mul;
+
+    return 0;
+}
+
 static void
 Play( audio_output_t *p_aout, block_t *p_buffer )
 {
@@ -1736,6 +1781,13 @@ Play( audio_output_t *p_aout, block_t *p_buffer )
     size_t i_buffer_offset = 0;
     aout_sys_t *p_sys = p_aout->sys;
 
+    if( p_sys->b_passthrough && !jfields.AudioFormat.has_ENCODING_IEC61937
+     && ConvertFromIEC61937( p_aout, p_buffer ) != 0 )
+    {
+        block_Release(p_buffer);
+        return;
+    }
+
     vlc_mutex_lock( &p_sys->lock );
 
     if( p_sys->b_error || !( env = GET_ENV() ) )
diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
index 0d600bd008..6208727b34 100644
--- a/modules/audio_output/directsound.c
+++ b/modules/audio_output/directsound.c
@@ -2,7 +2,7 @@
  * directsound.c: DirectSound audio output plugin for VLC
  *****************************************************************************
  * Copyright (C) 2001-2009 VLC authors and VideoLAN
- * $Id: 534c9952e2cb1b0284d58447d3bf637f2700eaf1 $
+ * $Id: 4aa9d28d5366223d308228aafa6aed039d972474 $
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
  *
@@ -140,7 +140,7 @@ struct aout_sys_t
     } volume;
 };
 
-static HRESULT Flush( aout_stream_sys_t *sys, bool drain);
+static HRESULT Flush( aout_stream_sys_t *sys );
 static HRESULT TimeGet( aout_stream_sys_t *sys, mtime_t *delay )
 {
     DWORD read, status;
@@ -171,7 +171,7 @@ static HRESULT TimeGet( aout_stream_sys_t *sys, mtime_t *delay )
 
     if( sys->i_data < 0 )
         /* underrun */
-        Flush(sys, false);
+        Flush(sys);
 
     *delay = ( sys->i_data / sys->i_bytes_per_sample ) * CLOCK_FREQ / sys->i_rate;
 
@@ -339,10 +339,10 @@ static void OutputPause( audio_output_t *aout, bool pause, mtime_t date )
     (void) date;
 }
 
-static HRESULT Flush( aout_stream_sys_t *sys, bool drain)
+static HRESULT Flush( aout_stream_sys_t *sys )
 {
     HRESULT ret = IDirectSoundBuffer_Stop( sys->p_dsbuffer );
-    if( ret == DS_OK && !drain )
+    if( ret == DS_OK )
     {
         vlc_mutex_lock(&sys->lock);
         sys->i_data = 0;
@@ -356,13 +356,21 @@ static HRESULT Flush( aout_stream_sys_t *sys, bool drain)
 
 static HRESULT StreamFlush( aout_stream_t *s )
 {
-    return Flush( s->sys, false );
+    return Flush( s->sys );
 }
 
 static void OutputFlush( audio_output_t *aout, bool drain )
 {
-    aout_stream_sys_t *sys = &aout->sys->s;
-    Flush( sys, drain );
+    aout_sys_t *sys = aout->sys;
+    if (drain)
+    {   /* Loosy drain emulation */
+        mtime_t delay;
+
+        if (OutputTimeGet(aout, &delay) == 0 && delay <= INT64_C(5000000))
+            Sleep((delay / (CLOCK_FREQ / 1000)) + 1);
+    }
+    else
+        Flush( &sys->s );
 }
 
 /**
diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h
index 560e77b4a2..fc85c18060 100644
--- a/modules/codec/avcodec/avcommon.h
+++ b/modules/codec/avcodec/avcommon.h
@@ -2,7 +2,7 @@
  * avcommon.h: common code for libav*
  *****************************************************************************
  * Copyright (C) 2012 VLC authors and VideoLAN
- * $Id: 65ad35f4ada4d2b7549ace885cc8b38ddbe20aed $
+ * $Id: 8c8298014ff95600cb5a171b93331979e3174047 $
  *
  * Authors: Rafaël Carré <funman@videolanorg>
  *
@@ -46,6 +46,9 @@
 #define AV_OPTIONS_TEXT     N_("Advanced options")
 #define AV_OPTIONS_LONGTEXT N_("Advanced options, in the form {opt=val,opt2=val2}.")
 
+#define AV_RESET_TS_TEXT     "Reset timestamps"
+#define AV_RESET_TS_LONGTEXT "The muxed content will start near a 0 timestamp."
+
 static inline void vlc_av_get_options(const char *psz_opts, AVDictionary** pp_dict)
 {
     config_chain_t *cfg = NULL;
diff --git a/modules/codec/avcodec/chroma.c b/modules/codec/avcodec/chroma.c
index 9155155884..448c1dec31 100644
--- a/modules/codec/avcodec/chroma.c
+++ b/modules/codec/avcodec/chroma.c
@@ -2,7 +2,7 @@
  * chroma.c: libavutil <-> libvlc conversion routines
  *****************************************************************************
  * Copyright (C) 1999-2008 VLC authors and VideoLAN
- * $Id: e622e25c7a68e74c9dc3caa132606ccfe7280427 $
+ * $Id: 10338450b2c2342edb857e513cef5dc83b3745c6 $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@videolan.org>
@@ -145,6 +145,14 @@ static const struct
     VLC_RGB( VLC_CODEC_RGB32, AV_PIX_FMT_0BGR32, AV_PIX_FMT_0RGB32, 0x000000ff, 0x0000ff00, 0x00ff0000 )
 #endif
 
+#if (LIBAVUTIL_VERSION_MICRO == 0 || LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 55, 0, 100 ) )
+#ifdef WORDS_BIGENDIAN
+    {VLC_CODEC_RGBA64, AV_PIX_FMT_RGBA64BE, 0, 0, 0 },
+#else /* !WORDS_BIGENDIAN */
+    {VLC_CODEC_RGBA64, AV_PIX_FMT_RGBA64LE, 0, 0, 0 },
+#endif /* !WORDS_BIGENDIAN */
+#endif
+
     {VLC_CODEC_RGBA, AV_PIX_FMT_RGBA, 0, 0, 0 },
     {VLC_CODEC_ARGB, AV_PIX_FMT_ARGB, 0, 0, 0 },
     {VLC_CODEC_BGRA, AV_PIX_FMT_BGRA, 0, 0, 0 },
diff --git a/modules/codec/avcodec/fourcc.c b/modules/codec/avcodec/fourcc.c
index a7cc91cdf2..589efd9b57 100644
--- a/modules/codec/avcodec/fourcc.c
+++ b/modules/codec/avcodec/fourcc.c
@@ -2,7 +2,7 @@
  * fourcc.c: libavcodec <-> libvlc conversion routines
  *****************************************************************************
  * Copyright (C) 1999-2009 VLC authors and VideoLAN
- * $Id: 40e98e06690c57dc5d7e334c102580fdd963aca0 $
+ * $Id: 33c6cae09abce0d21de04621c980ccec2375fed5 $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@videolan.org>
@@ -182,7 +182,9 @@ static const struct vlc_avcodec_fourcc video_codecs[] =
     /* AV_CODEC_ID_V210X */
     { VLC_CODEC_TMV, AV_CODEC_ID_TMV },
     { VLC_CODEC_V210, AV_CODEC_ID_V210 },
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 54, 50, 100 ) && LIBAVCODEC_VERSION_MICRO >= 100
     { VLC_CODEC_VUYA, AV_CODEC_ID_AYUV },
+#endif
     /* AV_CODEC_ID_DPX */
     { VLC_CODEC_MAD, AV_CODEC_ID_MAD },
     { VLC_CODEC_FRWU, AV_CODEC_ID_FRWU },
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index d7fb730850..a9e9e70d65 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -2,7 +2,7 @@
  * video.c: video decoder using the libavcodec library
  *****************************************************************************
  * Copyright (C) 1999-2001 VLC authors and VideoLAN
- * $Id: 8cb4003561532c72bc405f051b7e26a14bf773f6 $
+ * $Id: 097e7cb11ad5ed24766038a765da84376d69ea3d $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@videolan.org>
@@ -1557,8 +1557,11 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
      for (size_t i = 0; pi_fmt[i] != AV_PIX_FMT_NONE; i++)
         if (pi_fmt[i] == p_sys->pix_fmt)
         {
-            msg_Dbg(p_dec, "reusing decoder output format %d", pi_fmt[i]);
-            return p_sys->pix_fmt;
+            if (lavc_UpdateVideoFormat(p_dec, p_context, p_sys->pix_fmt, swfmt) == 0)
+            {
+                msg_Dbg(p_dec, "reusing decoder output format %d", pi_fmt[i]);
+                return p_sys->pix_fmt;
+            }
         }
 
 no_reuse:
diff --git a/modules/codec/dmo/dmo.c b/modules/codec/dmo/dmo.c
index 10e0c1e3bc..2025c833b0 100644
--- a/modules/codec/dmo/dmo.c
+++ b/modules/codec/dmo/dmo.c
@@ -2,7 +2,7 @@
  * dmo.c : DirectMedia Object decoder module for vlc
  *****************************************************************************
  * Copyright (C) 2002, 2003 VLC authors and VideoLAN
- * $Id: ba59c613bacbd615c367575ab4798891a1cced42 $
+ * $Id: 5ab1a11c54f7d705363534448223022269e60d23 $
  *
  * Author: Gildas Bazin <gbazin@videolan.org>
  *
@@ -868,6 +868,7 @@ static int DecBlock( decoder_t *p_dec, block_t **pp_block )
                        (IMediaBuffer *)p_in, DMO_INPUT_DATA_BUFFERF_SYNCPOINT,
                        0, 0 );
 
+        *pp_block = NULL;
         p_in->vt->Release( (IUnknown *)p_in );
 
         if( i_result == S_FALSE )
@@ -893,8 +894,6 @@ static int DecBlock( decoder_t *p_dec, block_t **pp_block )
 #ifdef DMO_DEBUG
             msg_Dbg( p_dec, "ProcessInput(): successful" );
 #endif
-            block_Release( p_block );
-            *pp_block = NULL;
         }
     }
 
diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 8e701496d4..687c576af0 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -2,7 +2,7 @@
  * faad.c: AAC decoder using libfaad2
  *****************************************************************************
  * Copyright (C) 2001, 2003 VLC authors and VideoLAN
- * $Id: 0e68626c493ef344b60a9e832714aa07afd21c13 $
+ * $Id: dae312b14728a43df52067faf07ad1797bdc6439 $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@videolan.org>
@@ -513,13 +513,13 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         /* Convert frame.channel_position to our own channel values */
         p_dec->fmt_out.audio.i_physical_channels = 0;
 
-        uint8_t  pi_neworder_table[AOUT_CHAN_MAX];
-        uint32_t pi_faad_channels_positions[FAAD_CHANNEL_ID_COUNT + 1] = {0};
+        uint8_t  pi_neworder_table[64] = {0};
+        uint32_t pi_faad_channels_positions[64 + 1] = {0};
 
         bool b_reorder = false;
         if (p_dec->fmt_out.audio.channel_type == AUDIO_CHANNEL_TYPE_BITMAP)
         {
-            for( size_t i = 0; i < frame.channels && i < FAAD_CHANNEL_ID_COUNT; i++ )
+            for( size_t i = 0; i < frame.channels; i++ )
             {
                 unsigned pos = frame.channel_position[i];
                 if( likely(pos < FAAD_CHANNEL_ID_COUNT) )
diff --git a/modules/codec/spudec/parse.c b/modules/codec/spudec/parse.c
index 08a28f037b..746e71cb50 100644
--- a/modules/codec/spudec/parse.c
+++ b/modules/codec/spudec/parse.c
@@ -2,7 +2,7 @@
  * parse.c: SPU parser
  *****************************************************************************
  * Copyright (C) 2000-2001, 2005, 2006 VLC authors and VideoLAN
- * $Id: 275864f187aa62119914038186d4d7ea7b23bf03 $
+ * $Id: 24eb465a7e8ff518fbc54e6e2420ba33881296db $
  *
  * Authors: Sam Hocevar <sam@zoy.org>
  *          Laurent Aimar <fenrir@via.ecp.fr>
@@ -326,6 +326,11 @@ static int ParseControlSeq( decoder_t *p_dec, subpicture_t *p_spu,
             p_spu_properties->i_height = (((p_sys->buffer[i_index+5]&0x0f)<<8)|
                               p_sys->buffer[i_index+6]) - p_spu_properties->i_y + 1;
 
+            if (p_spu_properties->i_width < 0 || p_spu_properties->i_height < 0) {
+                msg_Err( p_dec, "integer overflow in SPU command" );
+                return VLC_EGENERIC;
+            }
+
             /* Auto crop fullscreen subtitles */
             if( p_spu_properties->i_height > 250 )
                 p_spu_data->b_auto_crop = true;
diff --git a/modules/codec/svcdsub.c b/modules/codec/svcdsub.c
index 679ffcb924..6cad74bc23 100644
--- a/modules/codec/svcdsub.c
+++ b/modules/codec/svcdsub.c
@@ -2,7 +2,7 @@
  * svcdsub.c : Overlay Graphics Text (SVCD subtitles) decoder
  *****************************************************************************
  * Copyright (C) 2003, 2004 VLC authors and VideoLAN
- * $Id: e509effdbce524b8854874365d8b62d6f8f4d58e $
+ * $Id: 6be8a43c02c67cf6e45c16d5579cab5813998704 $
  *
  * Authors: Rocky Bernstein
  *          Gildas Bazin <gbazin@videolan.org>
@@ -362,18 +362,30 @@ static void ParseHeader( decoder_t *p_dec, block_t *p_block )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
     uint8_t *p = p_block->p_buffer;
+    size_t i_buffer = p_block->i_buffer;
     uint8_t i_options, i_cmd;
     int i;
 
+    if (i_buffer < 4) return;
+
     p_sys->i_spu_size = GETINT16(p);
     i_options  = *p++;
     // Skip over unused value
     p++;
 
-    if( i_options & 0x08 ) { p_sys->i_duration = GETINT32(p); }
+    i_buffer -= 4;
+
+    if( i_options & 0x08 ) {
+      if (i_buffer < 4) return;
+      p_sys->i_duration = GETINT32(p);
+      p += 4;
+      i_buffer -= 4;
+    }
     else p_sys->i_duration = 0; /* Ephemer subtitle */
     p_sys->i_duration *= 100 / 9;
 
+    if (i_buffer < 25) return;
+
     p_sys->i_x_start = GETINT16(p);
     p_sys->i_y_start = GETINT16(p);
     p_sys->i_width   = GETINT16(p);
@@ -388,12 +400,21 @@ static void ParseHeader( decoder_t *p_dec, block_t *p_block )
     }
 
     i_cmd = *p++;
+
+    i_buffer -= 25;
+
     /* We do not really know this, FIXME */
-    if( i_cmd ) { p += 4; }
+    if( i_cmd ) {
+      if (i_buffer < 4) return;
+      p += 4;
+      i_buffer -= 4;
+    }
 
     /* Actually, this is measured against a different origin, so we have to
      * adjust it */
+    if (i_buffer < 2) return;
     p_sys->second_field_offset = GETINT16(p);
+    i_buffer -= 2;
     p_sys->i_image_offset  = p - p_block->p_buffer;
     p_sys->i_image_length  = p_sys->i_spu_size - p_sys->i_image_offset;
     p_sys->metadata_length = p_sys->i_image_offset;
diff --git a/modules/codec/textst.c b/modules/codec/textst.c
index c5c414f1cb..d3949ced7d 100644
--- a/modules/codec/textst.c
+++ b/modules/codec/textst.c
@@ -73,6 +73,8 @@ static size_t textst_FillRegion(decoder_t *p_dec, const uint8_t *p_data, size_t
      /*   forced_on_flag b1 */
      /*   ? b6 */
 
+     assert( i_data >= 4 );
+
      //uint8_t region_style_id_ref = p_data[1];
      uint16_t i_data_length = GetWBE(&p_data[2]);
 
@@ -206,7 +208,7 @@ static void textst_FillRegions(decoder_t *p_dec, const uint8_t *p_data, size_t i
         uint8_t i_region_count = p_data[0];
         p_data++; i_data--;
 
-        for(uint8_t i=0; i<i_region_count && i_data > 0; i++)
+        for(uint8_t i=0; i<i_region_count && i_data > 4; i++)
         {
             if(*pp_last == NULL)
             {
diff --git a/modules/codec/vpx.c b/modules/codec/vpx.c
index 2b1e37818d..aba180361f 100644
--- a/modules/codec/vpx.c
+++ b/modules/codec/vpx.c
@@ -116,6 +116,7 @@ static const struct
     { VLC_CODEC_I440, VPX_IMG_FMT_I440, 8, 0 },
 
     { VLC_CODEC_YV12, VPX_IMG_FMT_YV12, 8, 0 },
+#if VPX_IMAGE_ABI_VERSION < 5
     { VLC_CODEC_YUVA, VPX_IMG_FMT_444A, 8, 0 },
     { VLC_CODEC_YUYV, VPX_IMG_FMT_YUY2, 8, 0 },
     { VLC_CODEC_UYVY, VPX_IMG_FMT_UYVY, 8, 0 },
@@ -128,7 +129,7 @@ static const struct
 
     { VLC_CODEC_ARGB, VPX_IMG_FMT_ARGB, 8, 0 },
     { VLC_CODEC_BGRA, VPX_IMG_FMT_ARGB_LE, 8, 0 },
-
+#endif
     { VLC_CODEC_GBR_PLANAR, VPX_IMG_FMT_I444, 8, 1 },
     { VLC_CODEC_GBR_PLANAR_10L, VPX_IMG_FMT_I44416, 10, 1 },
 
diff --git a/modules/codec/webvtt/subsvtt.c b/modules/codec/webvtt/subsvtt.c
index ebe725fd3e..2f79fb4529 100644
--- a/modules/codec/webvtt/subsvtt.c
+++ b/modules/codec/webvtt/subsvtt.c
@@ -1807,6 +1807,11 @@ static void Render( decoder_t *p_dec, mtime_t i_start, mtime_t i_stop )
     vlc_array_init( &timedtags );
 
     GetTimedTags( p_sys->p_root->p_child, i_start, i_stop, &timedtags );
+    if( timedtags.i_count == 0 )
+    {
+        vlc_array_clear( &timedtags );
+        return;
+    }
     qsort( timedtags.pp_elems, timedtags.i_count, sizeof(*timedtags.pp_elems), timedtagsArrayCmp );
 
     mtime_t i_substart = i_start;
diff --git a/modules/codec/webvtt/webvtt.c b/modules/codec/webvtt/webvtt.c
index ac78d1968b..76f2aee8ef 100644
--- a/modules/codec/webvtt/webvtt.c
+++ b/modules/codec/webvtt/webvtt.c
@@ -242,7 +242,7 @@ void webvtt_text_parser_Feed( webvtt_text_parser_t *p, char *psz_line )
             if( webvtt_scan_time( p->reads[1], &i_start ) &&
                 webvtt_scan_time( psz_split + 5,  &i_stop ) && i_start <= i_stop )
             {
-                const char *psz_attrs = strchr( psz_split + 5 + 9, ' ' );
+                const char *psz_attrs = strchr( psz_split + 5 + 5, ' ' );
                 p->p_cue = ( p->pf_get_cue ) ? p->pf_get_cue( p->priv ) : NULL;
                 if( p->p_cue )
                 {
diff --git a/modules/demux/adaptive/http/Chunk.h b/modules/demux/adaptive/http/Chunk.h
index a3773862da..fe2107b9d1 100644
--- a/modules/demux/adaptive/http/Chunk.h
+++ b/modules/demux/adaptive/http/Chunk.h
@@ -71,11 +71,11 @@ namespace adaptive
 
                 virtual block_t *   readBlock       ();
                 virtual block_t *   read            (size_t);
-                virtual void        onDownload      (block_t **) = 0;
 
             protected:
                 AbstractChunk(AbstractChunkSource *);
                 AbstractChunkSource *source;
+                virtual void        onDownload      (block_t **) = 0;
 
             private:
                 size_t              bytesRead;
@@ -149,6 +149,7 @@ namespace adaptive
                           const ID &, bool = false);
                 virtual ~HTTPChunk();
 
+            protected:
                 virtual void        onDownload      (block_t **) {} /* impl */
         };
     }
diff --git a/modules/demux/adaptive/http/HTTPConnection.cpp b/modules/demux/adaptive/http/HTTPConnection.cpp
index 451e81d2bd..5fc0144e14 100644
--- a/modules/demux/adaptive/http/HTTPConnection.cpp
+++ b/modules/demux/adaptive/http/HTTPConnection.cpp
@@ -70,7 +70,12 @@ HTTPConnection::HTTPConnection(vlc_object_t *p_object_, AuthStorage *auth,
     : AbstractConnection( p_object_ )
 {
     transport = socket_;
-    psz_useragent = var_InheritString(p_object_, "http-user-agent");
+    char *psz_useragent = var_InheritString(p_object_, "http-user-agent");
+    useragent = psz_useragent ? std::string(psz_useragent) : std::string("");
+    free(psz_useragent);
+    for(std::string::iterator it = useragent.begin(); it != useragent.end(); ++it)
+        if(!std::isprint(*it))
+            *it = ' ';
     queryOk = false;
     retries = 0;
     authStorage = auth;
@@ -83,7 +88,6 @@ HTTPConnection::HTTPConnection(vlc_object_t *p_object_, AuthStorage *auth,
 
 HTTPConnection::~HTTPConnection()
 {
-    free(psz_useragent);
     delete transport;
 }
 
@@ -433,7 +437,7 @@ std::string HTTPConnection::buildRequestHeader(const std::string &path) const
             req << "Cookie: " << cookie << "\r\n";
     }
     req << "Cache-Control: no-cache" << "\r\n" <<
-           "User-Agent: " << std::string(psz_useragent) << "\r\n";
+           "User-Agent: " << useragent << "\r\n";
     req << extraRequestHeaders();
     return req.str();
 }
diff --git a/modules/demux/adaptive/http/HTTPConnection.hpp b/modules/demux/adaptive/http/HTTPConnection.hpp
index c95ce15798..343336f0db 100644
--- a/modules/demux/adaptive/http/HTTPConnection.hpp
+++ b/modules/demux/adaptive/http/HTTPConnection.hpp
@@ -93,7 +93,7 @@ namespace adaptive
                 ssize_t         readChunk   (void *p_buffer, size_t len);
                 int parseReply();
                 std::string readLine();
-                char * psz_useragent;
+                std::string useragent;
 
                 AuthStorage        *authStorage;
                 ConnectionParams    locationparams;
diff --git a/modules/demux/adaptive/playlist/BasePeriod.cpp b/modules/demux/adaptive/playlist/BasePeriod.cpp
index 4f520d5bf6..93f4121741 100644
--- a/modules/demux/adaptive/playlist/BasePeriod.cpp
+++ b/modules/demux/adaptive/playlist/BasePeriod.cpp
@@ -32,6 +32,7 @@
 
 #include <vlc_common.h>
 #include <vlc_arrays.h>
+#include <cassert>
 
 using namespace adaptive::playlist;
 
@@ -63,6 +64,11 @@ void BasePeriod::addAdaptationSet(BaseAdaptationSet *adaptationSet)
 {
     if ( adaptationSet != NULL )
     {
+        if(adaptationSet->getRepresentations().empty())
+        {
+            assert(!adaptationSet->getRepresentations().empty());
+            return; /* will leak */
+        }
         adaptationSets.push_back(adaptationSet);
         childs.push_back(adaptationSet);
     }
diff --git a/modules/demux/adaptive/playlist/SegmentChunk.hpp b/modules/demux/adaptive/playlist/SegmentChunk.hpp
index 0d8906e59d..5673301c83 100644
--- a/modules/demux/adaptive/playlist/SegmentChunk.hpp
+++ b/modules/demux/adaptive/playlist/SegmentChunk.hpp
@@ -40,11 +40,11 @@ namespace adaptive
         public:
             SegmentChunk(ISegment *segment, AbstractChunkSource *, BaseRepresentation *);
             virtual ~SegmentChunk();
-            virtual void onDownload(block_t **); // reimpl
             StreamFormat getStreamFormat() const;
             bool discontinuity;
 
         protected:
+            virtual void onDownload(block_t **); // reimpl
             ISegment *segment;
             BaseRepresentation *rep;
         };
diff --git a/modules/demux/adaptive/plumbing/FakeESOut.cpp b/modules/demux/adaptive/plumbing/FakeESOut.cpp
index bc1517ebc7..52a71e8ef7 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.cpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.cpp
@@ -102,8 +102,6 @@ FakeESOutID * FakeESOut::createNewID( const es_format_t *p_fmt )
         extrainfo->fillExtraFMTInfo( &fmtcopy );
 
     FakeESOutID *es_id = new (std::nothrow) FakeESOutID( this, &fmtcopy );
-    if(likely(es_id))
-        fakeesidlist.push_back( es_id );
 
     vlc_mutex_unlock(&lock);
 
@@ -289,6 +287,7 @@ es_out_id_t * FakeESOut::esOutAdd_Callback(es_out_t *fakees, const es_format_t *
         AbstractCommand *command = me->commandsqueue->factory()->createEsOutAddCommand( es_id );
         if( likely(command) )
         {
+            me->fakeesidlist.push_back(es_id);
             me->commandsqueue->Schedule( command );
             return reinterpret_cast<es_out_id_t *>(es_id);
         }
diff --git a/modules/demux/asf/libasf.c b/modules/demux/asf/libasf.c
index 119ef4d0e3..89ebcbf501 100644
--- a/modules/demux/asf/libasf.c
+++ b/modules/demux/asf/libasf.c
@@ -1359,6 +1359,9 @@ static int ASF_ReadObject_marker(stream_t *s, asf_object_t *p_obj)
 
     p_data = &p_peek[ASF_OBJECT_COMMON_SIZE];
 
+    if( !ASF_HAVE( 16+4+2+2 ) )
+        return VLC_EGENERIC;
+
     ASF_GetGUID( &p_mk->i_reserved1, p_data );
     ASF_SKIP( 16 );
     p_mk->i_count = ASF_READ4();
@@ -1408,6 +1411,7 @@ static void ASF_FreeObject_marker( asf_object_t *p_obj)
     {
         FREENULL( p_mk->marker[i].p_marker_description  );
     }
+    FREENULL( p_mk->marker );
     FREENULL( p_mk->name );
 }
 
diff --git a/modules/demux/avformat/avformat.c b/modules/demux/avformat/avformat.c
index 3455588266..988eed3ee8 100644
--- a/modules/demux/avformat/avformat.c
+++ b/modules/demux/avformat/avformat.c
@@ -2,7 +2,7 @@
  * avformat.c: demuxer and muxer using libavformat library
  *****************************************************************************
  * Copyright (C) 1999-2008 VLC authors and VideoLAN
- * $Id: 8025a898b69656130dc5a3b4833ad4c27f4d6dc3 $
+ * $Id: 12d3881a21998949d485ef68da2d1763d69f6a50 $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@videolan.org>
@@ -57,6 +57,7 @@ vlc_module_begin ()
     add_string( "sout-avformat-mux", NULL, MUX_TEXT, MUX_LONGTEXT, true )
     add_obsolete_string("ffmpeg-mux") /* removed since 2.1.0 */
     add_string( "sout-avformat-options", NULL, AV_OPTIONS_TEXT, AV_OPTIONS_LONGTEXT, true )
+    add_bool( "sout-avformat-reset-ts", false, AV_RESET_TS_TEXT, AV_RESET_TS_LONGTEXT, true )
     set_callbacks( avformat_OpenMux, avformat_CloseMux )
 #endif
 #ifndef MERGE_FFMPEG
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 16d34f4a97..10e52c4f7b 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -2,7 +2,7 @@
  * mux.c: muxer using libavformat
  *****************************************************************************
  * Copyright (C) 2006 VLC authors and VideoLAN
- * $Id: 9500c915b4e4a457826fc0477153ced5d3d72ec0 $
+ * $Id: b5b0c9a0b6583efcf1b6b2ad8296673963d2ca4e $
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
  *
@@ -44,7 +44,7 @@
 //#define AVFORMAT_DEBUG 1
 
 static const char *const ppsz_mux_options[] = {
-    "mux", "options", NULL
+    "mux", "options", "reset-ts", NULL
 };
 
 /*****************************************************************************
@@ -150,6 +150,8 @@ int avformat_OpenMux( vlc_object_t *p_this )
     p_sys->io->write_data_type = IOWriteTyped;
     p_sys->b_header_done = false;
 #endif
+    if( var_GetBool( p_mux, "sout-avformat-reset-ts" ) )
+        p_sys->oc->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_ZERO;
 
     /* Fill p_mux fields */
     p_mux->pf_control   = Control;
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 9696aa2291..01101c1780 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -2,7 +2,7 @@
  * avi.c : AVI file Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001-2009 VLC authors and VideoLAN
- * $Id: 3492485a25ba60fbd24fcc8a154df3a82966f80d $
+ * $Id: fb1c8e728b2f4b22545c47836d88b125156c4a6f $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -944,7 +944,7 @@ static block_t * ReadFrame( demux_t *p_demux, const avi_track_t *tk,
         p_frame->i_buffer--;
     }
 
-    if( i_header >= p_frame->i_buffer )
+    if( i_header >= p_frame->i_buffer || tk->i_width_bytes > INT32_MAX - 3 )
     {
         p_frame->i_buffer = 0;
         return p_frame;
@@ -954,7 +954,7 @@ static block_t * ReadFrame( demux_t *p_demux, const avi_track_t *tk,
     p_frame->p_buffer += i_header;
     p_frame->i_buffer -= i_header;
 
-    const unsigned int i_stride_bytes = ((( (tk->i_width_bytes << 3) + 31) & ~31) >> 3);
+    const unsigned int i_stride_bytes = (tk->i_width_bytes + 3) & ~3;
 
     if ( !tk->i_width_bytes || !i_stride_bytes )
         return p_frame;
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index 23d0e5e117..1426a38cae 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -45,6 +45,7 @@
 #include "../adaptive/tools/Conversions.hpp"
 #include <vlc_stream.h>
 #include <cstdio>
+#include <limits>
 
 using namespace dash::mpd;
 using namespace adaptive::xml;
@@ -264,7 +265,11 @@ void    IsoffMainParser::parseAdaptationSets  (Node *periodNode, Period *period)
         parseSegmentInformation(*it, adaptationSet, &nextid);
 
         parseRepresentations((*it), adaptationSet);
-        period->addAdaptationSet(adaptationSet);
+
+        if(!adaptationSet->getRepresentations().empty())
+            period->addAdaptationSet(adaptationSet);
+        else
+            delete adaptationSet;
     }
 }
 void    IsoffMainParser::parseRepresentations (Node *adaptationSetNode, AdaptationSet *adaptationSet)
@@ -459,9 +464,13 @@ void IsoffMainParser::parseTimeline(Node *node, MediaSegmentTemplate *templ)
             if(!s->hasAttribute("d")) /* Mandatory */
                 continue;
             stime_t d = Integer<stime_t>(s->getAttributeValue("d"));
-            uint64_t r = 0; // never repeats by default
+            int64_t r = 0; // never repeats by default
             if(s->hasAttribute("r"))
-                r = Integer<uint64_t>(s->getAttributeValue("r"));
+            {
+                r = Integer<int64_t>(s->getAttributeValue("r"));
+                if(r < 0)
+                    r = std::numeric_limits<unsigned>::max();
+            }
 
             if(s->hasAttribute("t"))
             {
diff --git a/modules/demux/hls/HLSStreams.cpp b/modules/demux/hls/HLSStreams.cpp
index 3f5d4dccb5..cf26d6f21d 100644
--- a/modules/demux/hls/HLSStreams.cpp
+++ b/modules/demux/hls/HLSStreams.cpp
@@ -142,11 +142,13 @@ AbstractDemuxer *HLSStream::newDemux(demux_t *p_realdemux, const StreamFormat &f
             ret = AbstractStream::newDemux(p_realdemux, format, out, source);
             break;
 
+/* Disabled until we can handle empty segments/cue and absolute time
         case StreamFormat::WEBVTT:
             ret = new Demuxer(p_realdemux, "webvttstream", out, source);
             if(ret)
                 ret->setRestartsOnEachSegment(true);
             break;
+*/
 
         default:
         case StreamFormat::UNSUPPORTED:
diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index b5490248c4..d5b65cd15e 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -458,10 +458,13 @@ M3U8 * M3U8Parser::parse(vlc_object_t *p_object, stream_t *p_stream, const std::
         std::map<std::string, AttributesTag *>::const_iterator groupsit;
         for(groupsit = groupsmap.begin(); groupsit != groupsmap.end(); ++groupsit)
         {
+            std::pair<std::string, AttributesTag *> pair = *groupsit;
+            if(!pair.second->getAttributeByName("TYPE"))
+                continue;
+
             BaseAdaptationSet *altAdaptSet = new (std::nothrow) BaseAdaptationSet(period);
             if(altAdaptSet)
             {
-                std::pair<std::string, AttributesTag *> pair = *groupsit;
                 Representation *rep  = createRepresentation(altAdaptSet, pair.second);
                 if(rep)
                 {
@@ -516,10 +519,13 @@ M3U8 * M3U8Parser::parse(vlc_object_t *p_object, stream_t *p_stream, const std::
         BaseAdaptationSet *adaptSet = new (std::nothrow) BaseAdaptationSet(period);
         if(adaptSet)
         {
-            period->addAdaptationSet(adaptSet);
             AttributesTag *tag = new AttributesTag(AttributesTag::EXTXSTREAMINF, "");
             tag->addAttribute(new Attribute("URI", playlisturl));
             createAndFillRepresentation(p_object, adaptSet, tag, tagslist);
+            if(!adaptSet->getRepresentations().empty())
+                period->addAdaptationSet(adaptSet);
+            else
+                delete adaptSet;
             delete tag;
         }
     }
diff --git a/modules/demux/mkv/chapter_command.cpp b/modules/demux/mkv/chapter_command.cpp
index e3eb65cbcf..79b4b89d46 100644
--- a/modules/demux/mkv/chapter_command.cpp
+++ b/modules/demux/mkv/chapter_command.cpp
@@ -2,7 +2,7 @@
  * chapter_command.cpp : matroska demuxer
  *****************************************************************************
  * Copyright (C) 2003-2004 VLC authors and VideoLAN
- * $Id: cff2d56f9c0d2a683bcdce5ff860186cb4f44e93 $
+ * $Id: 1ec3ffe9f26c5cf51c6de8908561a1c7c1e5ab36 $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Steve Lhomme <steve.lhomme@free.fr>
@@ -716,7 +716,7 @@ bool matroska_script_interpretor_c::Interpret( const binary * p_command, size_t
         }
 
         std::string st = sz_command.substr( i+1, j-i-1 );
-        int64_t i_chapter_uid = atoi( st.c_str() );
+        int64_t i_chapter_uid = atoll( st.c_str() );
 
         virtual_segment_c *p_vsegment;
         virtual_chapter_c *p_vchapter = sys.FindChapter( i_chapter_uid, p_vsegment );
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index eb2943144e..41665dd5e3 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -2,7 +2,7 @@
  * matroska_segment_parse.cpp : matroska demuxer
  *****************************************************************************
  * Copyright (C) 2003-2010 VLC authors and VideoLAN
- * $Id: e9035db1b062301288ef1ad309fc2f23b6e34e4a $
+ * $Id: 4efabd5383daa1fdd229202682f97689d9db5a9d $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Steve Lhomme <steve.lhomme@free.fr>
@@ -40,6 +40,7 @@ extern "C" {
 #include <vlc_codecs.h>
 #include <stdexcept>
 #include <limits>
+#include <algorithm>
 
 /* GetFourCC helper */
 #define GetFOURCC( p )  __GetFOURCC( (uint8_t*)p )
@@ -198,7 +199,7 @@ void matroska_segment_c::ParseSeekHead( KaxSeekHead *seekhead )
 /*****************************************************************************
  * ParseTrackEntry:
  *****************************************************************************/
-
+#define ONLY_FMT(t) if(vars.tk->fmt.i_cat != t ## _ES) return
 void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
 {
     bool bSupported = true;
@@ -461,13 +462,11 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxTrackVideo, tkv )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Track Video");
 
             mkv_track_t *tk = vars.tk;
 
-            if (tk->fmt.i_cat != VIDEO_ES ) {
-                msg_Err( vars.p_demuxer, "Video elements not allowed for this track" );
-            } else {
             tk->f_fps = 0.0;
 
             if( tk->i_default_duration > 1000 ) /* Broken ffmpeg mux info when non set fps */
@@ -507,11 +506,11 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
             }
             /* FIXME: i_display_* allows you to not only set DAR, but also a zoom factor.
                we do not support this atm */
-            }
         }
 #if LIBMATROSKA_VERSION >= 0x010406
         E_CASE( KaxVideoProjection, proj )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Track Video Projection" ) ;
 
             vars.level += 1;
@@ -520,6 +519,7 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxVideoProjectionType, fint )
         {
+            ONLY_FMT(VIDEO);
             switch (static_cast<uint8>( fint ))
             {
             case 0:
@@ -538,19 +538,23 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxVideoProjectionPoseYaw, pose )
         {
+            ONLY_FMT(VIDEO);
             vars.tk->fmt.video.pose.yaw = static_cast<float>( pose );
         }
         E_CASE( KaxVideoProjectionPosePitch, pose )
         {
+            ONLY_FMT(VIDEO);
             vars.tk->fmt.video.pose.pitch = static_cast<float>( pose );
         }
         E_CASE( KaxVideoProjectionPoseRoll, pose )
         {
+            ONLY_FMT(VIDEO);
             vars.tk->fmt.video.pose.roll = static_cast<float>( pose );
         }
 #endif
         E_CASE( KaxVideoFlagInterlaced, fint ) // UNUSED
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Track Video Interlaced=%u", static_cast<uint8>( fint ) ) ;
         }
         E_CASE( KaxVideoStereoMode, stereo ) // UNUSED
@@ -559,46 +563,55 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxVideoPixelWidth, vwidth )
         {
+            ONLY_FMT(VIDEO);
             vars.tk->fmt.video.i_width += static_cast<uint16>( vwidth );
             debug( vars, "width=%d", vars.tk->fmt.video.i_width );
         }
         E_CASE( KaxVideoPixelHeight, vheight )
         {
+            ONLY_FMT(VIDEO);
             vars.tk->fmt.video.i_height += static_cast<uint16>( vheight );
             debug( vars, "height=%d", vars.tk->fmt.video.i_height );
         }
         E_CASE( KaxVideoDisplayWidth, vwidth )
         {
+            ONLY_FMT(VIDEO);
             vars.track_video_info.i_display_width = static_cast<uint16>( vwidth );
             debug( vars, "display width=%d", vars.track_video_info.i_display_width );
         }
         E_CASE( KaxVideoDisplayHeight, vheight )
         {
+            ONLY_FMT(VIDEO);
             vars.track_video_info.i_display_height = static_cast<uint16>( vheight );
             debug( vars, "display height=%d", vars.track_video_info.i_display_height );
         }
         E_CASE( KaxVideoPixelCropBottom, cropval )
         {
+            ONLY_FMT(VIDEO);
             vars.track_video_info.i_crop_bottom = static_cast<uint16>( cropval );
             debug( vars, "crop pixel bottom=%d", vars.track_video_info.i_crop_bottom );
         }
         E_CASE( KaxVideoPixelCropTop, cropval )
         {
+            ONLY_FMT(VIDEO);
             vars.track_video_info.i_crop_top = static_cast<uint16>( cropval );
             debug( vars, "crop pixel top=%d", vars.track_video_info.i_crop_top );
         }
         E_CASE( KaxVideoPixelCropRight, cropval )
         {
+            ONLY_FMT(VIDEO);
             vars.track_video_info.i_crop_right = static_cast<uint16>( cropval );
             debug( vars, "crop pixel right=%d", vars.track_video_info.i_crop_right );
         }
         E_CASE( KaxVideoPixelCropLeft, cropval )
         {
+            ONLY_FMT(VIDEO);
             vars.track_video_info.i_crop_left = static_cast<uint16>( cropval );
             debug( vars, "crop pixel left=%d", vars.track_video_info.i_crop_left );
         }
         E_CASE( KaxVideoDisplayUnit, vdmode )
         {
+            ONLY_FMT(VIDEO);
             vars.track_video_info.i_display_unit = static_cast<uint8>( vdmode );
             const char *psz_unit;
             switch (vars.track_video_info.i_display_unit)
@@ -613,15 +626,18 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxVideoAspectRatio, ratio ) // UNUSED
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Track Video Aspect Ratio Type=%u", static_cast<uint8>( ratio ) ) ;
         }
         E_CASE( KaxVideoFrameRate, vfps )
         {
+            ONLY_FMT(VIDEO);
             vars.tk->f_fps = __MAX( static_cast<float>( vfps ), 1 );
             debug( vars, "fps=%f", vars.tk->f_fps );
         }
         E_CASE( KaxVideoColourSpace, colourspace )
         {
+            ONLY_FMT(VIDEO);
             if ( colourspace.ValidateSize() )
             {
                 char clrspc[5];
@@ -636,6 +652,7 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
 #if LIBMATROSKA_VERSION >= 0x010405
         E_CASE( KaxVideoColour, colours)
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Colors");
             if (vars.tk->fmt.i_cat != VIDEO_ES ) {
                 msg_Err( vars.p_demuxer, "Video colors elements not allowed for this track" );
@@ -647,6 +664,7 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxVideoColourRange, range )
         {
+            ONLY_FMT(VIDEO);
             switch( static_cast<uint8>(range) )
             {
             case 1: // broadcast
@@ -662,6 +680,7 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxVideoColourTransferCharacter, tranfer )
         {
+            ONLY_FMT(VIDEO);
             switch( static_cast<uint8>(tranfer) )
             {
             case 1: // BT-709
@@ -702,6 +721,7 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxVideoColourPrimaries, primaries )
         {
+            ONLY_FMT(VIDEO);
             switch( static_cast<uint8>(primaries) )
             {
             case 1: // ITU-R BT.709
@@ -731,16 +751,19 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxVideoColourMaxCLL, maxCLL )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Max Pixel Brightness");
             vars.tk->fmt.video.lighting.MaxCLL = static_cast<uint16_t>(maxCLL);
         }
         E_CASE( KaxVideoColourMaxFALL, maxFALL )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Max Frame Brightness");
             vars.tk->fmt.video.lighting.MaxFALL = static_cast<uint16_t>(maxFALL);
         }
         E_CASE( KaxVideoColourMasterMeta, mastering )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Mastering Metadata");
             if (vars.tk->fmt.i_cat != VIDEO_ES ) {
                 msg_Err( vars.p_demuxer, "Video metadata elements not allowed for this track" );
@@ -752,67 +775,75 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxVideoLuminanceMax, maxLum )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Luminance Max");
             vars.tk->fmt.video.mastering.max_luminance = static_cast<float>(maxLum) * 10000.f;
         }
         E_CASE( KaxVideoLuminanceMin, minLum )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Luminance Min");
             vars.tk->fmt.video.mastering.min_luminance = static_cast<float>(minLum) * 10000.f;
         }
         E_CASE( KaxVideoGChromaX, chroma )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Green Chroma X");
             vars.tk->fmt.video.mastering.primaries[0] = static_cast<float>(chroma) * 50000.f;
         }
         E_CASE( KaxVideoGChromaY, chroma )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Green Chroma Y");
             vars.tk->fmt.video.mastering.primaries[1] = static_cast<float>(chroma) * 50000.f;
         }
         E_CASE( KaxVideoBChromaX, chroma )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Blue Chroma X");
             vars.tk->fmt.video.mastering.primaries[2] = static_cast<float>(chroma) * 50000.f;
         }
         E_CASE( KaxVideoBChromaY, chroma )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Blue Chroma Y");
             vars.tk->fmt.video.mastering.primaries[3] = static_cast<float>(chroma) * 50000.f;
         }
         E_CASE( KaxVideoRChromaX, chroma )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Red Chroma X");
             vars.tk->fmt.video.mastering.primaries[4] = static_cast<float>(chroma) * 50000.f;
         }
         E_CASE( KaxVideoRChromaY, chroma )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video Red Chroma Y");
             vars.tk->fmt.video.mastering.primaries[5] = static_cast<float>(chroma) * 50000.f;
         }
         E_CASE( KaxVideoWhitePointChromaX, white )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video WhitePoint X");
             vars.tk->fmt.video.mastering.white_point[0] = static_cast<float>(white) * 50000.f;
         }
         E_CASE( KaxVideoWhitePointChromaY, white )
         {
+            ONLY_FMT(VIDEO);
             debug( vars, "Video WhitePoint Y");
             vars.tk->fmt.video.mastering.white_point[1] = static_cast<float>(white) * 50000.f;
         }
 #endif
         E_CASE( KaxTrackAudio, tka ) {
+            ONLY_FMT(AUDIO);
             debug( vars, "Track Audio");
-            if (vars.tk->fmt.i_cat != AUDIO_ES ) {
-                msg_Err( vars.p_demuxer, "Audio elements not allowed for this track" );
-            } else {
             vars.level += 1;
             dispatcher.iterate( tka.begin(), tka.end(), &vars );
             vars.level -= 1;
-            }
         }
         E_CASE( KaxAudioSamplingFreq, afreq )
         {
+            ONLY_FMT(AUDIO);
             float const value = static_cast<float>( afreq );
 
             vars.tk->i_original_rate  = value;
@@ -822,16 +853,19 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxAudioOutputSamplingFreq, afreq )
         {
+            ONLY_FMT(AUDIO);
             vars.tk->fmt.audio.i_rate = static_cast<float>( afreq );
             debug( vars, "aoutfreq=%d", vars.tk->fmt.audio.i_rate ) ;
         }
         E_CASE( KaxAudioChannels, achan )
         {
+            ONLY_FMT(AUDIO);
             vars.tk->fmt.audio.i_channels = static_cast<uint8>( achan );
             debug( vars, "achan=%u", vars.tk->fmt.audio.i_channels );
         }
         E_CASE( KaxAudioBitDepth, abits )
         {
+            ONLY_FMT(AUDIO);
             vars.tk->fmt.audio.i_bitspersample = static_cast<uint8>( abits );
             debug( vars, "abits=%u", vars.tk->fmt.audio.i_bitspersample);
         }
@@ -881,6 +915,8 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
     }
 }
 
+#undef ONLY_FMT
+
 /*****************************************************************************
  * ParseTracks:
  *****************************************************************************/
@@ -1459,6 +1495,8 @@ bool matroska_segment_c::ParseCluster( KaxCluster *cluster, bool b_update_start_
     return true;
 }
 
+#define ONLY_FMT(t) if(vars.p_tk->fmt.i_cat != t ## _ES) \
+    throw std::runtime_error( "Mismatching track type" );
 
 bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
 {
@@ -1490,22 +1528,23 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
             }
             else
             {
+                ONLY_FMT(VIDEO);
                 VLC_BITMAPINFOHEADER *p_bih = (VLC_BITMAPINFOHEADER*)vars.p_tk->p_extra_data;
 
                 vars.p_fmt->video.i_width = GetDWLE( &p_bih->biWidth );
                 vars.p_fmt->video.i_height= GetDWLE( &p_bih->biHeight );
                 vars.p_fmt->i_codec       = GetFOURCC( &p_bih->biCompression );
 
-                vars.p_fmt->i_extra       = GetDWLE( &p_bih->biSize ) - sizeof( VLC_BITMAPINFOHEADER );
-                if( vars.p_fmt->i_extra > 0 )
+                /* Very unlikely yet possible: bug #5659*/
+                const unsigned int min_extra = std::min(GetDWLE( &p_bih->biSize ), vars.p_tk->i_extra_data);
+                if ( min_extra > sizeof( VLC_BITMAPINFOHEADER ))
                 {
-                    /* Very unlikely yet possible: bug #5659*/
-                    size_t maxlen = vars.p_tk->i_extra_data - sizeof( VLC_BITMAPINFOHEADER );
-                    vars.p_fmt->i_extra = ( (unsigned)vars.p_fmt->i_extra < maxlen )?
-                        vars.p_fmt->i_extra : maxlen;
-
+                    vars.p_fmt->i_extra = min_extra - sizeof( VLC_BITMAPINFOHEADER );
                     vars.p_fmt->p_extra = xmalloc( vars.p_fmt->i_extra );
-                    memcpy( vars.p_fmt->p_extra, &p_bih[1], vars.p_fmt->i_extra );
+                    if (likely(vars.p_fmt->p_extra != NULL))
+                        memcpy( vars.p_fmt->p_extra, &p_bih[1], vars.p_fmt->i_extra );
+                    else
+                        vars.p_fmt->i_extra = 0;
                 }
                 else if( vars.p_fmt->i_codec == VLC_FOURCC('W','V','C','1') )
                 {
@@ -1543,6 +1582,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
             if (
                 vars.p_tk->i_extra_data >= 26 && !memcmp(p+4, "VIDORV", 6) && strchr("34", p[10]) && p[11] == '0')
             {
+                ONLY_FMT(VIDEO);
                 vars.p_tk->fmt.video.i_frame_rate      = p[22] << 24 | p[23] << 16 | p[24] << 8 | p[25] << 0;
                 vars.p_tk->fmt.video.i_frame_rate_base = 65536;
             }
@@ -1604,6 +1644,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
             fill_extra_data( vars.p_tk, 0 );
         }
         S_CASE("V_QUICKTIME") {
+            ONLY_FMT(VIDEO);
             if( vars.p_tk->i_extra_data > 4 )
             {
                 MP4_Box_t *p_box = MP4_BoxNew(ATOM_root);
@@ -1643,6 +1684,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
         }
         S_CASE("V_MJPEG") {
             vars.p_fmt->i_codec = VLC_CODEC_MJPG;
+            vars.p_tk->b_pts_only = true;
         }
         S_CASE("V_UNCOMPRESSED") {
             msg_Dbg( vars.p_demuxer, "uncompressed format detected");
@@ -1666,6 +1708,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
             }
             else
             {
+                ONLY_FMT(AUDIO);
                 WAVEFORMATEX *p_wf = (WAVEFORMATEX*)p_tk->p_extra_data;
 
                 p_tk->fmt.audio.i_channels   = GetWLE( &p_wf->nChannels );
@@ -1675,7 +1718,9 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
                 p_tk->fmt.audio.i_bitspersample = GetWLE( &p_wf->wBitsPerSample );
 
                 p_tk->fmt.i_extra            = GetWLE( &p_wf->cbSize );
-                if( p_tk->fmt.i_extra > 0 )
+                if ( (size_t)p_tk->fmt.i_extra > p_tk->i_extra_data - sizeof( WAVEFORMATEX ) )
+                    p_tk->fmt.i_extra = 0;
+                if( p_tk->fmt.i_extra != 0 )
                 {
                     p_tk->fmt.p_extra = xmalloc( p_tk->fmt.i_extra );
                     if( p_tk->fmt.p_extra )
@@ -1738,6 +1783,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
         S_CASE("A_MPEG/L2") { A_MPEG_helper_(vars); }
         S_CASE("A_MPEG/L1") { A_MPEG_helper_(vars); }
         S_CASE("A_AC3") {
+            ONLY_FMT(AUDIO);
             // the AC-3 default duration cannot be trusted, see #8512
             if ( vars.p_tk->fmt.audio.i_rate == 8000 )
             {
@@ -1770,6 +1816,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
             fill_extra_data( vars.p_tk, 0 );
         }
         static void A_OPUS__helper(HandlerPayload& vars) {
+            ONLY_FMT(AUDIO);
             vars.p_fmt->i_codec = VLC_CODEC_OPUS;
             vars.p_tk->b_no_duration = true;
             if( !vars.p_tk->fmt.audio.i_rate )
@@ -1791,6 +1838,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
         S_CASE("A_OPUS")                { A_OPUS__helper( vars ); }
         S_CASE("A_OPUS/EXPERIMENTAL")   { A_OPUS__helper( vars ); }
         static void A_AAC_MPEG__helper(HandlerPayload& vars, int i_profile, bool sbr = false) {
+            ONLY_FMT(AUDIO);
             int i_srate;
 
             mkv_track_t * p_tk = vars.p_tk;
@@ -1852,6 +1900,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
             fill_extra_data( vars.p_tk, 0);
         }
         S_CASE("A_TTA1") {
+            ONLY_FMT(AUDIO);
             mkv_track_t * p_tk  = vars.p_tk;
             es_format_t * p_fmt = vars.p_fmt;
 
@@ -1875,6 +1924,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
             }
         }
         static void A_PCM__helper (HandlerPayload& vars, uint32_t i_codec) {
+            ONLY_FMT(AUDIO);
             vars.p_fmt->i_codec = i_codec;
             vars.p_fmt->audio.i_blockalign = ( vars.p_fmt->audio.i_bitspersample + 7 ) / 8 * vars.p_fmt->audio.i_channels;
 
@@ -1883,15 +1933,17 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
         S_CASE("A_PCM/INT/LIT")    { A_PCM__helper ( vars, VLC_FOURCC( 'a','r','a','w' ) ); }
         S_CASE("A_PCM/FLOAT/IEEE") { A_PCM__helper ( vars, VLC_FOURCC( 'a','f','l','t' ) ) ;}
         S_CASE("A_REAL/14_4") {
+            ONLY_FMT(AUDIO);
             vars.p_fmt->i_codec = VLC_CODEC_RA_144;
             vars.p_fmt->audio.i_channels = 1;
             vars.p_fmt->audio.i_rate = 8000;
             vars.p_fmt->audio.i_blockalign = 0x14;
         }
         static bool A_REAL__is_valid (HandlerPayload& vars) {
+            ONLY_FMT(AUDIO);
             uint8_t *p = vars.p_tk->p_extra_data;
 
-            if (vars.p_tk->i_extra_data <= 28)
+            if (vars.p_tk->i_extra_data <= sizeof(real_audio_private))
                 return false;
 
             if( memcmp( p, ".ra", 3 ) ) {
@@ -1987,25 +2039,30 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
             fill_extra_data( vars.p_tk, 0 );
         }
         S_CASE("S_KATE") {
+            ONLY_FMT(SPU);
             vars.p_fmt->i_codec = VLC_CODEC_KATE;
             vars.p_fmt->subs.psz_encoding = strdup( "UTF-8" );
 
             fill_extra_data( vars.p_tk, 0 );
         }
         S_CASE("S_TEXT/ASCII") {
+            ONLY_FMT(SPU);
             vars.p_fmt->i_codec = VLC_CODEC_SUBT;
             vars.p_fmt->subs.psz_encoding = strdup( "ASCII" );
         }
         S_CASE("S_TEXT/UTF8") {
+            ONLY_FMT(SPU);
             vars.p_tk->fmt.i_codec = VLC_CODEC_SUBT;
             vars.p_tk->fmt.subs.psz_encoding = strdup( "UTF-8" );
         }
         S_CASE("S_TEXT/USF") {
+            ONLY_FMT(SPU);
             vars.p_tk->fmt.i_codec = VLC_FOURCC( 'u', 's', 'f', ' ' );
             vars.p_tk->fmt.subs.psz_encoding = strdup( "UTF-8" );
             fill_extra_data( vars.p_tk, 0 );
         }
         static void SSA__helper (HandlerPayload& vars) {
+            ONLY_FMT(SPU);
             vars.p_tk->fmt.i_codec = VLC_CODEC_SSA;
             vars.p_tk->fmt.subs.psz_encoding = strdup( "UTF-8" );
             fill_extra_data( vars.p_tk, 0 );
@@ -2015,6 +2072,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
         S_CASE("S_SSA")      { SSA__helper( vars ); }
         S_CASE("S_ASS")      { SSA__helper( vars ); }
         S_CASE("S_VOBSUB") {
+            ONLY_FMT(SPU);
             mkv_track_t * p_tk = vars.p_tk;
 
             p_tk->fmt.i_codec = VLC_CODEC_SPU;
@@ -2068,10 +2126,12 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
             vars.p_fmt->i_codec = VLC_CODEC_BD_TEXT;
         }
         S_CASE("D_WEBVTT/SUBTITLES") {
+            ONLY_FMT(SPU);
             vars.p_fmt->i_codec = VLC_CODEC_SUBT;
             vars.p_fmt->subs.psz_encoding = strdup( "UTF-8");
         }
         S_CASE("S_TEXT/WEBVTT") {
+            ONLY_FMT(SPU);
             vars.p_fmt->i_codec = VLC_CODEC_WEBVTT;
             vars.p_fmt->subs.psz_encoding = strdup( "UTF-8");
         }
diff --git a/modules/demux/mkv/util.cpp b/modules/demux/mkv/util.cpp
index 1b5fc73608..a78687c813 100644
--- a/modules/demux/mkv/util.cpp
+++ b/modules/demux/mkv/util.cpp
@@ -2,7 +2,7 @@
  * util.cpp : matroska demuxer
  *****************************************************************************
  * Copyright (C) 2003-2004 VLC authors and VideoLAN
- * $Id: d2bdaef5552db7265e31158f1d1fda8eef41a868 $
+ * $Id: 68f715a821cd120f198e3b26aad3e31bceb55043 $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Steve Lhomme <steve.lhomme@free.fr>
@@ -87,6 +87,7 @@ int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t & tk )
         msg_Err( p_demux, "Couldn't allocate buffer to inflate data, ignore track %u",
                  tk.i_number );
         inflateEnd( &d_stream );
+        tk.p_extra_data = NULL;
         return 1;
     }
 
@@ -177,6 +178,7 @@ void handle_real_audio(demux_t * p_demux, mkv_track_t * p_tk, block_t * p_blk, m
                 p_sys->p_subpackets[i] = NULL;
             }
         p_sys->i_subpacket = 0;
+        p_sys->i_subpackets = 0;
 
         if ( !( p_blk->i_flags & BLOCK_FLAG_TYPE_I) )
         {
@@ -190,7 +192,9 @@ void handle_real_audio(demux_t * p_demux, mkv_track_t * p_tk, block_t * p_blk, m
         p_tk->fmt.i_codec == VLC_CODEC_ATRAC3 )
     {
         const uint16_t i_num = p_sys->i_frame_size / p_sys->i_subpacket_size;
-        const size_t y = p_sys->i_subpacket / ( p_sys->i_frame_size / p_sys->i_subpacket_size );
+        if ( i_num == 0 )
+            return;
+        const size_t y = p_sys->i_subpacket / i_num;
 
         for( uint16_t i = 0; i < i_num; i++ )
         {
@@ -234,6 +238,7 @@ void handle_real_audio(demux_t * p_demux, mkv_track_t * p_tk, block_t * p_blk, m
             p_sys->p_subpackets[i] = NULL;
         }
         p_sys->i_subpacket = 0;
+        p_sys->i_subpackets = 0;
     }
 }
 
diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index 133202d0ec..20f8935e76 100644
--- a/modules/demux/mp4/essetup.c
+++ b/modules/demux/mp4/essetup.c
@@ -1056,13 +1056,26 @@ int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
             break;
         }
 
+        case VLC_FOURCC( 't', 'w', 'o', 's' ):
+        case VLC_FOURCC( 's', 'o', 'w', 't' ):
+            p_track->fmt.i_codec = p_sample->i_type;
+            p_track->fmt.audio.i_bitspersample = 16;
+            break;
+
+        case 0x0000000:
         case( VLC_FOURCC( 'r', 'a', 'w', ' ' ) ):
         case( VLC_FOURCC( 'N', 'O', 'N', 'E' ) ):
         {
             if( (p_soun->i_samplesize+7)/8 == 1 )
+            {
                 p_track->fmt.i_codec = VLC_CODEC_U8;
+                p_track->fmt.audio.i_bitspersample = 8;
+            }
             else
+            {
                 p_track->fmt.i_codec = VLC_FOURCC( 't', 'w', 'o', 's' );
+                p_track->fmt.audio.i_bitspersample = 16;
+            }
 
             /* Buggy files workaround */
             if( (p_track->i_timescale != p_soun->i_sampleratehi) )
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index f069541f9a..e3ea40ce03 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -2321,8 +2321,9 @@ static int MP4_ReadBox_sgpd( stream_t *p_stream, MP4_Box_t *p_box )
                 {
                     if( i_read < 1 )
                     {
+                        free( p_sgpd->p_entries );
                         p_sgpd->i_entry_count = 0;
-                        MP4_FreeBox_sgpd( p_box );
+                        p_sgpd->p_entries = NULL;
                         MP4_READBOX_EXIT( 0 );
                     }
                     uint8_t i_data;
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 3b14b5dfb3..884eb8aef9 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1114,10 +1114,10 @@ typedef struct MP4_Box_data_mfhd_s
 
 typedef struct MP4_Box_sidx_item_s
 {
-    bool     b_reference_type;
     uint32_t i_referenced_size;
     uint32_t i_subsegment_duration;
-    bool     b_starts_with_SAP;
+    uint8_t  b_reference_type;
+    uint8_t  b_starts_with_SAP;
     uint8_t  i_SAP_type;
     uint32_t i_SAP_delta_time;
 
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index ccb4810318..edda423bed 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -166,6 +166,7 @@ static void MP4_GetDefaultSizeAndDuration( MP4_Box_t *p_moov,
 static stime_t GetMoovTrackDuration( demux_sys_t *p_sys, unsigned i_track_ID );
 
 static int  ProbeFragments( demux_t *p_demux, bool b_force, bool *pb_fragmented );
+static int  ProbeFragmentsChecked( demux_t *p_demux );
 static int  ProbeIndex( demux_t *p_demux );
 
 static int FragCreateTrunIndex( demux_t *, MP4_Box_t *, MP4_Box_t *, stime_t, bool );
@@ -1168,6 +1169,27 @@ static block_t * MP4_RTPHint_Convert( demux_t *p_demux, block_t *p_block, vlc_fo
     return p_converted;
 }
 
+static uint64_t OverflowCheck( demux_t *p_demux, mp4_track_t *tk,
+                               uint64_t i_readpos, uint64_t i_samplessize )
+{
+    demux_sys_t *p_sys = p_demux->p_sys;
+    if( !p_sys->b_seekable && p_sys->b_fragmented &&
+         p_sys->context.i_post_mdat_offset )
+    {
+        /* avoid breaking non seekable demux */
+        if( i_readpos + i_samplessize > p_sys->context.i_post_mdat_offset )
+        {
+            msg_Err(p_demux, "Broken file. track[0x%x] "
+                             "Sample @%" PRIu64 " overflowing "
+                             "parent mdat by %" PRIu64,
+                    tk->i_track_ID, i_readpos,
+                    i_readpos + i_samplessize - p_sys->context.i_post_mdat_offset );
+            i_samplessize = p_sys->context.i_post_mdat_offset - i_readpos;
+        }
+    }
+    return i_samplessize;
+}
+
 /*****************************************************************************
  * Demux: read packet and send them to decoders
  *****************************************************************************
@@ -1220,6 +1242,8 @@ static int DemuxTrack( demux_t *p_demux, mp4_track_t *tk, uint64_t i_readpos,
                 }
             }
 
+            i_samplessize = OverflowCheck( p_demux, tk, i_readpos, i_samplessize );
+
             /* now read pes */
             if( !(p_block = vlc_stream_Block( p_demux->s, i_samplessize )) )
             {
@@ -1251,8 +1275,9 @@ static int DemuxTrack( demux_t *p_demux, mp4_track_t *tk, uint64_t i_readpos,
         }
 
         /* Next sample */
-        if ( i_nb_samples ) /* sample size could be 0, need to go fwd. see return */
-            MP4_TrackNextSample( p_demux, tk, i_nb_samples );
+        if ( i_nb_samples && /* sample size could be 0, need to go fwd. see return */
+             MP4_TrackNextSample( p_demux, tk, i_nb_samples ) )
+            goto end;
 
         uint32_t i_next_run_seq = MP4_TrackGetRunSeq( tk );
         if( i_next_run_seq != i_run_seq )
@@ -1665,46 +1690,17 @@ static int FragSeekToTime( demux_t *p_demux, mtime_t i_nztime, bool b_accurate )
     }
     else
     {
-        bool b_buildindex = false;
-
         if( FragGetMoofByTfraIndex( p_demux, i_nztime, i_seek_track_ID, &i64, &i_sync_time ) == VLC_SUCCESS )
         {
             /* Does only provide segment position and a sync sample time */
             msg_Dbg( p_demux, "seeking to sync point %" PRId64, i_sync_time );
             b_iframesync = true;
         }
-        else if( !p_sys->b_fragments_probed && !p_sys->b_fastseekable )
-        {
-            const char *psz_msg = _(
-                "Because this file index is broken or missing, "
-                "seeking will not work correctly.\n"
-                "VLC won't repair your file but can temporary fix this "
-                "problem by building an index in memory.\n"
-                "This step might take a long time on a large file.\n"
-                "What do you want to do?");
-            b_buildindex = vlc_dialog_wait_question( p_demux,
-                                                     VLC_DIALOG_QUESTION_NORMAL,
-                                                     _("Do not seek"),
-                                                     _("Build index"),
-                                                     NULL,
-                                                     _("Broken or missing Index"),
-                                                     "%s", psz_msg );
-        }
-
-        if( !p_sys->b_fragments_probed && ( p_sys->b_fastseekable || b_buildindex ) )
-        {
-            bool foo;
-            int i_ret = vlc_stream_Seek( p_demux->s, p_sys->p_moov->i_pos + p_sys->p_moov->i_size );
-            if( i_ret == VLC_SUCCESS )
-            {
-                i_ret = ProbeFragments( p_demux, true, &foo );
-                p_sys->b_fragments_probed = true;
-            }
+        else if( !p_sys->b_fragments_probed )
+        {
+            int i_ret = ProbeFragmentsChecked( p_demux );
             if( i_ret != VLC_SUCCESS )
-            {
-                p_sys->b_error = (vlc_stream_Seek( p_demux->s, i_backup_pos ) != VLC_SUCCESS);
                 return i_ret;
-            }
         }
 
         if( p_sys->b_fragments_probed && p_sys->p_fragsindex )
@@ -1770,9 +1766,20 @@ static int FragSeekToTime( demux_t *p_demux, mtime_t i_nztime, bool b_accurate )
 static int FragSeekToPos( demux_t *p_demux, double f, bool b_accurate )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
-    const uint64_t i_duration = __MAX(p_sys->i_duration, p_sys->i_cumulated_duration);
 
-    if ( !p_sys->b_seekable || !p_sys->i_timescale || !i_duration )
+    if ( !p_sys->b_seekable || !p_sys->i_timescale )
+        return VLC_EGENERIC;
+
+    uint64_t i_duration = __MAX(p_sys->i_duration, p_sys->i_cumulated_duration);
+    if( !i_duration && !p_sys->b_fragments_probed )
+    {
+        int i_ret = ProbeFragmentsChecked( p_demux );
+        if( i_ret != VLC_SUCCESS )
+            return i_ret;
+        i_duration = __MAX(p_sys->i_duration, p_sys->i_cumulated_duration);
+    }
+
+    if( !i_duration )
         return VLC_EGENERIC;
 
     return FragSeekToTime( p_demux, (mtime_t)( f *
@@ -2864,7 +2871,8 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
     case SPU_ES:
         if ( ( p_sample->i_handler != ATOM_text &&
                p_sample->i_handler != ATOM_subt &&
-               p_sample->i_handler != ATOM_sbtl ) ||
+               p_sample->i_handler != ATOM_sbtl &&
+               p_sample->i_handler != ATOM_clcp ) ||
              !SetupSpuES( p_demux, p_track, p_sample ) )
            return VLC_EGENERIC;
         break;
@@ -3026,7 +3034,8 @@ static int TrackTimeToSampleChunk( demux_t *p_demux, mp4_track_t *p_track,
     /* *** find sample in the chunk *** */
     i_sample = p_track->chunk[i_chunk].i_sample_first;
     i_dts    = p_track->chunk[i_chunk].i_first_dts;
-    for( i_index = 0; i_sample < p_track->chunk[i_chunk].i_sample_count; )
+    for( i_index = 0;  i_index < p_track->chunk[i_chunk].i_entries_dts &&
+                       i_sample < p_track->chunk[i_chunk].i_sample_count; )
     {
         if( i_dts +
             p_track->chunk[i_chunk].p_sample_count_dts[i_index] *
@@ -4230,6 +4239,48 @@ static int ProbeFragments( demux_t *p_demux, bool b_force, bool *pb_fragmented )
     return VLC_SUCCESS;
 }
 
+static int ProbeFragmentsChecked( demux_t *p_demux )
+{
+    demux_sys_t *p_sys = p_demux->p_sys;
+
+    if( p_sys->b_fragments_probed )
+        return VLC_SUCCESS;
+
+    if( !p_sys->b_fastseekable )
+    {
+        const char *psz_msg = _(
+            "Because this file index is broken or missing, "
+            "seeking will not work correctly.\n"
+            "VLC won't repair your file but can temporary fix this "
+            "problem by building an index in memory.\n"
+            "This step might take a long time on a large file.\n"
+            "What do you want to do?");
+        bool b_continue = vlc_dialog_wait_question( p_demux,
+                                               VLC_DIALOG_QUESTION_NORMAL,
+                                               _("Do not seek"),
+                                               _("Build index"),
+                                               NULL,
+                                               _("Broken or missing Index"),
+                                               "%s", psz_msg );
+        if( !b_continue )
+            return VLC_EGENERIC;
+    }
+
+    const uint64_t i_backup_pos = vlc_stream_Tell( p_demux->s );
+    int i_ret = vlc_stream_Seek( p_demux->s, p_sys->p_moov->i_pos + p_sys->p_moov->i_size );
+    if( i_ret == VLC_SUCCESS )
+    {
+        bool foo;
+        i_ret = ProbeFragments( p_demux, true, &foo );
+        p_sys->b_fragments_probed = true;
+    }
+
+    if( i_ret != VLC_SUCCESS )
+        p_sys->b_error = (vlc_stream_Seek( p_demux->s, i_backup_pos ) != VLC_SUCCESS);
+
+    return i_ret;
+}
+
 static void FragResetContext( demux_sys_t *p_sys )
 {
     if( p_sys->context.p_fragment_atom )
@@ -4305,6 +4356,8 @@ static int FragDemuxTrack( demux_t *p_demux, mp4_track_t *p_track,
         if( !len )
             msg_Warn(p_demux, "Zero length sample in trun.");
 
+        len = OverflowCheck( p_demux, p_track, vlc_stream_Tell(p_demux->s), len );
+
         block_t *p_block = vlc_stream_Block( p_demux->s, len );
         uint32_t i_read = ( p_block ) ? p_block->i_buffer : 0;
         p_track->context.i_trun_sample_pos += i_read;
@@ -4695,6 +4748,8 @@ static int FragGetMoofBySidxIndex( demux_t *p_demux, mtime_t i_target_time,
     stime_t i_time = 0;
     for( uint16_t i=0; i<p_data->i_reference_count; i++ )
     {
+        if(p_data->p_items[i].b_reference_type != 0)
+            continue;
         if( i_time + p_data->p_items[i].i_subsegment_duration > i_target_time )
         {
             *pi_sampletime = MP4_rescale( i_time, p_data->i_timescale, CLOCK_FREQ );
diff --git a/modules/demux/mpeg/ps.h b/modules/demux/mpeg/ps.h
index f79843fdc2..124144e338 100644
--- a/modules/demux/mpeg/ps.h
+++ b/modules/demux/mpeg/ps.h
@@ -2,7 +2,7 @@
  * ps.h: Program Stream demuxer helper
  *****************************************************************************
  * Copyright (C) 2004-2009 VLC authors and VideoLAN
- * $Id: c73309e9be43d779f7ea178b634c914284641ec8 $
+ * $Id: c4aa75df4efb34fe365cc6bb30c0d8e7dc30c332 $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -322,7 +322,7 @@ static inline int ps_pkt_id( block_t *p_pkt )
     {
         uint8_t i_sub_id = 0;
         if( p_pkt->i_buffer >= 9 &&
-            p_pkt->i_buffer >= 9 + (size_t)p_pkt->p_buffer[8] )
+            p_pkt->i_buffer > 9 + (size_t)p_pkt->p_buffer[8] )
         {
             const unsigned i_start = 9 + p_pkt->p_buffer[8];
             i_sub_id = p_pkt->p_buffer[i_start];
@@ -624,7 +624,10 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt,
     int i_version;
     bool b_single_extension;
 
-    if( !p_psm || p_buffer[3] != PS_STREAM_ID_MAP )
+    // Demux() checks that we have at least 4 bytes, but we need
+    // at least 10 to read up to the info_length field
+    assert(i_buffer >= 4);
+    if( !p_psm || i_buffer < 10 || p_buffer[3] != PS_STREAM_ID_MAP)
         return VLC_EGENERIC;
 
     i_length = GetWBE(&p_buffer[4]) + 6;
diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index ac995c5a06..f3892bfea4 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -2,7 +2,7 @@
  * ts.c: Transport Stream input module for VLC.
  *****************************************************************************
  * Copyright (C) 2004-2016 VLC authors and VideoLAN
- * $Id: 0aabbb9a428fd25a652d2ed3f5daecf357effe8e $
+ * $Id: eae6a54947e5a10a97b48834853b1ad52c9328fb $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Jean-Paul Saman <jpsaman #_at_# m2x.nl>
@@ -408,7 +408,7 @@ static int Open( vlc_object_t *p_this )
 
     p_sys->patfix.i_first_dts = -1;
     p_sys->patfix.i_timesourcepid = 0;
-    p_sys->patfix.status = var_GetBool( p_demux, "ts-patfix" ) ? PAT_WAITING : PAT_FIXTRIED;
+    p_sys->patfix.status = var_CreateGetBool( p_demux, "ts-patfix" ) ? PAT_WAITING : PAT_FIXTRIED;
 
     /* Init PAT handler */
     patpid = GetPID(p_sys, 0);
@@ -437,7 +437,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_next_extraid = 1;
 
     p_sys->b_trust_pcr = var_CreateGetBool( p_demux, "ts-trust-pcr" );
-    p_sys->b_check_pcr_offset = p_sys->b_trust_pcr && var_GetBool(p_demux, "ts-pcr-offsetfix" );
+    p_sys->b_check_pcr_offset = p_sys->b_trust_pcr && var_CreateGetBool(p_demux, "ts-pcr-offsetfix" );
 
     /* We handle description of an extra PMT */
     char* psz_string = var_CreateGetString( p_demux, "ts-extra-pmt" );
@@ -527,7 +527,7 @@ static int Open( vlc_object_t *p_this )
     vlc_stream_Control( p_sys->stream, STREAM_CAN_FASTSEEK,
                         &p_sys->b_canfastseek );
 
-    if( !p_sys->b_access_control && var_GetBool( p_demux, "ts-pmtfix-waitdata" ) )
+    if( !p_sys->b_access_control && var_CreateGetBool( p_demux, "ts-pmtfix-waitdata" ) )
         p_sys->es_creation = DELAY_ES;
     else
         p_sys->es_creation = CREATE_ES;
diff --git a/modules/demux/nsc.c b/modules/demux/nsc.c
index 51b1efbf67..fb7f44f2cc 100644
--- a/modules/demux/nsc.c
+++ b/modules/demux/nsc.c
@@ -2,7 +2,7 @@
  * nsc.c: NSC file demux and encoding decoder
  *****************************************************************************
  * Copyright (C) 2005 VLC authors and VideoLAN
- * $Id: 068bb4f8257b14ce1755e7d15c6820ad7d70c337 $
+ * $Id: ba144816b34cdd0d9a62ad1378c12fb416d94599 $
  *
  * Authors: Derk-Jan Hartman <hartman at videolan dot org>
  *          based on work from Jon Lech Johansen <jon@nanocrew.net>
@@ -197,7 +197,7 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
             msg_Err( p_demux, "load_byte failed" );
             return NULL;
         }
-        length |= tmp << ((i - 1) * 8);
+        length |= (unsigned int)tmp << ((i - 1) * 8);
     }
 
     if( length == 0 )
diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c
index beefd45709..e8bbfea176 100644
--- a/modules/demux/ogg.c
+++ b/modules/demux/ogg.c
@@ -2,7 +2,7 @@
  * ogg.c : ogg stream demux module for vlc
  *****************************************************************************
  * Copyright (C) 2001-2007 VLC authors and VideoLAN
- * $Id: 0b368b77f8451d6d9bdbcf25a15d5906ee8fbd26 $
+ * $Id: 69fa492c42c6d285b9a745a1506f7bc8db93f50b $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *          Andre Pang <Andre.Pang@csiro.au> (Annodex support)
@@ -715,6 +715,7 @@ static void Ogg_ResetStream( logical_stream_t *p_stream )
     p_stream->i_pcr = VLC_TS_UNKNOWN;
     p_stream->i_previous_granulepos = -1;
     p_stream->i_previous_pcr = VLC_TS_UNKNOWN;
+    p_stream->b_interpolation_failed = false;
     ogg_stream_reset( &p_stream->os );
     FREENULL( p_stream->prepcr.pp_blocks );
     p_stream->prepcr.i_size = 0;
@@ -1137,6 +1138,7 @@ static void Ogg_UpdatePCR( demux_t *p_demux, logical_stream_t *p_stream,
             p_stream->i_pcr += ( CLOCK_FREQ * p_oggpacket->bytes /
                                  p_stream->fmt.i_bitrate / 8 );
         }
+        else p_stream->b_interpolation_failed = true;
     }
 
     p_stream->i_previous_granulepos = p_oggpacket->granulepos;
@@ -1477,7 +1479,8 @@ static void Ogg_DecodePacket( demux_t *p_demux,
 
         /* Blatant abuse of the i_length field. */
         p_block->i_length = p_stream->i_end_trim;
-        p_block->i_pts = p_block->i_dts = p_stream->i_pcr;
+        p_block->i_dts = p_stream->i_pcr;
+        p_block->i_pts = p_stream->b_interpolation_failed ? VLC_TS_INVALID : p_stream->i_pcr;
     }
     else if( p_stream->fmt.i_cat == SPU_ES )
     {
@@ -1485,6 +1488,8 @@ static void Ogg_DecodePacket( demux_t *p_demux,
         p_block->i_pts = p_block->i_dts = p_stream->i_pcr;
     }
 
+    p_stream->b_interpolation_failed = false;
+
     if( p_stream->fmt.i_codec != VLC_CODEC_VORBIS &&
         p_stream->fmt.i_codec != VLC_CODEC_SPEEX &&
         p_stream->fmt.i_codec != VLC_CODEC_OPUS &&
@@ -1609,8 +1614,11 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
                     return VLC_EGENERIC;
                 }
 
-                /* FIXME: check return value */
-                ogg_stream_packetpeek( &p_stream->os, &oggpacket );
+                if ( ogg_stream_packetpeek( &p_stream->os, &oggpacket ) != 1 )
+                {
+                    msg_Err( p_demux, "error in ogg_stream_packetpeek" );
+                    return VLC_EGENERIC;
+                }
 
                 /* Check for Vorbis header */
                 if( oggpacket.bytes >= 7 &&
@@ -3141,6 +3149,8 @@ static void Ogg_ReadAnnodexHeader( demux_t *p_demux,
 static void Ogg_ReadSkeletonHeader( demux_t *p_demux, logical_stream_t *p_stream,
                                     ogg_packet *p_oggpacket )
 {
+    if( p_oggpacket->bytes < 12 )
+        return;
     p_demux->p_sys->p_skelstream = p_stream;
     /* There can be only 1 skeleton for streams */
     p_demux->p_sys->skeleton.major = GetWLE( &p_oggpacket->packet[8] );
diff --git a/modules/demux/ogg.h b/modules/demux/ogg.h
index 16ac99793c..b7e52a1993 100644
--- a/modules/demux/ogg.h
+++ b/modules/demux/ogg.h
@@ -83,6 +83,7 @@ typedef struct logical_stream_s
      * granulepos */
     mtime_t          i_pcr;
     mtime_t          i_previous_pcr;
+    bool             b_interpolation_failed;    /* Don't use dts, it was not interpolated */
 
     /* Misc */
     bool b_initializing;
diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c
index 0801e8fd2c..eefdc43ec3 100644
--- a/modules/demux/playlist/m3u.c
+++ b/modules/demux/playlist/m3u.c
@@ -2,7 +2,7 @@
  * m3u.c : M3U playlist format import
  *****************************************************************************
  * Copyright (C) 2004 VLC authors and VideoLAN
- * $Id: 9fff1f0ff31f0a4b544c88cdec806cfc6d05ab3b $
+ * $Id: 9bd25379795b98f62d210cd4b7ef2b84b0533518 $
  *
  * Authors: Clément Stenac <zorglub@videolan.org>
  *          Sigmund Augdal Helberg <dnumgis@videolan.org>
@@ -225,7 +225,7 @@ static int ReadDir( stream_t *p_demux, input_item_node_t *p_subitems )
     bool b_cleanup = false;
     input_item_t *p_input;
 
-    input_item_t *p_current_input = GetCurrentItem(p_demux);
+    input_item_t *p_current_input = p_demux->p_input ? GetCurrentItem(p_demux) : NULL;
 
     psz_line = vlc_stream_ReadLine( p_demux->p_source );
     while( psz_line )
diff --git a/modules/demux/playlist/podcast.c b/modules/demux/playlist/podcast.c
index d822169e04..30cab9ff76 100644
--- a/modules/demux/playlist/podcast.c
+++ b/modules/demux/playlist/podcast.c
@@ -2,7 +2,7 @@
  * podcast.c : podcast playlist imports
  *****************************************************************************
  * Copyright (C) 2005-2009 VLC authors and VideoLAN
- * $Id: 9be1b08823d85f1b88abb38b439ec502daef0071 $
+ * $Id: a0d74a232de59a21aacb0664ec8b84fee0e899a5 $
  *
  * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
  *
@@ -287,7 +287,8 @@ static int ReadDir( stream_t *p_demux, input_item_node_t *p_subitems )
                     }
 
                     vlc_xml_decode( psz_item_mrl );
-                    vlc_xml_decode( psz_item_name );
+                    if( psz_item_name )
+                       vlc_xml_decode( psz_item_name );
                     p_input = input_item_New( psz_item_mrl, psz_item_name );
                     FREENULL( psz_item_mrl );
                     FREENULL( psz_item_name );
diff --git a/modules/demux/smf.c b/modules/demux/smf.c
index 90e7a21b86..2b1293bda8 100644
--- a/modules/demux/smf.c
+++ b/modules/demux/smf.c
@@ -2,7 +2,7 @@
  * smf.c : Standard MIDI File (.mid) demux module for vlc
  *****************************************************************************
  * Copyright © 2007 Rémi Denis-Courmont
- * $Id: 37b16d6ac5f8cbebe0ac98052b6e397708743957 $
+ * $Id: ab03097a80101cacf645f5d1c7d89765b25a1ec0 $
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -234,10 +234,8 @@ int HandleMeta (demux_t *p_demux, mtrk_t *tr)
             break;
 
         case 0x59: /* Key signature */
-            if (length == 2)
-                ;
-            else
-                ret = -1;
+            if (length != 2)
+                msg_Warn(p_demux, "invalid key signature");
             break;
 
         case 0x7f: /* Proprietary event */
diff --git a/modules/demux/smooth/playlist/Parser.cpp b/modules/demux/smooth/playlist/Parser.cpp
index eb16da463b..3868125823 100644
--- a/modules/demux/smooth/playlist/Parser.cpp
+++ b/modules/demux/smooth/playlist/Parser.cpp
@@ -248,7 +248,10 @@ static void ParseStreamIndex(BasePeriod *period, Node *streamIndexNode, unsigned
             for(it = qualLevels.begin(); it != qualLevels.end(); ++it)
                 ParseQualityLevel(adaptSet, *it, type, nextid++, id);
         }
-        period->addAdaptationSet(adaptSet);
+        if(!adaptSet->getRepresentations().empty())
+            period->addAdaptationSet(adaptSet);
+        else
+            delete adaptSet;
     }
 }
 
diff --git a/modules/demux/xiph.h b/modules/demux/xiph.h
index 397df48fff..ce9dea33d2 100644
--- a/modules/demux/xiph.h
+++ b/modules/demux/xiph.h
@@ -2,7 +2,7 @@
  * xiph.h: Xiph helpers
  *****************************************************************************
  * Copyright (C) 2010 Laurent Aimar
- * $Id: 7d244286bef989d294e82881836c4d4535cd1d42 $
+ * $Id: 793023dea91b0859638b78cbf9e1d805fb066985 $
  *
  * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
  *
@@ -45,7 +45,7 @@ static inline unsigned int xiph_CountHeaders( const void *extra, unsigned int i_
         {
             uint16_t i_size = GetWBE( extra );
             p_extra += 2 + i_size;
-            if ( overall_len > i_extra - i_size )
+            if ( i_extra < i_size || overall_len > i_extra - i_size )
                 return 0;
             overall_len += i_size;
         }
diff --git a/modules/gui/qt/components/simple_preferences.cpp b/modules/gui/qt/components/simple_preferences.cpp
index bc36ce5f7b..0b9d646169 100644
--- a/modules/gui/qt/components/simple_preferences.cpp
+++ b/modules/gui/qt/components/simple_preferences.cpp
@@ -2,7 +2,7 @@
  * simple_preferences.cpp : "Simple preferences"
  ****************************************************************************
  * Copyright (C) 2006-2010 the VideoLAN team
- * $Id: 7a31a6ea6f7cd5e3cde3b685ba726a32eb90ff61 $
+ * $Id: 8d27260fda3dcab87f3cc0ea711e3825009cc1df $
  *
  * Authors: Clément Stenac <zorglub@videolan.org>
  *          Antoine Cellerier <dionoea@videolan.org>
@@ -40,6 +40,7 @@
 #include <QSignalMapper>
 #include <QVBoxLayout>
 #include <QScrollArea>
+#include <QHeaderView>
 
 #include <QStyleFactory>
 #include <QSettings>
@@ -67,6 +68,11 @@ static struct {
     { "auto",  N_("Auto") },
     { "en",    "American English" },
     { "ar",    "عربي" },
+    { "an",    "Aragonés" },
+    { "as_IN", "অসমীয়া" },
+    { "ast",   "Asturianu" },
+    { "be",    "беларуская мова" },
+    { "brx",   "बर'/बड़" },
     { "bn",    "বাংলা" },
     { "pt_BR", "Português Brasileiro" },
     { "en_GB", "British English" },
@@ -85,19 +91,20 @@ static struct {
     { "ga",    "Gaeilge" },
     { "gd",    "Gàidhlig" },
     { "gl",    "Galego" },
-    { "ka",    "ქართული" },
+    { "gu",    "ગુજરાતી" },
     { "de",    "Deutsch" },
     { "he",    "עברית" },
     { "hr",    "hrvatski" },
+    { "kn",    "ಕನ್ನಡ" },
+    { "lv",    "Latviešu valoda" },
     { "hu",    "Magyar" },
-    { "hy",    "հայերեն" },
+    { "mr",    "मराठी" },
     { "is",    "íslenska" },
     { "id",    "Bahasa Indonesia" },
     { "it",    "Italiano" },
     { "ja",    "日本語" },
     { "ko",    "한국어" },
     { "lt",    "lietuvių" },
-    { "mn",    "Монгол хэл" },
     { "ms",    "Melayu" },
     { "nb",    "Bokmål" },
     { "nn",    "Nynorsk" },
@@ -105,7 +112,6 @@ static struct {
     { "km",    "ភាសាខ្មែរ" },
     { "ne",    "नेपाली" },
     { "oc",    "Occitan" },
-    { "fa",    "فارسی" },
     { "pl",    "Polski" },
     { "pt_PT", "Português" },
     { "pa",    "ਪੰਜਾਬੀ" },
@@ -116,10 +122,10 @@ static struct {
     { "sr",    "српски" },
     { "sk",    "Slovensky" },
     { "sl",    "slovenščina" },
-    { "ckb",   "کوردیی سۆرانی" },
     { "es",    "Español" },
+    { "es_MX", "Español Mexicano" },
     { "sv",    "Svenska" },
-    { "te",    "తెలుగు" },
+    { "th",    "ภาษาไทย" },
     { "tr",    "Türkçe" },
     { "uk",    "украї́нська мо́ва" },
     { "vi",    "tiếng Việt" },
diff --git a/modules/hw/vaapi/filters.c b/modules/hw/vaapi/filters.c
index 4f7305b756..593203da1e 100644
--- a/modules/hw/vaapi/filters.c
+++ b/modules/hw/vaapi/filters.c
@@ -979,13 +979,13 @@ Deinterlace_Flush(filter_t *filter)
 
 static inline bool
 OpenDeinterlace_IsValidType(filter_t * filter,
-                            VAProcDeinterlacingType const caps[],
+                            VAProcFilterCapDeinterlacing const caps[],
                             unsigned int num_caps,
                             struct deint_mode const * deint_mode)
 {
     (void) filter;
     for (unsigned int j = 0; j < num_caps; ++j)
-        if (caps[j] == deint_mode->type)
+        if (caps[j].type == deint_mode->type)
             return true;
     return false;
 }
@@ -993,7 +993,7 @@ OpenDeinterlace_IsValidType(filter_t * filter,
 static inline int
 OpenDeinterlace_GetMode(filter_t * filter, char const * deint_mode,
                         struct deint_mode * p_deint_mode,
-                        VAProcDeinterlacingType const caps[],
+                        VAProcFilterCapDeinterlacing const caps[],
                         unsigned int num_caps)
 {
     bool fallback = false;
@@ -1046,7 +1046,8 @@ OpenDeinterlace_InitFilterParams(filter_t * filter, void * p_data,
 {
     struct deint_data *const    p_deint_data = p_data;
     filter_sys_t *const         filter_sys = filter->p_sys;
-    VAProcDeinterlacingType     caps[VAProcDeinterlacingCount];
+    VAProcFilterCapDeinterlacing
+                                caps[VAProcDeinterlacingCount];
     unsigned int                num_caps = VAProcDeinterlacingCount;
 
     if (vlc_vaapi_QueryVideoProcFilterCaps(VLC_OBJECT(filter),
diff --git a/modules/mux/mp4/libmp4mux.c b/modules/mux/mp4/libmp4mux.c
index 78cb1e3a31..c806edf796 100644
--- a/modules/mux/mp4/libmp4mux.c
+++ b/modules/mux/mp4/libmp4mux.c
@@ -266,22 +266,22 @@ static bo_t *GetESDS(mp4mux_trackinfo_t *p_track)
     case VLC_CODEC_MPGV:
         if(p_track->fmt.i_original_fourcc == VLC_CODEC_MP1V)
         {
-            i_object_type_indication = 0x6b;
+            i_object_type_indication = 0x6a; /* Visual ISO/IEC 11172-2  */
             break;
         }
         /* fallthrough */
     case VLC_CODEC_MP2V:
         /* MPEG-I=0x6b, MPEG-II = 0x60 -> 0x65 */
-        i_object_type_indication = 0x65;
+        i_object_type_indication = 0x61; /* Visual 13818-2 Main Profile */
         break;
     case VLC_CODEC_MP1V:
-        /* MPEG-I=0x6b, MPEG-II = 0x60 -> 0x65 */
-        i_object_type_indication = 0x6b;
+        i_object_type_indication = 0x6a; /* Visual ISO/IEC 11172-2  */
         break;
     case VLC_CODEC_MP4A:
         /* FIXME for mpeg2-aac == 0x66->0x68 */
         i_object_type_indication = 0x40;
         break;
+    case VLC_CODEC_MP3:
     case VLC_CODEC_MPGA:
         i_object_type_indication =
             p_track->fmt.audio.i_rate < 32000 ? 0x69 : 0x6b;
@@ -857,7 +857,8 @@ static bo_t *GetSounBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
     vlc_fourcc_t codec = p_track->fmt.i_codec;
     char fcc[4];
 
-    if (codec == VLC_CODEC_MPGA) {
+    if (codec == VLC_CODEC_MPGA ||
+        codec == VLC_CODEC_MP3) {
         if (b_mov) {
             b_descr = false;
             memcpy(fcc, ".mp3", 4);
@@ -971,8 +972,8 @@ static bo_t *GetVideBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
     for (int i = 0; i < 3; i++)
         bo_add_32be(vide, 0);     // predefined;
 
-    bo_add_16be(vide, p_track->fmt.video.i_width);  // i_width
-    bo_add_16be(vide, p_track->fmt.video.i_height); // i_height
+    bo_add_16be(vide, p_track->fmt.video.i_visible_width);  // i_width
+    bo_add_16be(vide, p_track->fmt.video.i_visible_height); // i_height
 
     bo_add_32be(vide, 0x00480000);                // h 72dpi
     bo_add_32be(vide, 0x00480000);                // v 72dpi
@@ -1288,6 +1289,16 @@ static bo_t *GetStblBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
     return stbl;
 }
 
+static unsigned ApplyARtoWidth(const video_format_t *vfmt)
+{
+    if (vfmt->i_sar_num > 0 && vfmt->i_sar_den > 0)
+    {
+        return (int64_t)vfmt->i_sar_num *
+               (int64_t)vfmt->i_visible_width / vfmt->i_sar_den;
+    }
+    else return vfmt->i_visible_width;
+}
+
 bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks,
                          int64_t i_movie_duration,
                          bool b_fragmented, bool b_mov, bool b_64_ext, bool b_stco64 )
@@ -1422,34 +1433,24 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un
             bo_add_32be(tkhd, 0);                 // width (presentation)
             bo_add_32be(tkhd, 0);                 // height(presentation)
         } else if (p_stream->fmt.i_cat == VIDEO_ES) {
-            int i_width = p_stream->fmt.video.i_width << 16;
-            if (p_stream->fmt.video.i_sar_num > 0 && p_stream->fmt.video.i_sar_den > 0) {
-                i_width = (int64_t)p_stream->fmt.video.i_sar_num *
-                          ((int64_t)p_stream->fmt.video.i_width << 16) /
-                          p_stream->fmt.video.i_sar_den;
-            }
             // width (presentation)
-            bo_add_32be(tkhd, i_width);
+            bo_add_32be(tkhd, ApplyARtoWidth(&p_stream->fmt.video) << 16);
             // height(presentation)
-            bo_add_32be(tkhd, p_stream->fmt.video.i_height << 16);
+            bo_add_32be(tkhd, p_stream->fmt.video.i_visible_height << 16);
         } else {
-            int i_width = 320 << 16;
-            int i_height = 200;
-            for (unsigned int i = 0; i < i_tracks; i++) {
-                mp4mux_trackinfo_t *tk = pp_tracks[i];
-                if (tk->fmt.i_cat == VIDEO_ES) {
-                    if (tk->fmt.video.i_sar_num > 0 &&
-                        tk->fmt.video.i_sar_den > 0)
-                        i_width = (int64_t)tk->fmt.video.i_sar_num *
-                                  ((int64_t)tk->fmt.video.i_width << 16) /
-                                  tk->fmt.video.i_sar_den;
-                    else
-                        i_width = tk->fmt.video.i_width << 16;
-                    i_height = tk->fmt.video.i_height;
-                    break;
-                }
+            unsigned i_width = 320;
+            unsigned i_height = 200;
+            /* Find video track for SPU representation */
+            for (unsigned int i = 0; i < i_tracks; i++)
+            {
+                const mp4mux_trackinfo_t *tk = pp_tracks[i];
+                if (tk->fmt.i_cat != VIDEO_ES)
+                    continue;
+                i_width = ApplyARtoWidth(&tk->fmt.video);
+                i_height = tk->fmt.video.i_visible_height;
+                break;
             }
-            bo_add_32be(tkhd, i_width);     // width (presentation)
+            bo_add_32be(tkhd, i_width << 16);     // width (presentation)
             bo_add_32be(tkhd, i_height << 16);    // height(presentation)
         }
 
diff --git a/modules/packetizer/flac.c b/modules/packetizer/flac.c
index ff5e1ac076..a1a2b5fea4 100644
--- a/modules/packetizer/flac.c
+++ b/modules/packetizer/flac.c
@@ -466,7 +466,7 @@ static block_t *Packetize(decoder_t *p_dec, block_t **pp_block)
                 p_sys->crc = flac_crc16( p_sys->crc, p_sys->p_buf[p_sys->i_offset - 2] );
                 p_sys->crc = flac_crc16( p_sys->crc, p_sys->p_buf[p_sys->i_offset - 1] );
                 p_sys->i_offset += 1;
-                p_sys->i_state = STATE_NEXT_SYNC;
+                p_sys->i_state = !pp_block ? STATE_NOSYNC : STATE_NEXT_SYNC;
                 break; /* continue */
             }
 
diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 6b4e38073e..4cf4a1d9b6 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -2,7 +2,7 @@
  * h264.c: h264/avc video packetizer
  *****************************************************************************
  * Copyright (C) 2001, 2002, 2006 VLC authors and VideoLAN
- * $Id: efefc57e6f2381f91f866c2af268132d42dce491 $
+ * $Id: c625005c8eddf345713c0e89607d2e322925c8ba $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Eric Petit <titer@videolan.org>
@@ -939,6 +939,9 @@ static block_t *OutputPicture( decoder_t *p_dec )
                 date_Decrement( &pts, -diff );
 
             p_pic->i_pts = date_Get( &pts );
+            /* non monotonically increasing dts on some videos 33333 33333...35000 */
+            if( p_pic->i_pts < p_pic->i_dts )
+                p_pic->i_pts = p_pic->i_dts;
         }
         /* In case there's no PTS at all */
         else if( CanSwapPTSwithDTS( &p_sys->slice, p_sps ) )
diff --git a/modules/services_discovery/Makefile.am b/modules/services_discovery/Makefile.am
index efd9cf6708..e070d6463b 100644
--- a/modules/services_discovery/Makefile.am
+++ b/modules/services_discovery/Makefile.am
@@ -33,6 +33,9 @@ libupnp_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(sddir)'
 libupnp_plugin_la_LIBADD = $(UPNP_LIBS)
 EXTRA_LTLIBRARIES += libupnp_plugin.la
 sd_LTLIBRARIES += $(LTLIBupnp)
+if HAVE_OSX
+libupnp_plugin_la_LDFLAGS += -Wl,-framework,CoreFoundation,-framework,SystemConfiguration
+endif
 
 libpulselist_plugin_la_SOURCES = services_discovery/pulse.c
 libpulselist_plugin_la_CFLAGS = $(AM_CFLAGS) $(PULSE_CFLAGS)
diff --git a/modules/services_discovery/avahi.c b/modules/services_discovery/avahi.c
index dbfac40809..1457c75a61 100644
--- a/modules/services_discovery/avahi.c
+++ b/modules/services_discovery/avahi.c
@@ -206,7 +206,6 @@ static void resolve_callback(
             vlc_dictionary_insert( &p_sys->services_name_to_input_item,
                 name, p_input );
             services_discovery_AddItem( p_sd, p_input );
-            input_item_Release( p_input );
        }
     }
 
@@ -257,10 +256,17 @@ static void browse_callback(
             vlc_dictionary_remove_value_for_key(
                         &p_sys->services_name_to_input_item,
                         name, NULL, NULL );
+            input_item_Release( p_item );
         }
     }
 }
 
+static void clear_item( void* p_item, void* p_obj )
+{
+    VLC_UNUSED( p_obj );
+    input_item_Release( (input_item_t*)p_item );
+}
+
 /*****************************************************************************
  * Open: initialize and create stuff
  *****************************************************************************/
@@ -318,7 +324,7 @@ error:
     if( p_sys->poll != NULL )
         avahi_threaded_poll_free( p_sys->poll );
 
-    vlc_dictionary_clear( &p_sys->services_name_to_input_item, NULL, NULL );
+    vlc_dictionary_clear( &p_sys->services_name_to_input_item, clear_item, NULL );
     free( p_sys );
 
     return VLC_EGENERIC;
@@ -336,6 +342,6 @@ static void Close( vlc_object_t *p_this )
     avahi_client_free( p_sys->client );
     avahi_threaded_poll_free( p_sys->poll );
 
-    vlc_dictionary_clear( &p_sys->services_name_to_input_item, NULL, NULL );
+    vlc_dictionary_clear( &p_sys->services_name_to_input_item, clear_item, NULL );
     free( p_sys );
 }
diff --git a/modules/services_discovery/microdns.c b/modules/services_discovery/microdns.c
index f367c20cc6..a77af219b1 100644
--- a/modules/services_discovery/microdns.c
+++ b/modules/services_discovery/microdns.c
@@ -366,6 +366,8 @@ parse_entries( const struct rr_entry *p_entries, bool b_renderer,
     }
     if( psz_ip == NULL || i_nb_srv == 0 )
     {
+        for( unsigned int i = 0; i < i_nb_srv; ++i )
+            free( p_srvs[i].psz_device_name );
         free( p_srvs );
         return VLC_EGENERIC;
     }
diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index 14f1b1a030..950a38a014 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -2,7 +2,7 @@
  * upnp.cpp :  UPnP discovery module (libupnp)
  *****************************************************************************
  * Copyright (C) 2004-2016 VLC authors and VideoLAN
- * $Id: 127f562837b49ba29009f5e5c275e35f0bc6b50f $
+ * $Id: f1037c82c8ec98d7d54608494818b8e395ced240 $
  *
  * Authors: Rémi Denis-Courmont <rem # videolan.org> (original plugin)
  *          Christian Henz <henz # c-lab.de>
@@ -507,25 +507,20 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
             }
 
             /* Try to browse content directory. */
-            char* psz_url = ( char* ) malloc( strlen( psz_base_url ) + strlen( psz_control_url ) + 1 );
-            if ( psz_url )
+            char* psz_url = NULL;
+            if ( UpnpResolveURL2( psz_base_url, psz_control_url, &psz_url ) == UPNP_E_SUCCESS )
             {
-                if ( UpnpResolveURL( psz_base_url, psz_control_url, psz_url ) == UPNP_E_SUCCESS )
-                {
-                    SD::MediaServerDesc* p_server = new(std::nothrow) SD::MediaServerDesc( psz_udn,
-                            psz_friendly_name, psz_url, iconUrl );
-                    free( psz_url );
-                    if ( unlikely( !p_server ) )
-                        break;
+                SD::MediaServerDesc* p_server = new(std::nothrow) SD::MediaServerDesc( psz_udn,
+                    psz_friendly_name, psz_url, iconUrl );
+                free( psz_url );
+                if ( unlikely( !p_server ) )
+                    break;
 
-                    if ( !addServer( p_server ) )
-                    {
-                        delete p_server;
-                        continue;
-                    }
+                if ( !addServer( p_server ) )
+                {
+                    delete p_server;
+                    continue;
                 }
-                else
-                    free( psz_url );
             }
         }
         ixmlNodeList_free( p_service_list );
@@ -1542,11 +1537,74 @@ done:
 
 #ifdef UPNP_ENABLE_IPV6
 
+#ifdef __APPLE__
+#include <TargetConditionals.h>
+#endif
+
+#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+#include <CoreFoundation/CoreFoundation.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+#include "vlc_charset.h"
+
+inline char *FromCFString(const CFStringRef cfString,
+                          const CFStringEncoding cfStringEncoding)
+{
+    // Try the quick way to obtain the buffer
+    const char *tmpBuffer = CFStringGetCStringPtr(cfString, cfStringEncoding);
+    if (tmpBuffer != NULL) {
+        return strdup(tmpBuffer);
+    }
+
+    // The quick way did not work, try the long way
+    CFIndex length = CFStringGetLength(cfString);
+    CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, cfStringEncoding);
+
+    // If result would exceed LONG_MAX, kCFNotFound is returned
+    if (unlikely(maxSize == kCFNotFound)) {
+        return NULL;
+    }
+
+    // Account for the null terminator
+    maxSize++;
+
+    char *buffer = (char *)malloc(maxSize);
+    if (unlikely(buffer == NULL)) {
+        return NULL;
+    }
+
+    // Copy CFString in requested encoding to buffer
+    Boolean success = CFStringGetCString(cfString, buffer, maxSize, cfStringEncoding);
+
+    if (!success)
+        FREENULL(buffer);
+    return buffer;
+}
+
+inline char *getPreferedAdapter()
+{
+    SCDynamicStoreRef session = SCDynamicStoreCreate(NULL, CFSTR("session"), NULL, NULL);
+    CFDictionaryRef q = (CFDictionaryRef) SCDynamicStoreCopyValue(session, CFSTR("State:/Network/Global/IPv4"));
+    char *returnValue = NULL;
+
+    if (q != NULL) {
+        const void *val;
+        if (CFDictionaryGetValueIfPresent(q, CFSTR("PrimaryInterface"), &val)) {
+            returnValue = FromCFString((CFStringRef)val, kCFStringEncodingUTF8);
+        }
+    }
+    CFRelease(q);
+    CFRelease(session);
+
+    return returnValue;
+}
+#else
+
 static char *getPreferedAdapter()
 {
     return NULL;
 }
 
+#endif
 #else
 
 static char *getIpv4ForMulticast()
diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index 53227c258b..5d2aefc139 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -90,6 +90,7 @@ struct sout_stream_sys_t
         , cc_has_input( false )
         , cc_reload( false )
         , cc_flushing( false )
+        , cc_eof( false )
         , has_video( false )
         , out_force_reload( false )
         , perf_warning_shown( false )
@@ -137,6 +138,7 @@ struct sout_stream_sys_t
     bool                               cc_has_input;
     bool                               cc_reload;
     bool                               cc_flushing;
+    bool                               cc_eof;
     bool                               has_video;
     bool                               out_force_reload;
     bool                               perf_warning_shown;
@@ -163,8 +165,8 @@ struct sout_stream_id_sys_t
 
 #define SOUT_CFG_PREFIX "sout-chromecast-"
 
-static const char DEFAULT_MUXER[] = "avformat{mux=matroska,options={live=1}}";
-static const char DEFAULT_MUXER_WEBM[] = "avformat{mux=webm,options={live=1}}";
+static const char DEFAULT_MUXER[] = "avformat{mux=matroska,options={live=1},reset-ts}";
+static const char DEFAULT_MUXER_WEBM[] = "avformat{mux=webm,options={live=1},reset-ts}";
 
 
 /*****************************************************************************
@@ -318,12 +320,6 @@ static int ProxySend(sout_stream_t *p_stream, sout_stream_id_sys_t *id,
             }
         }
 
-        mtime_t pause_delay = p_sys->p_intf->getPauseDelay();
-        if( p_buffer->i_pts != VLC_TS_INVALID )
-            p_buffer->i_pts -= pause_delay;
-        if( p_buffer->i_dts != VLC_TS_INVALID )
-            p_buffer->i_dts -= pause_delay;
-
         int ret = sout_StreamIdSend(p_stream->p_next, id, p_buffer);
         if (ret == VLC_SUCCESS && !p_sys->cc_has_input)
         {
@@ -1227,9 +1223,9 @@ bool sout_stream_sys_t::UpdateOutput( sout_stream_t *p_stream )
         ssout << "}:";
     }
 
-    const bool is_webm = ( i_codec_audio == 0 || i_codec_audio == VLC_CODEC_VORBIS ||
+    const bool is_webm = ( i_codec_audio == VLC_CODEC_VORBIS ||
                            i_codec_audio == VLC_CODEC_OPUS ) &&
-                         ( i_codec_video == 0 || i_codec_video == VLC_CODEC_VP8 ||
+                         ( i_codec_video == VLC_CODEC_VP8 ||
                            i_codec_video == VLC_CODEC_VP9 );
 
     if ( !p_original_video )
@@ -1307,7 +1303,7 @@ static int Send(sout_stream_t *p_stream, sout_stream_id_sys_t *id,
     sout_stream_sys_t *p_sys = p_stream->p_sys;
     vlc_mutex_locker locker(&p_sys->lock);
 
-    if( p_sys->isFlushing( p_stream ) )
+    if( p_sys->isFlushing( p_stream ) || p_sys->cc_eof )
     {
         block_Release( p_buffer );
         return VLC_SUCCESS;
@@ -1335,7 +1331,7 @@ static void Flush( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
     sout_stream_id_sys_t *next_id = p_sys->GetSubId( p_stream, id, false );
     if ( next_id == NULL )
         return;
-    next_id->flushed = true;
+    id->flushed = true;
 
     if( !p_sys->cc_flushing )
     {
@@ -1366,7 +1362,8 @@ static void on_input_event_cb(void *data, enum cc_input_event event, union cc_in
             /* In case of EOF: stop the sout chain in order to drain all
              * sout/demuxers/access. If EOF changes to false, reset es_changed
              * in order to reload the sout from next Send calls. */
-            if( arg.eof )
+            p_sys->cc_eof = arg.eof;
+            if( p_sys->cc_eof )
                 p_sys->stopSoutChain( p_stream );
             else
                 p_sys->out_force_reload = p_sys->es_changed = true;
diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index a9ecee9c33..7781708fcd 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -198,7 +198,7 @@ private:
     bool processMessage(const castchannel::CastMessage &msg);
     void queueMessage( QueueableMessages msg );
 
-    void setPauseState(bool paused, mtime_t delay);
+    void setPauseState(bool paused);
     bool isFinishedPlaying();
     bool isStateError() const;
     bool isStatePlaying() const;
@@ -233,7 +233,7 @@ private:
     static void send_input_event(void *, enum cc_input_event event, union cc_input_arg arg);
     static void set_demux_enabled(void *, bool, on_paused_changed_itf, void *);
 
-    static void set_pause_state(void*, bool paused, mtime_t delay);
+    static void set_pause_state(void*, bool paused);
 
     static void set_meta(void*, vlc_meta_t *p_meta);
 
@@ -298,7 +298,6 @@ private:
     mtime_t           m_cc_time_last_request_date;
     mtime_t           m_cc_time_date;
     mtime_t           m_cc_time;
-    mtime_t           m_pause_delay;
 
     /* shared structure with the demux-filter */
     chromecast_common      m_common;
diff --git a/modules/stream_out/chromecast/chromecast_common.h b/modules/stream_out/chromecast/chromecast_common.h
index f5a378812d..32a399c36b 100644
--- a/modules/stream_out/chromecast/chromecast_common.h
+++ b/modules/stream_out/chromecast/chromecast_common.h
@@ -66,7 +66,7 @@ typedef struct
 
     void (*pf_send_input_event)(void*, enum cc_input_event, union cc_input_arg);
 
-    void (*pf_set_pause_state)(void*, bool paused, mtime_t delay);
+    void (*pf_set_pause_state)(void*, bool paused);
 
     void (*pf_set_meta)(void*, vlc_meta_t *p_meta);
 
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 3c752cf20d..6f086842ed 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -115,7 +115,6 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
  , m_art_idx(0)
  , m_cc_time_date( VLC_TS_INVALID )
  , m_cc_time( VLC_TS_INVALID )
- , m_pause_delay( VLC_TS_INVALID )
  , m_pingRetriesLeft( PING_WAIT_RETRIES )
 {
     m_communication = new ChromecastCommunication( p_this,
@@ -409,7 +408,6 @@ void intf_sys_t::setHasInput( const std::string mime_type )
     m_cc_time_last_request_date = VLC_TS_INVALID;
     m_cc_time_date = VLC_TS_INVALID;
     m_cc_time = VLC_TS_INVALID;
-    m_pause_delay = VLC_TS_INVALID;
     m_mediaSessionId = 0;
 
     tryLoad();
@@ -1119,7 +1117,7 @@ void intf_sys_t::setDemuxEnabled(bool enabled,
     }
 }
 
-void intf_sys_t::setPauseState(bool paused, mtime_t delay)
+void intf_sys_t::setPauseState(bool paused)
 {
     vlc_mutex_locker locker( &m_lock );
     if ( m_mediaSessionId == 0 || paused == m_paused || !m_communication )
@@ -1128,22 +1126,13 @@ void intf_sys_t::setPauseState(bool paused, mtime_t delay)
     m_paused = paused;
     msg_Info( m_module, "%s state", paused ? "paused" : "playing" );
     if ( !paused )
-    {
         m_last_request_id =
             m_communication->msgPlayerPlay( m_appTransportId, m_mediaSessionId );
-        m_pause_delay = delay;
-    }
     else if ( m_state != Paused )
         m_last_request_id =
             m_communication->msgPlayerPause( m_appTransportId, m_mediaSessionId );
 }
 
-mtime_t intf_sys_t::getPauseDelay()
-{
-    vlc_mutex_locker locker( &m_lock );
-    return m_pause_delay;
-}
-
 unsigned int intf_sys_t::getHttpStreamPort() const
 {
     return m_httpd.m_port;
@@ -1257,10 +1246,10 @@ void intf_sys_t::send_input_event(void *pt, enum cc_input_event event, union cc_
     return p_this->sendInputEvent(event, arg);
 }
 
-void intf_sys_t::set_pause_state(void *pt, bool paused, mtime_t delay)
+void intf_sys_t::set_pause_state(void *pt, bool paused)
 {
     intf_sys_t *p_this = static_cast<intf_sys_t*>(pt);
-    p_this->setPauseState( paused, delay );
+    p_this->setPauseState( paused );
 }
 
 void intf_sys_t::set_meta(void *pt, vlc_meta_t *p_meta)
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index 589556406f..d8fde46272 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -45,8 +45,6 @@ struct demux_cc
         :p_demux(demux)
         ,p_renderer(renderer)
         ,m_enabled( true )
-        ,m_pause_date( VLC_TS_INVALID )
-        ,m_pause_delay( VLC_TS_INVALID )
     {
         init();
     }
@@ -179,21 +177,14 @@ struct demux_cc
                                          cc_input_arg { false } );
     }
 
-    void setPauseState(bool paused, mtime_t delay)
+    void setPauseState(bool paused)
     {
-        p_renderer->pf_set_pause_state( p_renderer->p_opaque, paused, delay );
+        p_renderer->pf_set_pause_state( p_renderer->p_opaque, paused );
     }
 
     mtime_t getCCTime()
     {
-        mtime_t system, delay;
-        if( es_out_ControlGetPcrSystem( p_demux->p_next->out, &system, &delay ) )
-            return VLC_TS_INVALID;
-
-        mtime_t cc_time = p_renderer->pf_get_time( p_renderer->p_opaque );
-        if( cc_time != VLC_TS_INVALID )
-            return cc_time - system + m_pause_delay;
-        return VLC_TS_INVALID;
+        return p_renderer->pf_get_time( p_renderer->p_opaque );
     }
 
     mtime_t getTime()
@@ -355,8 +346,6 @@ struct demux_cc
 
         case DEMUX_SET_POSITION:
         {
-            m_pause_delay = m_pause_date = VLC_TS_INVALID;
-
             double pos = va_arg( args, double );
             /* Force unprecise seek */
             int ret = demux_Control( p_demux->p_next, DEMUX_SET_POSITION, pos, false );
@@ -369,8 +358,6 @@ struct demux_cc
         }
         case DEMUX_SET_TIME:
         {
-            m_pause_delay = m_pause_date = VLC_TS_INVALID;
-
             mtime_t time = va_arg( args, int64_t );
             /* Force unprecise seek */
             int ret = demux_Control( p_demux->p_next, DEMUX_SET_TIME, time, false );
@@ -389,21 +376,7 @@ struct demux_cc
             int paused = va_arg( ap, int );
             va_end( ap );
 
-            if (paused)
-            {
-                if (m_pause_date == VLC_TS_INVALID)
-                    m_pause_date = mdate();
-            }
-            else
-            {
-                if (m_pause_date != VLC_TS_INVALID)
-                {
-                    m_pause_delay += mdate() - m_pause_date;
-                    m_pause_date = VLC_TS_INVALID;
-                }
-            }
-
-            setPauseState( paused != 0, m_pause_delay );
+            setPauseState( paused != 0 );
             break;
         }
         case DEMUX_SET_ES:
@@ -476,8 +449,6 @@ protected:
     double        m_last_pos;
     mtime_t       m_start_time;
     mtime_t       m_last_time;
-    mtime_t       m_pause_date;
-    mtime_t       m_pause_delay;
 };
 
 static void on_paused_changed_cb( void *data, bool paused )
diff --git a/modules/video_chroma/copy.c b/modules/video_chroma/copy.c
index 8a0bdf49fb..5ce666d50a 100644
--- a/modules/video_chroma/copy.c
+++ b/modules/video_chroma/copy.c
@@ -2,7 +2,7 @@
  * copy.c: Fast YV12/NV12 copy
  *****************************************************************************
  * Copyright (C) 2010 Laurent Aimar
- * $Id: 2baf076d535a65f790b728c7ead160c97bb992fe $
+ * $Id: 08f41f164b3f805750c6aa4281c4ed7271b0a0c4 $
  *
  * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
  *          Victorien Le Couviour--Tuffet <victorien.lecouviour.tuffet@gmail.com>
@@ -469,7 +469,7 @@ static void SSE_CopyPlane(uint8_t *dst, size_t dst_pitch,
     const size_t copy_pitch = __MIN(src_pitch, dst_pitch);
     const unsigned w16 = (copy_pitch+15) & ~15;
     const unsigned hstep = cache_size / w16;
-    const unsigned cache_width = __MIN(src_pitch, hstep);
+    const unsigned cache_width = __MIN(src_pitch, cache_size);
     assert(hstep > 0);
 
     /* If SSE4.1: CopyFromUswc is faster than memcpy */
@@ -502,8 +502,8 @@ SSE_InterleavePlanes(uint8_t *dst, size_t dst_pitch,
     size_t copy_pitch = __MIN(dst_pitch / 2, srcu_pitch);
     unsigned int const  w16 = (srcu_pitch+15) & ~15;
     unsigned int const  hstep = (cache_size) / (2*w16);
-    const unsigned cacheu_width = __MIN(srcu_pitch, hstep);
-    const unsigned cachev_width = __MIN(srcv_pitch, hstep);
+    const unsigned cacheu_width = __MIN(srcu_pitch, cache_size);
+    const unsigned cachev_width = __MIN(srcv_pitch, cache_size);
     assert(hstep > 0);
 
     for (unsigned int y = 0; y < height; y += hstep)
@@ -536,7 +536,7 @@ static void SSE_SplitPlanes(uint8_t *dstu, size_t dstu_pitch,
     size_t copy_pitch = __MIN(__MIN(src_pitch / 2, dstu_pitch), dstv_pitch);
     const unsigned w16 = (src_pitch+15) & ~15;
     const unsigned hstep = cache_size / w16;
-    const unsigned cache_width = __MIN(src_pitch, hstep);
+    const unsigned cache_width = __MIN(src_pitch, cache_size);
     assert(hstep > 0);
 
     for (unsigned y = 0; y < height; y += hstep) {
@@ -969,7 +969,7 @@ int picture_UpdatePlanes(picture_t *picture, uint8_t *data, unsigned pitch)
 
             p->p_pixels = o->p_pixels + o->i_lines * o->i_pitch;
             p->i_pitch  = pitch;
-            p->i_lines  = picture->format.i_height;
+            p->i_lines  = picture->format.i_height / 2;
             assert(p->i_visible_pitch <= p->i_pitch);
             assert(p->i_visible_lines <= p->i_lines);
         }
diff --git a/share/lua/playlist/dailymotion.lua b/share/lua/playlist/dailymotion.lua
index f117b0d5de..c9f58ec0d0 100644
--- a/share/lua/playlist/dailymotion.lua
+++ b/share/lua/playlist/dailymotion.lua
@@ -1,10 +1,8 @@
 --[[
-    Translate Daily Motion video webpages URLs to the corresponding
-    FLV URL.
+    Translate Dailymotion video webpages URLs to corresponding
+    video stream URLs.
 
- $Id$
-
- Copyright © 2007-2016 the VideoLAN team
+ Copyright © 2007-2019 the VideoLAN team
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
@@ -36,6 +34,7 @@ function parse()
 		if string.match( line, "<meta property=\"og:title\"" ) then
 			_,_,name = string.find( line, "content=\"(.-)\"" )
 			name = vlc.strings.resolve_xml_special_chars( name )
+			name = string.gsub( name, " %- Vidéo dailymotion$", "" )
 		end
 		if string.match( line, "<meta name=\"description\"" ) then
 			_,_,description = string.find( line, "content=\"(.-)\"" )
@@ -43,13 +42,26 @@ function parse()
                 description = vlc.strings.resolve_xml_special_chars( description )
             end
 		end
-		if string.match( line, "<link rel=\"thumbnail\" type=\"image/jpeg\"" ) then
-			_,_,arturl = string.find( line, "href=\"(.-)\"" )
+		if string.match( line, "<meta property=\"og:image\"" ) then
+			arturl = string.match( line, "content=\"(.-)\"" )
 		end
+    end
+
+    local video_id = string.match( vlc.path, "^www%.dailymotion%.com/video/([^/?#]+)" )
+    if video_id then
+        local metadata = vlc.stream( vlc.access.."://www.dailymotion.com/player/metadata/video/"..video_id )
+        if metadata then
+            local line = metadata:readline() -- data is on one line only
 
-        if string.match( line, "var __PLAYER_CONFIG__ = {" ) then
+            -- TODO: fetch "title" and resolve \u escape sequences
+            -- FIXME: use "screenname" instead and resolve \u escape sequences
             artist = string.match( line, '"username":"([^"]+)"' )
 
+            local poster = string.match( line, '"poster_url":"([^"]+)"' )
+            if poster then
+                arturl = string.gsub( poster, "\\/", "/")
+            end
+
             local streams = string.match( line, "\"qualities\":{(.-%])}" )
             if streams then
                 local prefres = vlc.var.inherit(nil, "preferred-resolution")
@@ -80,7 +92,7 @@ function parse()
     end
 
     if not path then
-        vlc.msg.err("Couldn't extract the video URL from dailymotion")
+        vlc.msg.err("Couldn't extract dailymotion video URL, please check for updates to this script")
         return { }
     end
 
diff --git a/share/lua/playlist/soundcloud.lua b/share/lua/playlist/soundcloud.lua
index ee210c686d..f20c80dd89 100644
--- a/share/lua/playlist/soundcloud.lua
+++ b/share/lua/playlist/soundcloud.lua
@@ -83,10 +83,10 @@ function parse()
 
     if track then
         -- API magic
-        local client_id = "WKcQQdEZw7Oi01KqtHWxeVSxNyRzgT8M"
+        local client_id = "NxDq1GKZ5tLDRohQGfJ7lYVKiephsF3G"
         -- app_version is not required by the API but we send it anyway
         -- to remain unconspicuous
-        local app_version = "1505226596"
+        local app_version = "1553518929"
 
         local api = vlc.stream( vlc.access.."://api.soundcloud.com/i1/tracks/"..track.."/streams?client_id="..client_id.."&app_version="..app_version..( secret and "&secret_token="..secret or "" ) )
 
diff --git a/share/lua/playlist/vimeo.lua b/share/lua/playlist/vimeo.lua
index c6362660f4..312b7684dd 100644
--- a/share/lua/playlist/vimeo.lua
+++ b/share/lua/playlist/vimeo.lua
@@ -1,7 +1,6 @@
 --[[
- $Id$
 
- Copyright © 2009-2013 the VideoLAN team
+ Copyright © 2009-2019 the VideoLAN team
 
  Authors: Konstantin Pavlov (thresh@videolan.org)
           François Revol (revol@free.fr)
@@ -24,45 +23,31 @@
 
 -- Probe function.
 function probe()
-    local path = vlc.path
-    path = path:gsub("^www%.", "")
     return ( vlc.access == "http" or vlc.access == "https" )
-        and ( string.match( path, "^vimeo%.com/%d+$" )
-              or string.match( path, "^vimeo%.com/channels/(.-)/%d+$" )
-              or string.match( path, "^player%.vimeo%.com/" ) )
-        -- do not match other addresses,
-        -- else we'll also try to decode the actual video url
+        and ( string.match( vlc.path, "^vimeo%.com/%d+" )
+              or string.match( vlc.path, "^vimeo%.com/channels/.-/%d+" )
+              or string.match( vlc.path, "^player%.vimeo%.com/" ) )
 end
 
 -- Parse function.
 function parse()
-    if not string.match( vlc.path, "player%.vimeo%.com" ) then -- Web page URL
+    if string.match( vlc.path, "^player%.vimeo%.com/" ) then
+        -- The /config API will return the data on a single line.
+        -- Otherwise, search the web page for the config.
+        local config = vlc.readline()
         while true do
             local line = vlc.readline()
             if not line then break end
-
-            -- Get the appropriate ubiquitous meta tag
-            -- <meta name="twitter:player" content="https://player.vimeo.com/video/123456789";>
-            local meta = string.match( line, "(<meta[^>]- name=\"twitter:player\"[^>]->)" )
-            if meta then
-                local path = string.match( meta, " content=\"(.-)\"" )
-                if path then
-                    path = vlc.strings.resolve_xml_special_chars( path )
-                    return { { path = path } }
-                end
+            if string.match( line, "var config = {" ) then
+                config = line
+                break
             end
         end
 
-        vlc.msg.err( "Couldn't extract vimeo video URL, please check for updates to this script" )
-        return { }
-
-    else -- API URL
-
         local prefres = vlc.var.inherit(nil, "preferred-resolution")
         local bestres = nil
-        local line = vlc.readline() -- data is on one line only
 
-        for stream in string.gmatch( line, "{([^}]*\"profile\":[^}]*)}" ) do
+        for stream in string.gmatch( config, "{([^}]*\"profile\":[^}]*)}" ) do
             local url = string.match( stream, "\"url\":\"(.-)\"" )
             if url then
                 -- Apparently the different formats available are listed
@@ -89,11 +74,37 @@ function parse()
             return { }
         end
 
-        local name = string.match( line, "\"title\":\"(.-)\"" )
-        local artist = string.match( line, "\"owner\":{[^}]-\"name\":\"(.-)\"" )
-        local arturl = string.match( line, "\"thumbs\":{\"[^\"]+\":\"(.-)\"" )
-        local duration = string.match( line, "\"duration\":(%d+)[,}]" )
+        local name = string.match( config, "\"title\":\"(.-)\"" )
+        local artist = string.match( config, "\"owner\":{[^}]-\"name\":\"(.-)\"" )
+        local arturl = string.match( config, "\"thumbs\":{\"[^\"]+\":\"(.-)\"" )
+        local duration = string.match( config, "\"duration\":(%d+)[,}]" )
 
         return { { path = path; name = name; artist = artist; arturl = arturl; duration = duration } }
+
+    else -- Video web page
+        local api
+        while true do
+            local line = vlc.readline()
+            if not line then break end
+
+            if string.match( line, "clip_page_config = {" ) then
+                api = string.match( line, '"config_url":"(.-)"' )
+                if api then
+                    api = string.gsub( api, "\\/", "/" )
+                    break
+                end
+            end
+        end
+
+        if not api then
+            vlc.msg.warn( "Couldn't extract vimeo API URL, falling back to preprogrammed URL pattern" )
+
+            local path = string.gsub( vlc.path, "^vimeo%.com/channels/.-/(%d+)", "/%1" )
+            local video_id = string.match( path, "/(%d+)" )
+
+            api = vlc.access.."://player.vimeo.com/video/"..video_id.."/config"
+        end
+
+        return { { path = api } }
     end
 end
diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua
index ab2a1ecaf4..c4da544803 100644
--- a/share/lua/playlist/youtube.lua
+++ b/share/lua/playlist/youtube.lua
@@ -316,7 +316,7 @@ function parse()
                 if not path then
                     -- If this is a live stream, the URL map will be empty
                     -- and we get the URL from this field instead
-                    local hlsvp = string.match( line, "\"hlsvp\": *\"(.-)\"" )
+                    local hlsvp = string.match( line, '\\"hlsManifestUrl\\": *\\"(.-)\\"' )
                     if hlsvp then
                         hlsvp = string.gsub( hlsvp, "\\/", "/" )
                         path = hlsvp
@@ -372,7 +372,7 @@ function parse()
         if not path then
             -- If this is a live stream, the URL map will be empty
             -- and we get the URL from this field instead
-            local hlsvp = string.match( line, "&hlsvp=([^&]*)" )
+            local hlsvp = string.match( line, "%%22hlsManifestUrl%%22%%3A%%22(.-)%%22" )
             if hlsvp then
                 hlsvp = vlc.strings.decode_uri( hlsvp )
                 path = hlsvp
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 6772724eba..9cadb39da3 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -2,7 +2,7 @@
  * es_out.c: Es Out handler for input.
  *****************************************************************************
  * Copyright (C) 2003-2004 VLC authors and VideoLAN
- * $Id: 77eca7d9662f50dc9e6294e3a557d3b72a7a8498 $
+ * $Id: 5a2b1946880b30ba023c4e3b00101bf57b533a41 $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
@@ -3231,7 +3231,7 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
                [TRANSFER_FUNC_BT470_BG] = "ITU-R BT.470 BG",
                [TRANSFER_FUNC_BT470_M] = "ITU-R BT.470 M",
                [TRANSFER_FUNC_BT709] = "ITU-R BT.709",
-               [TRANSFER_FUNC_SMPTE_ST2084] = "SMPTE ST2084",
+               [TRANSFER_FUNC_SMPTE_ST2084] = "SMPTE ST2084 (PQ)",
                [TRANSFER_FUNC_SMPTE_240] = "SMPTE 240M",
                [TRANSFER_FUNC_HLG] = N_("Hybrid Log-Gamma"),
            };
diff --git a/src/input/input.c b/src/input/input.c
index 1e5e38fe2a..687cff5c5d 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2,7 +2,7 @@
  * input.c: input thread
  *****************************************************************************
  * Copyright (C) 1998-2007 VLC authors and VideoLAN
- * $Id: 0cb2729a40a3f5ee47095c2d97911786c34afa45 $
+ * $Id: ef8d95adacdb83e18152405ffb3a721639335ac5 $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Laurent Aimar <fenrir@via.ecp.fr>
@@ -3217,6 +3217,8 @@ static void input_ChangeState( input_thread_t *p_input, int i_state )
     input_priv(p_input)->i_state = i_state;
     if( i_state == ERROR_S )
         input_item_SetErrorWhenReading( input_priv(p_input)->p_item, true );
+    else if ( i_state == PLAYING_S )
+        input_item_SetErrorWhenReading( input_priv(p_input)->p_item, false );
     input_SendEventState( p_input, i_state );
 }
 
diff --git a/src/misc/keystore.c b/src/misc/keystore.c
index 116849e042..b21016c5f5 100644
--- a/src/misc/keystore.c
+++ b/src/misc/keystore.c
@@ -435,9 +435,6 @@ vlc_credential_get(vlc_credential *p_credential, vlc_object_t *p_parent,
 
         case GET_FROM_MEMORY_KEYSTORE:
         {
-            if (!psz_dialog_title || !psz_dialog_fmt)
-                return false;
-
             vlc_keystore *p_keystore = get_memory_keystore(p_parent);
             if (p_keystore != NULL)
                 credential_find_keystore(p_credential, p_keystore);
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index ede6c9b3ce..b914cd5e4f 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -261,6 +261,7 @@ playlist_t *playlist_Create( vlc_object_t *p_parent )
     pl_priv(p_playlist)->status.p_item = NULL;
     pl_priv(p_playlist)->status.p_node = p_playlist->p_playing;
     pl_priv(p_playlist)->request.b_request = false;
+    pl_priv(p_playlist)->i_consecutive_errors = 0;
     p->request.input_dead = false;
 
     if (ml != NULL)
diff --git a/src/playlist/playlist_internal.h b/src/playlist/playlist_internal.h
index 2b9431d6b4..733dd87188 100644
--- a/src/playlist/playlist_internal.h
+++ b/src/playlist/playlist_internal.h
@@ -2,7 +2,7 @@
  * playlist_internal.h : Playlist internals
  *****************************************************************************
  * Copyright (C) 1999-2008 VLC authors and VideoLAN
- * $Id: 9537a5f2702f97a9f527b1478189a35d1254ce25 $
+ * $Id: 178933c76d533f19bf3e8707559951ffd7bae098 $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Clément Stenac <zorglub@videolan.org>
@@ -87,6 +87,7 @@ typedef struct playlist_private_t
 
     int      i_last_playlist_id; /**< Last id to an item */
     bool     b_reset_currently_playing; /** Reset current item array */
+    unsigned i_consecutive_errors; /**< Number of consecutive items in error */
 
     bool     b_tree; /**< Display as a tree */
     bool     b_preparse; /**< Preparse items */
diff --git a/src/playlist/thread.c b/src/playlist/thread.c
index 4cdc1d895f..9a568293af 100644
--- a/src/playlist/thread.c
+++ b/src/playlist/thread.c
@@ -2,7 +2,7 @@
  * thread.c : Playlist management functions
  *****************************************************************************
  * Copyright © 1999-2008 VLC authors and VideoLAN
- * $Id: ef96d92d3a0b61fea6f0f52c20ad02fc17137010 $
+ * $Id: 8f2d1ca87609c77a335e00ccd0dfb86c85a32857 $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Clément Stenac <zorglub@videolan.org>
@@ -421,7 +421,7 @@ static playlist_item_t *NextItem( playlist_t *p_playlist )
     return p_new;
 }
 
-static void LoopInput( playlist_t *p_playlist )
+static bool LoopInput( playlist_t *p_playlist )
 {
     playlist_private_t *p_sys = pl_priv(p_playlist);
     input_thread_t *p_input = p_sys->p_input;
@@ -439,6 +439,10 @@ static void LoopInput( playlist_t *p_playlist )
         vlc_cond_wait( &p_sys->signal, &p_sys->lock );
     }
 
+    input_item_t *item = input_GetItem(p_input);
+    assert(item);
+    bool ok = !input_item_HasErrorWhenReading(item);
+
     /* This input is dead. Remove it ! */
     PL_DEBUG( "dead input" );
     p_sys->p_input = NULL;
@@ -455,6 +459,8 @@ static void LoopInput( playlist_t *p_playlist )
 
     input_Close( p_input );
     PL_LOCK;
+
+    return ok;
 }
 
 static bool Next( playlist_t *p_playlist )
@@ -492,7 +498,19 @@ static void *Thread ( void *data )
         /* Playlist in running state */
         while( !p_sys->killed && Next( p_playlist ) )
         {
-            LoopInput( p_playlist );
+            bool ok = LoopInput( p_playlist );
+            if (ok)
+                p_sys->i_consecutive_errors = 0;
+            else
+            {
+                if (p_sys->i_consecutive_errors < 6)
+                    p_sys->i_consecutive_errors++;
+
+                int slowdown = 1 << p_sys->i_consecutive_errors;
+                /* 100ms, 200ms, 400ms, 800ms, 1.6s, 3.2s */
+                mtime_t deadline = mdate() + slowdown * 100000L; /* usecs */
+                vlc_cond_timedwait(&p_sys->signal, &p_sys->lock, deadline);
+            }
             played = true;
         }
 
diff --git a/src/revision.c b/src/revision.c
index c5cbc6f42d..db46437bbd 100644
--- a/src/revision.c
+++ b/src/revision.c
@@ -1 +1 @@
-const char psz_vlc_changeset[] = "3.0.6-0-g5803e85f73";
+const char psz_vlc_changeset[] = "3.0.7-0-g86cee31099";
diff --git a/src/revision.txt b/src/revision.txt
index 325f34fb04..07fb8c5868 100644
--- a/src/revision.txt
+++ b/src/revision.txt
@@ -1 +1 @@
-3.0.6-0-g5803e85f73
+3.0.7-0-g86cee31099
diff --git a/src/text/url.c b/src/text/url.c
index 44afaba3fa..83bba30e09 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -511,7 +511,8 @@ static int vlc_UrlParseInner(vlc_url_t *restrict url, const char *str)
             if (next != NULL)
                 *(next++) = '\0';
 
-            url->psz_host = vlc_idna_to_ascii(vlc_uri_decode(cur));
+            const char *host = vlc_uri_decode(cur);
+            url->psz_host = (host != NULL) ? vlc_idna_to_ascii(host) : NULL;
         }
 
         if (url->psz_host == NULL)

Attachment: signature.asc
Description: PGP signature


Reply to: