Commit Graph

98062 Commits

Author SHA1 Message Date
Dale Curtis 460132c998 lavf/mp3dec: don't adjust start time; packets are not adjusted.
7546ac2fee made it so that the start_time for mp3 files is
adjusted for skip_samples. However, this appears incorrect because
subsequent packet timestamps are not adjusted and skip_samples are
applied by deleting data from a packet without changing the timestamp.

E.g., we are told the start_time is ~25ms and we get a packet with a
timestamp of 0 that has had the skip_samples discarded from it. As such
rendering engines may incorrectly discard everything prior to the
25ms thinking that is where playback should officially start. Since the
samples were deleted without adjusting timestamps though, the true
start_time is still 0.

Other formats like MP4 with edit lists will adjust both the start
time and the timestamps of subsequent packets to avoid this issue.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2020-05-27 10:22:17 +02:00
Linjie Fu 7ae340111e lavc/vaapi_hevc: add missing max_8bit_constraint_flag
This is accidentally missed while rebasing.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-27 15:34:16 +08:00
Xu Guangxin 8b5ffaea64 lavc/hevc_refs: Fix the logic of find_ref_idx()
Currently find_ref_idx() would trigger 2 scans in DPB to find the
requested POC:
1. Firstly, ignore MSB of ref->poc and search for the requested POC;
2. Secondly, compare the entire ref->poc with requested POC;

For long term reference, we are able to only check LSB if MSB is not
presented(e.g. delta_poc_msb_present_flag == 0). However, for short
term reference, we should never ignore poc's MSB and it should be
kind of bit-exact. (Details in 8.3.2)

Otherwise this leads to decoding failures like:
[hevc @ 0x5638f4328600] Error constructing the frame RPS.
[hevc @ 0x5638f4328600] Error parsing NAL unit #2.
[hevc @ 0x5638f4338a80] Could not find ref with POC 21
Error while decoding stream #0:0: Invalid data found when processing input

Search the requested POC based on whether MSB is used, and avoid
the 2-times scan for DPB buffer. This benefits both native HEVC
decoder and integrated HW decoders.

Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-27 14:47:55 +08:00
Xu Guangxin 939a4db227 lavc/hevc: Add poc_msb_present filed in LongTermRPS
delta_poc_msb_present_flag is needed in find_ref_idx() to
indicate whether MSB of POC should be taken into account.

Details in 8.3.2.

Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-27 14:39:36 +08:00
Paul B Mahol d5f87f8567 avfilter/vf_blend: add support for float formats 2020-05-26 23:27:02 +02:00
Martin Storsjö 6c33a230e4 mfenc: Avoid including codecapi.h, fix building in UWP mode with clang
Including codecapi.h and uuids.h in UWP mode doesn't define all defines
properly, ending up with constructs that MSVC silently tolerates, but
that clang errors out on, like this:
    DEFINE_GUIDEX(CODECAPI_AVEncCommonFormatConstraint);

Just avoid including codecapi.h completely and hardcode the last few
enum values we use from there. We already use local versions of most
enums from there, due to older mingw-w64 headers being incomplete.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-27 00:19:32 +03:00
Martin Storsjö 869f655e2e mfenc: Remove an unused include
This might have been used originally for the decoder parts of
the MediaFoundation wrapper, which aren't merged yet.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-27 00:19:32 +03:00
Marton Balint efe7a59364 fftools/ffmpeg: add new abort_on flag which aborts if there is a stream which received no packets
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-26 21:50:50 +02:00
Lynne 64b12624e2
hwcontext_vulkan: fix uploading and downloading from/to flipped images
We want to copy the lowest amount of bytes per line, but while the buffer
stride is sanitized, the src/dst stride can be negative, and negative numbers
of bytes do not make a lot of sense.
2020-05-26 12:03:42 +01:00
Lynne 2502e13b07
opusenc: add apply_phase_inv option
By popular request.
Does the same as in libopusenc.
2020-05-26 10:52:12 +01:00
Lynne c0344cbfb0
lavfi/vulkan: fix queue counts and set indices 2020-05-26 10:52:11 +01:00
Lynne fb49d5c0b1
lavfi/vulkan: use dedicated allocation for buffers when necessary 2020-05-26 10:52:11 +01:00
Lynne bf056caf54
hwcontext_vulkan: check for dedicated allocation when mapping from drm/vaapi
Some vendors (AMD) require dedicated allocation to be used for all imported
images.
2020-05-26 10:52:11 +01:00
Lynne b6d4bedbb1
hwcontext_vulkan: initialize the frames context when deriving
Otherwise, the frames context is considered to be ready to handle
mapping, and it doesn't get initialized the normal way through
.frames_init.
2020-05-26 10:52:10 +01:00
Lynne 6bb718aabd
hwcontext_vulkan: use dedicated allocation for buffers when necessary 2020-05-26 10:52:10 +01:00
Lynne 4dcb50c58a
hwcontext_vulkan: use host mapped buffers when uploading and downloading
Speeds up both use cases by 30%.
2020-05-26 10:52:10 +01:00
Lynne b8d9bc2e87
pngdec: add ability to check chunk CRC
By default now, if AV_EF_CRCCHECK or AV_EF_IGNORE_ERR are enabled the decoder
will skip the chunk and carry on with the next one. This should make the
decoder able to decode more corrupt files because the functions which decode
individual chunks will very likely error out if fed invalid data and stop the
decoding of the entire image.
2020-05-26 10:23:13 +01:00
Lynne e69f407b52
mpegaudiodec_template: add ability to check CRC
A lot of files have CRC included.
The CRC only covers 34 bytes at most from the frame but it should still be
enough for some amount of error detection.
2020-05-26 10:23:11 +01:00
Lynne 1cc8eecd38
apedec: add ability to check CRC
The CRC flag is only signalled once every few minutes but CRC is still
always present so the patch uses the file version instead.
CRC on 24-bit files wants non-padded samples so skip such files.
Some corrupt samples may have been output before the final check
depending on the -max_samples setting.
2020-05-26 10:23:06 +01:00
Andreas Rheinhardt 731c775898 avutil/mem: Use max_alloc_size as-is
The size of a single allocation performed by av_malloc() or av_realloc()
is supposed to be bounded by max_alloc_size, which defaults to INT_MAX
and can be set by the user; yet currently this is not completely
honoured: The actual value used is max_alloc_size - 32. How this came
to be can only be understood historically:

a) 0ecca7a49f disallowed allocations
> INT_MAX. At that time the size parameter of av_malloc() was an
unsigned and the commentary added ("lets disallow possible ambiguous
cases") indicates that this was done as a precaution against calling the
functions with negative int values. Genuinely limiting the size of
allocations to INT_MAX doesn't seem to have been the intention given
that at this time the memalign hack introduced in commit
da9b170c6f (which when enabled increased
the size of allocations slightly so that one can return a correctly
aligned pointer that actually does not point to the beginning of the
allocated buffer) was already present.
b) Said memalign hack allocated 17 bytes more than actually desired, yet
allocating 16 bytes more is actually enough and so this was changed in
a9493601638b048c44751956d2360f215918800c; this commit also replaced
INT_MAX by INT_MAX - 16 (and made the limit therefore a limit on the size
of the allocated buffer), but kept the comment, although there is nothing
ambiguous about allocating (INT_MAX - 16)..INT_MAX.
c) 13dfce3d44 then increased 16 to 32 for
AVX, 6b4c0be558 replaced INT_MAX by
MAX_MALLOC_SIZE (which was of course defined to be INT_MAX) and
5a8e994287 added max_alloc_size and made
it user-selectable.
d) 4fb311c804 then dropped the memalign
hack, yet it kept the -32 (probably because the comment about ambiguous
cases was still present?), although it is no longer needed at all after
this commit. Therefore this commit removes it and uses max_alloc_size
directly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-26 06:47:31 +02:00
Andreas Rheinhardt 1fd8528c4e avformat/matroskadec: Beautify matroska_parse_laces()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-26 06:19:25 +02:00
Michael Niedermayer 2a3bbc0086 avformat/oggparsevorbis: Error out on double init of vp
Fixes: memleak
Fixes: 19949/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5743636058210304

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-26 00:45:27 +02:00
Matthieu Bouron 6268034b5d avcodec/mediacodec_wrapper: use MediaFormat to probe frame color characteristics 2020-05-25 18:07:45 +02:00
James Almer cde7818d9f avcodec/frame_thread_encoder: remove usage of avcodec_encode_video2()
Call the encoder's internal AVCodec.encode2() function instead.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-25 12:46:22 -03:00
Andreas Rheinhardt 82bf41f3ab avformat: Replace ffurl_close() by ffurl_closep() where appropriate
It avoids leaving dangling pointers behind in memory.

Also remove redundant checks for whether the URLContext to be closed is
already NULL.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-25 13:11:36 +02:00
Mattias Wadman af97c9865f libavformat/flacdec: Workaround for truncated metadata picture size
Some flac muxers write truncated metadata picture size if the picture
data do not fit in 24 bits. Detect this by truncting the size found inside
the picture block and if it matches the block size use it and read rest
of picture data.

This workaround is only for flac files and not ogg files with flac
METADATA_BLOCK_PICTURE comments and it can be disabled with strict level
above normal. Currently there is a 500MB limit on truncate size to protect
from large memory allocations.

The truncation bug in lavf flacenc was fixed in e447a4d112
but based on existing broken files other unknown flac muxers seems to truncate also.
Before the fix a broken flac file for reproduction could be generated with:
ffmpeg -f lavfi -i sine -f lavfi -i color=red:size=2400x2400 -map 0:0 -map 1:0 -c✌️0 bmp -disposition:1 attached_pic -t 1 test.flac

Fixes ticket 6333

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2020-05-25 11:59:45 +02:00
Anton Khirnov ea980d4162 fate: add tests for h264 and vp9 video enc parameters export 2020-05-25 11:59:45 +02:00
Anton Khirnov 064b875e89 h264dec: support exporting QP tables through the AVVideoEncParams API 2020-05-25 11:59:42 +02:00
Andreas Rheinhardt 37140ebd87 avformat/id3v2: Remove unnecessary indirection
ff_id3v2_parse_apic/chapters/priv/priv_dict all had a parameter
extra_meta of type ID3v2ExtraMeta ** as if the functions wanted to make
*extra_meta point to something else. But they don't, so just use an
ID3v2ExtraMeta *.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-25 07:06:44 +02:00
Andreas Rheinhardt f08853b284 avformat/id3v2: Avoid allocations for ID3v2ExtraMeta
Up until now, the ID3v2ExtraMeta structure (which is used when parsing
ID3v2 tags containing attached pictures, chapters etc.) contained a
pointer to separately allocated data that depended on the type of the
tag. Yet the difference of the sizes of the largest and the smallest of
these structures is fairly small, so that it is better to simply include
a union of all the possible types of tag-dependent structures in
ID3v2ExtraMeta. This commit implements this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-25 06:56:57 +02:00
Andreas Rheinhardt 1ebbb493cc avformat/aiffenc: Don't forget chapters
If the write_id3v2 option is set, the aiff muxer would write id3v2 tags
if there is global metadata or if there are attached pics to write.
Chapters are ignored in this check that precedes writing id3v2 tags.
Yet 47ac344970 added support for writing
chapters as id3v2 tags, so one should check for the existence of chapters,
too; otherwise the chapters would only be written in case there is
global metadata or an attached pic.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-25 05:38:15 +02:00
James Almer c7c8f141eb avcodec: move avcodec_flush_buffers from decode.c to utils.c
It's not a decoding exclusive function anymore.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-05-24 12:05:40 -03:00
Andreas Rheinhardt 26b4509690 libavcodec/libvpxenc: Don't free user-provided AVPacket
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 20:25:11 +02:00
Andreas Rheinhardt 7e6941e185 libavcodec/libmp3lame: Don't free user-provided AVPacket
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 20:25:08 +02:00
Andreas Rheinhardt b803993b6d avcodec/libopusenc: Don't free user-provided AVPacket
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 20:24:37 +02:00
Martin Storsjö 2a1fd3c84e mfenc: Fix building with clang in MSVC mode
Just including icodecapi.h + codecapi.h apparently misses some bits,
that MSVC doesn't complain about, but Clang does. Thus add a missing
header to the custom hacky include path (required for keeping
ICodecAPI visible when building in UWP mode, as it is intended to).

The issue in Windows SDK headers about ICodecAPI availability in
UWP/app mode has been reported upstream at
https://developercommunity.visualstudio.com/content/problem/1037125/icodecapi-not-visible-when-compiling-in-uwp-mode.html,
and later also filed in Feedback Hub (which can't be linked to
externally).

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-05-23 21:17:55 +03:00
Lynne 727cac88b8
lavfi/vulkan: use all enabled queues in the queue family
This should significantly improve the performance with certain
filterchains.
2020-05-23 19:07:50 +01:00
Lynne fac17fd46f
lavfi/vulkan: fix 2 minor memory leaks 2020-05-23 19:07:48 +01:00
Lynne dc9cf7f2cd
hwcontext_vulkan: move physical device feature discovery to device_init
Otherwise custom vulkan device contexts won't work.
2020-05-23 19:07:46 +01:00
Lynne d870e75c39
hwcontext_vulkan: split uploading and downloading contexts
This allows us to speed up only-uploading or only-downloading use cases.
2020-05-23 19:07:45 +01:00
Lynne 192997dd7f
hwcontext_vulkan: set usage for DRM imports to the frames context usage
They're nothing special, and there's no reason they should always use the
default flags.
2020-05-23 19:07:43 +01:00
Lynne 2c6366590e
hwcontext_vulkan: do not OR the user-specified usage with our default flags
Some users may need special formats that aren't available when the STORAGE
flag bit is set, which would result in allocations failing.
2020-05-23 19:07:41 +01:00
Lynne 98405422be
hwcontext_vulkan: actually use the frames exec context for prep/import/export
This was never actually used, likely due to confusion, as the device context
also had one used for uploads and downloads.
Also, since we're only using it for very quick image barriers (which are
practically free on all hardware), use the compute queue instead of the
transfer queue.
2020-05-23 19:07:39 +01:00
Lynne 3dd3d1b7fb
hwcontext_vulkan: support user-provided pools
If an external pool was provided we skipped all of frames init,
including the exec context.
2020-05-23 19:07:37 +01:00
Lynne c0b0807871
hwcontext_vulkan: use all enabled queues for transfers, make uploads async
This commit makes full use of the enabled queues to provide asynchronous
uploads of images (downloads remain synchronous).
For a pure uploading use cases, the performance gains can be significant.
2020-05-23 19:07:36 +01:00
Lynne cdb949a05c
hwcontext_vulkan: wrap ImageBufs into AVBufferRefs
Makes it easier to support multiple queues
2020-05-23 19:07:34 +01:00
Lynne c6df64035f
hwcontext_vulkan: improve public header documentation
Some things like using ImageLists were from a really old version that
still used multiplanar images.
2020-05-23 19:07:32 +01:00
Lynne ea1a7f6064
hwcontext_vulkan: expose the enabled device features
With this, the puzzle of making libplacebo, ffmpeg and any other Vulkan
API users interoperable is complete.
Users of both libraries can initialize one another's contexts without having
to create a new one.
2020-05-23 19:07:30 +01:00
Lynne 01c7539f30
hwcontext_vulkan: expose the amount of queues for each queue family
This, along with the next patch, are the last missing pieces to being
interoperable with libplacebo.
2020-05-23 19:07:29 +01:00
Lynne 2e08b39444
hwcontext: add av_hwdevice_ctx_create_derived_opts
This allows for users who derive devices to set options for the
new device context they derive.
The main use case of this is to allow users to enable extensions
(such as surface drawing extensions) in Vulkan while deriving from
the device their frames are on. That way, users don't need to write
any initialization code themselves, since the Vulkan spec invalidates
mixing instances, physical devices and active devices.
Apart from Vulkan, other hwcontexts ignore the opts argument since they
don't support options at all (or in VAAPI and OpenCL's case, options are
currently only used for device selection, which device_derive overrides).
2020-05-23 19:07:26 +01:00