]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoavformat: add argo_asf muxer
Zane van Iperen [Mon, 27 Jul 2020 12:53:24 +0000 (22:53 +1000)]
avformat: add argo_asf muxer

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec: add adpcm_argo encoder
Zane van Iperen [Sun, 26 Jul 2020 14:23:14 +0000 (00:23 +1000)]
avcodec: add adpcm_argo encoder

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/adpcm_argo: add ff_adpcm_argo_expand_nibble() and cleanup parameters
Zane van Iperen [Wed, 29 Jul 2020 12:58:52 +0000 (22:58 +1000)]
avcodec/adpcm_argo: add ff_adpcm_argo_expand_nibble() and cleanup parameters

Replaces adpcm_argo_expand_nibble(). Preparation for the encoder.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavformat/argo_asf: check sample count in demuxer
Zane van Iperen [Sun, 2 Aug 2020 12:22:42 +0000 (22:22 +1000)]
avformat/argo_asf: check sample count in demuxer

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/tiff: Check bpp/bppcount for 0
Michael Niedermayer [Thu, 6 Aug 2020 19:42:43 +0000 (21:42 +0200)]
avcodec/tiff: Check bpp/bppcount for 0

Fixes: division by zero
Fixes: 24253/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6250318007107584
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/snowdec: Sanity check hcoeff
Michael Niedermayer [Thu, 6 Aug 2020 19:35:06 +0000 (21:35 +0200)]
avcodec/snowdec: Sanity check hcoeff

Fixes: signed integer overflow: -2147483648 * -1 cannot be represented in type 'int'
Fixes: 24011/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5486376610168832
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 agodnn_backend_native_layer_mathunary: add floor support
Mingyu Yin [Thu, 6 Aug 2020 06:47:16 +0000 (14:47 +0800)]
dnn_backend_native_layer_mathunary: add floor support

It can be tested with the model generated with below python script:

import tensorflow as tf
import os
import numpy as np
import imageio
from tensorflow.python.framework import graph_util
name = 'floor'

pb_file_path = os.getcwd()
if not os.path.exists(pb_file_path+'/{}_savemodel/'.format(name)):
    os.mkdir(pb_file_path+'/{}_savemodel/'.format(name))

with tf.Session(graph=tf.Graph()) as sess:
    in_img = imageio.imread('detection.jpg')
    in_img = in_img.astype(np.float32)
    in_data = in_img[np.newaxis, :]
    input_x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in')
    y_ = tf.math.floor(input_x*255)/255
    y = tf.identity(y_, name='dnn_out')
    sess.run(tf.global_variables_initializer())
    constant_graph = graph_util.convert_variables_to_constants(sess, sess.graph_def, ['dnn_out'])

    with tf.gfile.FastGFile(pb_file_path+'/{}_savemodel/model.pb'.format(name), mode='wb') as f:
        f.write(constant_graph.SerializeToString())

    print("model.pb generated, please in ffmpeg path use\n \n \
    python tools/python/convert.py {}_savemodel/model.pb --outdir={}_savemodel/ \n \nto generate model.model\n".format(name,name))

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

    print("To verify, please ffmpeg path use\n \n \
    ./ffmpeg -i detection.jpg -vf format=rgb24,dnn_processing=model={}_savemodel/model.pb:input=dnn_in:output=dnn_out:dnn_backend=tensorflow -f framemd5 {}_savemodel/tensorflow_out.md5\n  \
    or\n \
    ./ffmpeg -i detection.jpg -vf format=rgb24,dnn_processing=model={}_savemodel/model.pb:input=dnn_in:output=dnn_out:dnn_backend=tensorflow {}_savemodel/out_tensorflow.jpg\n \nto generate output result of tensorflow model\n".format(name, name, name, name))

    print("To verify, please ffmpeg path use\n \n \
    ./ffmpeg -i detection.jpg -vf format=rgb24,dnn_processing=model={}_savemodel/model.model:input=dnn_in:output=dnn_out:dnn_backend=native -f framemd5 {}_savemodel/native_out.md5\n  \
    or \n \
    ./ffmpeg -i detection.jpg -vf format=rgb24,dnn_processing=model={}_savemodel/model.model:input=dnn_in:output=dnn_out:dnn_backend=native {}_savemodel/out_native.jpg\n \nto generate output result of native model\n".format(name, name, name, name))

Signed-off-by: Mingyu Yin <mingyu.yin@intel.com>
3 years agoavformat/mxfdec: Read color metadata from MXF
Harry Mallon [Fri, 31 Jul 2020 10:09:54 +0000 (11:09 +0100)]
avformat/mxfdec: Read color metadata from MXF

Reads color_primaries, color_trc and color_space from mxf
headers. ULs are from https://registry.smpte-ra.org/ site.

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
3 years agoavcodec/libx264: fix chroma quantizer offset usage
Takio Yamaoka [Tue, 28 Jul 2020 12:22:02 +0000 (21:22 +0900)]
avcodec/libx264: fix chroma quantizer offset usage

The default for the chromaoffset field in AVCodecContext
is zero, which until now always ended up overriding the
AVOption-set value, thus leading to the AVOption not working.

Additionally, the previous usage prevented the usage of
negative values, while both the variable as well as x264's
API would successfully handle such.

Thus, the default value of the AVOption is changed to match
the default of x264 (and what is currently the default for
the AVCodecContext chromaoffset field), and the checks are
changed to check for nonzero values.

This way:
1. the library default is still utilized if the value is zero.
2. both negative and positive values are correctly passed to
   x264.

For historical context, this was initially similarly
implemented in 5764d38173661c29d954711dd5abfddf709e9ba4, and
then b340bd8a58c32453172404a8e4240e3317e341da broke the
value.

Partially reverts commit b340bd8a58c32453172404a8e4240e3317e341da.

Signed-off-by: Takio Yamaoka <y.takio@gmail.com>
3 years agoavcodec/mpegaudiodec_template: Fix some whitespace issues
Michael Niedermayer [Wed, 5 Aug 2020 06:54:13 +0000 (08:54 +0200)]
avcodec/mpegaudiodec_template: Fix some whitespace issues

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/jpeg2000dec: Handle reducedresno of 32
Michael Niedermayer [Tue, 4 Aug 2020 20:42:21 +0000 (22:42 +0200)]
avcodec/jpeg2000dec: Handle reducedresno of 32

Fixes: shift exponent 32 is too large for 32-bit type 'int'
Fixes: 24566/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6033783737024512
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Gautam Ramakrishnan <gautamramk@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibavcodec/j2kenc: Allow Encoder to use SOP and EPH markers
Gautam Ramakrishnan [Tue, 4 Aug 2020 12:58:02 +0000 (18:28 +0530)]
libavcodec/j2kenc: Allow Encoder to use SOP and EPH markers

This patch allows the encoder to use SOP and EPH
markers. This would be useful as these markers
provide better error detection mechanisms.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/dv: Avoid allocation for reading timecode
Andreas Rheinhardt [Sat, 1 Aug 2020 22:58:48 +0000 (00:58 +0200)]
avformat/dv: Avoid allocation for reading timecode

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/dv: Avoid alloction of DVDemuxContext
Andreas Rheinhardt [Sat, 1 Aug 2020 22:41:31 +0000 (00:41 +0200)]
avformat/dv: Avoid alloction of DVDemuxContext

This commit avoids allocating a DVDemuxContext when demuxing raw DV by
making it part of the demuxer's context. This also allows to remove
dv_read_close().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/3dostr: Return directly after having read packet
Andreas Rheinhardt [Mon, 27 Jul 2020 03:19:18 +0000 (05:19 +0200)]
avformat/3dostr: Return directly after having read packet

Avoids an avio_skip(s->pb, 0).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolavc/libopenh264enc: use framerate if available
Jun Zhao [Sun, 26 Jul 2020 11:16:43 +0000 (19:16 +0800)]
lavc/libopenh264enc: use framerate if available

Respecting the framerate in the libopenh264enc codec context.

Both the libx264 and libx265 encoders already contain similar logic
to first check the framerate before falling back to the timebase.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
3 years agoavformat/mov: Check comp_brand_size
Michael Niedermayer [Sat, 1 Aug 2020 22:51:12 +0000 (00:51 +0200)]
avformat/mov: Check comp_brand_size

Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 24457/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5760093644390400
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/mpegaudiodec_template: Check CRCs for layer1 and layer2
Michael Niedermayer [Mon, 3 Aug 2020 14:33:56 +0000 (16:33 +0200)]
avcodec/mpegaudiodec_template: Check CRCs for layer1 and layer2

This differs from the MPEG specification as the actual real world
files do compute their CRC over variable areas and not the fixed
ones listed in the specification. This is also the reason for
the complexity of this code and the need to perform the CRC
check for layer2 in the middle of layer2 decoding.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agodnn_backend_native_layer_mathunary: add ceil support
Mingyu Yin [Fri, 31 Jul 2020 07:41:24 +0000 (15:41 +0800)]
dnn_backend_native_layer_mathunary: add ceil support

It can be tested with the model generated with below python script:

import tensorflow as tf
import os
import numpy as np
import imageio
from tensorflow.python.framework import graph_util
name = 'ceil'

pb_file_path = os.getcwd()
if not os.path.exists(pb_file_path+'/{}_savemodel/'.format(name)):
    os.mkdir(pb_file_path+'/{}_savemodel/'.format(name))

with tf.Session(graph=tf.Graph()) as sess:
    in_img = imageio.imread('detection.jpg')
    in_img = in_img.astype(np.float32)
    in_data = in_img[np.newaxis, :]
    input_x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in')
    y = tf.math.ceil( input_x, name='dnn_out')
    sess.run(tf.global_variables_initializer())
    constant_graph = graph_util.convert_variables_to_constants(sess, sess.graph_def, ['dnn_out'])

    with tf.gfile.FastGFile(pb_file_path+'/{}_savemodel/model.pb'.format(name), mode='wb') as f:
        f.write(constant_graph.SerializeToString())

    print("model.pb generated, please in ffmpeg path use\n \n \
    python tools/python/convert.py ceil_savemodel/model.pb --outdir=ceil_savemodel/ \n \n \
    to generate model.model\n")

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

    print("To verify, please ffmpeg path use\n \n \
    ./ffmpeg -i detection.jpg -vf format=rgb24,dnn_processing=model=ceil_savemodel/model.pb:input=dnn_in:output=dnn_out:dnn_backend=tensorflow -f framemd5 ceil_savemodel/tensorflow_out.md5\n \n \
    to generate output result of tensorflow model\n")

    print("To verify, please ffmpeg path use\n \n \
    ./ffmpeg -i detection.jpg -vf format=rgb24,dnn_processing=model=ceil_savemodel/model.model:input=dnn_in:output=dnn_out:dnn_backend=native -f framemd5 ceil_savemodel/native_out.md5\n \n \
    to generate output result of native model\n")

Signed-off-by: Mingyu Yin <mingyu.yin@intel.com>
Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
3 years agoavcodec/adpcm_argo: fix incorrect documentation
Zane van Iperen [Sat, 1 Aug 2020 23:20:15 +0000 (09:20 +1000)]
avcodec/adpcm_argo: fix incorrect documentation

Flag bit was in the wrong place.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/cfhd: fix overflow in multiplication in LUT calculation
Paul B Mahol [Tue, 4 Aug 2020 06:20:36 +0000 (08:20 +0200)]
avcodec/cfhd: fix overflow in multiplication in LUT calculation

3 years agoavcodec/aacdec_template: add support for 22.2 / channel_config 13
Jan Ekström [Sat, 13 Jun 2020 12:05:30 +0000 (15:05 +0300)]
avcodec/aacdec_template: add support for 22.2 / channel_config 13

3 years agoavcodec/aacdec_template: mark second LFE element as LFE2
Jan Ekström [Sat, 13 Jun 2020 11:34:44 +0000 (14:34 +0300)]
avcodec/aacdec_template: mark second LFE element as LFE2

We now have the capability to do this.

3 years agoavcodec/aacdectab: add mapping for 22.2
Jan Ekström [Wed, 10 Jun 2020 22:49:07 +0000 (01:49 +0300)]
avcodec/aacdectab: add mapping for 22.2

Utilizes the newly added 22.2 channel layout for channel_layout 13.

3 years agoavcodec/mpeg4audio: add newer channel_coding mappings
Jan Ekström [Wed, 10 Jun 2020 21:07:15 +0000 (00:07 +0300)]
avcodec/mpeg4audio: add newer channel_coding mappings

Additionally, add comments regarding their definitions. Based on
ARIB STD-B32, which bases on 14496-3:2009 and 14496-3:2009/AMD4.

3 years agoswresample/rematrix: treat 22.2 as 5.1 (back) when mixing
Jan Ekström [Fri, 31 Jul 2020 22:55:39 +0000 (01:55 +0300)]
swresample/rematrix: treat 22.2 as 5.1 (back) when mixing

Only this sub-set of channels actually follows the bit mask order
in the official 22.2 channel mapping. Additionally, the 5.1 channels
are there for backwards compatibility with the previous system.

This enables the utilization of 22.2 content until a proper down/up
matrix is added into swresample.

3 years agoswresample/matrix: switch internal clean_layout function to not drop high bits
Jan Ekström [Fri, 31 Jul 2020 22:52:08 +0000 (01:52 +0300)]
swresample/matrix: switch internal clean_layout function to not drop high bits

These bits are utilized by channel layouts such as 22.2. If those
are dropped, the returned channel layout is no longer a match
against the AV_CH_LAYOUT define when returned from this function.

3 years agoavutil/channel_layout: add 22.2 layout
Jan Ekström [Thu, 11 Jun 2020 19:08:30 +0000 (22:08 +0300)]
avutil/channel_layout: add 22.2 layout

Requires some extraneous top side and bottom front channels to be
defined.

According to STD-B59v2, the defined channel layout is:
- FL
- FR
- FC
- LFE1
- BL
- BR
- FLc
- FRc
- BC
- LFE2
- SiL
- SiR
- TpFL
- TpFR
- TpFC
- TpC
- TpBL
- TpBR
- TpSiL
- TpSiR
- TpBC
- BtFC
- BtFL
- BtFR

3 years agotest: hlsenc: Use unique init/segment file names for the fmp4_ac3 test
Martin Storsjö [Sat, 1 Aug 2020 21:28:18 +0000 (00:28 +0300)]
test: hlsenc: Use unique init/segment file names for the fmp4_ac3 test

Previously, the hls-fmp4 and hls-fmp4_ac3 tests used the same file
names for init and segment files, which occasionally could cause
corruption and failed tests, if the input files for both tests are
generated in parallel, as they could overwrite each other.

This happened to work some of the time, as the fmp4_ac3 test actually
only checked the init segment file (which the fmp4 test case never
wrote, due to using the incorrect hls_segment_type option) and the
fmp4 test case always regenerated the input files due to mismatched
target and file names.

Signed-off-by: Martin Storsjö <martin@martin.st>
3 years agotest: hlsenc: Make the hls_fmp4 sample file name match the target
Martin Storsjö [Sat, 1 Aug 2020 21:20:27 +0000 (00:20 +0300)]
test: hlsenc: Make the hls_fmp4 sample file name match the target

Previously, with the file name not matching the target, the files
were regenerated every time fate is rerun - contrary to the other
test targets in the same file. (While regenerating it every time
might be desireable, as that's what the test is about, the file
at least has a dependency on the ffmpeg executable, making them
regenerated every time the executable is updated - and this change
at least makes it consistent with the rest.)

Signed-off-by: Martin Storsjö <martin@martin.st>
3 years agoavcodec/cfhd: correct 71 tag usage
Paul B Mahol [Mon, 3 Aug 2020 20:41:45 +0000 (22:41 +0200)]
avcodec/cfhd: correct 71 tag usage

It stores input format and never codebook.

3 years agoavcodec/cfhdenc: fix setting default compression level
Paul B Mahol [Mon, 3 Aug 2020 20:18:47 +0000 (22:18 +0200)]
avcodec/cfhdenc: fix setting default compression level

3 years agoavcodec/cfhdenc: extend quantization table
Paul B Mahol [Mon, 3 Aug 2020 20:14:14 +0000 (22:14 +0200)]
avcodec/cfhdenc: extend quantization table

Should give better quality.

3 years agoavcodec/cfhd: use LUT for 9 and 18 codebook decompanding
Paul B Mahol [Mon, 3 Aug 2020 07:33:36 +0000 (09:33 +0200)]
avcodec/cfhd: use LUT for 9 and 18 codebook decompanding

Also fix codebook 9 decompanding, fixing artifact with codebook 9
samples. Reused Gagandeep Singh patch.

3 years agoavcodec/cfhdenc: fix PrescaleTable for YUV422P10
Paul B Mahol [Mon, 3 Aug 2020 17:31:31 +0000 (19:31 +0200)]
avcodec/cfhdenc: fix PrescaleTable for YUV422P10

3 years agoavcodec/mpegaudiodec_template: disable CRC checking for layers 1 and 2
James Almer [Mon, 3 Aug 2020 13:40:10 +0000 (10:40 -0300)]
avcodec/mpegaudiodec_template: disable CRC checking for layers 1 and 2

Layers 1 and 2 use lengths in bits which are not a multiple of 8,
and our CRC works on a per-byte basis.

Based on b48397e7b8

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoRevert "mpegaudiodec_template: disable CRC checking for layers 1 and 2"
James Almer [Mon, 3 Aug 2020 13:27:21 +0000 (10:27 -0300)]
Revert "mpegaudiodec_template: disable CRC checking for layers 1 and 2"

This reverts commit b48397e7b84864f2d4c70361a4c4bed93e826753.

The change did not disable crc checks for layer 1 & 2, it removed reading
the CRC field.

Fixes decoding some mp2 samples and FATE test failures.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agofate/aac: add missing bitexact flag to some encoder tests
James Almer [Sun, 2 Aug 2020 23:38:58 +0000 (20:38 -0300)]
fate/aac: add missing bitexact flag to some encoder tests

Will prevet FATE from breaking once LIBAVCODEC_VERSION_MINOR is bumped to 100.

Reported-by: zane
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agompegaudiodec_template: disable CRC checking for layers 1 and 2
Lynne [Sun, 2 Aug 2020 20:45:00 +0000 (22:45 +0200)]
mpegaudiodec_template: disable CRC checking for layers 1 and 2

Layers 1 and 2 use lengths in bits which are not a multiple of 8,
and our CRC works on a per-byte basis.

3 years agohwcontext_vulkan: remove plane size alignment checks when host importing
Lynne [Mon, 20 Jul 2020 12:36:47 +0000 (12:36 +0000)]
hwcontext_vulkan: remove plane size alignment checks when host importing

The process space is guaranteed to be aligned to the page size, hence we're
never going to map outside of our address space.
There are more optimizations to do with respect to chroma plane alignment and
buffer offsets, but that can be done later.

3 years agoavcodec/v4l2_m2m: reindent after last commit
Andriy Gelman [Sun, 2 Aug 2020 18:36:04 +0000 (14:36 -0400)]
avcodec/v4l2_m2m: reindent after last commit

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
3 years agoavcodec/v4l2_m2m: adapt to call close() on init fail
Andriy Gelman [Sun, 2 Aug 2020 18:31:22 +0000 (14:31 -0400)]
avcodec/v4l2_m2m: adapt to call close() on init fail

This fixes several mem leaks when init of encoder/decoder failed.

Fixes ticket #8285

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
3 years agoavcodec/cfhd: set correct bits_per_raw_sample
Paul B Mahol [Sun, 2 Aug 2020 06:39:37 +0000 (08:39 +0200)]
avcodec/cfhd: set correct bits_per_raw_sample

3 years agoavcodec/cfhd: add more tag names
Paul B Mahol [Sat, 1 Aug 2020 09:08:34 +0000 (11:08 +0200)]
avcodec/cfhd: add more tag names

3 years agoavcodec: add CFHD encoder
Paul B Mahol [Sat, 25 Jul 2020 16:18:18 +0000 (18:18 +0200)]
avcodec: add CFHD encoder

3 years agoavcodec/cfhd: improve decompanding quality with reference implementation
Paul B Mahol [Sat, 1 Aug 2020 08:47:07 +0000 (10:47 +0200)]
avcodec/cfhd: improve decompanding quality with reference implementation

3 years agoavcodec/cfhd: fix non-aligned to 8 height decoding
Paul B Mahol [Fri, 31 Jul 2020 07:42:47 +0000 (09:42 +0200)]
avcodec/cfhd: fix non-aligned to 8 height decoding

3 years agoavcodec/cfhd: move if/else out of loop in inverse transform
Paul B Mahol [Wed, 29 Jul 2020 08:01:35 +0000 (10:01 +0200)]
avcodec/cfhd: move if/else out of loop in inverse transform

3 years agolavc/libkvazaar: fix framerate setting
Jun Zhao [Sun, 26 Jul 2020 10:51:19 +0000 (18:51 +0800)]
lavc/libkvazaar: fix framerate setting

fix framerate setting.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
3 years agoavcodec/g723_1enc: Avoid skip_put_bits()
Andreas Rheinhardt [Fri, 31 Jul 2020 08:45:48 +0000 (10:45 +0200)]
avcodec/g723_1enc: Avoid skip_put_bits()

If a bit is reserved, it matters very much what value it has, because
otherwise a decoder conforming to a future version of the standard might
interpret the output file in an unintended manner. This implies that
one must not use skip_put_bits() for it (which does not give any
guarantees wrt what ends up in the output (in case of a little-endian
bitstream writer (as here) it writes a 0 bit)); given that the reference
encoder as well as the earlier code write a zero bit at this place, the
new code does, too.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec, avfilter, avformat: Remove redundant avpriv_align_put_bits
Andreas Rheinhardt [Thu, 30 Jul 2020 19:44:51 +0000 (21:44 +0200)]
avcodec, avfilter, avformat: Remove redundant avpriv_align_put_bits

flush_put_bits() already fills the bitstream with zeroes, so it is
unnecessary to align the bitstream before.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agovaapi_encode: Delete unused field
Mark Thompson [Tue, 28 Jul 2020 22:50:23 +0000 (23:50 +0100)]
vaapi_encode: Delete unused field

3 years agovaapi_encode_h265: Don't require uniform_spacing_flag
Mark Thompson [Tue, 28 Jul 2020 22:50:22 +0000 (23:50 +0100)]
vaapi_encode_h265: Don't require uniform_spacing_flag

Though still use it if the tile arrangement matches.  Also try to keep the
fields in the same order as the standard.

3 years agovaapi_encode_h265: Fix ordering of tile dimensions
Mark Thompson [Tue, 28 Jul 2020 22:50:21 +0000 (23:50 +0100)]
vaapi_encode_h265: Fix ordering of tile dimensions

Dimensions are normally specified as width x height, and this will match
the same option to libaom-av1.

Remove the indirection through the private context at the same time.

3 years agovaapi_encode_h265: Remove confusing and redundant tile options
Mark Thompson [Tue, 28 Jul 2020 22:50:20 +0000 (23:50 +0100)]
vaapi_encode_h265: Remove confusing and redundant tile options

The tile_rows/cols options currently do a confusingly different thing to
the options of the same name on other encoders like libvpx and libaom.
There is no backward-compatibility reason to implement the log2 behaviour
as there was for libaom, so just get rid of them entirely.

3 years agolibsvtav1: Fix the documentation to match the actual options
Mark Thompson [Thu, 30 Jul 2020 21:32:00 +0000 (22:32 +0100)]
libsvtav1: Fix the documentation to match the actual options

3 years agolibsvtav1: Use _ rather than - in options
Mark Thompson [Thu, 30 Jul 2020 21:31:59 +0000 (22:31 +0100)]
libsvtav1: Use _ rather than - in options

3 years agolibsvtav1: Rename without a _
Mark Thompson [Thu, 30 Jul 2020 21:31:58 +0000 (22:31 +0100)]
libsvtav1: Rename without a _

The external library is called libsvtav1, so use this name everywhere.

3 years agotests/imgutils: test the output of av_image_fill_* functions
James Almer [Sat, 25 Jul 2020 03:10:38 +0000 (00:10 -0300)]
tests/imgutils: test the output of av_image_fill_* functions

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/apm: fix APM_FILE_HEADER_SIZE value
Zane van Iperen [Wed, 29 Jul 2020 12:06:50 +0000 (22:06 +1000)]
avformat/apm: fix APM_FILE_HEADER_SIZE value

Value was incorrectly changed in 3bf1be210150b435c51c7c8eb8fd05a1fca08814.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agoavcodec/options_table: make AVCodecContext->level search for child constants
James Almer [Wed, 29 Jul 2020 22:08:17 +0000 (19:08 -0300)]
avcodec/options_table: make AVCodecContext->level search for child constants

This change makes it possible for child encoders to define custom level
option names which can be used for setting the AVCodecContext->level.

Based on 337fe4bcc2

Reviewed-by: jkqxz
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agolibavcodec/pgxdec Fix pix format selection error
Gautam Ramakrishnan [Wed, 29 Jul 2020 15:49:11 +0000 (21:19 +0530)]
libavcodec/pgxdec Fix pix format selection error

This patch makes the pgx decoder select the correct
byte order instead of selecting big endian format for
16 bit images.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolibavcodec/j2kenc: Encoding up to 16 bits
Gautam Ramakrishnan [Wed, 29 Jul 2020 15:49:10 +0000 (21:19 +0530)]
libavcodec/j2kenc: Encoding up to 16 bits

This patch allows the JPEG2000 encoder to
encode images to up to 16 bits.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mips: Fix segfault in imdct36_mips_float.
Shiyou Yin [Wed, 29 Jul 2020 10:11:01 +0000 (18:11 +0800)]
avcodec/mips: Fix segfault in imdct36_mips_float.

'li.s' is a synthesized instruction, it does not work properly
when compiled with clang on mips, and A segfault occurred.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mips/cabac: Fix a bug in get_cabac_inline_mips.
Shiyou Yin [Wed, 29 Jul 2020 10:11:00 +0000 (18:11 +0800)]
avcodec/mips/cabac: Fix a bug in get_cabac_inline_mips.

Failed fate case: fate-h264-conformance-caba2_sony_e
Clang is more strict in the use of register constraint.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavutil/mips/generic_macros_msa: Fix prob that 'ulw' and 'uld' unsupported by clang.
Shiyou Yin [Wed, 29 Jul 2020 10:10:59 +0000 (18:10 +0800)]
avutil/mips/generic_macros_msa: Fix prob that 'ulw' and 'uld' unsupported by clang.

GCC support these two synthesized instruction, but clang does not yet.
Use machine instruction instead to adapt clang compiler.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mips: Fix register constraint error reported by clang.
Shiyou Yin [Wed, 29 Jul 2020 10:10:58 +0000 (18:10 +0800)]
avcodec/mips: Fix register constraint error reported by clang.

Clang report following error in aacsbr_mips.c,ac3dsp_mips.c and aacdec_mips.c:
"couldn't allocate output register for constraint 'r'"

Use 'f' constraint for float variable.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/hlsenc: increase initial program date time precision
Marton Balint [Sat, 18 Jul 2020 21:57:42 +0000 (23:57 +0200)]
avformat/hlsenc: increase initial program date time precision

Also query time only once, not for every variant stream, otherwise variant
streams might get a slightly different initial program date time. And we can
set this unconditionally because HLS_PROGRAM_DATE_TIME flag is checked
elsewhere.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agofftools/ffmpeg: make specifying thread_queue_size turn on threaded input
Marton Balint [Sat, 4 Jul 2020 21:43:12 +0000 (23:43 +0200)]
fftools/ffmpeg: make specifying thread_queue_size turn on threaded input

Threaded input can increase smoothness of e.g. x11grab significantly. Before
this patch, in order to activate threaded input the user had to specify a
"dummy" additional input, with this change it is no longer required.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec/libsvt_av1: remove forced-idr option
Lynne [Wed, 29 Jul 2020 20:38:44 +0000 (22:38 +0200)]
avcodec/libsvt_av1: remove forced-idr option

This option is directly copy-pasted from the SVT1-HEVC wrapper and has
no place in the options for an AV1 encoder.

AV1 has no H.264/5 IDR frames nor anything like them.
All this option does is change all real keyframes to an intra-only
AV1 frame, which is not seekable. Hence, any streams encoded with
this option enabled will not be seekable.

3 years agoavcodec: Add an SVT-AV1 encoder wrapper
Daryl Seah [Fri, 18 Jan 2019 02:11:38 +0000 (02:11 +0000)]
avcodec: Add an SVT-AV1 encoder wrapper

Signed-off-by: Daryl Seah <daryl.seah@intel.com>
Signed-off-by: Jing SUN <jing.a.sun@intel.com>
Signed-off-by: ZhiZhen Tang <zhizhen.tang@intel.com>
Signed-off-by: Zhong Li <zhong.li@intel.com>
Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cavsdec, h264*, hevc_parser: Use get_ue_golomb_31 where possible
Andreas Rheinhardt [Tue, 14 Jul 2020 13:20:09 +0000 (15:20 +0200)]
avcodec/cavsdec, h264*, hevc_parser: Use get_ue_golomb_31 where possible

instead of get_ue_golomb(). The difference between the two is that the
latter also has to take into account the case in which the read code is
more than 9 bits (four preceding zeroes + at most five value bits) long,
leading to more code.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/golomb: Document return value of get_ue_golomb_31 on error
Andreas Rheinhardt [Tue, 14 Jul 2020 12:59:47 +0000 (14:59 +0200)]
avcodec/golomb: Document return value of get_ue_golomb_31 on error

get_ue_golomb_31() reads nine bits and an array with 512 entries to
parse golomb codes. The longest golomb codes that fit into 9 bits use
four leading zeroes and five value bits and can encode numbers in the
0..30 range. 31 meanwhile is encoded on 11 bits and if the nine bits
read coincide with the first nine bits of the encoding of 31,
get_ue_golomb_31() returns 31 (and skips 11 bits).

But looking at the first nine bits only makes it impossible to distinguish
31 from 32..34. Therefore the documentation of get_ue_golomb_31() simply
states that the return value is undefined if the value of the encountered
exp golomb code was outside the 0..31 range.

But actually get_ue_golomb_31() does not behave that bad: If the returned
value is in the range of 0..30, then this is the actually encountered value,
so that this function can be used without any problems to parse and validate
parameters whose legal values are a subset of the 0..30 range.

This commit documents this fact.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/golomb: Prevent shift by negative number
Andreas Rheinhardt [Fri, 10 Jul 2020 13:12:26 +0000 (15:12 +0200)]
avcodec/golomb: Prevent shift by negative number

This happened in get_ue_golomb() if the cached bitstream reader was in
use, because there was no check to handle the case of the read value
not being in the supported range.
For consistency with the uncached bitstream reader and for compliance
with the documentation, every value not in the 0-8190 range is treated as
error although the cached bitstream reader could actually read values in
the range 0..65534 without problems.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolibavcodec/jpeg2000dec: Support for PPM marker
Gautam Ramakrishnan [Sat, 25 Jul 2020 14:16:34 +0000 (19:46 +0530)]
libavcodec/jpeg2000dec: Support for PPM marker

This patch adds support for PPM marker for JPEG2000
decoder. It allows the samples p1_03.j2k and p1_05.j2k
to be decoded.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/jpeg2000dec: Move reslevelno check before use in case JPEG2000_PGOD_RPCL
Michael Niedermayer [Sun, 26 Jul 2020 17:41:30 +0000 (19:41 +0200)]
avcodec/jpeg2000dec: Move reslevelno check before use in case JPEG2000_PGOD_RPCL

Fixes: division by zero
Fixes: 24201/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5665813827420160
Fixes: 24245/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6285831682392064
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Gautam Ramakrishnan <gautamramk@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agolavc/libxavs2.c: mark key-frame packets
hwren [Mon, 27 Jul 2020 06:21:35 +0000 (14:21 +0800)]
lavc/libxavs2.c: mark key-frame packets

Signed-off-by: hwren <hwrenx@126.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/nvenc: fix B-Ref-Mode support check for recent HEVC
Timo Rothenpieler [Tue, 28 Jul 2020 19:44:11 +0000 (21:44 +0200)]
avcodec/nvenc: fix B-Ref-Mode support check for recent HEVC

3 years agoavcodec/golomb: Don't emit error message in get_ue_golomb
Andreas Rheinhardt [Fri, 10 Jul 2020 15:48:06 +0000 (17:48 +0200)]
avcodec/golomb: Don't emit error message in get_ue_golomb

Said error message is not very informative and lacked a proper logging
context; furthermore, many callers already provided more descriptive
error messages of their own. So just drop this one.

Suggested-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/smacker: Don't return packets for streams with AVDISCARD_ALL
Andreas Rheinhardt [Fri, 26 Jun 2020 07:09:01 +0000 (09:09 +0200)]
avformat/smacker: Don't return packets for streams with AVDISCARD_ALL

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/smacker: Fix duration for PCM audio
Andreas Rheinhardt [Fri, 24 Jul 2020 07:43:02 +0000 (09:43 +0200)]
avformat/smacker: Fix duration for PCM audio

For non-PCM audio, a Smacker frame contains the size of the decoded
audio in the first four bytes of the audio packet data; for PCM data,
said information would be redundant and according to [1] this field does
not exist. Therefore this commit sets the duration and timestamps
properly for PCM audio.

[1]: https://wiki.multimedia.cx/index.php/Smacker#Audio_Track_Chunk

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/smacker: Set audio duration
Andreas Rheinhardt [Fri, 24 Jul 2020 07:33:31 +0000 (09:33 +0200)]
avformat/smacker: Set audio duration

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/smacker: Support seeking to first frame
Timotej Lazar [Wed, 17 Jun 2020 19:45:39 +0000 (21:45 +0200)]
avformat/smacker: Support seeking to first frame

Add .read_seek function to the smacker demuxer for the special case of
seeking to ts=0. This is useful because smacker – like bink, with a
similar implementation – was mostly used to encode clips in video
games, where random seeks are rare but looping media are common.

Signed-off-by: Timotej Lazar <timotej.lazar@araneo.si>
3 years agolavf/srt: fix build fail when used the libsrt 1.4.1
Jun Zhao [Sun, 12 Jul 2020 05:48:48 +0000 (13:48 +0800)]
lavf/srt: fix build fail when used the libsrt 1.4.1

libsrt changed the:
SRTO_SMOOTHER   -> SRTO_CONGESTION
SRTO_STRICTENC  -> SRTO_ENFORCEDENCRYPTION
and removed the front of deprecated options (SRTO_SMOOTHER/SRTO_STRICTENC)
in the header, it's lead to build fail

fix #8760

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
3 years agoRevert "lavc/vaapi_encode: add EQUAL_MULTI_ROWS support for slice structure"
Mark Thompson [Mon, 27 Jul 2020 21:27:14 +0000 (22:27 +0100)]
Revert "lavc/vaapi_encode: add EQUAL_MULTI_ROWS support for slice structure"

This reverts commit 489c5db0791f39518775b12eef6d48276c17f96f.

Treating EQUAL_MULTI_ROWS in the same way as the arbitrary-size cases is
just wrong.  Consider 9 rows, 4 slices - we pick 4 slices with sizes
{ 3, 2, 2, 2 }, which EQUAL_MULTI_ROWS does not allow.  It isn't possible
to split the frame into 4 slices at all with the EQUAL_MULTI_ROWS
structure - the closest options are 3 slices with sizes { 3, 3, 3 } or 5
slices with sizes { 2, 2, 2, 2, 1 }.

3 years agohwcontext_vaapi: remove duplicate formats from sw_format list
Haihao Xiang [Fri, 24 Jul 2020 02:39:09 +0000 (10:39 +0800)]
hwcontext_vaapi: remove duplicate formats from sw_format list

hwcontext_vaapi maps different VA fourcc to the same pix_fmt for U/V
plane swap cases, however duplicate formats are not expected in sw_format
list when merging formats.

For example:
ffmpeg -loglevel debug -init_hw_device vaapi -filter_hw_device vaapi0 \
-f lavfi -i smptebars -vf \
"hwupload=derive_device=vaapi,scale_vaapi,hwdownload,format=yuv420p" \
-vframes 1 -f null -

Without this fix, an auto scaler is required for the above command
   Duplicate formats in ff_merge_formats detected
   [auto_scaler_0 @ 0x560df58f4550] Setting 'flags' to value 'bicubic'
   [auto_scaler_0 @ 0x560df58f4550] w:iw h:ih flags:'bicubic' interl:0
   [Parsed_hwupload_0 @ 0x560df58f0ec0] auto-inserting filter
   'auto_scaler_0' between the filter 'graph 0 input from stream 0:0' and
   the filter 'Parsed_hwupload_0'

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
3 years agohwcontext_vaapi: avoid fd leak in vaapi_device_derive
Haihao Xiang [Fri, 24 Jul 2020 07:29:03 +0000 (15:29 +0800)]
hwcontext_vaapi: avoid fd leak in vaapi_device_derive

3 years agoavutil/imgutils: always zero data pointers in av_image_fill_pointers()
James Almer [Mon, 27 Jul 2020 00:50:25 +0000 (21:50 -0300)]
avutil/imgutils: always zero data pointers in av_image_fill_pointers()

This restores the relevant behavior of the function as it was before
3a8e927176.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavutil/imgutils: don't fill data pointers for missing planes
James Almer [Fri, 24 Jul 2020 18:04:05 +0000 (15:04 -0300)]
avutil/imgutils: don't fill data pointers for missing planes

The size for a previous plane doesn't signal the presence of another after it.
If the plane is present, av_image_fill_plane_sizes() will have returned a size
for it.

Fixes a regression since 3a8e927176.

Reported-by: Imad R. Faiad <irfaiad@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavformat/ape: Error out in case of EOF in the header
Michael Niedermayer [Fri, 24 Jul 2020 21:51:11 +0000 (23:51 +0200)]
avformat/ape: Error out in case of EOF in the header

Fixes: OOM
Fixes: 24375/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6216862443241472
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 agoavformat/segafilmenc: Avoid seek when writing header
Andreas Rheinhardt [Fri, 17 Jul 2020 10:04:03 +0000 (12:04 +0200)]
avformat/segafilmenc: Avoid seek when writing header

Up until now, the Sega FILM muxer would first write all the packet data,
then shift the data (in the muxer's write_trailer function) by the amount
necessary to write the header at the front (which entails a seek to the
front), then seek back to the beginning and actually write the header.

This commit changes this: The dynamic buffer that is used to write the
sample table (containing information about each sample in the file) is
now used to write the complete header. This is possible because the size
of everything in the header except the sample table is known in advance.
Said buffer can then be used as one of the two temporary buffers used
for shifting which also reduces the amount one has to allocate for this.
Thereby the header will be written when shifting, so that the second
seek to the beginning is unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segafilmenc: Don't store packet info in linked list
Andreas Rheinhardt [Fri, 17 Jul 2020 07:25:24 +0000 (09:25 +0200)]
avformat/segafilmenc: Don't store packet info in linked list

Up until now, the Sega FILM muxer would store some information about
each packet in a linked list. When writing the trailer, the information
in said linked list would be used to write a table in the file header.
Each entry in said table is 16 bytes long, but each entry of the linked
list is 32 bytes long (assuming 64 bit pointer and no padding).
Therefore it makes sense to remove the linked list and write the array
entries directly into a dynamic buffer while writing the packet (this is
possible because the table entries don't depend on any information not
available when writing the packet (the offset is not relative to the
beginning of the file, but to the end of the table). This also
simplifies writing the array at the end (there is no need to traverse a
linked list).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segafilmenc: Simplify writing two bytes
Andreas Rheinhardt [Fri, 17 Jul 2020 07:11:53 +0000 (09:11 +0200)]
avformat/segafilmenc: Simplify writing two bytes

Use avio_wb16() instead of avio_write() to write two zero bytes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segafilmenc: Remove write-only variable
Andreas Rheinhardt [Fri, 17 Jul 2020 06:06:15 +0000 (08:06 +0200)]
avformat/segafilmenc: Remove write-only variable

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/segafilm: Reorder elements of struct to make it smaller
Andreas Rheinhardt [Fri, 17 Jul 2020 05:47:44 +0000 (07:47 +0200)]
avformat/segafilm: Reorder elements of struct to make it smaller

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/daudenc: Return proper error codes instead if -1
Andreas Rheinhardt [Fri, 17 Jul 2020 05:38:52 +0000 (07:38 +0200)]
avformat/daudenc: Return proper error codes instead if -1

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/daudenc: Turn write_header function into init function
Andreas Rheinhardt [Fri, 17 Jul 2020 05:36:11 +0000 (07:36 +0200)]
avformat/daudenc: Turn write_header function into init function

daud_write_header() doesn't write anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/webmdashenc: Cosmetics
Andreas Rheinhardt [Fri, 17 Jul 2020 05:32:52 +0000 (07:32 +0200)]
avformat/webmdashenc: Cosmetics

Mostly using intermediate pointers for accesses (i.e. storing s->pb in a
variable pb and then using pb for writing instead of s->pb) to improve
readability. Furthermore, the opening brace '{' of a function has been
moved into a line of its own in instances where it wasn't before.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/webmdashenc: Only check for existence of metadata if it is used
Andreas Rheinhardt [Fri, 17 Jul 2020 04:17:44 +0000 (06:17 +0200)]
avformat/webmdashenc: Only check for existence of metadata if it is used

Also return proper error codes when it is absent: AVERROR(EINVAL)
instead of AVERROR_INVALIDDATA.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/webmdashenc: Avoid allocations, fix memleak
Andreas Rheinhardt [Tue, 14 Jul 2020 22:06:10 +0000 (00:06 +0200)]
avformat/webmdashenc: Avoid allocations, fix memleak

When using the WebM DASH Manifest muxer, every stream of each adaptation
set has to contain a metadata entry containing the filename of the
source file. In case of live stream manifests, said filename has to
conform to a pattern of
<file_description>_<representation_id>.<extension>. These pieces are
used to create the other strings that are actually output. Up until now,
these other strings would be allocated, used once and then freed
directly after usage. This commit changes this: The function that
allocated and assembled these strings now returns pointers to the '_'
and '.' delimiters and so that the caller can easily pick substrings
from it without needing to copy the string.

Avoiding allocations also fixes a memleak: One of the allocated strings
would leak upon a subsequent allocation failure.

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