Sync minilzo from 2.03 to 2.07.

This commit is UNTESTED. I don't have any framegrabbers. However
there's no reason it shouldn't work as it's just a minor version bump.

Refs LMS-2014-06-16-1, CVE-2014-4607

(cherry picked from commit b99f21b2791c4685fb48460a165a7cd804256f03)
Signed-off-by: Stuart Morgan <smorgan@mythtv.org>
Player: Don't call DoneDisplayingFrame for PiP until next frame is ready

When displaying 'pictute in picture' (PiP), VideoOutput::ShowPIP
composites the PiP windows onto the main video frame.  To do so, it uses
the player's GetCurrentFrame method to obtain the most recently displayed
PiP frame.  However, MythPlayer::DisplayNormalFrames immediately releases
the last frame displayed back to the decoding queue.  Consequently when
GetCurrentFrame calls GetLastShownFrame to obtain that frame it may have been
overwritten by the decoder thread.

This patch defers calling DoneDisplayingFrame if the player is a PiP
player so that future calls to GetLastShownFrame return an intact frame.

Fixes #10878

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit 49df62f1a76f0e617208e261a09f5f8a634b3ce9)

Conflicts:
	mythtv/libs/libmythtv/mythplayer.cpp
Fix 0b9470c Fix fileringbuffer locking...

Commit 0b9470c (Fix fileringbuffer locking up on read()) modified
FileRingBuffer::safe_read to use fstat() to check the file size
before reading.  The new code compares (internalreadpos + tot)
with the reported size.  This is mostly correct except when
MythPlayer::SwitchProgram detects the transition across a livetv
programme boundary.  In this case internalreadpos holds the read
position for the old file until the decoder calls FileChanged().

This patch includes readAdjust (set by SetAdjustFilesize()) to
correctly determine the current read position in the file.

Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
(cherry picked from commit 363361a9e26322d9e6a87e17effc50add8653533)
avformat/avidec: allow rounding errors between scale/rate and timebase

Fixes Ticket3670

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 571ab8344a9a2864d22d01af41283cee9328b927)

Conflicts:
	libavformat/avidec.c
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
avcodec/utvideodec: Increase vlc len

Fixes a regression since fb3e380 similar to ticket #2661,
reported by fluffrabbit at aol dot com.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 673716c54b39eba9579a38ad222130e3f9549167)

Conflicts:
	libavcodec/utvideodec.c
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
adpcm: Fix trellis encoding of IMA QT

This was broken in 095be4fb - samples+ch (for the previous
non-planar case) equals &samples_p[ch][0]. The confusion
probably stemmed from the IMA WAV case where it originally
was &samples[avctx->channels + ch], which was correctly
changed into &samples_p[ch][1].

Fixes part of Ticket3701

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit a32765c4252eb106a2ade543026ef6f59e699bfa)
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
adpcm: Write the proper predictor in trellis mode in IMA QT

The actual predictor value, set by the trellis code, never
was written back into the variable that was written into
the block header. This was accidentally removed in b304244b.

This significantly improves the audio quality of the trellis
case, which was plain broken since b304244b.

Encoding IMA QT with trellis still actually gives a slightly
worse quality than without trellis, since the trellis encoder
doesn't use the exact same way of rounding as in
adpcm_ima_qt_compress_sample and adpcm_ima_qt_expand_nibble.

Fixes part of Ticket3701

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit fa8f060b75bf9074792a0f9ff4ed002652ef62b8)

Conflicts:
	tests/ref/acodec/adpcm-ima_qt-trellis
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
Revert two backports to release/1.2 that broke fate.

Revert "ff_id3v2_read: add option to limit ID3 magic number search"
Revert "ff_id3v2_free_extra_meta: set the pointer pointing to extra_meta to NULL"

This reverts commit 7f8aa37bc3666d060b3eb2baa02fcea3597a22fd.
This reverts commit 5219e20d58e15305e188ba60a75bfc37a1f82341.

Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
Show duration for large asf files as written in the file header.

Fixes ticket #3428.
(cherry picked from commit e3fd263f0b73e4425192d6dd1ab18027ecaa35db)

Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
swscale/swscale: fix integer overflow

Should fix fate failure with clang ftrapv

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit c9c0451224fd7bc38b4e135e99f114f80c1ae67f)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
avcodec/x86/mpegvideoenc_template: fix integer overflow

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
avcodec/h264_mp4toannexb_bsf: prepend global headers before any in stream parameter sets

Fixes h264_mp4toannexb_bsf_failure.mkv

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 289b149cecb381522cc9ccdf382825330169c655)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
avcodec/libx264: move where x264opts is applied down so it isnt overridden by avctx & defaults

fixes x264opts opengop=1

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 64b79141bdfdffaa9fda69eecce140473d0a9a18)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
lavu/opt: validate range before dereference

This change make error handling simplier.
av_opt_freep_ranges may be called when some ranges are NULL,
for example after memory allocation fail.

Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 3aac5fcfa9d3748659d78ab2a66d0ccce22cfd4f)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
avcodec/wma: use av_freep(), do not leave stale pointers in memory

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit d167faafe9dfa0b82bebb267c3c4e5fa5286bd67)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
avcodec/msrle: check return code for success before use

The check is possibly redundant, but better to check for errors
that dont occur than to skip the check and crash

Fixes CID1197060

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 754f84663e8b3a88fa2e953b195d59230393fb8d)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
swresample/resample: Limit filter length

Related to CID1197063

The limit choosen is arbitrary and much larger than what makes sense.
It avoids the need for checking arithmetic operations with the length for overflow

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit f9158b01d0f3effb58e87fb07db0382bc1e47de5)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
swresample/dither: use av_malloc_array()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit a5290cb1ac047851563da7aca06569e3ada55f79)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
swresample/resample: use av_malloc_array() where appropriate

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 5027f39712fdce25b9008e72d52e5abfeefd5fe6)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>
swscale/x86/swscale_template: loose hardcoded dstw_offset

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit f6759d9ad4a8b71e6f212ca4f1e7da9fa56d3298)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Jean-Yves Avenard <jyavenard@mythtv.org>