ffmpeg.git
2 months agoavformat/utils: Use av_sat_add64() when updating start_time by skip_samples.
Dale Curtis [Thu, 14 May 2020 21:29:15 +0000 (14:29 -0700)]
avformat/utils: Use av_sat_add64() when updating start_time by skip_samples.

Avoids overflow from fuzzed skip_samples values.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoUse av_sat_sub64() when updating pts by duration.
Dale Curtis [Thu, 14 May 2020 21:33:55 +0000 (14:33 -0700)]
Use av_sat_sub64() when updating pts by duration.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/adpcm_data: extend ff_adpcm_ima_cunning_index_table
Michael Niedermayer [Wed, 27 May 2020 22:05:16 +0000 (00:05 +0200)]
avcodec/adpcm_data: extend ff_adpcm_ima_cunning_index_table

Fixes: overread by 1
Fixes: 21880/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_CUNNING_fuzzer-5717917221257216.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agolavfi/vulkan: use av_get_random_seed instead of rand
Lynne [Fri, 29 May 2020 12:10:58 +0000 (13:10 +0100)]
lavfi/vulkan: use av_get_random_seed instead of rand

We need at least a few bits of entropy to determine the start index of each
queue, in order to let filters run in parallel as much as possible, and
rand() is not thread safe and disrupts any external API's usage of rand,
so instead replace it with av_get_random_seed.
While it has more overhead than rand, we only run it once per filter upon init.

2 months agoavformat/oggdec: Avoid duplicating buffer when adding side-data
Andreas Rheinhardt [Sat, 23 May 2020 11:06:04 +0000 (13:06 +0200)]
avformat/oggdec: Avoid duplicating buffer when adding side-data

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/img2dec: Avoid duplicating buffer when adding side-data
Andreas Rheinhardt [Sat, 23 May 2020 11:02:54 +0000 (13:02 +0200)]
avformat/img2dec: Avoid duplicating buffer when adding side-data

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/concatdec: Avoid duplicating buffer when adding side-data
Andreas Rheinhardt [Sat, 23 May 2020 10:57:29 +0000 (12:57 +0200)]
avformat/concatdec: Avoid duplicating buffer when adding side-data

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/flvdec: Avoid duplicating extradata when adding side-data
Andreas Rheinhardt [Sat, 23 May 2020 10:52:17 +0000 (12:52 +0200)]
avformat/flvdec: Avoid duplicating extradata when adding side-data

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/hlsenc, hlsplaylist: Cosmetics
Andreas Rheinhardt [Mon, 25 May 2020 18:33:40 +0000 (20:33 +0200)]
avformat/hlsenc, hlsplaylist: Cosmetics

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/hlsenc: Avoid duplicating strings when parsing
Andreas Rheinhardt [Mon, 25 May 2020 17:22:19 +0000 (19:22 +0200)]
avformat/hlsenc: Avoid duplicating strings when parsing

Up until now, the HLS muxer uses av_strtok() to split an input string
controlling parameters of the VariantStreams and then duplicates
parts of this string containing parameters such as the language or the
name of the VariantStream. But these parts are proper zero-terminated
strings of their own that are never modified lateron, so one can simply
use the substring as-is without creating a copy. This commit implements
this.

The same also happened for the string controlling the closed caption
groups.

Furthermore, add const to indicate that the pointers to these substrings
are not used to modify them and also to indicate that these strings are
not allocated on their own.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/hlsenc: Don't unnecessarily duplicate baseurl string
Andreas Rheinhardt [Mon, 25 May 2020 16:52:57 +0000 (18:52 +0200)]
avformat/hlsenc: Don't unnecessarily duplicate baseurl string

Up until now, the HLS muxer duplicated a string for every VariantStream,
although neither the original nor the copies are ever modified. So use
the original directly and stop copying.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/hlsplaylist: Add const where appropriate
Andreas Rheinhardt [Mon, 25 May 2020 17:11:34 +0000 (19:11 +0200)]
avformat/hlsplaylist: Add const where appropriate

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agolavf/mpegtsenc: misc style fixes
Jun Zhao [Tue, 26 May 2020 16:49:50 +0000 (00:49 +0800)]
lavf/mpegtsenc: misc style fixes

commit 32aeba12755 missed coding style fix.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2 months agolavc/libx264: misc style fixes
Jun Zhao [Tue, 26 May 2020 16:42:12 +0000 (00:42 +0800)]
lavc/libx264: misc style fixes

commit 4ed3a01d717 missed coding style fix.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2 months agodoc: add dia_size option documentation
Limin Wang [Wed, 27 May 2020 04:18:52 +0000 (12:18 +0800)]
doc: add dia_size option documentation

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2 months agodnn-layer-mathunary-test: add unit test for abs
Ting Fu [Mon, 25 May 2020 14:46:27 +0000 (22:46 +0800)]
dnn-layer-mathunary-test: add unit test for abs

Signed-off-by: Ting Fu <ting.fu@intel.com>
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
2 months agodnn_backend_native_layer_mathunary: add abs support
Ting Fu [Mon, 25 May 2020 14:46:26 +0000 (22:46 +0800)]
dnn_backend_native_layer_mathunary: add abs support

more math unary operations will be added here

It can be tested with the model file generated with below python scripy:

import tensorflow as tf
import numpy as np
import imageio

in_img = imageio.imread('input.jpeg')
in_img = in_img.astype(np.float32)/255.0
in_data = in_img[np.newaxis, :]

x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in')
x1 = tf.subtract(x, 0.5)
x2 = tf.abs(x1)
y = tf.identity(x2, name='dnn_out')

sess=tf.Session()
sess.run(tf.global_variables_initializer())

graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, ['dnn_out'])
tf.train.write_graph(graph_def, '.', 'image_process.pb', as_text=False)

print("image_process.pb generated, please use \
path_to_ffmpeg/tools/python/convert.py to generate image_process.model\n")

output = sess.run(y, feed_dict={x: in_data})
imageio.imsave("out.jpg", np.squeeze(output))

Signed-off-by: Ting Fu <ting.fu@intel.com>
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
2 months agoavcodec/decode: fix decoding when frames are allocated using AVHWAccel.alloc_frame()
James Almer [Thu, 28 May 2020 02:10:04 +0000 (23:10 -0300)]
avcodec/decode: fix decoding when frames are allocated using AVHWAccel.alloc_frame()

Regression since a1133db30ef07896afd96f067e5c51531a4e85ab

Found-by: comex <comexk@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2 months agotools/target_dec_fuzzer: Adjust max_pixels for AV_CODEC_ID_HAP
Michael Niedermayer [Sun, 15 Mar 2020 19:26:27 +0000 (20:26 +0100)]
tools/target_dec_fuzzer: Adjust max_pixels for AV_CODEC_ID_HAP

Fixes: Timeout (170sec -> 6sec)
Fixes: 20956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5713643025203200

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agotools/target_dec_fuzzer: Reduce maxpixels for HEVC
Michael Niedermayer [Sun, 19 Apr 2020 21:54:08 +0000 (23:54 +0200)]
tools/target_dec_fuzzer: Reduce maxpixels for HEVC

high resolutions with only small blocks appear to be rather
slow with the fuzzer + sanitizers.
A solution which makes this run faster is welcome.

Fixes: Timeout (did not wait -> 17sec)
Fixes: 21006/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6002552539971584

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agotools/target_dec_fuzzer: Do not test AV_CODEC_FLAG2_FAST with AV_CODEC_ID_H264
Michael Niedermayer [Sun, 15 Mar 2020 16:59:49 +0000 (17:59 +0100)]
tools/target_dec_fuzzer: Do not test AV_CODEC_FLAG2_FAST with AV_CODEC_ID_H264

This combination skips allocating large padding which can read out of array

Fixes: 20978/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5746381832847360

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat/mpegts: use get_packet_size in mpegts_resync for determining raw_packet_size
Marton Balint [Wed, 20 May 2020 19:44:39 +0000 (21:44 +0200)]
avformat/mpegts: use get_packet_size in mpegts_resync for determining raw_packet_size

The old resync logic had some bugs, for example the packet size could stuck
into 192 bytes, because pos47_full was not updated for every packet, and for
unseekable inputs the resync logic simply skipped some 0x47 sync bytes,
therefore the calculated distance between sync bytes was a multiple of 188
bytes.

AVIO only buffers a single packet (for UDP/mpegts, that usually means 1316
bytes), so for every ten consecutive 188-byte MPEGTS packets there was always a
seek failure, and that caused the old code to not find the 188 byte pattern
across 10 consecutive packets.

This patch changes the custom logic to the one which is used when probing to
determine the packet size. This was already proposed as a FIXME a long time
ago...

2 months agoavcodec/adpcmenc: fix formatting
Zane van Iperen [Sat, 16 May 2020 11:53:40 +0000 (11:53 +0000)]
avcodec/adpcmenc: fix formatting

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec: add adpcm_ima_ssi encoder
Zane van Iperen [Sat, 16 May 2020 11:53:36 +0000 (11:53 +0000)]
avcodec: add adpcm_ima_ssi encoder

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/adpcmenc: add capabilities argument to ADPCM_ENCODER()
Zane van Iperen [Sat, 16 May 2020 11:53:32 +0000 (11:53 +0000)]
avcodec/adpcmenc: add capabilities argument to ADPCM_ENCODER()

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoUse gcc/clang builtins for av_sat_(add|sub)_64_c if available.
Dale Curtis [Fri, 1 May 2020 17:20:43 +0000 (10:20 -0700)]
Use gcc/clang builtins for av_sat_(add|sub)_64_c if available.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavformat: fix apm makefile dependency
Zane van Iperen [Tue, 26 May 2020 10:57:49 +0000 (10:57 +0000)]
avformat: fix apm makefile dependency

Uses ff_get_wav_header() in riffdec.c

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2 months agoavcodec/h264dec: Add FF_CODEC_CAP_INIT_CLEANUP
Limin Wang [Wed, 27 May 2020 04:35:28 +0000 (12:35 +0800)]
avcodec/h264dec: Add FF_CODEC_CAP_INIT_CLEANUP

then ff_h264_free_tables() and h264_decode_end() can be removed
in h264_decode_init() if it's failed.

The FF_CODEC_CAP_INIT_CLEANUP flag is need for single thread, For multithread,
it'll be cleanup still by AV_CODEC_CAP_FRAME_THREADS flag if have.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2 months agoavcodec: Add FF_CODEC_CAP_INIT_CLEANUP
Limin Wang [Wed, 27 May 2020 03:45:49 +0000 (11:45 +0800)]
avcodec: Add FF_CODEC_CAP_INIT_CLEANUP

then ff_mpv_encode_end() will be unnecessary in ff_mpv_encode_init()
if it's failed.

The FF_CODEC_CAP_INIT_CLEANUP flag is need for single thread, For multithread,
it'll be cleanup still by AV_CODEC_CAP_FRAME_THREADS flag if have.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2 months agoavcodec/adpcmenc: Add FF_CODEC_CAP_INIT_CLEANUP
Limin Wang [Fri, 15 May 2020 15:25:59 +0000 (23:25 +0800)]
avcodec/adpcmenc: Add FF_CODEC_CAP_INIT_CLEANUP

then we can remove adpcm_encode_close() in adpcm_encode_init() if have failed.
so the goto error lable will be unnecessary and can be removed later.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2 months agoconfigure: NotchLC depends on lzf
Paul B Mahol [Wed, 27 May 2020 13:22:35 +0000 (15:22 +0200)]
configure: NotchLC depends on lzf

2 months agoavformat/mpegtsenc: cosmetic
Limin Wang [Wed, 20 May 2020 12:22:42 +0000 (20:22 +0800)]
avformat/mpegtsenc: cosmetic

Merge the short lines after the last commit

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2 months agoavformat/mpegtsenc: simplify code by using OFFSET() and ENC macros
Limin Wang [Wed, 20 May 2020 12:16:53 +0000 (20:16 +0800)]
avformat/mpegtsenc: simplify code by using OFFSET() and ENC macros

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2 months agoavcodec.h: move avcodec_get_{type,name} to codec_id.h
Anton Khirnov [Mon, 25 May 2020 13:06:14 +0000 (15:06 +0200)]
avcodec.h: move avcodec_get_{type,name} to codec_id.h

2 months agoavcodec.h: split AVCodec API into its own header
Anton Khirnov [Mon, 25 May 2020 13:04:20 +0000 (15:04 +0200)]
avcodec.h: split AVCodec API into its own header

2 months agodoc/APIchanges: fix typo in version number
Anton Khirnov [Fri, 22 May 2020 12:45:05 +0000 (14:45 +0200)]
doc/APIchanges: fix typo in version number

2 months agolavf/mp3dec: don't adjust start time; packets are not adjusted.
Dale Curtis [Thu, 23 Apr 2020 23:18:18 +0000 (16:18 -0700)]
lavf/mp3dec: don't adjust start time; packets are not adjusted.

7546ac2fee4 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>
2 months agolavc/vaapi_hevc: add missing max_8bit_constraint_flag
Linjie Fu [Tue, 12 May 2020 13:46:40 +0000 (21:46 +0800)]
lavc/vaapi_hevc: add missing max_8bit_constraint_flag

This is accidentally missed while rebasing.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2 months agolavc/hevc_refs: Fix the logic of find_ref_idx()
Xu Guangxin [Tue, 12 May 2020 13:44:21 +0000 (21:44 +0800)]
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>
2 months agolavc/hevc: Add poc_msb_present filed in LongTermRPS
Xu Guangxin [Tue, 12 May 2020 13:42:49 +0000 (21:42 +0800)]
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>
2 months agoavfilter/vf_blend: add support for float formats
Paul B Mahol [Tue, 26 May 2020 21:07:36 +0000 (23:07 +0200)]
avfilter/vf_blend: add support for float formats

2 months agomfenc: Avoid including codecapi.h, fix building in UWP mode with clang
Martin Storsjö [Mon, 25 May 2020 10:26:04 +0000 (13:26 +0300)]
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>
2 months agomfenc: Remove an unused include
Martin Storsjö [Mon, 25 May 2020 10:18:03 +0000 (13:18 +0300)]
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>
2 months agofftools/ffmpeg: add new abort_on flag which aborts if there is a stream which receive...
Marton Balint [Tue, 12 May 2020 22:06:08 +0000 (00:06 +0200)]
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>
2 months agohwcontext_vulkan: fix uploading and downloading from/to flipped images
Lynne [Tue, 26 May 2020 11:01:54 +0000 (12:01 +0100)]
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.

2 months agoopusenc: add apply_phase_inv option
Lynne [Mon, 25 May 2020 13:41:33 +0000 (14:41 +0100)]
opusenc: add apply_phase_inv option

By popular request.
Does the same as in libopusenc.

2 months agolavfi/vulkan: fix queue counts and set indices
Lynne [Mon, 25 May 2020 14:37:17 +0000 (15:37 +0100)]
lavfi/vulkan: fix queue counts and set indices

2 months agolavfi/vulkan: use dedicated allocation for buffers when necessary
Lynne [Mon, 25 May 2020 14:36:41 +0000 (15:36 +0100)]
lavfi/vulkan: use dedicated allocation for buffers when necessary

2 months agohwcontext_vulkan: check for dedicated allocation when mapping from drm/vaapi
Lynne [Mon, 25 May 2020 19:57:16 +0000 (20:57 +0100)]
hwcontext_vulkan: check for dedicated allocation when mapping from drm/vaapi

Some vendors (AMD) require dedicated allocation to be used for all imported
images.

2 months agohwcontext_vulkan: initialize the frames context when deriving
Lynne [Mon, 25 May 2020 19:56:00 +0000 (20:56 +0100)]
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.

2 months agohwcontext_vulkan: use dedicated allocation for buffers when necessary
Lynne [Tue, 26 May 2020 09:34:31 +0000 (10:34 +0100)]
hwcontext_vulkan: use dedicated allocation for buffers when necessary

2 months agohwcontext_vulkan: use host mapped buffers when uploading and downloading
Lynne [Sat, 23 May 2020 18:02:08 +0000 (19:02 +0100)]
hwcontext_vulkan: use host mapped buffers when uploading and downloading

Speeds up both use cases by 30%.

2 months agopngdec: add ability to check chunk CRC
Lynne [Thu, 7 Mar 2019 18:15:23 +0000 (18:15 +0000)]
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.

2 months agompegaudiodec_template: add ability to check CRC
Lynne [Wed, 6 Mar 2019 17:04:04 +0000 (17:04 +0000)]
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.

2 months agoapedec: add ability to check CRC
Lynne [Wed, 6 Mar 2019 11:01:01 +0000 (11:01 +0000)]
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.

2 months agoavutil/mem: Use max_alloc_size as-is
Andreas Rheinhardt [Thu, 21 May 2020 00:03:56 +0000 (02:03 +0200)]
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) 0ecca7a49f8e254c12a3a1de048d738bfbb614c6 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
da9b170c6f06184a5114dc66afb8385cd0ffff83 (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) 13dfce3d44f99a2d7df71aba8ae003d58db726f7 then increased 16 to 32 for
AVX, 6b4c0be5586acad3bbafd7d2dd02a8328a5ab632 replaced INT_MAX by
MAX_MALLOC_SIZE (which was of course defined to be INT_MAX) and
5a8e994287d8ef181c0a5eac537547d7059b4524 added max_alloc_size and made
it user-selectable.
d) 4fb311c804098d78e5ce5f527f9a9c37536d3a08 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>
2 months agoavformat/matroskadec: Beautify matroska_parse_laces()
Andreas Rheinhardt [Wed, 20 May 2020 19:24:34 +0000 (21:24 +0200)]
avformat/matroskadec: Beautify matroska_parse_laces()

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/oggparsevorbis: Error out on double init of vp
Michael Niedermayer [Sun, 19 Apr 2020 15:05:52 +0000 (17:05 +0200)]
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>
2 months agoavcodec/mediacodec_wrapper: use MediaFormat to probe frame color characteristics
Matthieu Bouron [Mon, 26 Aug 2019 13:15:05 +0000 (15:15 +0200)]
avcodec/mediacodec_wrapper: use MediaFormat to probe frame color characteristics

2 months agoavcodec/frame_thread_encoder: remove usage of avcodec_encode_video2()
James Almer [Fri, 15 May 2020 23:24:19 +0000 (20:24 -0300)]
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>
2 months agoavformat: Replace ffurl_close() by ffurl_closep() where appropriate
Andreas Rheinhardt [Fri, 3 Apr 2020 15:03:38 +0000 (17:03 +0200)]
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>
2 months agolibavformat/flacdec: Workaround for truncated metadata picture size
Mattias Wadman [Tue, 19 May 2020 09:27:11 +0000 (11:27 +0200)]
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 e447a4d112bcfee10126c54eb4481fa8712957c8
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:v:0 bmp -disposition:1 attached_pic -t 1 test.flac

Fixes ticket 6333

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2 months agofate: add tests for h264 and vp9 video enc parameters export
Anton Khirnov [Mon, 11 May 2020 15:06:11 +0000 (17:06 +0200)]
fate: add tests for h264 and vp9 video enc parameters export

2 months agoh264dec: support exporting QP tables through the AVVideoEncParams API
Anton Khirnov [Tue, 10 Mar 2020 17:26:00 +0000 (18:26 +0100)]
h264dec: support exporting QP tables through the AVVideoEncParams API

2 months agoavformat/id3v2: Remove unnecessary indirection
Andreas Rheinhardt [Tue, 19 May 2020 10:09:48 +0000 (12:09 +0200)]
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>
2 months agoavformat/id3v2: Avoid allocations for ID3v2ExtraMeta
Andreas Rheinhardt [Tue, 19 May 2020 09:43:48 +0000 (11:43 +0200)]
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>
2 months agoavformat/aiffenc: Don't forget chapters
Andreas Rheinhardt [Tue, 19 May 2020 04:10:27 +0000 (06:10 +0200)]
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 47ac344970f1d6ef149c4b8a883b68cdb15112c2 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>
2 months agoavcodec: move avcodec_flush_buffers from decode.c to utils.c
James Almer [Sat, 16 May 2020 22:17:13 +0000 (19:17 -0300)]
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>
2 months agolibavcodec/libvpxenc: Don't free user-provided AVPacket
Andreas Rheinhardt [Sat, 23 May 2020 10:13:26 +0000 (12:13 +0200)]
libavcodec/libvpxenc: Don't free user-provided AVPacket

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agolibavcodec/libmp3lame: Don't free user-provided AVPacket
Andreas Rheinhardt [Sat, 23 May 2020 10:11:30 +0000 (12:11 +0200)]
libavcodec/libmp3lame: Don't free user-provided AVPacket

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/libopusenc: Don't free user-provided AVPacket
Andreas Rheinhardt [Sat, 23 May 2020 09:40:23 +0000 (11:40 +0200)]
avcodec/libopusenc: Don't free user-provided AVPacket

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agomfenc: Fix building with clang in MSVC mode
Martin Storsjö [Sat, 23 May 2020 18:14:40 +0000 (21:14 +0300)]
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>
2 months agolavfi/vulkan: use all enabled queues in the queue family
Lynne [Wed, 13 May 2020 23:37:21 +0000 (00:37 +0100)]
lavfi/vulkan: use all enabled queues in the queue family

This should significantly improve the performance with certain
filterchains.

2 months agolavfi/vulkan: fix 2 minor memory leaks
Lynne [Thu, 14 May 2020 20:52:53 +0000 (21:52 +0100)]
lavfi/vulkan: fix 2 minor memory leaks

2 months agohwcontext_vulkan: move physical device feature discovery to device_init
Lynne [Fri, 15 May 2020 12:21:10 +0000 (13:21 +0100)]
hwcontext_vulkan: move physical device feature discovery to device_init

Otherwise custom vulkan device contexts won't work.

2 months agohwcontext_vulkan: split uploading and downloading contexts
Lynne [Thu, 14 May 2020 23:01:08 +0000 (00:01 +0100)]
hwcontext_vulkan: split uploading and downloading contexts

This allows us to speed up only-uploading or only-downloading use cases.

2 months agohwcontext_vulkan: set usage for DRM imports to the frames context usage
Lynne [Thu, 14 May 2020 23:21:51 +0000 (00:21 +0100)]
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.

2 months agohwcontext_vulkan: do not OR the user-specified usage with our default flags
Lynne [Thu, 14 May 2020 23:16:58 +0000 (00:16 +0100)]
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.

2 months agohwcontext_vulkan: actually use the frames exec context for prep/import/export
Lynne [Thu, 14 May 2020 22:37:14 +0000 (23:37 +0100)]
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.

2 months agohwcontext_vulkan: support user-provided pools
Lynne [Thu, 14 May 2020 22:59:22 +0000 (23:59 +0100)]
hwcontext_vulkan: support user-provided pools

If an external pool was provided we skipped all of frames init,
including the exec context.

2 months agohwcontext_vulkan: use all enabled queues for transfers, make uploads async
Lynne [Wed, 13 May 2020 23:28:00 +0000 (00:28 +0100)]
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.

2 months agohwcontext_vulkan: wrap ImageBufs into AVBufferRefs
Lynne [Thu, 14 May 2020 20:53:22 +0000 (21:53 +0100)]
hwcontext_vulkan: wrap ImageBufs into AVBufferRefs

Makes it easier to support multiple queues

2 months agohwcontext_vulkan: improve public header documentation
Lynne [Fri, 22 May 2020 18:54:00 +0000 (19:54 +0100)]
hwcontext_vulkan: improve public header documentation

Some things like using ImageLists were from a really old version that
still used multiplanar images.

2 months agohwcontext_vulkan: expose the enabled device features
Lynne [Wed, 13 May 2020 15:39:00 +0000 (16:39 +0100)]
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.

2 months agohwcontext_vulkan: expose the amount of queues for each queue family
Lynne [Wed, 13 May 2020 15:20:15 +0000 (16:20 +0100)]
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.

2 months agohwcontext: add av_hwdevice_ctx_create_derived_opts
Lynne [Wed, 20 May 2020 19:58:03 +0000 (20:58 +0100)]
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).

2 months agooggdec: remove the oggparsedaala subdemuxer
Lynne [Fri, 22 May 2020 09:30:41 +0000 (10:30 +0100)]
oggdec: remove the oggparsedaala subdemuxer

The Xiph foundation never standardized either Daala nor its mapping in Ogg,
and all files that were created are undecodable without knowledge of the
git hash.

2 months agolavfi: add untile filter.
Nicolas George [Thu, 16 Apr 2020 20:25:24 +0000 (22:25 +0200)]
lavfi: add untile filter.

2 months agolavfi/framesync: use av_gcd_q().
Nicolas George [Thu, 16 Apr 2020 19:36:35 +0000 (21:36 +0200)]
lavfi/framesync: use av_gcd_q().

2 months agolavu: add av_gcd_q().
Nicolas George [Thu, 16 Apr 2020 19:36:00 +0000 (21:36 +0200)]
lavu: add av_gcd_q().

2 months agolavfi/tests/formats: reindent.
Nicolas George [Thu, 16 Apr 2020 15:24:36 +0000 (17:24 +0200)]
lavfi/tests/formats: reindent.

2 months agolavfi/formats: remove dead code.
Nicolas George [Thu, 16 Apr 2020 14:55:36 +0000 (16:55 +0200)]
lavfi/formats: remove dead code.

Move the contents of all_channel_layouts.inc directly into
libavfilter/tests/formats.c.

2 months agolavfi/vf_crop: use ff_formats_pixdesc_filter().
Nicolas George [Thu, 16 Apr 2020 14:40:53 +0000 (16:40 +0200)]
lavfi/vf_crop: use ff_formats_pixdesc_filter().

2 months agolavfi/formats: add ff_formats_pixdesc_filter().
Nicolas George [Thu, 16 Apr 2020 14:40:40 +0000 (16:40 +0200)]
lavfi/formats: add ff_formats_pixdesc_filter().

2 months agoavformat/webm_chunk: Open AVIOContext before initializing sub-muxer
Andreas Rheinhardt [Sun, 17 May 2020 19:37:42 +0000 (21:37 +0200)]
avformat/webm_chunk: Open AVIOContext before initializing sub-muxer

The description of AVOutputFormat.init contains the statement that "this
method must not write output". Due to this, the webm_chunk muxer defers
opening the AVIOContext for the child muxer until avformat_write_header(),
i.e. there is no AVIOContext when the sub-muxer's avformat_init_output()
is called. But this violates the documentation of said function which
requires the AVFormatContext to have an already opened AVIOContext.
This commit fixes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/matroskaenc: Forward errors from avpriv_split_xiph_headers()
Andreas Rheinhardt [Sun, 17 May 2020 15:30:19 +0000 (17:30 +0200)]
avformat/matroskaenc: Forward errors from avpriv_split_xiph_headers()

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/matroskadec: Use proper context for logging
Andreas Rheinhardt [Sun, 17 May 2020 22:25:48 +0000 (00:25 +0200)]
avformat/matroskadec: Use proper context for logging

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavcodec/xiph: Return better error codes
Andreas Rheinhardt [Sun, 17 May 2020 16:04:52 +0000 (18:04 +0200)]
avcodec/xiph: Return better error codes

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/segment: Propagate disposition
Andreas Rheinhardt [Sat, 16 May 2020 21:31:08 +0000 (23:31 +0200)]
avformat/segment: Propagate disposition

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2 months agoavformat/segment: Access AVStream more directly
Andreas Rheinhardt [Sun, 17 May 2020 00:36:46 +0000 (02:36 +0200)]
avformat/segment: Access AVStream more directly

by storing s->streams[i] in a pointer instead of constantly using
s->streams[i]->...

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>