pvr: Fix crash when opening PVROSDChannels while playing a recording

This fixes a crash when sending the action XBMC.ActivateWindow(PVROSDChannels)
to open the channel view while playing back a PVR recording.

 0  0x00007ffff0d2b037 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 1  0x00007ffff0d2e698 in __GI_abort () at abort.c:90
 2  0x00007ffff0d23e03 in __assert_fail_base (
    fmt=0x7ffff0e7a578 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=assertion@entry=0x10e09c9 "px != 0",
    file=file@entry=0x10e06f8 "/usr/include/boost/smart_ptr/shared_ptr.hpp",
    line=line@entry=424,
    function=function@entry=0x119ede0
      <_ZZNK5boost10shared_ptrIN3PVR11CPVRChannelEEptEvE19__PRETTY_FUNCTION__>
      "T* boost::shared_ptr<T>::operator->() const [with T = PVR::CPVRChannel]")
      at assert.c:92
 3  0x00007ffff0d23eb2 in __GI___assert_fail (assertion=0x10e09c9 "px != 0",
    file=0x10e06f8 "/usr/include/boost/smart_ptr/shared_ptr.hpp", line=424,
    function=0x119ede0
       <_ZZNK5boost10shared_ptrIN3PVR11CPVRChannelEEptEvE19__PRETTY_FUNCTION__>
      "T* boost::shared_ptr<T>::operator->() const [with T = PVR::CPVRChannel]")
      at assert.c:101
 4  0x00000000006db05e in boost::shared_ptr<PVR::CPVRChannel>::operator-> (
    this=<optimized out>) at /usr/include/boost/smart_ptr/shared_ptr.hpp:424
 5  0x000000000103af4d in PVR::CGUIDialogPVRChannelsOSD::Update (
    this=this@entry=0x1fe2a40) at GUIDialogPVRChannelsOSD.cpp:183
 6  0x000000000103b2fd in PVR::CGUIDialogPVRChannelsOSD::OnInitWindow (
    this=0x1fe2a40) at GUIDialogPVRChannelsOSD.cpp:105
 7  0x000000000080e3f9 in CGUIWindow::OnMessage (this=this@entry=0x1fe2a40,
    message=...) at GUIWindow.cpp:546
 8  0x00000000007f25ab in CGUIDialog::OnMessage (this=0x1fe2a40, message=...)
    at GUIDialog.cpp:103
 9  0x00000000007f222e in CGUIDialog::DoModal_Internal (this=0x1fe2a40,
    iWindowID=10610, param=...) at GUIDialog.cpp:185
 10 0x00000000008145ea in CGUIWindowManager::ActivateWindow_Internal (
    this=this@entry=0x16e5df0, iWindowID=iWindowID@entry=10610, params=...,
    swappingWindows=swappingWindows@entry=false) at GUIWindowManager.cpp:405
 11 0x000000000081496f in CGUIWindowManager::ActivateWindow (this=0x16e5df0,
    iWindowID=iWindowID@entry=10610, params=...,
    swappingWindows=swappingWindows@entry=false) at GUIWindowManager.cpp:353
 12 0x0000000000ae56ac in CBuiltins::Execute (execString=...)
    at Builtins.cpp:394
 13 0x0000000000bda289 in CApplication::OnAction (this=this@entry=0x16e1070,
    action=...) at Application.cpp:2502
 14 0x0000000000d78e08 in EVENTSERVER::CEventServer::ExecuteNextAction (
    this=this@entry=0x2c3d9c0) at EventServer.cpp:353
 15 0x0000000000bdc9ba in CApplication::ProcessEventServer (
    this=this@entry=0x16e1070, frameTime=frameTime@entry=0.0400000028)
    at Application.cpp:3039
 16 0x0000000000bdd326 in CApplication::FrameMove (this=0x16e1070,
    processEvents=<optimized out>, processGUI=<optimized out>)
    at Application.cpp:2838
 17 0x0000000000c521f2 in CXBApplicationEx::Run (this=this@entry=0x16e1070)
    at XBApplicationEx.cpp:140
 18 0x000000000071d5d7 in XBMC_Run (renderGUI=<optimized out>) at xbmc.cpp:69
 19 0x00000000006dba7e in main (argc=1, argv=0x7fffffffdff8)
    at xbmc/main/main.cpp:76
CharsetConverter: add UTF-8 <-> UTF-32 and UTF-32 <-> wide conversion functions
CharsetConverter: add convenient overloads to new conversion functions
gles, fixed, more missing code
Merge pull request #3317 from Karlson2k/charsetconverter_rework_02

CharsetСonverter rework - Part 2
Merge pull request #3263 from fetzerch/bugfix-osdchannels

pvr: Fix crash when opening PVROSDChannels while playing a recording
[win32] update package list
[3D] Support switching to 3D resolutions

Include matching 3D flags (SBS/TAB) in the score of a resolution to switch to, to enable switching to 3d modes.
Also remove the old code that treated 3D modes differently when assigning a score.

I've also added a small weight to higher multiples of the desired framerate, so if display supports 30, 60 and 120Hz
and the video is 30fps then 30 will now be chosen rather than 120. This reduces the overhead of rendering the gui.
[confluence] Use animated gif as a cheaper working spinner
[rbp/omxplayer] Do we need discontinuity handling?

So far I've not seen what this is needed for and it does cause problems for some files.
[rbp/omxplayer] Cosmetics
h264_parser: Initialize the h264dsp context in the parser as well

Each AVStream struct for an H.264 elementary stream actually has two
copies of the H264DSPContext struct (and in fact all the other members
of H264Context as well):

((H264Context *) ((AVStream *)st)->codec->priv_data)->h264dsp
((H264Context *) ((AVStream *)st)->parser->priv_data)->h264dsp

but only the first of these was actually being initialised. This
prevented the addition of platform-specific implementations of
parser-related functions.

Signed-off-by: Martin Storsjö <martin@martin.st>
h264dsp: Factorize code into a new function, h264_find_start_code_candidate

This performs the start code search which was previously part of
h264_find_frame_end() - the most CPU intensive part of the function.

By itself, this results in a performance regression:
              Before          After
              Mean   StdDev   Mean   StdDev  Change
Overall time  2925.6 26.2     3068.5 31.7    -4.7%

but this can more than be made up for by platform-optimised
implementations of the function.

Signed-off-by: Martin Storsjö <martin@martin.st>
arm: Add assembly version of h264_find_start_code_candidate

               Before          After
               Mean   StdDev   Mean   StdDev  Change
This function   508.8 23.4      185.4  9.0    +174.4%
Overall        3068.5 31.7     2752.1 29.4     +11.5%

In combination with the preceding patch:
                Before          After
                Mean   StdDev   Mean   StdDev  Change
Overall         2925.6 26.2     2752.1 29.4     +6.3%

Signed-off-by: Martin Storsjö <martin@martin.st>
[ffmpeg] Backport of h264_find_start_code_candidate optimisation
Revert "[rbp/omxplayer] Avoid audio codec when in passthrough modes"

This reverts commit 9d6e3524ec14401961f64376f01eaca596ae39da.
Speedup for opening music song library

Previously, this repeatedly parsed the same URL string over and over again
for every song, each time the list of songs was opened.

Benchmarks for CMusicDatabase::GetSongsByWhere() on a Raspberry Pi with a
library of 4115 songs:

Before patch: 14.5 seconds
After patch:   4.0 seconds
Faster sorting of CFileItemLists, step 1

CFileItemLists are sorted by first construcing a SortItems object that refers
back to each CFileItem by index, sorting the SortItems object, then rebuilding
CSortItemList::m_items (a vector of pointers to CFileItems) by examination of
the sorted version of the SortItems object.

It might be more sensible, long-term, to sort m_items directly, but in the
meantime, there are a couple of simple ways to make sorting with SortItems
sufficiently efficient that it's not a problem any more.

Previously, SortItems was a vector of SortItem objects, held by value; each
SortItem was a std::map (implemented as a red-black tree) which ended up
being constructed and destructed as each element of SortItems was moved.
This patch changes SortItems to be a vector of pointers to SortItems instead.

Benchmarks for CFileItemList::Sort() on a Raspberry Pi with a library of
600 movies:
Before patch: 4.6 seconds
After patch:  1.1 seconds
Faster sorting of CFileItemLists, step 2

Each time a CFileItemList is sorted, multiple SortItem objects are
constructed and destructed. Each object is a std::map ,implemented as a
red-black tree with one node for each attribute (Field) upon which the
CFileItemList could conceivably have been sorted, even though for any given
SortBy, very few attributes are actually examined by SortUtils::Sort(). Worse
still, many of those nodes involve creating an associated fresh copy of a
string, with all the associated heap thrashing that entails.

This patch changes the various ToSortable methods to limit the number of
items in each SortItem's std::map to those actually required for performing
the chosen sort.

Benchmarks for CFileItemList::Sort() on a Raspberry Pi with a library of
600 movies:
Before patch: 1.1 seconds
After patch:  0.36 seconds
[rbp/omxplayer] Only apply boost centre to multichannel audio