Commit Graph

94309 Commits

Author SHA1 Message Date
Andreas Rheinhardt
ddd53ef66d h265_metadata: Avoid allocations and copies of packet structures
This commit changes h265_metadata to (a) use ff_bsf_get_packet_ref
instead of ff_bsf_get_packet (thereby avoiding one malloc and free per
filtered packet) and (b) to use only one packet structure at all,
thereby avoiding a call to av_packet_copy_props.

(b) has been made possible by the recent changes to ff_cbs_write_packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:59:20 +01:00
Andreas Rheinhardt
9362f1a982 h264_redundant_pps: Fix looping over an access unit's units
When looping over an access unit's units in positive direction and
deleting some of them, one needs to make sure that a unit that is at
the position of a unit that just got deleted gets checked, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:59:16 +01:00
Andreas Rheinhardt
d78553cc4c h264_redundant_pps: Avoid allocations and copies of packet structures
This commit changes h264_redundant_pps to (a) use ff_bsf_get_packet_ref
instead of ff_bsf_get_packet (thereby avoiding one malloc and free per
filtered packet) and (b) to use only one packet structure at all,
thereby avoiding a call to av_packet_copy_props.

(b) has been made possible by the recent changes to ff_cbs_write_packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:57:55 +01:00
Andreas Rheinhardt
3f81cc8c94 av1_metadata: Error out if fragment is empty
If the fragment is empty after parsing (i.e. it contains no OBUs), then
the check for the type of the fragment's first OBU is nonsensical; so
error out in this case just as h264_metadata and hevc_metadata do.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:40:55 +01:00
Andreas Rheinhardt
3c8a2a1180 h264_metadata: Localize code for display orientation
The recent changes to h264_metadata (enabled by the recent changes to
ff_cbs_write_packet) made it possible to add side_data to the output
packet at any place, not only after the output packet has been written
and the properties of the input packet copied. This means that one can
now localize the code to add display orientation side-data to the packet
to the place dealing with said display-orientation.

Furthermore, the documentation of av_display_rotation_set states that
the matrix will be fully overwritten by it, so there is no need to
allocate it with av_mallocz.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:17:07 +01:00
Andreas Rheinhardt
a72cc47a27 h264_metadata: Avoid allocations and copies of packet structures
This commit changes h264_metadata to (a) use ff_bsf_get_packet_ref
instead of ff_bsf_get_packet (thereby avoiding one malloc and free per
filtered packet) and (b) to use only one packet structure at all,
thereby avoiding a call to av_packet_copy_props.

(b) has been made possible by the recent changes to ff_cbs_write_packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:17:07 +01:00
Andreas Rheinhardt
36fcdc3fbe av1/h264_metadata, filter_units: Count down when deleting units
When testing whether a particular unit should be kept or discarded, it
is best to start at the very last unit of a fragment and count down,
because that way a unit that will eventually be deleted won't be
memmoved during earlier deletions; and frag/au->nb_units need only be
evaluated once in this case and the counter is automatically correct
when a unit got deleted.

It also works for double loops, i.e. when looping over all SEI messages
in all SEI units of an access unit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:17:07 +01:00
Andreas Rheinhardt
b0810454e4 filter_units: Avoid allocations and copies of packet structures
This commit changes filter_units to (a) use ff_bsf_get_packet_ref
instead of ff_bsf_get_packet (thereby avoiding one malloc and free per
filtered packet) and (b) to use only one packet structure at all,
thereby avoiding a call to av_packet_copy_props (or, in case of
passthrough, to av_packet_move_ref).

(b) has been made possible by the recent changes to ff_cbs_write_packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:17:07 +01:00
Andreas Rheinhardt
57f9bc90ae filter_units: Reindent after previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:17:07 +01:00
Andreas Rheinhardt
83be17cfcd filter_units: Don't use fake loop
According to the BSF API, when a BSF is finished with an input packet,
it should return AVERROR(EAGAIN) to signal that another packet should be
sent to the BSF via av_bsf_send_packet that the actual BSF can receive
via ff_bsf_get_packet[_ref]. filter_units on the other hand simply called
ff_bsf_get_packet again if the first packet received didn't result in
any output. This call of course returned AVERROR(EAGAIN) which was
returned, but it is nevertheless better to not include a fake loop.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:17:07 +01:00
Andreas Rheinhardt
45fd7e44a4 filter_units: Unref packet on failure
According to the API, the packet structure a bsf receives must not be
touched on failure, yet filter_units nevertheless did it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:17:07 +01:00
Andreas Rheinhardt
7549f0ac1b av1_metadata: Avoid allocations and copies of packet structures
This commit changes av1_metadata to (a) use ff_bsf_get_packet_ref
instead of ff_bsf_get_packet (thereby avoiding one malloc and free per
filtered packet) and (b) to use only one packet structure at all,
thereby avoiding a call to av_packet_copy_props.

(b) has been made possible by the recent changes to ff_cbs_write_packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:17:06 +01:00
Andreas Rheinhardt
1e93f5060f cbs: Allow non-blank packets in ff_cbs_write_packet
Up until now, ff_cbs_write_packet always initialized the packet
structure it received without documenting this behaviour; furthermore,
the packet's buffer would (on success) be overwritten with the new
buffer without unreferencing the old. This meant that the input packet
had to be either clean (otherwise there would be memleaks) in which case
the initialization is redundant or uninitialized. ff_cbs_write_packet
was never used with uninitialized packets, so the initialization was
redundant. Worse yet, it forced callers to use more than one packet and
made it difficult to add side-data to a packet designated for output,
because said side-data could only be attached after the call to
ff_cbs_write_packet.

This has been changed. It is now allowed to use a non-blank packet.
The currently existing buffer will be unreferenced and replaced by
the new one, as will be the accompanying fields (i.e. data and size).
The rest isn't touched at all.

This change will enable us to use only one packet in the bitstream
filters that rely on CBS.

This commit also updates the documentation of ff_cbs_write_extradata
and ff_cbs_write_packet (to better describe existing behaviour and in
the latter case to also describe the new behaviour).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 22:17:06 +01:00
Amir Pauker
f6dece864d avcodec/h264dec: set AVFrame decode_error_flags in case of decoding error
set AVFrame decode_error_flags in case h->slice_ctx->er.error_occurred is set
after the call to ff_h264_execute_decode_slices. This allows the user to detect
concealed decoding errors in the call to avcodec_receive_frame

Signed-off-by: Amir Pauker <amir@livelyvideo.tv>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-07 22:34:05 +02:00
Amir Pauker
70ba8e2fa0 avcodec/error_resilience: set AVFrame decode_error_flags in case of decoding error
Signed-off-by: Amir Pauker <amir@livelyvideo.tv>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-07 22:34:05 +02:00
Mark Thompson
f6c572bd89 libx265: Update ROI behaviour to match documentation
Equivalent to the previous patch for libx264.
2019-07-07 19:19:26 +01:00
Mark Thompson
d76e2aaf08 libx264: Update ROI behaviour to match documentation
Fix the quantisation offset - use the whole range, and don't change the
offset size based on bit depth.

Iterate the list in reverse order.  The first region in the list is the one
that applies in the case of overlapping regions.
2019-07-07 19:19:26 +01:00
Mark Thompson
451a51124d lavu/frame: Improve ROI documentation
Clarify and add examples for the behaviour of the quantisation offset,
and define how multiple ranges should be handled.
2019-07-07 19:19:26 +01:00
Mark Thompson
cd3578a8e4 lavc/h265_profile_level: Add new profiles
Monochrome 10 and Main 10 Still Picture profiles are added by the 2018
version of the standard.
2019-07-07 13:29:51 +01:00
Mark Thompson
e3424575f5 lavc/h265_profile_level: Add unit test
Operates in the same way as the h264-levels test.
2019-07-07 13:29:50 +01:00
Mark Thompson
c7142875c3 h265_metadata: Add option to set the level of the stream
To match the same option in h264_metadata.
2019-07-07 13:29:50 +01:00
Mark Thompson
f344bb2466 lavc/h265_profile_level: Do not allow high tier at level < 4 2019-07-07 13:29:50 +01:00
Mark Thompson
c1a430885d lavc/h265_profile_level: Fix DPB size calculation
The maxDpbPicBuf value which is used in the DPB size calculation depends
on the profile (it's usually 6, but 7 for screen-extended profiles).
2019-07-07 13:29:50 +01:00
Paul B Mahol
ca576833e4 avcodec/cngdec: set .caps_internal 2019-07-07 11:33:19 +02:00
Calvin Walton
2bd21b9609 vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
Changes to vf_drawtext.c written by
Calvin Walton <calvin.walton@kepstin.ca>

Changes to filters.texi written by
greg Luce <electron.rotoscope@gmail.com>
with lots of help from Moritz Barsnick and Gyan

Fixes #7947.
2019-07-07 11:12:07 +05:30
Michael Niedermayer
b7b6ddd596 avcodec/alsdec: Add FF_CODEC_CAP_INIT_CLEANUP
Fixes: multiple memleaks
Fixes: 15293/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5642409288925184

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-06 22:50:21 +02:00
Michael Niedermayer
5f64f6058e avcodec/alsdec: Fix integer overflow with buffer number
Fixes: signed integer overflow: 65313 * 65313 cannot be represented in type 'int'
Fixes: 15290/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5738074249625600

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-06 22:50:21 +02:00
Michael Niedermayer
7f527021df avcodec/alsdec: Fixes signed integer overflow in LSB addition
Fixes: signed integer overflow: 8 * 536870912 cannot be represented in type 'int'
Fixes: 15281/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5744458785619968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-06 22:50:21 +02:00
Michael Niedermayer
0794494c8f avcodec/alsdec: Check opt_order / sb_length in ra_block handling
Fixes: out of array access
Fixes: 15277/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5184853437317120
Fixes: 15280/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5741062137577472

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-06 22:50:21 +02:00
Michael Niedermayer
a3bd4b260e avcodec/alsdec: Fix integer overflow with shifting samples
Fixes: signed integer overflow: -346039050 * 8 cannot be represented in type 'int'
Fixes: 15283/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5692700268953600

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-06 22:50:21 +02:00
Michael Niedermayer
51f6870c37 avcodec/alsdec: Fix undefined behavior in decode_rice()
Fixes: left shift of 72 by 26 places cannot be represented in type 'int'
Fixes: 15279/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5700665621348352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-06 22:50:21 +02:00
Michael Niedermayer
e131568752 avcodec/alsdec: Fixes invalid shifts in read_var_block_data() and INTERLEAVE_OUTPUT()
Fixes: left shift of negative value -6
Fixes: 15275/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5742361767837696
Fixes: signed integer overflow: 41582592 * 256 cannot be represented in type 'int'
Fixes: 15296/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5739558227935232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-06 22:50:21 +02:00
Andreas Rheinhardt
eb33be188d matroskadec: Fix overflow introduced in a569a7b3
This commit fixes an overflow introduced in a569a7b3 that affected EBML
elements that the Matroska demuxer doesn't want to parse like CRC-32
elements. The return value of avio_skip (the new position on success or
an AVERROR on failure) has been assigned to an integer which meant that
new positions in the range of 2GB to 4GB-1 etc. were considered errors.

Fixes ticket #8001.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-07-06 14:48:54 -03:00
Paul B Mahol
b9a6106842 avfilter/af_afftfilt: remove invalid scaling 2019-07-06 12:01:38 +02:00
Jun Zhao
feade2b403 doc/filters: Document missing options for scale in/out color matrix
Document missing options for scale in/out color matrix

Reviewed-by: Gyan Doshi <ffmpeg@gyani.pro>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-07-06 13:12:13 +08:00
Jun Zhao
3ed0b3f6f7 lavfi/scale: Add sub-options for in_color_matrix/out_color_matrix
Add sub-options for in_color_matrix/out_color_matrix

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-07-06 13:12:13 +08:00
James Almer
7c644989a5 avcodec/hevc_ps: fix range of num_tile_{columns,rows}_minus1
From 7.4.3.3.1:

num_tile_columns_minus1 shall be in the range of 0 to PicWidthInCtbsY - 1, inclusive.
num_tile_rows_minus1 shall be in the range of 0 to PicHeightInCtbsY - 1, inclusive.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-07-05 16:30:40 -03:00
Cameron Cawley
0cbdedbd2f avformat/rpl: Calculate the duration of the video track
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-05 18:14:11 +02:00
Cameron Cawley
1f8336fd98 avformat/rpl: Allow a file to have audio, but not video
Signed-off-by: Cameron Cawley <ccawley2011@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-05 17:08:44 +02:00
Cameron Cawley
dcf3f8b368 avformat/rpl: Fix detection of 8-bit linear formats
Was previously broken by commit 8cf5f94.
Fixes ticket #7859

Signed-off-by: Cameron Cawley <ccawley2011@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-05 17:08:44 +02:00
Paul B Mahol
0f39ef4db2 avfilter/vf_lut: fix regression with >8bit planar filtering 2019-07-05 12:55:02 +02:00
Steven Liu
a514244319 avformat/dashdec: fix code style in dash_read_packet 2019-07-05 11:52:49 +08:00
Jun Zhao
9269bccbb3 doc/muxers: fix docs format for DASH muxer
fix docs format for DASH muxer

Reviewed-by: Gyan Doshi <ffmpeg@gyani.pro>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-07-04 19:42:01 +08:00
Steven Liu
6e988b75df avformat/dashdec: refine and fix code style of dash_read_header
move the temp variable to the top of the expression paragraph
rename the pls to rep(representation)
2019-07-04 16:11:47 +08:00
Steven Liu
43e0ddd33d avformat/dashdec: simplified code in open_demux_for_component
change from pls->ctx->streams[i]->codecpar to ist->codecpar

Signed-off-by: Steven Liu <lq@onvideo.cn>
2019-07-04 15:08:41 +08:00
Yonglin Luo
664a27ea40 libavfilter/vf_colorspace.c: fix demarcation point of gamma linearize function
The linearize function (usually refered to EOTF) is the inverse of
delinearize function (usually referred to OETF). Demarcation point of
EOTF should be beta*delta, but the actual value used now in the source
code is beta.

For ITU Rec.709, they are 0.081 (0.018*4.5) and 0.018 respectively
(beta = 0.018 and delta = 4.5), and they correspond to pixel value 5
and 21 for an 8-bit image. Linearized result of pixel within that range
(5-21) will be different, but this commit will make linearize function
of the filter more accurate in the mathematical sense.

Signed-off-by: Yonglin Luo <vincenluo@tencent.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2019-07-03 13:57:11 -04:00
Paul B Mahol
1ac643f066 avfilter/vf_lut2: use time_base from framesync
Fixes non-monotonous timestamps.
2019-07-03 14:54:05 +02:00
Paul B Mahol
cc5c636780 avfilter/vf_midequalizer: use time_base from framesync
Fixes non-monotonous timestamps.
2019-07-03 14:54:05 +02:00
Paul B Mahol
d49d7d238f avfilter/vf_blend: use time_base from framesync
Fixes non-monotonous timestamps.
2019-07-03 14:54:05 +02:00
Paul B Mahol
d71dafb2ab avfilter/vf_maskedclamp: use time_base from framesync
Fixes non-monotonous timestamps.
2019-07-03 14:54:05 +02:00