ffmpeg.git
7 months agoavcodec/hevc_filter: remove unneeded headers
Limin Wang [Sat, 9 Oct 2021 14:00:50 +0000 (22:00 +0800)]
avcodec/hevc_filter: remove unneeded headers

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavcodec/hevcdec: remove unused code
Limin Wang [Sat, 9 Oct 2021 14:17:54 +0000 (22:17 +0800)]
avcodec/hevcdec: remove unused code

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavformat/rtpdec_rfc4175: add support for RANGE
Limin Wang [Mon, 11 Oct 2021 16:17:14 +0000 (00:17 +0800)]
avformat/rtpdec_rfc4175: add support for RANGE

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavformat/rtpdec_rfc4175: add support for colorimetry
Limin Wang [Mon, 11 Oct 2021 16:13:28 +0000 (00:13 +0800)]
avformat/rtpdec_rfc4175: add support for colorimetry

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavformat/rtpdec_rfc4175: add support for TCS
Limin Wang [Mon, 11 Oct 2021 16:08:42 +0000 (00:08 +0800)]
avformat/rtpdec_rfc4175: add support for TCS

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavformat/rtpdec_rfc4175: add support for exactframerate
Limin Wang [Mon, 11 Oct 2021 15:37:17 +0000 (23:37 +0800)]
avformat/rtpdec_rfc4175: add support for exactframerate

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavcodec/av1_vaapi: improve decode quality
Fei Wang [Tue, 12 Oct 2021 08:24:04 +0000 (16:24 +0800)]
avcodec/av1_vaapi: improve decode quality

- quantizer delta and matrix level specific.
- support loop filter delta.
- support use superres.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
7 months agoavcodec/av1_vaapi: enable segmentation features
Fei Wang [Tue, 12 Oct 2021 08:24:03 +0000 (16:24 +0800)]
avcodec/av1_vaapi: enable segmentation features

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
7 months agoavcodec/av1_vaapi: setting 2 output surface for film grain
Fei Wang [Tue, 12 Oct 2021 08:24:02 +0000 (16:24 +0800)]
avcodec/av1_vaapi: setting 2 output surface for film grain

VAAPI needs 2 output surface for film grain frame. One used for
reference and the other used for applying film grain and pushing
to downstream.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
7 months agoavcodec/vaapi: increase av1 decode pool size
Fei Wang [Tue, 12 Oct 2021 08:24:01 +0000 (16:24 +0800)]
avcodec/vaapi: increase av1 decode pool size

For film grain clip, vaapi_av1 decoder will cache additional 8
surfaces that will be used to store frames which apply film grain.
So increase the pool size by plus 8 to avoid leak of surface.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
7 months agoavcodec/dxva2_av1: fix global motion params
Tong Wu [Tue, 12 Oct 2021 08:24:00 +0000 (16:24 +0800)]
avcodec/dxva2_av1: fix global motion params

Defined in spec 5.9.24/5.9.25. Since function void
global_motion_params(AV1DecContext *s) already updates
gm type/params, the wminvalid parameter only need to get
the value from cur_frame.gm_invalid.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
7 months agoavcodec/av1_vaapi: add gm params valid check
Fei Wang [Tue, 12 Oct 2021 08:23:59 +0000 (16:23 +0800)]
avcodec/av1_vaapi: add gm params valid check

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
7 months agoavcodec/av1dec: support setup shear process
Fei Wang [Tue, 12 Oct 2021 08:23:58 +0000 (16:23 +0800)]
avcodec/av1dec: support setup shear process

Defined in spec 7.11.3.6/7.11.3.7.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
7 months agoavcodec/av1: extend some definitions in spec section 3
Fei Wang [Tue, 12 Oct 2021 08:23:57 +0000 (16:23 +0800)]
avcodec/av1: extend some definitions in spec section 3

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
7 months agocbs_av1: fix incorrect data type
Fei Wang [Tue, 12 Oct 2021 08:23:56 +0000 (16:23 +0800)]
cbs_av1: fix incorrect data type

Since order_hint_bits_minus_1 range is 0~7, cur_frame_hint can be
most 128. And similar return value for cbs_av1_get_relative_dist.
So if plus them and use int8_t for the result may lose its precision.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
7 months agoavfilter/opencl: Fix program_opencl for source code larger than 64kB
Tsutomu Seki [Thu, 6 May 2021 05:13:15 +0000 (14:13 +0900)]
avfilter/opencl: Fix program_opencl for source code larger than 64kB

The condition (pos < len) is always true and the
rest of the OpenCL program code would not be read, while
the maximum number of "rb" is "len - pos - 1", and then, the
maximum number of the "pos" is "len - 1".

Fixes: trac.ffmpeg.org/ticket/9217

7 months agoavfilter/vf_v360: add reset_rot option
Paul B Mahol [Sat, 16 Oct 2021 09:37:07 +0000 (11:37 +0200)]
avfilter/vf_v360: add reset_rot option

7 months agoavcodec/hevcdec: apply H.274 film grain
Niklas Haas [Tue, 28 Sep 2021 23:06:02 +0000 (01:06 +0200)]
avcodec/hevcdec: apply H.274 film grain

Similar in spirit and design to 66845cffc3bbb, but slightly simpler due
to the lack of interlaced frames in HEVC. See that commit for more
details.

For the seed value, since no specification for this appears to exist, I
semi-arbitrarily decided to base it off the POC id alone, since there's
no analog of the idr_pic_id in HEVC's I-frames. This design is stable
across remuxes and seeks, but changes for adjacent frames with a period
that's typically long enough not to be noticeable, which makes it
satisfy all of the requirements that a film grain seed should have.

Tested with and without threading, using a patch to insert film grain
metadata artificially (for lack of real files containing film grain).

7 months agoavformat/argo_asf: use title metadata when muxing
Zane van Iperen [Mon, 11 Oct 2021 11:20:28 +0000 (21:20 +1000)]
avformat/argo_asf: use title metadata when muxing

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
7 months agoavformat/argo_asf: pass name through as metadata
Zane van Iperen [Mon, 11 Oct 2021 11:21:35 +0000 (21:21 +1000)]
avformat/argo_asf: pass name through as metadata

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
7 months agoavformat/argo_asf: cleanup and NULL-terminate name field in header
Zane van Iperen [Tue, 12 Oct 2021 10:45:45 +0000 (20:45 +1000)]
avformat/argo_asf: cleanup and NULL-terminate name field in header

Preparation for metadata changes in the following patches. Saves
having to create an extra buffer.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
7 months agolibswscale/x86/rgb2rgb: add shuffle_bytes avx2
Wu Jianhua [Thu, 30 Sep 2021 01:56:09 +0000 (09:56 +0800)]
libswscale/x86/rgb2rgb: add shuffle_bytes avx2

Performance data(Less is better):
    shuffle_bytes_ssse3   3.64654
    shuffle_bytes_avx2    0.94288

Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
7 months agoavfilter/window_func: unify all filters win_func option that use this header
Paul B Mahol [Fri, 15 Oct 2021 08:41:01 +0000 (10:41 +0200)]
avfilter/window_func: unify all filters win_func option that use this header

7 months agox86/vf_lut3d: use three operand form for some instructions
James Almer [Thu, 14 Oct 2021 21:09:08 +0000 (18:09 -0300)]
x86/vf_lut3d: use three operand form for some instructions

Fixes compilation with old yasm.

Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavfilter/vf_fftfilt: export FFT arrays size
Paul B Mahol [Thu, 14 Oct 2021 18:22:20 +0000 (20:22 +0200)]
avfilter/vf_fftfilt: export FFT arrays size

7 months agoavfilter/vf_overlay: unbreak alpha composition with negative y and threads > 1
Paul B Mahol [Thu, 14 Oct 2021 17:58:56 +0000 (19:58 +0200)]
avfilter/vf_overlay: unbreak alpha composition with negative y and threads > 1

7 months agoavfilter/vf_fftfilt: Use av_clip_uint8
Martin Storsjö [Thu, 14 Oct 2021 06:29:08 +0000 (09:29 +0300)]
avfilter/vf_fftfilt: Use av_clip_uint8

The refactoring in 844890b1bc86316a38bc9e1dbf8ba0dd254307e3 caused
fate-source to point out that this could be av_clip_uintp2 (or
rather av_clip_uint8).

Signed-off-by: Martin Storsjö <martin@martin.st>
7 months agofate: update histogram test results
Paul B Mahol [Thu, 14 Oct 2021 10:20:57 +0000 (12:20 +0200)]
fate: update histogram test results

7 months agoavfilter/vf_histogram: add colors_mode option
Paul B Mahol [Thu, 14 Oct 2021 10:04:19 +0000 (12:04 +0200)]
avfilter/vf_histogram: add colors_mode option

7 months agoavfilter/vf_fftfilt: add gray formats >8 depth support
Paul B Mahol [Thu, 14 Oct 2021 08:08:01 +0000 (10:08 +0200)]
avfilter/vf_fftfilt: add gray formats >8 depth support

7 months agoavformat/westwood_vqa: Store VQFL codebook chunks
Pekka Väänänen [Wed, 22 Sep 2021 12:42:23 +0000 (15:42 +0300)]
avformat/westwood_vqa: Store VQFL codebook chunks

High color 15-bit VQA3 video streams contain high level chunks with
only codebook updates that shouldn't be considered new frames. Now
the demuxer stores a reference to such VQFL chunks and returns them
later along with a VQFR chunk with full frame data.

7 months agoavfilter/vf_fftfilt: add slice threading support
Paul B Mahol [Wed, 13 Oct 2021 22:57:03 +0000 (00:57 +0200)]
avfilter/vf_fftfilt: add slice threading support

7 months agoavfilter/vf_fftfilt: simplify bits/len calculation
Paul B Mahol [Wed, 13 Oct 2021 21:10:05 +0000 (23:10 +0200)]
avfilter/vf_fftfilt: simplify bits/len calculation

7 months agoavfilter: add xcorrelate video filter
Paul B Mahol [Thu, 7 Oct 2021 17:33:54 +0000 (19:33 +0200)]
avfilter: add xcorrelate video filter

7 months agoavfilter: add limitdiff video filter
Paul B Mahol [Thu, 7 Oct 2021 09:56:39 +0000 (11:56 +0200)]
avfilter: add limitdiff video filter

7 months agoavfilter/vf_palettegen: cosmetic changes
Soft Works [Sun, 26 Sep 2021 17:23:01 +0000 (17:23 +0000)]
avfilter/vf_palettegen: cosmetic changes

Signed-off-by: softworkz <softworkz@hotmail.com>
7 months agoavfilter/vf_palette(gen|use): support palettes with alpha
Soft Works [Wed, 13 Oct 2021 16:33:05 +0000 (18:33 +0200)]
avfilter/vf_palette(gen|use): support palettes with alpha

7 months agoavfilter/vf_lut3d: fix building with --disable-optimizations
Mark Reid [Mon, 11 Oct 2021 06:10:26 +0000 (23:10 -0700)]
avfilter/vf_lut3d: fix building with --disable-optimizations

7 months agoavcodec/videotoolboxenc: use goto end for memory cleanup
Limin Wang [Mon, 4 Oct 2021 03:59:21 +0000 (11:59 +0800)]
avcodec/videotoolboxenc: use goto end for memory cleanup

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavcodec/avs3_parser: Fix usage of init_get_bits() and use init_get_bits8()
Limin Wang [Fri, 8 Oct 2021 14:08:12 +0000 (22:08 +0800)]
avcodec/avs3_parser: Fix usage of init_get_bits() and use init_get_bits8()

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavcodec/audiotoolboxdec: Fix usage of init_get_bits() and use init_get_bits8()
Limin Wang [Fri, 8 Oct 2021 14:00:13 +0000 (22:00 +0800)]
avcodec/audiotoolboxdec: Fix usage of init_get_bits() and use init_get_bits8()

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavformat/dhav: make duration extraction more robust
Paul B Mahol [Wed, 13 Oct 2021 10:12:35 +0000 (12:12 +0200)]
avformat/dhav: make duration extraction more robust

7 months agoavformat/dhav: check if timestamp matches when seeking
Paul B Mahol [Wed, 13 Oct 2021 09:46:15 +0000 (11:46 +0200)]
avformat/dhav: check if timestamp matches when seeking

7 months agolibavformat/hls: correct indentation
Nachiket Tarate [Tue, 21 Sep 2021 18:42:28 +0000 (00:12 +0530)]
libavformat/hls: correct indentation

Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
7 months agolibavformat/hls: add support for decryption of HLS media segments encrypted using...
Nachiket Tarate [Tue, 21 Sep 2021 18:42:00 +0000 (00:12 +0530)]
libavformat/hls: add support for decryption of HLS media segments encrypted using SAMPLE-AES encryption method

Apple HTTP Live Streaming Sample Encryption:

https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption

Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
7 months agolibavformat/mov: add support for 'cens', 'cbc1' and 'cbcs' encryption schemes specifi...
Nachiket Tarate [Tue, 21 Sep 2021 18:41:31 +0000 (00:11 +0530)]
libavformat/mov: add support for 'cens', 'cbc1' and 'cbcs' encryption schemes specified in Common Encryption (CENC) standard

correct implementation of 'cenc' encryption scheme to support
decryption of partial cipher blocks at the end of subsamples

https://www.iso.org/standard/68042.html

Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
7 months agolibavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS...
Nachiket Tarate [Tue, 21 Sep 2021 18:40:58 +0000 (00:10 +0530)]
libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header

These will be used by HLS demuxer in case of sample decryption.

Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
7 months agoavcodec/gemdec: Use ff_set_dimensions()
Michael Niedermayer [Sun, 10 Oct 2021 21:31:13 +0000 (23:31 +0200)]
avcodec/gemdec: Use ff_set_dimensions()

Fixes: OOM
Fixes: 39798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GEM_fuzzer-5611636853964800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/utils: Ensure 8x8 alignment for ARGO in avcodec_align_dimensions2()
Michael Niedermayer [Sun, 10 Oct 2021 21:13:43 +0000 (23:13 +0200)]
avcodec/utils: Ensure 8x8 alignment for ARGO in avcodec_align_dimensions2()

Fixes: out of array access
Fixes: 39736/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARGO_fuzzer-4820016722214912

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/rtpdec_rfc4175: return the proper value
Limin Wang [Fri, 2 Jul 2021 12:02:44 +0000 (20:02 +0800)]
avformat/rtpdec_rfc4175: return the proper value

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavformat/rtpdec_rfc4175: Remove redundant initialization
Limin Wang [Fri, 2 Jul 2021 11:42:45 +0000 (19:42 +0800)]
avformat/rtpdec_rfc4175: Remove redundant initialization

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavformat/rtpdec_rfc4175: use av_get_bits_per_pixel()
Limin Wang [Fri, 2 Jul 2021 11:38:51 +0000 (19:38 +0800)]
avformat/rtpdec_rfc4175: use av_get_bits_per_pixel()

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavcodec/bitpacked: check av_buffer_ref result
Limin Wang [Sat, 2 Oct 2021 14:23:19 +0000 (22:23 +0800)]
avcodec/bitpacked: check av_buffer_ref result

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agolibavcodec/speexdec: fix memleak in error path
Zhao Zhili [Mon, 11 Oct 2021 07:39:39 +0000 (15:39 +0800)]
libavcodec/speexdec: fix memleak in error path

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoRevert "avfilter/vf_idet: reduce noisyness if the filter has been auto inserted"
Andreas Rheinhardt [Thu, 7 Oct 2021 10:53:49 +0000 (12:53 +0200)]
Revert "avfilter/vf_idet: reduce noisyness if the filter has been auto inserted"

This reverts commit 723c37d3b7b5555f23bfdfe3e5c3599543c06332.
Said commit was in preparation for auto-inserting the idet filter.
This has never happened; even if it did, the code is wrong, because
it segfaults if the filter instance doesn't have a name (having one
is not mandatory). Furthermore, it is documented for libavfilter to
not assign any semantics to the name, which this check violates.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavformat/libsrt: add snddropdelay parameter for srt
Limin Wang [Sun, 10 Oct 2021 15:03:26 +0000 (23:03 +0800)]
avformat/libsrt: add snddropdelay parameter for srt

Reviewed-by: "zhilizhao(赵志立)" <quinkblack@foxmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavfilter/vsrc_testsrc: add planar formats for haldclutsrc
Paul B Mahol [Mon, 11 Oct 2021 08:52:26 +0000 (10:52 +0200)]
avfilter/vsrc_testsrc: add planar formats for haldclutsrc

7 months agoavfilter/vf_lut3d: add x86-optimized tetrahedral interpolation
Mark Reid [Wed, 6 Oct 2021 03:58:30 +0000 (20:58 -0700)]
avfilter/vf_lut3d: add x86-optimized tetrahedral interpolation

I spotted an interesting pattern that I didn't see before that leads to the implementation being faster.
The bit shifting table I was using before is no longer needed, and was able to remove quite a few lines. 
I also add use of FMA on the AVX2 version.

f32 1920x1080 1 thread with prelut
c impl
1434012700 UNITS in lut3d->interp,       1 runs,      0 skips
1434035335 UNITS in lut3d->interp,       2 runs,      0 skips
1423615347 UNITS in lut3d->interp,       4 runs,      0 skips
1426268863 UNITS in lut3d->interp,       8 runs,      0 skips

sse2
905484420 UNITS in lut3d->interp,       1 runs,      0 skips
905659010 UNITS in lut3d->interp,       2 runs,      0 skips
915167140 UNITS in lut3d->interp,       4 runs,      0 skips
915834222 UNITS in lut3d->interp,       8 runs,      0 skips

avx
574794860 UNITS in lut3d->interp,       1 runs,      0 skips
581035090 UNITS in lut3d->interp,       2 runs,      0 skips
584116720 UNITS in lut3d->interp,       4 runs,      0 skips
581460290 UNITS in lut3d->interp,       8 runs,      0 skips

avx2
301698880 UNITS in lut3d->interp,       1 runs,      0 skips
301982880 UNITS in lut3d->interp,       2 runs,      0 skips
306962430 UNITS in lut3d->interp,       4 runs,      0 skips
305472025 UNITS in lut3d->interp,       8 runs,      0 skips

gbrap16 1920x1080 1 thread with prelut
c impl
1480894840 UNITS in lut3d->interp,       1 runs,      0 skips
1502922990 UNITS in lut3d->interp,       2 runs,      0 skips
1496114307 UNITS in lut3d->interp,       4 runs,      0 skips
1492554551 UNITS in lut3d->interp,       8 runs,      0 skips

sse2
980777180 UNITS in lut3d->interp,       1 runs,      0 skips
986121520 UNITS in lut3d->interp,       2 runs,      0 skips
986489840 UNITS in lut3d->interp,       4 runs,      0 skips
998832248 UNITS in lut3d->interp,       8 runs,      0 skips

avx
622212360 UNITS in lut3d->interp,       1 runs,      0 skips
622981160 UNITS in lut3d->interp,       2 runs,      0 skips
645396315 UNITS in lut3d->interp,       4 runs,      0 skips
641057075 UNITS in lut3d->interp,       8 runs,      0 skips

avx2
321336400 UNITS in lut3d->interp,       1 runs,      0 skips
321268920 UNITS in lut3d->interp,       2 runs,      0 skips
323459895 UNITS in lut3d->interp,       4 runs,      0 skips
324949967 UNITS in lut3d->interp,       8 runs,      0 skips

7 months agoavcodec/lagarith: return early on error
Paul B Mahol [Sun, 10 Oct 2021 17:39:11 +0000 (19:39 +0200)]
avcodec/lagarith: return early on error

Also return proper error values.

7 months agoavcodec: add native Speex decoder
Paul B Mahol [Mon, 13 Sep 2021 15:00:38 +0000 (17:00 +0200)]
avcodec: add native Speex decoder

7 months agoavformat/librist: replace deprecated functions
Gijs Peskens [Tue, 28 Sep 2021 08:22:39 +0000 (10:22 +0200)]
avformat/librist: replace deprecated functions

This gets rid of of rist_receiver_data_read, rist_receiver_data_block_free and rist_parse_address
these functions have been deprecated since librist release v0.2.1 and are replaced with functions
suffixed with 2.
I added a version macro check at the top of the file to ensure ffmpeg can still be compiled against
older versions.

Signed-off-by: Gijs Peskens <gijs@peskens.net>
Signed-off-by: Marton Balint <cus@passwd.hu>
7 months agoavformat/mpegts: fix max_packet_size in mpegts payload parsing
Marton Balint [Tue, 21 Sep 2021 20:30:55 +0000 (22:30 +0200)]
avformat/mpegts: fix max_packet_size in mpegts payload parsing

The maximum allowed useful PES payload data was set to PES_packet_length, but
it is in fact smaller by the length of the PES header.

This changes how corrupt streams are packetized:
- If PES header length is bigger than PES_packet_length then the PES packet
  payload will be handled as an unbound packet
- PES packets with payload across multiple MPEGTS packets will always be
  splitted if with the next chunk of data the payload should exceed
  PES_packet_length, previously a PES_header_length amount of excess was
  allowed.

Fixes ticket #9355.

Signed-off-by: Marton Balint <cus@passwd.hu>
7 months agoavformat/mpegts: rename PES total_size to PES_packet_length
Marton Balint [Tue, 21 Sep 2021 20:02:34 +0000 (22:02 +0200)]
avformat/mpegts: rename PES total_size to PES_packet_length

This renames PESContext->total_size to PESContext->PES_packet_length and keeps
it 0 for unbound packets, so its name and semantics will match the standard.

There should be no change in functionality.

Signed-off-by: Marton Balint <cus@passwd.hu>
7 months agoavformat/mpegts: delay allocation of PES buffer
Marton Balint [Tue, 21 Sep 2021 04:02:21 +0000 (06:02 +0200)]
avformat/mpegts: delay allocation of PES buffer

This allows us to allocate the buffer in a single code path.

Signed-off-by: Marton Balint <cus@passwd.hu>
7 months agoavformat/mpegts: use named constants for stream_id types
Marton Balint [Sun, 19 Sep 2021 00:11:33 +0000 (02:11 +0200)]
avformat/mpegts: use named constants for stream_id types

Signed-off-by: Marton Balint <cus@passwd.hu>
7 months agoavfilter/asrc_flite: Remove double ';'
Andreas Rheinhardt [Thu, 7 Oct 2021 06:11:35 +0000 (08:11 +0200)]
avfilter/asrc_flite: Remove double ';'

(Inside a function a stray ';' is an empty statement; outside of
a function it is actually invalid, but compilers happen to accept
it without complaint (unless e.g. using -pedantic).)

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter/asrc_flite: Fix races upon (un)registering voices
Andreas Rheinhardt [Wed, 6 Oct 2021 18:58:06 +0000 (20:58 +0200)]
avfilter/asrc_flite: Fix races upon (un)registering voices

The voice registration system in libflite is broken: It is not
thread-safe and also not based on internal counters; instead
any call to unregister a voice frees said voice even if there are still
many other users of said voice who have also registered said voice.
While there is no way to guard against another library unregistering
voices behind our back, we can at least be correct in the absence of
other users of libflite. The current code already tried this by using
a reference count of our own for each voice; but the implementation
of this is not thread-safe at all.

Fix this by using a mutex to guard all of libavfilter's libflite
registration and unregistration calls, thereby being thread-safe
in the absence of other libflite users.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter/asrc_flite: Fix use-after-frees
Andreas Rheinhardt [Wed, 6 Oct 2021 15:21:04 +0000 (17:21 +0200)]
avfilter/asrc_flite: Fix use-after-frees

When an flite filter instance is uninitialized and the refcount
of the corresponding voice_entry reaches zero, the voice is
unregistered, yet the voice_entry's pointer to the voice is not reset.
(Whereas some other pointers are needlessly reset.)
Because of this a new flite filter instance will believe said voice
to already be registered, leading to use-after-frees.
Fix this by resetting the right pointer instead of the wrong ones.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter/asrc_flite: Don't segfault when using list_voices option
Andreas Rheinhardt [Wed, 6 Oct 2021 14:33:00 +0000 (16:33 +0200)]
avfilter/asrc_flite: Don't segfault when using list_voices option

Could also happen if initializing flite failed* or if an unknown voice
has been selected or if registering the voice failed.

*: which it currently can't, because it is a no-op.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter/tests/filtfmts: Check for existence of formats/channel layouts
Andreas Rheinhardt [Tue, 5 Oct 2021 20:18:36 +0000 (22:18 +0200)]
avfilter/tests/filtfmts: Check for existence of formats/channel layouts

Fixes segfaults with filters that either return AVERROR(EAGAIN)
(or another error) or that do not set everything and rely on
filter_query_formats() to set the rest.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter/vf_scale: Reindentation
Andreas Rheinhardt [Tue, 5 Oct 2021 19:55:18 +0000 (21:55 +0200)]
avfilter/vf_scale: Reindentation

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter/vf_scale: Remove always-true checks
Andreas Rheinhardt [Tue, 5 Oct 2021 19:52:49 +0000 (21:52 +0200)]
avfilter/vf_scale: Remove always-true checks

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter/vf_transpose: Don't call av_pix_fmt_desc_get() twice
Andreas Rheinhardt [Tue, 5 Oct 2021 19:16:44 +0000 (21:16 +0200)]
avfilter/vf_transpose: Don't call av_pix_fmt_desc_get() twice

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter/tests/filtfmts: Replace macro by ordinary function
Andreas Rheinhardt [Tue, 5 Oct 2021 18:49:00 +0000 (20:49 +0200)]
avfilter/tests/filtfmts: Replace macro by ordinary function

This is possible now that AVFilterFormatsConfig exists.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavformat/libsrt: specify base of maxbw string to 10 instead of auto-detect
Limin Wang [Wed, 29 Sep 2021 12:24:12 +0000 (20:24 +0800)]
avformat/libsrt: specify base of maxbw string to 10 instead of auto-detect

Make all options string conversion consistent.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavformat/libsrt: use strtoll/strtol for int64_t/int
Limin Wang [Wed, 29 Sep 2021 11:39:58 +0000 (19:39 +0800)]
avformat/libsrt: use strtoll/strtol for int64_t/int

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoavformat/matroskadec: Reset state also on failure in matroska_reset_status()
Michael Niedermayer [Thu, 24 Jun 2021 17:53:47 +0000 (19:53 +0200)]
avformat/matroskadec: Reset state also on failure in matroska_reset_status()

The calling code does not handle failures and will fail with assertion failures later.
Seeking can always fail even when the position was previously read.

Fixes: Assertion failure
Fixes: 35253/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-4693059982983168

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavfilter/vf_v360: fix scaling to give proper results
Paul B Mahol [Sat, 9 Oct 2021 14:24:58 +0000 (16:24 +0200)]
avfilter/vf_v360: fix scaling to give proper results

7 months agoavfilter/vf_v360: do not round second arg for rescale()
Paul B Mahol [Sat, 9 Oct 2021 13:42:03 +0000 (15:42 +0200)]
avfilter/vf_v360: do not round second arg for rescale()

7 months agoavcodec/mpeg12dec: Fix usage of init_get_bits() and use init_get_bits8()
Limin Wang [Fri, 8 Oct 2021 14:17:12 +0000 (22:17 +0800)]
avcodec/mpeg12dec: Fix usage of init_get_bits() and use init_get_bits8()

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
7 months agoconfigure: export pkg-config includedir variable
James Almer [Fri, 8 Oct 2021 13:27:19 +0000 (10:27 -0300)]
configure: export pkg-config includedir variable

Some packages may not define custom cflags, in which case a simple
"pkg-config --cflags" call will return an empty string.
This change will be useful to get a valid include path that can be
used in library checks.

Reviewed-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
7 months agoavdevice/caca: Don't free AVOpt-enabled string manually
Andreas Rheinhardt [Sat, 9 Oct 2021 08:33:22 +0000 (10:33 +0200)]
avdevice/caca: Don't free AVOpt-enabled string manually

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavdevice/caca: Make deinit function out of write_trailer
Andreas Rheinhardt [Sat, 9 Oct 2021 08:30:54 +0000 (10:30 +0200)]
avdevice/caca: Make deinit function out of write_trailer

Fixes memleaks in case the trailer is never written.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter: add audio signal to distortion ratio filter
Paul B Mahol [Sun, 12 Sep 2021 18:11:24 +0000 (20:11 +0200)]
avfilter: add audio signal to distortion ratio filter

7 months agoavfilter/af_axcorrelate: add DBLP sample format support
Paul B Mahol [Sat, 9 Oct 2021 11:58:07 +0000 (13:58 +0200)]
avfilter/af_axcorrelate: add DBLP sample format support

7 months agodoc/filters: specify more axcorrelate design
Paul B Mahol [Fri, 8 Oct 2021 23:50:04 +0000 (01:50 +0200)]
doc/filters: specify more axcorrelate design

The typical 1D normalized cross-correlation is not same as
1D windowed normalized cross-correlation.

7 months agoavdevice/xv: Increase array size
Andreas Rheinhardt [Sat, 9 Oct 2021 11:00:24 +0000 (13:00 +0200)]
avdevice/xv: Increase array size

av_image_copy() expects an array of four pointers according to its
declaration; although it currently only touches pointers that
are actually in use (depending upon the pixel format) this might
change at any time (as has already happened for the linesizes
in d7bc52bf456deba0f32d9fe5c288ec441f1ebef5).

This fixes ticket #9264 as well as a warning from GCC 11.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter/af_atilt: Constify filter
Andreas Rheinhardt [Fri, 8 Oct 2021 15:18:08 +0000 (17:18 +0200)]
avfilter/af_atilt: Constify filter

(It is actually UB if a declaration and its definition differ wrt
their types like they do in this case (the declaration in allfilters
is const).)

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavformat/allformats: Fix data race when accessing devices lists
Andreas Rheinhardt [Fri, 1 Oct 2021 16:17:42 +0000 (18:17 +0200)]
avformat/allformats: Fix data race when accessing devices lists

Up until now setting the input and output devices lists is guarded
by a mutex. This prevents data races emanating from multiple concurrent
calls to avpriv_register_devices() (triggered by multiple concurrent
calls to avdevice_register_all()). Yet reading the lists pointers was
done without any lock and with nonatomic variables. This means that
there are data races in case of concurrent calls to
av_(de)muxer_iterate() and avdevice_register_all() (but only if the
iteration in av_(de)muxer_iterate exhausts the non-device (de)muxers).

This commit fixes this by putting said pointers into atomic objects.
Due to the unavailability of _Atomic the object is an atomic_uintptr,
leading to ugly casts. Switching to atomics also allowed to remove
the mutex currently used in avpriv_register_devices().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavcodec/h274: Fix signed left shift
Michael Niedermayer [Mon, 4 Oct 2021 21:52:52 +0000 (23:52 +0200)]
avcodec/h274: Fix signed left shift

Fixes: 39463/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5736517629247488

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/wavdec: Check smv_block_size
Michael Niedermayer [Mon, 4 Oct 2021 21:54:46 +0000 (23:54 +0200)]
avformat/wavdec: Check smv_block_size

Fixes: Timeout
Fixes: 39554/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-4915221701984256

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavformat/rmdec: Check for multiple audio_stream_info
Michael Niedermayer [Wed, 29 Sep 2021 18:49:27 +0000 (20:49 +0200)]
avformat/rmdec: Check for multiple audio_stream_info

Fixes: memleak
Fixes: 39166/clusterfuzz-testcase-minimized-ffmpeg_dem_IVR_fuzzer-5153276690038784

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavcodec/h264_slice: Check idr_pic_id
Michael Niedermayer [Wed, 29 Sep 2021 18:59:56 +0000 (20:59 +0200)]
avcodec/h264_slice: Check idr_pic_id

Fixes: left shift of negative value -1
Fixes: 39223/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5498831521841152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
7 months agoavfilter/af_axcorrelate: fix integer overflow for huge segments
Paul B Mahol [Fri, 8 Oct 2021 23:39:46 +0000 (01:39 +0200)]
avfilter/af_axcorrelate: fix integer overflow for huge segments

7 months agoavfilter/af_axcorrelate: always process all input samples
Paul B Mahol [Fri, 8 Oct 2021 11:09:07 +0000 (13:09 +0200)]
avfilter/af_axcorrelate: always process all input samples

7 months agofftools/ffmpeg, ffmpeg_opt: Allocate (In|Out)putStream.pkt early
Andreas Rheinhardt [Fri, 8 Oct 2021 09:24:09 +0000 (11:24 +0200)]
fftools/ffmpeg, ffmpeg_opt: Allocate (In|Out)putStream.pkt early

Avoids checks lateron in the hot path.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agofftools/ffmpeg: Remove unnecessary av_packet_unref()
Andreas Rheinhardt [Fri, 8 Oct 2021 07:55:23 +0000 (09:55 +0200)]
fftools/ffmpeg: Remove unnecessary av_packet_unref()

avcodec_receive_packet() already unreferences the packet on its own.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agofftools/ffmpeg: Fix crash when flushing non-fully setup output stream
Andreas Rheinhardt [Fri, 8 Oct 2021 07:47:33 +0000 (09:47 +0200)]
fftools/ffmpeg: Fix crash when flushing non-fully setup output stream

The output stream's packet may not have been allocated
at that point. This happens when quitting in the following command line:
$ ./ffmpeg -lavfi abuffer=sample_fmt=u8:sample_rate=48000:channel_layout=stereo -f null -

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agotests/fate-run: Use DEC_OPTS for additional input, too
Andreas Rheinhardt [Fri, 8 Oct 2021 07:39:10 +0000 (09:39 +0200)]
tests/fate-run: Use DEC_OPTS for additional input, too

Should fix failures in the cover-art-flac-remux test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
7 months agoavfilter/avfiltergraph: Fix use-after-free when inserting auto-converter
Andreas Rheinhardt [Fri, 8 Oct 2021 06:55:56 +0000 (08:55 +0200)]
avfilter/avfiltergraph: Fix use-after-free when inserting auto-converter

When inserting an auto-resampler, it may be that the configuration
of the filters that the auto-resampler is supposed to connect is
already partially merged, i.e. converter->inputs[0].incfg.foo and
converter->outputs[0].outcfg.foo (where foo is one of formats,
samplerates, channel_layouts) can coincide. Therefore merging
the converter filter's input link might modify the outcfg of the
converter' outlink. Yet the current code in avfiltergraph.c used
pointers from before merging the inlink for merging the outlink,
leading to a use-after-free in command lines like:
$ ffmpeg -f lavfi -i anullsrc=cl=stereo -lavfi channelsplit,axcorrelate -f null -
Fix this by not using outdated values when merging the outlink.

This is a regression since 85a6404d7e6c759ddf71d6374812d7ff719728ec.

Found-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>