libav.git
2 years agocbs_h265: Fix ranges of prediction weight offsets
Mark Thompson [Mon, 28 Aug 2017 16:07:01 +0000 (17:07 +0100)]
cbs_h265: Fix ranges of prediction weight offsets

The bracketing was wrong - '-' binds before '<<'.  This would
previously incorrectly reject the streams in the WP_A and WP_B
conformance tests.

2 years agocbs_h265: Fix reading of unknown parameter set extension data
Mark Thompson [Mon, 28 Aug 2017 16:06:14 +0000 (17:06 +0100)]
cbs_h265: Fix reading of unknown parameter set extension data

2 years agovaapi_h264: Fix CPB/DPB delays
Mark Thompson [Sat, 9 Sep 2017 21:49:14 +0000 (22:49 +0100)]
vaapi_h264: Fix CPB/DPB delays

This should be ticks, not time_scale steps - it was wrong for all
framerates not a multiple of 1/2.

2 years agoRevert "vaapi_h265: Reduce the amount of padding in the stream"
Mark Thompson [Tue, 12 Sep 2017 21:11:52 +0000 (22:11 +0100)]
Revert "vaapi_h265: Reduce the amount of padding in the stream"

This reverts commit a14a12ca137bf1526452b97bedfc9f7b301d4e04.

The CTU size is always 32x32; the surface size is what actually sets
the desired property, and it is already correct.

2 years agoh264_metadata: Fix double-free
Mark Thompson [Sun, 20 Aug 2017 21:46:17 +0000 (22:46 +0100)]
h264_metadata: Fix double-free

Whether the udu string should be freed depends on whether the SEI it
gets added to was created internally by cbs or externally by the bsf.
The current code frees it twice in the former case.

2 years agocbs: Add buffer padding when splitting fragments
Mark Thompson [Tue, 12 Sep 2017 21:11:47 +0000 (22:11 +0100)]
cbs: Add buffer padding when splitting fragments

Remove any trailing zeroes from H.26[45] NAL units at the same time.

2 years agocbs: Always check for bitstream end before reading
Mark Thompson [Tue, 12 Sep 2017 21:11:41 +0000 (22:11 +0100)]
cbs: Always check for bitstream end before reading

2 years agoqsv: Load the hw hevc plugin by default on Linux
Luca Barbato [Wed, 6 Sep 2017 13:07:40 +0000 (13:07 +0000)]
qsv: Load the hw hevc plugin by default on Linux

Only on Windows the software plugin is available.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2 years agoaviocat: Check for output write errors
Martin Storsjö [Sat, 2 Sep 2017 21:02:54 +0000 (00:02 +0300)]
aviocat: Check for output write errors

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agoflvdec: Check the avio_seek return value after reading a metadata packet
Martin Storsjö [Sat, 2 Sep 2017 20:20:26 +0000 (23:20 +0300)]
flvdec: Check the avio_seek return value after reading a metadata packet

If the metadata packet is corrupted, flv_read_metabody can accidentally
read past the start of the next packet. If the start of the next packet
had been flushed out of the IO buffer, we would be unable to seek to
the right position (on a nonseekable stream).

Prefer to clearly error out instead of silently trying to read from a
desynced stream which will only be interpreted as garbage.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agoRevert "checkasm: Test more h264 idct variants"
Martin Storsjö [Sat, 2 Sep 2017 19:22:59 +0000 (22:22 +0300)]
Revert "checkasm: Test more h264 idct variants"

This reverts commit 547db1eaecd597031165a2bf637acaaacde52788.

This commit wasn't supposed to be pushed (yet) since it hasn't
been reviewed.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agoarm: Fix SIGBUS on ARM when compiled with binutils 2.29
Martin Storsjö [Thu, 31 Aug 2017 09:06:44 +0000 (12:06 +0300)]
arm: Fix SIGBUS on ARM when compiled with binutils 2.29

In binutils 2.29, the behavior of the ADR instruction changed so that 1 is
added to the address of a Thumb function (previously nothing was added). This
allows the loaded address to be passed to a BLX instruction and the correct
mode change will occur.

See: https://sourceware.org/bugzilla/show_bug.cgi?id=21458

By using adr with a label that isn't annotated as a thumb function,
we avoid the new behaviour in binutils 2.29 and get the same behaviour
as in prior releases, and as in other assemblers (ms armasm.exe,
clang's built in assembler) - an idea that Janne Grunau came up with.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agocheckasm: Test more h264 idct variants
Martin Storsjö [Tue, 29 Aug 2017 20:23:12 +0000 (23:23 +0300)]
checkasm: Test more h264 idct variants

2 years agoRevert "fate: Skip the checkasm test if CONFIG_STATIC is disabled"
Martin Storsjö [Fri, 25 Aug 2017 06:42:15 +0000 (09:42 +0300)]
Revert "fate: Skip the checkasm test if CONFIG_STATIC is disabled"

When we use dllexport properly for shared libraries on windows,
there's no longer any issue with linking the object files for
e.g. libavcodec statically into checkasm. (It's still not possible
to link the built object files for e.g. libavformat statically to
libavcodec though, since libavformat exepcts to load av_export_*
symbols from a DLL.)

This reverts commit 4e62b57ee03928c12a3119dcaf78ffa1f4d6985f.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agoconfigure: Use dllexport/dllimport for data symbols across DLLs with mingw
Martin Storsjö [Thu, 24 Aug 2017 20:27:16 +0000 (23:27 +0300)]
configure: Use dllexport/dllimport for data symbols across DLLs with mingw

This avoids having to use pseudo relocations.

The version script used for exporting functions is skipped as soon
as the set of object files contains symbols marked with dllexport,
therefore we need to use makedef to produce the full list of symbols
to be exported.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agomakedef: Extend the script for use with mingw tools as well
Martin Storsjö [Thu, 24 Aug 2017 20:05:21 +0000 (23:05 +0300)]
makedef: Extend the script for use with mingw tools as well

This is invoked by setting the NM and AR variables to the names of
those specific tools. The ARCH variable also needs to be provided,
to choose the symbol prefix (nm doesn't provide any option that
dumps the architecture easily).

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agomakedef: Fold as much text transformations as possible into the initial dump
Martin Storsjö [Thu, 24 Aug 2017 20:04:38 +0000 (23:04 +0300)]
makedef: Fold as much text transformations as possible into the initial dump

This avoids redoing them for each expression in the list.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agomsvc: Properly specify dllexport for data symbols shared across dll boundaries
Martin Storsjö [Thu, 24 Aug 2017 19:07:04 +0000 (22:07 +0300)]
msvc: Properly specify dllexport for data symbols shared across dll boundaries

We currently only have exported data symbols within libavcodec, but
the concept is easy to extend to other libraries if necessary.
The attribute declaration needs to be in a private header though,
since we can't use CONFIG_SHARED in public installed headers.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agoRemove support for building for mingw32ce (Windows CE)
Martin Storsjö [Wed, 30 Aug 2017 19:04:30 +0000 (22:04 +0300)]
Remove support for building for mingw32ce (Windows CE)

The toolchain for this target is unmaintained since many years.

While it has been continuously build tested on fate, it hasn't
actually been tested at runtime since many, many years (and back
then, only a few codecs in libavcodec were tested).

So far, keeping support for it has been mostly effortless, but
the compiler does seem to have issues with dllimported data symbols,
ending up as internal compiler errors in some cases. Instead of
jumping through further hoops to work around that, just remove the
target.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agolavf: make avio_read_partial() public
wm4 [Thu, 17 Aug 2017 13:01:44 +0000 (15:01 +0200)]
lavf: make avio_read_partial() public

Main use-case is proxying avio through a foreign I/O layer and a custom
AVIO context, without losing latency and performance characteristics.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2 years agoswscale: Do not expand a macro with 'defined' in it
Derek Buitenhuis [Thu, 24 Aug 2017 20:04:13 +0000 (21:04 +0100)]
swscale: Do not expand a macro with 'defined' in it

Fixes:

    libswscale/utils.c:1632:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
    #if USE_MMAP
        ^
    libswscale/utils.c:1577:49: note: expanded from macro 'USE_MMAP'
    #define USE_MMAP (HAVE_MMAP && HAVE_MPROTECT && defined MAP_ANONYMOUS)
                                                    ^
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2 years agoconfigure: Include d3d11va_extralibs in libavutil
Martin Storsjö [Thu, 24 Aug 2017 19:17:16 +0000 (22:17 +0300)]
configure: Include d3d11va_extralibs in libavutil

This fixes shared WinRT/UWP builds with d3d11va enabled.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agoyadif: Account for the buffer alignment while processing the frame edges
Michael Niedermayer [Mon, 21 Aug 2017 07:55:48 +0000 (09:55 +0200)]
yadif: Account for the buffer alignment while processing the frame edges

Avoid out of bound reads.

Bug-Id: 1031
CC: libav-stable@libav.org
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2 years agoaarch64: Fix negative movrel offsets for windows
Martin Storsjö [Sun, 9 Jul 2017 20:52:10 +0000 (23:52 +0300)]
aarch64: Fix negative movrel offsets for windows

On windows, the offset for the relocation doesn't get stored in
the relocation itself, but as an unsigned immediate in the opcode.
Therefore, negative offsets has to be handled via a separate sub
instruction, just as on MachO.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agopng: Support RGBA64 pixel format
Luca Barbato [Sun, 16 Jul 2017 12:35:40 +0000 (14:35 +0200)]
png: Support RGBA64 pixel format

2 years agopng: Report more details regarding unsupported pixel formats
Luca Barbato [Sun, 16 Jul 2017 11:46:16 +0000 (13:46 +0200)]
png: Report more details regarding unsupported pixel formats

2 years agompeg2enc: Don't mark all streams as component video
Mark Thompson [Sat, 12 Aug 2017 21:16:13 +0000 (22:16 +0100)]
mpeg2enc: Don't mark all streams as component video

Since there is no information about the source format, "unspecified"
is the correct value to write here.

All tests using the MPEG-2 encoder are updated, as this changes the
header on all outputs.

2 years agolavc: Add mpeg2_metadata bitstream filter
Mark Thompson [Tue, 1 Aug 2017 14:35:14 +0000 (15:35 +0100)]
lavc: Add mpeg2_metadata bitstream filter

2 years agolavc: Add coded bitstream read/write support for MPEG-2
Mark Thompson [Thu, 4 May 2017 22:03:03 +0000 (23:03 +0100)]
lavc: Add coded bitstream read/write support for MPEG-2

Also enable MPEG-2 support in the trace_headers filter.

2 years agocbs_h2645: Return error if writing fails
Mark Thompson [Mon, 14 Aug 2017 15:46:32 +0000 (16:46 +0100)]
cbs_h2645: Return error if writing fails

2 years agoh264dec: use a large enough field for reference list modification values
Anton Khirnov [Thu, 17 Aug 2017 10:15:58 +0000 (12:15 +0200)]
h264dec: use a large enough field for reference list modification values

pic_num can be at most 17-bit, so uint8_t is not sufficient.

Found-By: Bradley Sepos <bradley@bradleysepos.com>
CC: libav-stable@libav.org
2 years agoxwddec: support 8bpp grayscale
Piotr Bandurski [Sun, 24 Jun 2012 11:34:02 +0000 (11:34 +0000)]
xwddec: support 8bpp grayscale

(cherry picked from commit b9c94e826e7551027754ecfa60e3e487e0c28fcb)
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2 years agodfa: Disallow odd width/height and add proper bounds check for DDS1 chunks
Diego Biurrun [Fri, 11 Aug 2017 17:15:20 +0000 (19:15 +0200)]
dfa: Disallow odd width/height and add proper bounds check for DDS1 chunks

DDS1 chunks are decoded in 2x2 blocks, odd chunk width or height is not
allowed in that case. Also ensure that the decode buffer is big enough
for all blocks being processed.

Bug-Id: CVE-2017-9992
CC: libav-stable@libav.org
2 years agovaapi_h265: Reduce the amount of padding in the stream
Mark Thompson [Sat, 12 Aug 2017 20:32:29 +0000 (21:32 +0100)]
vaapi_h265: Reduce the amount of padding in the stream

It is not necessary to pad to the CTU size.  The CB size of 8x8 should be
sufficient, but due to constraints in the Intel driver (the one usable
implementation of this) it has to be padded to 16x16 like in H.264.

2 years agovaapi_h265: Add support for AUD NAL units
Mark Thompson [Sun, 23 Jul 2017 22:22:54 +0000 (23:22 +0100)]
vaapi_h265: Add support for AUD NAL units

Matching the H.264 encoder.

2 years agovaapi_h265: Convert to use coded bitstream infrastructure
Mark Thompson [Sun, 14 May 2017 20:36:24 +0000 (21:36 +0100)]
vaapi_h265: Convert to use coded bitstream infrastructure

Also improves the metadata and generally makes the configuration
a bit cleaner.

2 years agovaapi_h264: Add support for SEI recovery points
Mark Thompson [Sun, 7 May 2017 22:02:09 +0000 (23:02 +0100)]
vaapi_h264: Add support for SEI recovery points

Included by default with non-IDR intra frames.

2 years agovaapi_h264: Add support for AUD NAL units
Mark Thompson [Sun, 7 May 2017 21:58:56 +0000 (22:58 +0100)]
vaapi_h264: Add support for AUD NAL units

Adds a new private option to enable them (off by default).

2 years agovaapi_h264: Convert to use coded bitstream infrastructure
Mark Thompson [Sun, 7 May 2017 14:01:42 +0000 (15:01 +0100)]
vaapi_h264: Convert to use coded bitstream infrastructure

2 years agolavc: Add hevc_metadata bitstream filter
Mark Thompson [Sun, 23 Jul 2017 15:23:51 +0000 (16:23 +0100)]
lavc: Add hevc_metadata bitstream filter

This is able to modify some header metadata found in the VPS/SPS/VUI,
and can also add/remove AUDs.

2 years agolavc: Add h264_redundant_pps bitstream filter
Mark Thompson [Thu, 4 May 2017 22:10:19 +0000 (23:10 +0100)]
lavc: Add h264_redundant_pps bitstream filter

This applies a specific fixup to some Bluray streams which contain
redundant PPSs modifying irrelevant parameters of the stream which
confuse other transformations which require correct extradata.

A new single global PPS is created, and all of the redundant PPSs
within the stream are removed.

2 years agolavc: Add h264_metadata bitstream filter
Mark Thompson [Thu, 4 May 2017 22:09:02 +0000 (23:09 +0100)]
lavc: Add h264_metadata bitstream filter

This is able to modify some header metadata found in the SPS/VUI,
and can also add/remove AUDs and insert user data in SEI NAL units.

2 years agolavc: Add trace_headers bitstream filter
Mark Thompson [Thu, 4 May 2017 22:06:20 +0000 (23:06 +0100)]
lavc: Add trace_headers bitstream filter

Supports all streams that the coded bitstream infrastructure does
(currently H.264 and H.265).

2 years agolavc: Add coded bitstream read/write support for H.265
Mark Thompson [Sun, 14 May 2017 15:32:00 +0000 (16:32 +0100)]
lavc: Add coded bitstream read/write support for H.265

2 years agolavc: Add coded bitstream read/write support for H.264
Mark Thompson [Sun, 14 May 2017 15:18:25 +0000 (16:18 +0100)]
lavc: Add coded bitstream read/write support for H.264

2 years agolavc: Add coded bitstream read/write API
Mark Thompson [Thu, 4 May 2017 22:01:51 +0000 (23:01 +0100)]
lavc: Add coded bitstream read/write API

2 years agopixfmt: Support chroma-derived and ictcp color matrices
Vittorio Giovara [Tue, 8 Aug 2017 14:30:32 +0000 (16:30 +0200)]
pixfmt: Support chroma-derived and ictcp color matrices

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2 years agoh264: Add support for alternative transfer characterics SEI
Vittorio Giovara [Tue, 8 Aug 2017 14:06:29 +0000 (16:06 +0200)]
h264: Add support for alternative transfer characterics SEI

The use of this SEI is for backward compatibility in HLG HDR systems:
older devices that cannot interpret the "arib-std-b67" transfer will
get the compatible transfer (usually bt709 or bt2020) from the VUI,
while newer devices that can interpret HDR will read the SEI and use
its value instead.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2 years agovaapi_encode: Move quality option to common code
Mark Thompson [Sun, 30 Apr 2017 18:27:54 +0000 (19:27 +0100)]
vaapi_encode: Move quality option to common code

Use AVCodecContext.compression_level rather than a private option,
replacing the H.264-specific quality option (which stays only for
compatibility).

This now works with the H.265 encoder in the i965 driver, as well as
the existing cases with the H.264 encoder.

2 years agohevc: Validate the number of long term reference pictures
Mark Thompson [Fri, 23 Jun 2017 23:29:14 +0000 (00:29 +0100)]
hevc: Validate the number of long term reference pictures

This would overflow if the stream contained a value greater than the
maximum allowed by the standard (32).

2 years agohevc: Improve stream constraint values in common header
Mark Thompson [Fri, 23 Jun 2017 23:29:02 +0000 (00:29 +0100)]
hevc: Improve stream constraint values in common header

Add comments to describe the sources of the constraint values expressed here,
and add some more related values which will be used in following patches.

Fix the incorrect values for SPS and PPS count (they are not the same as those
used for H.264), and remove HEVC_MAX_CU_SIZE because it is not used anywhere.

2 years agoh264: Add stream constraint values to the common header
Mark Thompson [Fri, 23 Jun 2017 23:30:20 +0000 (00:30 +0100)]
h264: Add stream constraint values to the common header

With comments describing the derivation of each value.

2 years agomov: move stsd finalization to an appropriate place
Sean McGovern [Sat, 29 Jul 2017 23:17:16 +0000 (19:17 -0400)]
mov: move stsd finalization to an appropriate place

mov_finalize_stsd_codec() parses stream information from the ALAC extradata,
so run it after the extradata processing is completed in mov_read_stsd().

Fixes playback of 96kHz ALAC streams muxed by qaac or the reference alac encoder.

Adapted from an FFmpeg patch by Hendrik Leppkes <h.leppkes@gmail.com>

Bug-Id: 1072

2 years agomov: Do not set stsd_count if mov_read_stsd() fails
Sean McGovern [Fri, 28 Jul 2017 20:29:35 +0000 (16:29 -0400)]
mov: Do not set stsd_count if mov_read_stsd() fails

Based on an FFmpeg patch by Michael Niedermayer <michael@niedermayer.cc>

2 years agomov: log and return early on non-positive stsd entry counts
Sean McGovern [Fri, 28 Jul 2017 20:17:33 +0000 (16:17 -0400)]
mov: log and return early on non-positive stsd entry counts

Based on an FFmpeg patch by Michael Niedermayer <michael@niedermayer.cc>

2 years agohevcdec: add a CUVID hwaccel
Anton Khirnov [Sat, 11 Feb 2017 15:49:34 +0000 (16:49 +0100)]
hevcdec: add a CUVID hwaccel

2 years agofate/hevc: specify output pixel format explicitly
Anton Khirnov [Mon, 24 Jul 2017 09:42:09 +0000 (11:42 +0200)]
fate/hevc: specify output pixel format explicitly

This allows running those tests with hwaccel.

2 years agohevcdec: set the active SPS before calling get_format()
Anton Khirnov [Mon, 24 Jul 2017 09:41:31 +0000 (11:41 +0200)]
hevcdec: set the active SPS before calling get_format()

This way the SPS is available to the hwaccel init code.

2 years agoavconv: when using -loop option bail out if seek to start fails
Peter Große [Fri, 30 Jun 2017 15:28:53 +0000 (17:28 +0200)]
avconv: when using -loop option bail out if seek to start fails

Fixes an infinite loop when a demuxer fails to seek to the start of the input.

Signed-off-by: Peter Große <pegro@friiks.de>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2 years agocuvid: add cuvid.h to SKIPHEADERS
Anton Khirnov [Thu, 27 Jul 2017 10:42:03 +0000 (12:42 +0200)]
cuvid: add cuvid.h to SKIPHEADERS

2 years agoh264dec: add a CUVID hwaccel
Anton Khirnov [Sat, 11 Feb 2017 15:49:34 +0000 (16:49 +0100)]
h264dec: add a CUVID hwaccel

Some parts of the code are based on a patch by
Timo Rothenpieler <timo@rothenpieler.org>

2 years agodecode: add a per-frame private data for hwaccel use
Anton Khirnov [Sat, 1 Jul 2017 10:09:58 +0000 (12:09 +0200)]
decode: add a per-frame private data for hwaccel use

This will be useful in the CUVID hwaccel. It should also eventually
replace current decoder-specific mechanisms used by various other
hwaccels.

2 years agodecode: add a mechanism for performing delayed processing on the decoded frames
Anton Khirnov [Sat, 1 Jul 2017 10:09:58 +0000 (12:09 +0200)]
decode: add a mechanism for performing delayed processing on the decoded frames

This will be useful in the CUVID hwaccel.

2 years agodecode: add a method for attaching lavc-internal data to frames
Anton Khirnov [Sat, 1 Jul 2017 09:12:44 +0000 (11:12 +0200)]
decode: add a method for attaching lavc-internal data to frames

Use the AVFrame.opaque_ref field. The original user's opaque_ref is
wrapped in the lavc struct and then unwrapped before the frame is
returned to the caller.

This new struct will be useful in the following commits.

2 years agodecode: avoid leaks on failure in ff_get_buffer()
Anton Khirnov [Sat, 1 Jul 2017 09:32:56 +0000 (11:32 +0200)]
decode: avoid leaks on failure in ff_get_buffer()

If the get_buffer() call fails, the frame might have some side data
already set. Make sure it gets freed.

CC: libav-stable@libav.org
2 years agoh264dec: Fix mix of lossless and lossy MBs decoding
Anton Mitrofanov [Thu, 15 Jun 2017 22:56:16 +0000 (18:56 -0400)]
h264dec: Fix mix of lossless and lossy MBs decoding

CC: libav-stable@libav.org
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2 years agoh264_cabac: Fix CABAC+8x8dct in 4:4:4
Anton Mitrofanov [Thu, 15 Jun 2017 22:56:14 +0000 (18:56 -0400)]
h264_cabac: Fix CABAC+8x8dct in 4:4:4

Use the correct ctxIdxInc calculation for coded_block_flag.
Keep old behavior for old versions of x264 for backward compatibility.

CC: libav-stable@libav.org
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2 years agoh264dec: fix Lossless Decoding (Profile 244) for 8x8 Intra Prediction
Yogender Kumar Gupta [Thu, 15 Jun 2017 22:56:13 +0000 (18:56 -0400)]
h264dec: fix Lossless Decoding (Profile 244) for 8x8 Intra Prediction

CC: libav-stable@libav.org
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2 years agoh264dec: track the last seen value of x264_build
Anton Khirnov [Sat, 22 Jul 2017 12:52:27 +0000 (14:52 +0200)]
h264dec: track the last seen value of x264_build

Do not use the one in the SEI directly as that is reset at certain
points.

Inspired by patches from Michael Niedermayer <michaelni@gmx.at> and
Anton Mitrofanov <BugMaster@narod.ru>.

CC: libav-stable@libav.org
2 years agoimgutils: add function to clear an image to black
wm4 [Sat, 22 Jul 2017 21:05:14 +0000 (23:05 +0200)]
imgutils: add function to clear an image to black

Black isn't always just memset(ptr, 0, size). Limited YUV in particular
requires relatively non-obvious values, and filling a frame with
repeating 0 bytes is disallowed in some contexts. With component sizes
larger than 8 or packed YUV, this can become relatively complicated. So
having a generic function for this seems helpful.

In order to handle the complex cases in a generic way without destroying
performance, this code attempts to compute a black pixel, and then uses
that value to clear the image data quickly by using a function like
memset.

Common cases like yuv410p10 or rgba can't be handled with a simple
memset, so there is some code to fill memory with 2/4/8 byte patterns.
For the remaining cases, a generic slow fallback is used.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2 years agolavc, lavu: move frame cropping to a convenience function
wm4 [Sat, 22 Jul 2017 21:05:13 +0000 (23:05 +0200)]
lavc, lavu: move frame cropping to a convenience function

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2 years agormdec: add missing brackets to compound statement
Sean McGovern [Tue, 25 Jul 2017 22:04:32 +0000 (18:04 -0400)]
rmdec: add missing brackets to compound statement

Accidentally left out of 95ce02b35d3d1bb16111031df1d82a6e4d894d36.

2 years agolavf/vf_deinterlace_qsv: Enable the qsv deinterlace vpp
Huang, Zhengxu [Thu, 20 Jul 2017 08:16:44 +0000 (16:16 +0800)]
lavf/vf_deinterlace_qsv: Enable the qsv deinterlace vpp

The current qsv deinterlace module does not work at all because MSDK needs user to pass
extra parameters to enable hint functions,such as denoise,deinterlace,composition and so on.

Usage:-hwaccel qsv -r 25 -c:v h264_qsv -i in -vf deinterlace_qsv=bob -b 2M
      -maxrate 3M -c:v h264_qsv -y out.h264

Signed-off-by: ChaoX A Liu <chaox.a.liu@gmail.com>
Signed-off-by: Zhengxu Huang <zhengxu.maxwell@gmail.com>
Signed-off-by: Andrew Zhang <huazh407@gmail.com>
Change-Id: I9e7ddcf884f2788c2820f6c98affacfb9d8f3287
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
2 years agolibavcodec/mjpeg_qsv: Add QSV MJPEG encoder
Huang, Zhengxu [Fri, 21 Jul 2017 04:12:44 +0000 (12:12 +0800)]
libavcodec/mjpeg_qsv: Add QSV MJPEG encoder

usage:
-hwaccel qsv -c:v h264_qsv -i in -c:v mjpeg_qsv -global_quality 80 -f
mjpeg out

Signed-off-by: ChaoX A Liu <chaox.a.liu@gmail.com>
Signed-off-by: Zhengxu Huang <zhengxu.maxwell@gmail.com>
Signed-off-by: Andrew Zhang <huazh407@gmail.com
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
2 years agolavf: allow avformat_close_input() with NULL
wm4 [Sun, 16 Jul 2017 10:43:09 +0000 (12:43 +0200)]
lavf: allow avformat_close_input() with NULL

This is consistent with how other destructors behave.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2 years agodxva: DXVA2_ModeHEVC_VLD_Main10 does not support Main
wm4 [Mon, 10 Jul 2017 13:59:38 +0000 (15:59 +0200)]
dxva: DXVA2_ModeHEVC_VLD_Main10 does not support Main

This mode apparently does not support decoding of HEVC Main (8 bit).
With D3D11 and Intel drivers on Windows 10 I get green corruption, while
using DXVA2_ModeHEVC_VLD_Main works.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2 years agocaf: add an Opus tag
Anton Khirnov [Sat, 1 Jul 2017 08:49:58 +0000 (10:49 +0200)]
caf: add an Opus tag

CC: libav-stable@libav.org
2 years agohevc: Make sure to update the current frame transfer characteristic
Vittorio Giovara [Thu, 20 Jul 2017 12:43:53 +0000 (14:43 +0200)]
hevc: Make sure to update the current frame transfer characteristic

Otherwise the first decoded frame will still be tagged with the
original transfer instead of the alternative one.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2 years agormdec: don't ignore the return value of av_get_packet()
Sean McGovern [Wed, 12 Jul 2017 23:45:46 +0000 (19:45 -0400)]
rmdec: don't ignore the return value of av_get_packet()

2 years agobuild: Add feature test macros for glibc 2.19+
Diego Biurrun [Sat, 8 Jul 2017 11:18:39 +0000 (13:18 +0200)]
build: Add feature test macros for glibc 2.19+

glibc introduced _DEFAULT_SOURCE in version 2.19 to replace _BSD_SOURCE and
_SVID_SOURCE, which were deprecated in version 2.20. Add _DEFAULT_SOURCE
where the latter two are used to be forwards-compatible and avoid warnings
about the use of deprecated definitions.

2 years agoflac: Use a local cache for decode_residual()
Luca Barbato [Sat, 29 Apr 2017 02:15:32 +0000 (02:15 +0000)]
flac: Use a local cache for decode_residual()

About an additional 4% speedup.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2 years agoflac: Postpone unlikely condition checks
Luca Barbato [Sat, 29 Apr 2017 02:15:31 +0000 (02:15 +0000)]
flac: Postpone unlikely condition checks

About 2% speedup on gcc-6.3.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2 years agoflac: Convert to the new bitstream reader
Alexandra Hájková [Sat, 29 Apr 2017 02:15:30 +0000 (02:15 +0000)]
flac: Convert to the new bitstream reader

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2 years agobitstream: Avoid undefined behavior in bitstream_skip()
Luca Barbato [Sat, 8 Jul 2017 19:04:44 +0000 (21:04 +0200)]
bitstream: Avoid undefined behavior in bitstream_skip()

Do not use skip_remaining() to fully wipe the cache, as this could do
a 64-bit shift of a 64-bit variable which is undefined behavior in C.
Instead set the related variables to zero directly.

Thanks to Uoti for pointing out the problem.

CC: libav-stable@libav.org
2 years agobink: Split read_dct_coeffs()
Diego Biurrun [Wed, 5 Jul 2017 13:03:56 +0000 (15:03 +0200)]
bink: Split read_dct_coeffs()

This works around type aliasing violations and related warnings.
Also add some missing error checking.

2 years agofate: Add cinepak encoder vsynth tests
Diego Biurrun [Tue, 27 Jun 2017 22:27:19 +0000 (00:27 +0200)]
fate: Add cinepak encoder vsynth tests

2 years agocinepakenc: misc small changes
Diego Biurrun [Tue, 27 Jun 2017 22:27:18 +0000 (00:27 +0200)]
cinepakenc: misc small changes

Avoid anonymously typedeffed structs and enums, drop an unused context member,
fix a small wording mishap, sizeof(type) ---> sizeof(*variable), drop a
needlessly verbose log message, use av_malloc_array() where appropriate.

2 years agocinepakenc: K&R formatting cosmetics
Diego Biurrun [Tue, 27 Jun 2017 22:27:17 +0000 (00:27 +0200)]
cinepakenc: K&R formatting cosmetics

2 years agocinepakenc: Stop using AVPicture
Timothy Gu [Tue, 27 Jun 2017 22:27:15 +0000 (00:27 +0200)]
cinepakenc: Stop using AVPicture

2 years agocinepakenc: Drop broken debug code
Diego Biurrun [Tue, 27 Jun 2017 22:27:14 +0000 (00:27 +0200)]
cinepakenc: Drop broken debug code

2 years agocinepakenc: add option handling for flexibility
addr-see-the-website@aetey.se [Tue, 27 Jun 2017 22:27:13 +0000 (00:27 +0200)]
cinepakenc: add option handling for flexibility

Now it is possible to adjust compression speed vs R/D when needed
and also skip vintage player compatibility at will.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2 years agocinepakenc: fixes and improvements
addr-see-the-website@aetey.se [Tue, 27 Jun 2017 22:27:12 +0000 (00:27 +0200)]
cinepakenc: fixes and improvements

version 2013-02-08 Rl
- fixes/optimization in multistrip encoding and codebook size choice,
  quality/bitrate is now better than that of the binary proprietary encoder

version 2013-02-12 Rl
- separated codebook training sets, avoided the transfer of wasted bytes,
  which yields both better quality and smaller files
- now using the correct colorspace (TODO: move conversion to libswscale)

version 2013-02-14 Rl "Valentine's Day" version:
- made strip division more robust
- minimized bruteforcing the number of strips,
  (costs some R/D but speeds up compession a lot), the heuristic
  assumption is that score as a function of the number of strips has
  one wide minimum which moves slowly, of course not fully true
- simplified codebook generation,
  the old code was meant for other optimizations than we actually do
- optimized the codebook generation / error estimation for MODE_MC

version 2013-04-28 Rl
- bugfixed codebook optimization logic

version 2014-01-20 Rl
- made the encoder compatible with vintage decoders
  and added some yet unused code for possible future
  incremental codebook updates
- fixed a small memory leak

version 2014-01-21 Rl
- believe it or not, now we get even smaller files, with better quality
  (which means I missed an optimization earlier :)

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2 years agoAdd Cinepak encoder
Tomas Härdin [Tue, 27 Jun 2017 22:27:11 +0000 (00:27 +0200)]
Add Cinepak encoder

With permission of Tomas Härdin applied by Rl aetey.se

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2 years agoos_support: Use HAVE_UWP instead of manually checking WINAPI_FAMILY
Martin Storsjö [Wed, 5 Jul 2017 09:36:03 +0000 (12:36 +0300)]
os_support: Use HAVE_UWP instead of manually checking WINAPI_FAMILY

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agod3d11va: Check WINAPI_FAMILY instead of HAVE_LOADLIBRARY
Martin Storsjö [Tue, 4 Jul 2017 17:03:00 +0000 (20:03 +0300)]
d3d11va: Check WINAPI_FAMILY instead of HAVE_LOADLIBRARY

If using the winstore compat library, a fallback LoadLibrary
function does exist, that only calls LoadPackagedLibrary though
(which doesn't work for dynamically loading d3d11 DLLs).

Therefore explicitly check the targeted API family instead.

Make this check a reusable HAVE_* component which other parts
of the libraries can check when necessary as well.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agolavf: Remove codec_tag from dashenc and smoothstreamingenc
Martin Storsjö [Fri, 30 Jun 2017 09:49:49 +0000 (12:49 +0300)]
lavf: Remove codec_tag from dashenc and smoothstreamingenc

Currently, the tags enforced and set on the segmenter muxer level
mismatch what the mp4/ismv muxer uses (since 713efb2c0d013).

Skip the codec_tag altogether here, to let the user (try to) set
whichever codec/tag is preferred; the individual chained muxer will
reject invalid codecs anyway.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 years agohevc: Add support for alternative transfer characterics SEI
Vittorio Giovara [Fri, 9 Jun 2017 21:27:22 +0000 (17:27 -0400)]
hevc: Add support for alternative transfer characterics SEI

The use of this SEI is for backward compatibility in HLG HDR systems:
older devices that cannot interpret the "arib-std-b67" transfer will
get the compatible transfer (usually bt709 or bt2020) from the VUI,
while newer devices that can interpret HDR will read the SEI and use
its value instead.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2 years agodvbsubdec: Free subrect memory on allocation error
Vittorio Giovara [Tue, 13 Jun 2017 15:35:16 +0000 (11:35 -0400)]
dvbsubdec: Free subrect memory on allocation error

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2 years agodvbsubdec: Fixed segfault when decoding subtitles
Lorenz Brun [Fri, 21 Oct 2016 20:51:37 +0000 (22:51 +0200)]
dvbsubdec: Fixed segfault when decoding subtitles

This fixes a segfault (originally found in Movian, but traced to libav)
when decoding subtitles because only an array of rects is allocated,
but not the actual structs it contains. The issue was probably
introduced in commit 2383323 where the loop to allocate the rects in
the array was thrown away.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2 years agohwframe: Allow hwaccel frame allocators to align surface sizes
Anton Khirnov [Thu, 22 Jun 2017 18:05:12 +0000 (20:05 +0200)]
hwframe: Allow hwaccel frame allocators to align surface sizes

Hardware accelerated decoding generally uses AVHWFramesContext for pool
allocation of hardware surfaces. These are setup to allocate surfaces
aligned to hardware and hwaccel API requirements. Due to the
architecture, av_hwframe_get_buffer() will return AVFrames with
the dimensions set to the aligned sizes.

This causes some decoders (like hevc) return these aligned size as
final frame size, instead of cropping them to the video's actual
dimensions. To make sure this doesn't happen, crop the frame to the
size the decoder expects when ff_get_buffer() is called.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>