]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavformat/argo_asf: bail if invalid tag
Zane van Iperen [Sun, 6 Sep 2020 01:00:17 +0000 (11:00 +1000)]
avformat/argo_asf: bail if invalid tag

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavdevice/decklink_dec: add support for querying RP188 High Frame Rate timecode
Marton Balint [Sat, 5 Sep 2020 19:18:17 +0000 (21:18 +0200)]
avdevice/decklink_dec: add support for querying RP188 High Frame Rate timecode

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavdevice/decklink_dec: add support for rgb/yuv pixel format autodetection
Marton Balint [Wed, 15 Jul 2020 18:45:22 +0000 (20:45 +0200)]
avdevice/decklink_dec: add support for rgb/yuv pixel format autodetection

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavdevice/decklink_dec: use decklink_ctx->raw_format as bmdPixelFormat
Marton Balint [Wed, 15 Jul 2020 18:23:12 +0000 (20:23 +0200)]
avdevice/decklink_dec: use decklink_ctx->raw_format as bmdPixelFormat

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavdevice/decklink_common.h: remove unsupported decklink version ifdef
Marton Balint [Wed, 15 Jul 2020 18:06:22 +0000 (20:06 +0200)]
avdevice/decklink_common.h: remove unsupported decklink version ifdef

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat: use av_timecode_make_smpte_tc_string2
Marton Balint [Fri, 24 Jul 2020 14:26:58 +0000 (16:26 +0200)]
avformat: use av_timecode_make_smpte_tc_string2

WSD format has no frames stored for playback time.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavfilter/vf_showinfo: use av_timecode_make_smpte_tc_string2
Marton Balint [Fri, 24 Jul 2020 14:26:25 +0000 (16:26 +0200)]
avfilter/vf_showinfo: use av_timecode_make_smpte_tc_string2

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec: use av_timecode_make_smpte_tc_string2 in hevc and h264 decoder
Marton Balint [Fri, 24 Jul 2020 14:26:04 +0000 (16:26 +0200)]
avcodec: use av_timecode_make_smpte_tc_string2 in hevc and h264 decoder

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agofftools/ffprobe: use av_timecode_make_smpte_tc_string2
Marton Balint [Fri, 24 Jul 2020 14:25:45 +0000 (16:25 +0200)]
fftools/ffprobe: use av_timecode_make_smpte_tc_string2

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavutil/timecode: add av_timecode_make_smpte_tc_string2
Marton Balint [Fri, 24 Jul 2020 13:09:32 +0000 (15:09 +0200)]
avutil/timecode: add av_timecode_make_smpte_tc_string2

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavutil/timecode: do not trash bits on invalid av_timecode_get_smpte arguments
Marton Balint [Sat, 5 Sep 2020 15:46:42 +0000 (17:46 +0200)]
avutil/timecode: do not trash bits on invalid av_timecode_get_smpte arguments

The function has no way to return error, so let's clip or calculate modulo.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavutil/timecode: cosmetics on av_timecode_get_smpte
Marton Balint [Mon, 20 Jul 2020 20:33:20 +0000 (22:33 +0200)]
avutil/timecode: cosmetics on av_timecode_get_smpte

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavutil/timecode: fix av_timecode_get_smpte_from_framenum with 50/60 fps
Marton Balint [Mon, 20 Jul 2020 19:38:21 +0000 (21:38 +0200)]
avutil/timecode: fix av_timecode_get_smpte_from_framenum with 50/60 fps

SMPTE 12M timecode can only count frames up to 39, because the tens-of-frames
value is stored in 2 bit. In order to resolve this 50/60 fps SMPTE timecode is
using the field bit (which is the same bit as the phase correction bit) to
signal the least significant bit of a 50/60 fps timecode. See SMPTE ST
12-1:2014 section 12.1.

Therefore we slightly change the format of the return value of
av_timecode_get_smpte_from_framenum and AV_FRAME_DATA_S12M_TIMECODE and start
using the previously unused Phase Correction bit as Field bit. (As the SMPTE
standard suggests)

We add 50/60 fps support to av_timecode_get_smpte_from_framenum by calling the
recently added av_timecode_get_smpte function in it which already handles this
properly.

This change affects the decklink indev and the DV and MXF muxers. MXF has no
fate test for 50/60fps content, DV does, therefore the changes.

MediaInfo (a recent version) confirms that half-frame timecode must be inserted
to DV. MXFInspect confirms valid timecode insertion to the System Item of MXF
files. For MXF, also see EBU R122.

Note that for DV the field flag is not used because in the HDV specs (SMPTE
370M) it is still defined as biphase mark polarity correction flag. So it
should not matter that the DV muxer overrides the field bit.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavformat: add Square SVS demuxer
Paul B Mahol [Fri, 11 Sep 2020 09:47:34 +0000 (11:47 +0200)]
avformat: add Square SVS demuxer

3 years agoavformat/moflex: make seeking more useful
Paul B Mahol [Thu, 10 Sep 2020 20:36:48 +0000 (22:36 +0200)]
avformat/moflex: make seeking more useful

3 years agoavcodec/mobiclip: add missing flush
Paul B Mahol [Thu, 10 Sep 2020 20:37:56 +0000 (22:37 +0200)]
avcodec/mobiclip: add missing flush

3 years agoavformat/flic: add support for seeking to start
Paul B Mahol [Thu, 10 Sep 2020 11:55:50 +0000 (13:55 +0200)]
avformat/flic: add support for seeking to start

3 years agoavcodec/cdgraphics: fix decoded output when seeking to start of file
Paul B Mahol [Wed, 9 Sep 2020 22:39:47 +0000 (00:39 +0200)]
avcodec/cdgraphics: fix decoded output when seeking to start of file

Also in cdg demuxer do not skip packets data, and remove
private context which is not really needed.

3 years agoavfilter/asrc_anullsrc: actually return correct EOF pts
Paul B Mahol [Sun, 13 Sep 2020 11:25:05 +0000 (13:25 +0200)]
avfilter/asrc_anullsrc: actually return correct EOF pts

3 years agoavfilter/asrc_anullsrc: give better limits to number of samples per frame
Paul B Mahol [Sun, 13 Sep 2020 11:10:54 +0000 (13:10 +0200)]
avfilter/asrc_anullsrc: give better limits to number of samples per frame

3 years agoavfilter/asrc_anullsrc: make number of output samples match duration
Paul B Mahol [Sun, 13 Sep 2020 11:08:35 +0000 (13:08 +0200)]
avfilter/asrc_anullsrc: make number of output samples match duration

3 years agoavformat/cdg: Fix integer overflow in duration computation
Michael Niedermayer [Sun, 19 Jul 2020 14:54:28 +0000 (16:54 +0200)]
avformat/cdg: Fix integer overflow in duration computation

Fixes: signed integer overflow: 8398407 * 300 cannot be represented in type 'int'
Fixes: 23914/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4702539290509312
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotools:target_dem_fuzzer: Split into a fuzzer fuzzing at the protocol level and one...
Michael Niedermayer [Sun, 19 Jul 2020 15:54:10 +0000 (17:54 +0200)]
tools:target_dem_fuzzer: Split into a fuzzer fuzzing at the protocol level and one fuzzing a fixed demuxer input

This should improve coverage and should improve the efficiency of seed files

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/crystalhd: Remove unused packet
Andreas Rheinhardt [Fri, 11 Sep 2020 14:28:25 +0000 (16:28 +0200)]
avcodec/crystalhd: Remove unused packet

Unused since 41b0561dc7246b72a834067da539ae98b1ec6631.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/av1dec: fix setting pix_fmt
James Almer [Sat, 12 Sep 2020 20:39:45 +0000 (17:39 -0300)]
avcodec/av1dec: fix setting pix_fmt

Fill the array with the software pix_fmt and move the avctx->hwaccel
check back to the proper place.
Also remove the avoid probing flag to ensure an external av1 decoder
will not set a pix_fmt we don't want during format probing.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/av1dec: update reference frame state on show_existing_frame
James Almer [Wed, 9 Sep 2020 22:14:01 +0000 (19:14 -0300)]
avcodec/av1dec: update reference frame state on show_existing_frame

As defined in Section 7.4

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/av1dec: set chroma_sample_location
James Almer [Wed, 9 Sep 2020 21:42:00 +0000 (18:42 -0300)]
avcodec/av1dec: set chroma_sample_location

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/av1dec: use av_cmp_q() to compare aspect ratio
James Almer [Wed, 9 Sep 2020 19:57:50 +0000 (16:57 -0300)]
avcodec/av1dec: use av_cmp_q() to compare aspect ratio

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/av1_parser: don't set AVCodecContext frame dimensions
James Almer [Wed, 9 Sep 2020 18:40:07 +0000 (15:40 -0300)]
avcodec/av1_parser: don't set AVCodecContext frame dimensions

Let the internal decoder take care of it, as frame reordering
may result in different values exported by either module.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec: add AV1 hardware accelerated decoder
Fei Wang [Wed, 9 Sep 2020 03:39:55 +0000 (11:39 +0800)]
avcodec: add AV1 hardware accelerated decoder

This AV1 decoder is currently only used for hardware accelerated decoding.
It can be extended into a native decoder in the future, so set its name to
"av1" and temporarily give it the lowest priority in the codec list.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/av1_parser: don't set AVCodecContext pixel format
James Almer [Wed, 9 Sep 2020 18:22:27 +0000 (15:22 -0300)]
avcodec/av1_parser: don't set AVCodecContext pixel format

This is a property a decoder must set, not a parser.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/mpc: Fix multiple numerical overflows in ff_mpc_dequantize_and_synth()
Michael Niedermayer [Sun, 10 May 2020 17:04:23 +0000 (19:04 +0200)]
avcodec/mpc: Fix multiple numerical overflows in ff_mpc_dequantize_and_synth()

Fixes: -2.4187e+09 is outside the range of representable values of type 'int'
Fixes: signed integer overflow: -14512205 + -2147483648 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPC7_fuzzer-5747263166480384
Fixes: 23528/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPC7_fuzzer-5747263166480384
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mobiclip: Check quantizer before table setup
Michael Niedermayer [Thu, 10 Sep 2020 21:59:53 +0000 (23:59 +0200)]
avcodec/mobiclip: Check quantizer before table setup

Fixes: index -1 out of bounds for type 'const uint8_t [6][16]'
Fixes: out of array read
Fixes: shift exponent -21 is negative
Fixes: 25422/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOBICLIP_fuzzer-5748258226569216
Fixes: shift exponent 8039082 is too large for 32-bit type 'int'
Fixes: 25430/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOBICLIP_fuzzer-5698567770210304
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/adpcm: take into account block_align when decoding ADPCM_PSX
Paul B Mahol [Fri, 11 Sep 2020 11:28:12 +0000 (13:28 +0200)]
avcodec/adpcm: take into account block_align when decoding ADPCM_PSX

Should reduce decoding overhead.

3 years agoavformat/brstm: remove custom allocation of table to hold coeffs
Paul B Mahol [Sat, 12 Sep 2020 12:49:15 +0000 (14:49 +0200)]
avformat/brstm: remove custom allocation of table to hold coeffs

3 years agoavformat/brstm: fix decoding brstm with custom coeff offsets
Paul B Mahol [Sat, 12 Sep 2020 12:45:31 +0000 (14:45 +0200)]
avformat/brstm: fix decoding brstm with custom coeff offsets

3 years agofate: use correct uint32 layer
Mark Reid [Sat, 12 Sep 2020 09:07:13 +0000 (02:07 -0700)]
fate: use correct uint32 layer

3 years agolavf/mov: Remove redundant code
Jun Zhao [Fri, 7 Aug 2020 12:48:42 +0000 (20:48 +0800)]
lavf/mov: Remove redundant code

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
3 years agodnn/openvino: add input/output name info
Ting Fu [Wed, 9 Sep 2020 01:52:19 +0000 (09:52 +0800)]
dnn/openvino: add input/output name info

show all input/output names when the input or output name not correct

Signed-off-by: Ting Fu <ting.fu@intel.com>
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agodnn/openvino: support run inference via GPU
Ting Fu [Wed, 9 Sep 2020 01:52:18 +0000 (09:52 +0800)]
dnn/openvino: support run inference via GPU

for enabling OpenVINO GPU please:
1. install required OpenCL drivers, see: https://github.com/intel/compute-runtime/releases/tag/19.41.14441
2. build OpenVINO c lib with GPU enabled: use cmake config with: -DENABLE_CLDNN=ON
3. then make, and include the OpenVINO c lib in environment variables
detailed steps please refer: https://github.com/openvinotoolkit/openvino/blob/master/build-instruction.md

inference model with GPU please add: optioins=device=GPU

Signed-off-by: Ting Fu <ting.fu@intel.com>
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
3 years agoavcodec/exr: initialize axmax and bxmin to 0
Paul B Mahol [Sat, 12 Sep 2020 08:06:35 +0000 (10:06 +0200)]
avcodec/exr: initialize axmax and bxmin to 0

They can be used uninitialized.

3 years agoavcodec/exr: add support data windows larger or outside display window
Mark Reid [Mon, 7 Sep 2020 21:54:35 +0000 (14:54 -0700)]
avcodec/exr: add support data windows larger or outside display window

3 years agoavcodec/utils: make the src paramater for ff_thread_ref_frame const
James Almer [Thu, 10 Sep 2020 13:38:01 +0000 (10:38 -0300)]
avcodec/utils: make the src paramater for ff_thread_ref_frame const

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavfilter/formats: Remove pointless checks
Andreas Rheinhardt [Thu, 10 Sep 2020 23:29:38 +0000 (01:29 +0200)]
avfilter/formats: Remove pointless checks

ff_formats_ref() takes a pointer to an AVFilterFormats and a pointer to
a pointer to an AVFilterFormats as arguments and adds the latter as an
owner to the list pointed to by the former; the latter is hereby always
the address of a list contained in an AVFilterFormatsConfig and can
therefore not be NULL. So remove the check for whether it is NULL; also
do the same for ff_channel_layouts_ref().

Also do the same for the unref functions where argument is never NULL
because it is always the address of an existing lvalue.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/formats: Don't typedef structure a second time
Andreas Rheinhardt [Thu, 10 Sep 2020 22:27:26 +0000 (00:27 +0200)]
avfilter/formats: Don't typedef structure a second time

Before commit 2f76476549a01ae2c4ec2a440e4b14c5aba64869, avfilter.h
contained no typedef for AVFilterChannelLayouts; all references to it
were done using its struct tag. formats.h meanwhile contained the
definition of the struct and a typedef for it. Said commit now added a
typedef in avfilter.h, too, bringing it in line with AVFilterFormats;
yet this means that there are two typedefs for AVFilterChannelLayouts
(in contrast to AVFilterFormats which is only typedef'ed in avfilter.h).

The problem is that older versions of GCC don't like this and error out:
http://fate.ffmpeg.org/history.cgi?slot=x86_64-openbsd5.6-gcc4.2-conf2
is one of the FATE boxes that now fail to compile. So just remove the
typedef in formats.h.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agofftools, libavcodec, libavfilter: Add const to some AVCodec *
Andreas Rheinhardt [Thu, 10 Sep 2020 20:11:57 +0000 (22:11 +0200)]
fftools, libavcodec, libavfilter: Add const to some AVCodec *

The user has no business modifying the underlying AVCodec.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_subtitles: Remove obsolete LIBAVCODEC_VERSION_INT checks
Andreas Rheinhardt [Thu, 10 Sep 2020 19:55:52 +0000 (21:55 +0200)]
avfilter/vf_subtitles: Remove obsolete LIBAVCODEC_VERSION_INT checks

libavcodec major version is already 58.

Reviewed-by: Nicolas George <george@nsup.org>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_subtitles: Remove unnecessary initialization of AVPacket
Andreas Rheinhardt [Thu, 10 Sep 2020 19:50:06 +0000 (21:50 +0200)]
avfilter/vf_subtitles: Remove unnecessary initialization of AVPacket

av_read_frame() can handle uninitialized packets.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_subtitles: Fix leaks on failure
Andreas Rheinhardt [Thu, 10 Sep 2020 19:39:28 +0000 (21:39 +0200)]
avfilter/vf_subtitles: Fix leaks on failure

init_subtitles() sometimes returned directly upon error without cleaning
up after itself. The easiest way to trigger this is by using
picture-based subtitles; it is also possible to run into this in case of
missing decoders or allocation failures.

Furthermore, return the proper error code in case of missing decoder.

Reviewed-by: Nicolas George <george@nsup.org>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/vf_uspp: Fix potential leak of dict on error
Andreas Rheinhardt [Thu, 10 Sep 2020 14:57:13 +0000 (16:57 +0200)]
avfilter/vf_uspp: Fix potential leak of dict on error

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/lavfutils: Avoid initializing packet
Andreas Rheinhardt [Thu, 10 Sep 2020 14:09:37 +0000 (16:09 +0200)]
avfilter/lavfutils: Avoid initializing packet

av_read_frame() can handle uninitialized packets.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/lavfutils: Fix memleak when avformat_find_stream_info() fails
Andreas Rheinhardt [Thu, 10 Sep 2020 14:07:28 +0000 (16:07 +0200)]
avfilter/lavfutils: Fix memleak when avformat_find_stream_info() fails

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/lavfutils: Don't use uninitialized pointers for freeing
Andreas Rheinhardt [Thu, 10 Sep 2020 13:36:11 +0000 (15:36 +0200)]
avfilter/lavfutils: Don't use uninitialized pointers for freeing

Happened on several error conditions, e.g. if there is just no decoder
for the format (like with svg images).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/utils: Avoid duplicating extradata from extract_extradata BSF
Andreas Rheinhardt [Mon, 7 Sep 2020 13:47:07 +0000 (15:47 +0200)]
avformat/utils: Avoid duplicating extradata from extract_extradata BSF

Instead move the extradata contained in packet side-data to its
destination. This is possible because the side data already has zeroed
padding.

Notice that the check for FF_MAX_EXTRADATA_SIZE has been dropped,
because said constant is from libavcodec/internal.h. If libavcodec
wanted to enforce this, it should do so in the extract_extradata BSF
instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/extract_extradata: Reindent after the last commit
Andreas Rheinhardt [Mon, 7 Sep 2020 13:01:23 +0000 (15:01 +0200)]
avcodec/extract_extradata: Reindent after the last commit

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/extract_extradata: Remove always-true check
Andreas Rheinhardt [Mon, 7 Sep 2020 12:44:04 +0000 (14:44 +0200)]
avcodec/extract_extradata: Remove always-true check

If a sequence header has already been found, it is certain that next
startcode (being disjoint from the sequence header startcode) can begin
at index four at the earliest.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/agm: Fix off by 1 error in decode_inter_plane()
Michael Niedermayer [Thu, 10 Sep 2020 16:52:48 +0000 (18:52 +0200)]
avcodec/agm: Fix off by 1 error in decode_inter_plane()

Fixes: Regression since 1f2096945709a32315da740691b5716da55893c3
Found-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/fastaudio: Remove redundant % 32
Michael Niedermayer [Tue, 8 Sep 2020 20:50:51 +0000 (22:50 +0200)]
avcodec/fastaudio: Remove redundant % 32

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoconfigure: Fix msa can't be disabled when '--cpu=loongson3a' assigned.
Shiyou Yin [Thu, 3 Sep 2020 06:29:52 +0000 (14:29 +0800)]
configure: Fix msa can't be disabled when '--cpu=loongson3a' assigned.

There are compiler and runtime check for MSA and MMI.
Remove the redundant setting of MSA and MMI for cores specified by "--cpu".

Signed-off-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mips: [loongson] Fixed mmi optimization
gxw [Thu, 3 Sep 2020 06:29:51 +0000 (14:29 +0800)]
avcodec/mips: [loongson] Fixed mmi optimization

Test case fate-checkasm-h264pred failed in latest community code.
This patch fixed the bug.

Signed-off-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavfilter/src_movie: Fix leak of packet upon error
Andreas Rheinhardt [Thu, 10 Sep 2020 01:14:39 +0000 (03:14 +0200)]
avfilter/src_movie: Fix leak of packet upon error

If allocating the AVFrame to contain a decoded frame fails, the AVPacket
containing the data intended to be decoded leaks. This commit fixes
this.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/src_movie: Remove unnecessary secondary AVPacket
Andreas Rheinhardt [Thu, 10 Sep 2020 00:21:59 +0000 (02:21 +0200)]
avfilter/src_movie: Remove unnecessary secondary AVPacket

The movie and amovie filters currently use two packets. One of the two,
pkt0, is the owner of the returned packet; it is also the destination
packet for av_read_frame(). The other one pkt is initially (i.e. after
av_read_frame()) a copy of pkt0; copy means that the contents of both
are absolutely the same: They both point to the same AVBufferRef and the
same side data. This violation of the refcounted packet API is only
possible because pkt is not considered to own its data. Only pkt0 is
ever unreferenced.
The reason for pkt's existence seems to be historic:
The API used for decoding audio (namely avcodec_decode_audio4()) could
consume frames partially, i.e. it could return multiple frames for one
packet and therefore it returned how much of the input buffer had been
consumed. The caller was then supposed to update the packet's data and
size pointer to reflect this and call avcodec_decode_audio4() again with
the updated packet to get the next frame.
But before the introduction of refcounted AVPackets where knowledge and
responsibility about what to free lies with the underlying AVBuffer such
a procedure required a spare packet (or one would need to record the
original data and size fields separately to restore them before freeing
the packet; notice that this code has been written when AVPackets still
had a destruct field). But these times are long gone, so just remove the
secondary AVPacket.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/src_movie: Remove unneeded resetting of AVPacket
Andreas Rheinhardt [Thu, 10 Sep 2020 00:13:51 +0000 (02:13 +0200)]
avfilter/src_movie: Remove unneeded resetting of AVPacket

av_read_frame() already returns clean packets on error.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/brstm: clip timestamp when seeking into acceptable range
Paul B Mahol [Thu, 10 Sep 2020 15:23:41 +0000 (17:23 +0200)]
avformat/brstm: clip timestamp when seeking into acceptable range

3 years agoavformat/mca: clip timestamp when seeking into acceptable range
Paul B Mahol [Thu, 10 Sep 2020 15:20:19 +0000 (17:20 +0200)]
avformat/mca: clip timestamp when seeking into acceptable range

3 years agoavformat: add mca demuxer
Zixing Liu [Thu, 3 Sep 2020 22:32:37 +0000 (16:32 -0600)]
avformat: add mca demuxer

Signed-off-by: liushuyu <liushuyu@aosc.io>
3 years agotests: fix warning ISO C90 forbids mixed declarations and code
Limin Wang [Wed, 26 Aug 2020 06:28:46 +0000 (14:28 +0800)]
tests: fix warning ISO C90 forbids mixed declarations and code

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agolibavcodec/options_table: Add missing colorspace options
Harry Mallon [Wed, 19 Aug 2020 20:31:03 +0000 (21:31 +0100)]
libavcodec/options_table: Add missing colorspace options

* chroma-derived-nc / chroma-derived-c and ictcp

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
3 years agoavformat/segment: Avoid duplicating string when parsing frames list
Andreas Rheinhardt [Sun, 6 Sep 2020 10:07:39 +0000 (12:07 +0200)]
avformat/segment: Avoid duplicating string when parsing frames list

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segment: Fix error messages
Andreas Rheinhardt [Sun, 6 Sep 2020 09:24:22 +0000 (11:24 +0200)]
avformat/segment: Fix error messages

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segment: Remove redundant code for freeing in write_trailer
Andreas Rheinhardt [Sat, 5 Sep 2020 21:45:22 +0000 (23:45 +0200)]
avformat/segment: Remove redundant code for freeing in write_trailer

This code mostly duplicates code in the deinit function; the only
exception is av_opt_free(): The options are freed generically lateron.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segment: Free SegmentListEntries in deinit, not write_trailer
Andreas Rheinhardt [Sat, 5 Sep 2020 21:36:03 +0000 (23:36 +0200)]
avformat/segment: Free SegmentListEntries in deinit, not write_trailer

This fixes leaks when the trailer is never written.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segment: Fix leak and invalid free of AVIOContext
Andreas Rheinhardt [Sat, 5 Sep 2020 22:29:33 +0000 (00:29 +0200)]
avformat/segment: Fix leak and invalid free of AVIOContext

seg_init() and seg_write_header() currently contain a few error paths
in which an already opened AVIOContext for the child muxer leaks (namely
if there are unrecognized options for the child muxer or if writing the
header of the child muxer fails); the reason for this is that this
AVIOContext is not closed in the deinit function. If all goes well, it
is closed when writing the trailer. From this it also follows that the
AVIOContext also leaks when the trailer is never written, even when
writing the header succeeds.

But simply freeing said AVIOContext in the deinit function is
complicated by the fact that the AVIOContext may or may not have been
opened via the io_open callback: If options are set to discard header
and trailer, said AVIOContext can also be a null context which must not
be closed via the io_close callback. This may lead to crashes, as
io_close may presume the AVIOContext's opaque to be set. It currently
works with the default io_close callback which simply calls avio_close(),
because avio_close() doesn't care about opaque being NULL since commit
6e8e8431e15a58aa44cfdd8c11f9ea096837c0fa. Therefore this commit records
which of the two kinds of AVIOContext is currently in use to use the
right way to close it.

Finally there was one instance (namely if initializing the child muxer
fails with no unrecognized options) where the AVIOContext was always
closed via the io_close callback. The above remark applies to this; it
has been fixed, too.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segment: Fix leak of string on error
Andreas Rheinhardt [Sat, 5 Sep 2020 19:22:21 +0000 (21:22 +0200)]
avformat/segment: Fix leak of string on error

A string containing the segment's filename that the segment muxer
allocates got only freed in its write_trailer function. This implies
that it leaks if write_trailer is never called, e.g. if initializing
the child muxer fails. This commit fixes this by freeing the string
in the deinit function instead.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segment: Fix segfault when error happens and segment list is output
Andreas Rheinhardt [Sat, 5 Sep 2020 16:12:27 +0000 (18:12 +0200)]
avformat/segment: Fix segfault when error happens and segment list is output

The segment muxer has an option to output a file containing a list of
the segments written. The AVIOContext used for writing this file is
opened via the main AVFormatContext's io_open callback; seg_free()
meanwhile unconditionally closes this AVIOContext by calling
ff_format_io_close() with the child muxer (the one for the actual output
format) as AVFormatContext.

The problem hereby is that the child AVFormatContext need not exist,
even when the AVIOContext does. This leads to a segfault in
ff_format_io_close() when the child muxer's io_close callback is called.

Situations in which the AVFormatContext can be NULL range from an
invalid reference stream parameter to an unavailable/bogus/unsupported
output format to inability to allocate the AVFormatContext.

The solution is to simply close the AVIOContext with the AVFormatContext
that was used to open it: The main AVFormatContext.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segment: Fix segfault on allocation error, avoid allocation
Andreas Rheinhardt [Sun, 6 Sep 2020 10:34:58 +0000 (12:34 +0200)]
avformat/segment: Fix segfault on allocation error, avoid allocation

If the user has set none of the options specifying the segments'
durations, a default value of 2s is used by duplicating a "2" string and
using av_parse_time() on it. Yet duplicating the string was unchecked
and if the allocation failed, one would get a segfault in
av_parse_time().

This commit solves this by turning said option into an option of type
AV_OPT_TYPE_DURATION (which also uses av_parse_time() internally),
avoiding duplicating the string altogether.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segment: Fix leak of duration/framenumber lists upon error
Andreas Rheinhardt [Sat, 5 Sep 2020 17:36:31 +0000 (19:36 +0200)]
avformat/segment: Fix leak of duration/framenumber lists upon error

The code to free them is not in the segment muxer's deinit function,
but in its write_trailer function which means that these lists leak if
write_trailer isn't called after their allocation. This happens e.g. if
the given lists are invalid (e.g. consisting only of ',' (which delimit
entries)), so that parsing them fails and so does the muxer's init
function; write_trailer is then never called.

This has been fixed by moving the code to free them to the deinit
function.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segment: Don't overwrite AVCodecParameters after init
Andreas Rheinhardt [Sun, 6 Sep 2020 11:24:03 +0000 (13:24 +0200)]
avformat/segment: Don't overwrite AVCodecParameters after init

The segment muxer copies the user-provided AVCodecParameters to the
newly created child streams in its init function before initializing the
child muxer; and since commit 8e6478b723affe4d44f94d34b98e0c47f6a0b411,
it does this again before calling avformat_write_header() if that is
called from seg_write_header(). The reason for this is complicated:

At that time writing the header was delayed, i.e. it was not triggered
by avformat_write_header() (unless the AVFMT_FLAG_AUTO_BSF was unset),
but instead by writing the very first packet. The rationale behind this
was to allow to run bitstream filters on the packets in the interleavement
queue in order to generate missing extradata from them before the muxer's
write_header function is actually called.

The segment muxer went even further: It initialized the child muxer and
ran the child muxer's check_bitstream functions on the packets in its
own muxing queue and stole any bitstream filters that got inserted. The
reason for this is that the segment muxer has an option to write the
header to a separate file and for this it is needed to write the child
muxer's header without delay, but with correct extradata. Unsetting
AVFMT_FLAG_AUTO_BSF for the child muxer accomplished the first goal and
stealing the bitstream filters the second; and in order for the child
muxer to actually use the updated extradata, the old AVCodecParameters
(set before avformat_init_output()) were overwritten with the new ones.

Updating the extradata proceeded as follows: The bitstream filter itself
simply updated the AVBSFContext's par_out when processing a packet, in
violation of the new BSF API (where par_out may only be set in the init
function); the muxing code then simply forwarded the updated extradata,
overwriting the par_in of the next BSF in the BSF chain with the fresh
par_out of the last one and the AVStream's par with the par_out of the
last BSF. This was an API violation, too, of course, but it made
remuxing ADTS AAC into mp4/matroska work.

But this no longer serves a useful purpose since the aac_adtstoasc BSF
was updated to propagate new extradata via packet side data in commit
f63c3516577d605e51cf16358cbdfa0bc97565d8; the next commit then removed
the code in mux.c passing new extradata along the filter chain. This
alone justifies removing the code for setting the AVCodecParameters a
second time.

But there is even another reason to do so: It is harmful. The ogg muxer
parses the extradata of Theora and Vorbis in its init function and keeps
pointers to parts of it. Said pointers become dangling when the
extradata is overwritten by the segment muxer, leading to
use-after-frees as has happened in ticket #8881 which this commit fixes.

Ticket #8517 is about another issue caused by this: Immediately after
having overwritten the old AVCodecParameters the segment muxer checks
whether the codec_tag is ok (the codec_tag is set generically when
initializing the child muxer based upon muxer-specific lists). The check
used is: If the child output format has such a list and if the codec tag
of the non-child stream does not match the codec id given the list of
codec tags and if there is a match for the codec id in the codec tag
list, then set the codec tag to zero (and not to the existing match),
otherwise set the codec tag of the child stream to the codec tag
of the corresponding stream of the main AVFormatContext (which is btw
redundant given that the child AVCodecParameters have just been
overwritten with the AVCodecParameters of the corresponding stream of
the main AVFormatContext).

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/avfilter: remove obsolete comment
Paul B Mahol [Wed, 9 Sep 2020 17:42:40 +0000 (19:42 +0200)]
avfilter/avfilter: remove obsolete comment

3 years agoavfilter/vf_premultiply: add support for gbrapf32 format
Mark Reid [Thu, 10 Sep 2020 03:36:08 +0000 (20:36 -0700)]
avfilter/vf_premultiply: add support for gbrapf32 format

3 years agolavfi/buffersink: cast to uint64_t before shifting.
Nicolas George [Tue, 8 Sep 2020 17:55:41 +0000 (19:55 +0200)]
lavfi/buffersink: cast to uint64_t before shifting.

Fix CID 1466666.

3 years agoavcodec/extract_extradata: Consolidate zeroing extradata padding
Andreas Rheinhardt [Mon, 7 Sep 2020 12:42:46 +0000 (14:42 +0200)]
avcodec/extract_extradata: Consolidate zeroing extradata padding

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agodnn/dnn_backend_native_layer_conv2d: Fix allocation size
Andreas Rheinhardt [Wed, 9 Sep 2020 12:10:24 +0000 (14:10 +0200)]
dnn/dnn_backend_native_layer_conv2d: Fix allocation size

Found via ASAN with the dnn-layer-conv2d FATE-test.

Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Don't check for clipping in separate loop
Andreas Rheinhardt [Sat, 29 Aug 2020 05:15:53 +0000 (07:15 +0200)]
avfilter/af_headphone: Don't check for clipping in separate loop

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Remove pointless additions
Andreas Rheinhardt [Fri, 28 Aug 2020 13:28:33 +0000 (15:28 +0200)]
avfilter/af_headphone: Remove pointless additions

buffer_length is a power-of-two and modulo is buffer_length - 1, so that
buffer_length & modulo is zero.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Use more appropriate variable name
Andreas Rheinhardt [Wed, 26 Aug 2020 07:14:53 +0000 (09:14 +0200)]
avfilter/af_headphone: Use more appropriate variable name

Also unify incrementing the variable containing the pointer
to the currently used HRIR data.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Avoid indirection for function pointer
Andreas Rheinhardt [Fri, 28 Aug 2020 12:07:42 +0000 (14:07 +0200)]
avfilter/af_headphone: Avoid indirection for function pointer

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Avoid allocating array
Andreas Rheinhardt [Wed, 26 Aug 2020 04:51:18 +0000 (06:51 +0200)]
avfilter/af_headphone: Avoid allocating array

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Don't allocate unused element in array
Andreas Rheinhardt [Wed, 26 Aug 2020 04:24:51 +0000 (06:24 +0200)]
avfilter/af_headphone: Don't allocate unused element in array

The headphone filter uses an array with as many elements as the
filter has inputs to store some per-input information; yet actually it
only stores information for all inputs except the very first one (which
is special for this filter). Therefore this commit modifies the code to
remove this unused element.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Only keep one AVFrame at a time
Andreas Rheinhardt [Wed, 26 Aug 2020 04:10:47 +0000 (06:10 +0200)]
avfilter/af_headphone: Only keep one AVFrame at a time

Despite the headphone filter only using one AVFrame at a time, it kept
an array each of whose entries contained a pointer to an AVFrame at all
times; the pointers were mostly NULL. This commit instead replaces them
by using a single pointer to an AVFrame on the stack of the only
function that actually uses them.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Avoid intermediate buffer III
Andreas Rheinhardt [Tue, 25 Aug 2020 13:08:31 +0000 (15:08 +0200)]
avfilter/af_headphone: Avoid intermediate buffer III

The headphone filter allocates a pair of buffers to be used as
intermediate buffers lateron: Before every use they are zeroed, then
some elements of the buffer are set and lateron the complete buffers are
copied into another, bigger buffer. These intermediate buffers are
unnecessary as the data can be directly written into the bigger buffer.
Furthermore, the whole buffer has been zeroed initially and because no
piece of this buffer is set twice (due to the fact that duplicate
channel map entries are skipped), it is unnecessary to rezero the part
of the big buffer that is about to be written to.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Simplify finding channel index
Andreas Rheinhardt [Thu, 27 Aug 2020 05:28:55 +0000 (07:28 +0200)]
avfilter/af_headphone: Simplify finding channel index

Before this commit, the headphone filter called
av_channel_layout_extract_channel() in a loop in order to find out
the index of a channel (given via its AV_CH_* value) in a channel layout.
This commit changes this to av_get_channel_layout_channel_index()
instead.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Fix channel assignment
Andreas Rheinhardt [Wed, 26 Aug 2020 02:24:26 +0000 (04:24 +0200)]
avfilter/af_headphone: Fix channel assignment

The documentation of the map argument of the headphone filter states:

"Set mapping of input streams for convolution. The argument is a
’|’-separated list of channel names in order as they are given as
additional stream inputs for filter."

Yet this has not been honoured at all. Instead for the kth given HRIR
channel pair it was checked whether there was a kth mapping and if the
channel position so given was present in the channel layout of the main
input; if so, then the given HRIR channel pair was matched to the kth
channel of the main input. It should actually have been matched to the
channel given by the kth mapping. A consequence of the current algorithm
is that if N additional HRIR channel pairs are given, a permutation of
the first N entries of the mapping does not affect the output at all.

The old code might even set arrays belonging to streams that don't exist
(i.e. whose index is >= the number of channels of the main input
stream); these parts were not read lateron at all. The new code doesn't
do this any longer and therefore the number of elements of some of the
allocated arrays has been reduced (in case the number of mappings was
bigger than the number of channels of the first input stream).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Avoid intermediate buffers II
Andreas Rheinhardt [Tue, 25 Aug 2020 13:35:23 +0000 (15:35 +0200)]
avfilter/af_headphone: Avoid intermediate buffers II

When the headphone filter is configured to perform its processing in the
frequency domain, it allocates (among other things) two pairs of
buffers, all of the same size. One pair is used to store data in it
during the initialization of the filter; the other pair is only
allocated lateron. It is zero-initialized and yet its data is
immediately overwritten by the content of the other pair of buffers
mentioned above; the latter pair is then freed.

This commit eliminates the pair of intermediate buffers.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Avoid intermediate buffers I
Andreas Rheinhardt [Tue, 25 Aug 2020 13:31:04 +0000 (15:31 +0200)]
avfilter/af_headphone: Avoid intermediate buffers I

The headphone filter has two modes; in one of them (say A), it needs
certain buffers to store data. But it allocated them in both modes.
Furthermore when in mode A it also allocated intermediate buffers of the
same size, initialized them, copied their contents into the permanent
buffers and freed them.

This commit changes this: The permanent buffer is only allocated when
needed; the temporary buffer has been completely avoided.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Remove delay fields
Andreas Rheinhardt [Tue, 25 Aug 2020 12:57:31 +0000 (14:57 +0200)]
avfilter/af_headphone: Remove delay fields

They seem to exist for an option that was never implemented.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Remove unused arrays
Andreas Rheinhardt [Tue, 25 Aug 2020 12:47:09 +0000 (14:47 +0200)]
avfilter/af_headphone: Remove unused arrays

The delay arrays were never properly initialized, only zero-initialized;
furthermore these arrays duplicate fields in the headphone_inputs
struct. So remove them.
(Btw: The allocations for them have not been checked.)

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Avoid duplicating string needlessly
Andreas Rheinhardt [Mon, 24 Aug 2020 21:03:45 +0000 (23:03 +0200)]
avfilter/af_headphone: Avoid duplicating string needlessly

The string given by an AVOption that contains the channel assignment
is used only once; ergo it doesn't matter that parsing the string via
av_strtok() is destructive. There is no need to make a copy.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Simplify parsing channel mapping string
Andreas Rheinhardt [Thu, 27 Aug 2020 01:14:02 +0000 (03:14 +0200)]
avfilter/af_headphone: Simplify parsing channel mapping string

When parsing the channel mapping string (a string containing '|'
delimited tokens each of which is supposed to contain a channel name
like "FR"), the old code would at each step read up to seven uppercase
characters from the input string and give this to
av_get_channel_layout() to parse. The returned layout is then checked
for being a layout with a single channel set by computing its logarithm.

Besides being overtly complicated this also has the drawback of relying
on the assumption that every channel name consists of at most seven
uppercase letters only; but said assumption is wrong: The abbreviation
of the second low frequency channel is LFE2. Furthermore it treats
garbage like "FRfoo" as valid channel.

This commit changes this by using av_get_channel_layout() directly;
furthermore, av_get_channel_layout_nb_channels() (which uses popcount)
is used to find out the number of channels instead of the custom code
to calculate the logarithm.

(As a consequence, certain other formats to specify the channel layouts
are now accepted (like the hex versions of av_get_channel_layout()); but
this is actually not bad at all.)

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavfilter/af_headphone: Use uint64_t for channel mapping
Andreas Rheinhardt [Mon, 24 Aug 2020 20:17:02 +0000 (22:17 +0200)]
avfilter/af_headphone: Use uint64_t for channel mapping

The headphone filter has an option for the user to specify an assignment
of inputs to channels (or from pairs of channels of the second input to
channels). Up until now, these channels were stored in an int containing
the logarithm of the channel layout. Yet it is not the logarithm that is
used lateron and so a retransformation was necessary. Therefore this
commit simply stores the uint64_t as is, avoiding the retransformation.

This also has the advantage that unset channels (whose corresponding
entry is zero) can't be mistaken for valid channels any more; the old
code had to initialize the channels to -1 to solve this problem and had
to check for whether a channel is set before the retransformation
(because 1 << -1 is UB).

The only downside of this approach is that the size of the context
increases (by 256 bytes); but this is not exceedingly much.

Finally, the array has been moved to the end of the context; it is only
used a few times during the initialization process and moving it
decreased the offsets of lots of other entries, reducing codesize.

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