Commit Graph

44379 Commits

Author SHA1 Message Date
Jose Da Silva
c31a7d07f6 avcodec/xbmenc: Allow for making UW images
I've run into some bugs where I was downloading a bunch of data and began
seeing weird hiccups. For example, javascript promises to allow you to push
some very long lines of data, but the hiccups I saw was with data larger
than 2k in length (windows) pushed out of a child process stdout piped into
the stdin of the calling parent program.
Soo much for smooth promises, this was broken and would run into similar
problems on a linux PC with 32k line limits.
The solution was to break the data into smaller chunks than 2k - and then
these data hiccups disappeared (windows PC).

It would be expected to be similar for linux PCs (32k I think) and other
OSes with different sizes.

If the ANSI required minimum needs to be 509 chars or larger (assuming
509+<CR>+<LF>+<0>=512), then 509 was chosen as the shortest worst-case
scenario) in this patch.
Most small pictures will go output looking pretty much the same data out
until you get to about 84bytes (672 pixels wide), where lines out begin to
be split. For example a UW 4K will exceed a 2k readln and a UW 10K picture
approaches an 8k readln

The purpose for this patch is to ensure that data remains below the
readline limits (of 509 chars), so that programs (like javascript) can push
data in large chunks without breaking into hiccups because the data length
is too long to be pushed cleanly in one go.
Subject: [PATCH 3/3] avcodec/xbmenc: Allow for making UW images

Worst-case ANSI must allow for 509 chars, while Windows allows for 2048
and Linux for 32K line length. This allows an OS with a small readline
access limitation to fetch very wide images (created from ffmpeg).
2021-01-28 15:50:37 +01:00
Jose Da Silva
cb70e1921a avcodec/xbmenc: xbm Lower memory use
Two minor memory improvements.

First bug reduces memory needed to about 6/7 the needed amount, which
allows you to host almost 7 pictures in the same memory needed for 6
Second is a recalculation of the total additional memory for headers etc.

size = avctx->height x (linesize * 6 + 1) + (31+32+38+4+1)
Subject: [PATCH 2/3] avcodec/xbmenc: xbm Lower memory use

Small 6/7th size memory reduction.
size = avctx->height x (linesize * 6 + 1) + (31+32+38+4+1)

Signed-off-by: Joe Da Silva <digital@joescat.com>
2021-01-28 15:50:25 +01:00
Jose Da Silva
41b8fd3a16 avcodec/xbmenc: Do not add last comma into output
There is a minor bug in xbm encode which adds a trailing comma at the end
of data. This isn't a big problem, but it would be nicer to be more
technically true to an array of data (by not including the last comma).

This bug fixes the output from something like this (having 4 values):
static unsigned char image_bits[] = { 0x00, 0x11, 0x22, }
to C code that looks like this instead (having 3 values):
static unsigned char image_bits[] = { 0x00, 0x11, 0x22 }
which is the intended results.
Subject: [PATCH 1/3] avcodec/xbmenc: Do not add last comma into output array

xbm outputs c arrays of data.
Including a comma at the end means there is another value to be added.
This bug fix changes something like this:
static unsigned char image_bits[] = { 0x00, 0x11, 0x22, }
to C code like this:
static unsigned char image_bits[] = { 0x00, 0x11, 0x22 }

Signed-off-by: Joe Da Silva <digital@joescat.com>
2021-01-28 15:50:09 +01:00
Andreas Rheinhardt
9267e2ff0d avcodec/flashsv2enc: Fix use of uninitialized value
Before 257a83b969, certain buffers were
zero-allocated in the init function and only reallocated lateron if they
turned out to be too small; now they are only allocated during init,
leading to use-of-uninitialized values lateron. The same could happen
before if the dimensions are big enough so that the buffers would be
reallocated, as the new part of the reallocated buffer would not be
zeroed (happened for 960x960). So always zero the buffers in the
function designed to init them.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-28 13:59:00 +01:00
Andreas Rheinhardt
9f38fac053 avcodec/h261dec: Make VLC smaller
The VLC for the macroblock address increment uses nine bits;
yet there is no code with this length: All codes are either shorter or
longer. So one can make the table smaller without changing the amount of
codes that need more than one round of parsing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-27 11:53:22 +01:00
Andreas Rheinhardt
ba96f2254a Revert "mpeg4videodec: raise an error if sprite_trajectory.table is NULL"
This reverts commit 6ac0e78183.

The mpeg4video parser can reach code that presumes that a certain VLC
has been initialized; yet Libav did not ensure this and Libav bug #1012
[1] is about an ensuing crash.

Instead of fixing the root cause a simple check for whether said VLC
has already been initialized was added; said check is inherently racy.

The proper fix is of course to ensure that the VLC is initialized and
commit 7c76eaeca2 already ensured this,
so there was no need to merge 6ac0e78183
at all. This commit therefore reverts said commit.

[1]: https://bugzilla.libav.org/show_bug.cgi?id=1012

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-27 11:53:22 +01:00
James Almer
683cd25c5a avcodec/sei: add Parameter Sets Inclusion Indication enum value
Defined in H.274, it shares the same value as Active Parameter Sets from the
H.265 spec.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-26 21:27:29 -03:00
Michael Niedermayer
33f6d8e376 avcodec/cri: Fix whitespace issue in unpack_10bit()
Found-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-01-26 19:52:59 +01:00
Michael Niedermayer
59a6becf8e avcodec/apedec: Use FFABSU() in do_apply_filter()
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 29053/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-4814432697974784

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-01-26 18:37:12 +01:00
Anton Khirnov
9e30859cb6 lavc: shedule old encoding/decoding API for removal
It has been deprecated for 4 years and certain new codecs do not work
with it.

Also include AVCodecContext.refcounted_frames, as it has no effect with
the new API.
2021-01-26 17:05:58 +01:00
Anton Khirnov
25f4304ebb lavc/decode: move unrefcount_frame() right before its only caller
Will make wrapping it in deprecation guards simpler.
2021-01-26 17:05:49 +01:00
Andreas Rheinhardt
2490ac635c avcodec/mpeg4videodec: Fix indentation
It was wrong since e03bf251d8.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-26 13:57:00 +01:00
Andreas Rheinhardt
f410febddc avcodec/mpeg4videodec: Move code around to avoid forward declaration
Also fix the indentation of decode_studio_vol_header while at it;
it was wrong since 177133a0f4.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-26 13:57:00 +01:00
Andreas Rheinhardt
d9f5bd15fd avcodec/sp5x: Remove unused quant tables
Only the fifth one is used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-26 13:57:00 +01:00
Andreas Rheinhardt
f15477169e avcodec/exif: Avoid allocation for small buffer
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-26 13:56:59 +01:00
Andreas Rheinhardt
458acb61fa avcodec/amrnbdata: Remove unused array
Always unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-26 13:56:59 +01:00
Andreas Rheinhardt
edfdcb0487 avcodec/ilbcdata: Remove unused array
Never used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-26 13:56:59 +01:00
Andreas Rheinhardt
2668caf13c avcodec/atrac3plus_data: Remove unused arrays
Forgotten in 58fc810d42.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-26 13:56:59 +01:00
Andreas Rheinhardt
10d059bb24 avcodec/dnxhd: Make ff_dxnhd_get_cid_table return a pointer, not index
All callers only use the index into ff_dnxhd_cid_table to get a pointer
to the desired entry.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-26 13:56:59 +01:00
James Almer
56709ca8aa avcodec: deprecate AVCodecContext.debug_mv
It's been unused for almost three years now.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-25 19:31:04 -03:00
James Almer
c3f3b562c9 avcodec: remove long dead debug_mv code
FF_API_DEBUG_MV has been zero since ffmpeg 4.0

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-25 19:03:22 -03:00
James Almer
81d070dd09 avcodec/dolby_e: split decoder and parser more thoroughly
Neither module should depend on the other.

Move shared functions to its own file for this purpose, and ensure
source files are compiled only when the required modules are enabled.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-25 16:45:20 -03:00
Andreas Rheinhardt
61fe481586 avcodec/h263data, ituh263*: Make initializing RL inter table thread-safe
Up until now, ff_h263_rl_inter was initialized by both ituh263dec and
ituh263enc; this is an obstacle in making the codecs that use this code
init-threadsafe.

This obstacle is eliminated by only initializing this RLTable from
a single place that is guarded by a dedicated AVOnce.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:52:58 +01:00
Andreas Rheinhardt
12d0bb382b avcodec/ituh263enc: Remove unused function parameter
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:52:55 +01:00
Andreas Rheinhardt
1ea13f949a avcodec/ituh263dec: Don't initialize unused parts of RLTable
The RLTable ff_rl_intra_aic is only used by ituh263dec and ituh263enc;
the former only uses the RLTable's VLC, the latter only index_run,
max_level and max_run. Yet ituh263dec also initializes the latter.
This commit stops doing so.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:52:52 +01:00
Andreas Rheinhardt
18e89b964c avcodec/h261enc: Make encoder init-threadsafe
This is easy now that the H.261 encoder is the only user that
initializes the non-VLC parts of ff_h261_rl_tcoeff.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:52:51 +01:00
Andreas Rheinhardt
41826f84bb avcodec/h261dec: Reindentation
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:52:49 +01:00
Andreas Rheinhardt
7afc6d71a0 avcodec/h261dec: Make decoder init-threadsafe
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:52:24 +01:00
Andreas Rheinhardt
ed913fcb59 avcodec/h261dec: Don't initialize unused part of RLTable
The H.261 decoder only uses an RLTable's VLC table, yet it also
initializes its index_run, max_level and max_run. This commit stops
doing so; it will also simplify making this decoder init-threadsafe,
as the H.261 decoder and encoder now initialize disjoint parts of their
common RLTable.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:52:05 +01:00
Andreas Rheinhardt
44bb776f13 avcodec/mpegvideo_enc: Make mpv_encode_defaults thread-safe
This is a prerequisite for making any encoder that uses
ff_mpv_encode_init() init-threadsafe; it already makes the AMV,
the MJPEG and the MPEG-1/2 encoders init-threadsafe.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Andreas Rheinhardt
27eea249cc avcodec/msmpeg4dec: Reuse identical MV VLC
msmpeg4dec and ituh263dec both create VLCs with identical parameters out
of ff_mvtab. Given that ff_msmpeg4_decode_init() always (indirectly) calls
ff_h263_decode_init_vlc(), the VLC initialized by the latter can be
directly used by msmpeg4dec. Doing so saves a bit more than 2KB from the
.bss segment as well as the code to initialize a VLC.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Andreas Rheinhardt
d90d0a715f avcodec/msmpeg4dec: Reuse identical RL VLCs
Some of the RLTables used by msmpeg4dec actually coincide with other
RLTables: ff_rl_table[5] coincides with ff_h263_rl_inter (and
ff_rl_table[2] with ff_mpeg4_rl_intra). Given that ff_h263_rl_inter is
always initialized before msmpeg4dec's RLTables are initialized, one can
just reuse the VLC tables by copying the pointers; after all, there are
no ownership issues for static data. This saves 70912B from the .bss
segment, translating into actual memory savings when this decoder is
actually used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Andreas Rheinhardt
a3831e81ff avcodec/ituh263dec: Don't initialize unused RL VLCs
The ff_rl_intra_aic RLTable is only used by ituh263dec and ituh263enc;
the former is the only user of its RL VLC tables. It uses only the very
first one of these VLC tables, but up until now all 32 are initialized,
wasting 68696B from the .bss segment (or that amount of memory if this
decoder has actually been used). This commit changes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Andreas Rheinhardt
3e0bd5064d avcodec/mpeg4videodec: Don't initialize unused RL VLCs
The RLTables whose VLC tables are only used for intra blocks only use
the very first VLC table; yet all 32 have been initialized. This commit
stops this by switching to INIT_FIRST_VLC_RL. This saves 201624B from
the .bss segment; in case the decoder is actually used, this translates
into less memory used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Andreas Rheinhardt
b0c4748770 avcodec/msmpeg4dec: Don't initialize unused RL VLCs
For the RLTables ff_rl_table[0..2] only the very first VLC is only ever
used, so it makes no sense to create 32 of them. This saves 285200B from
the .bss segment; this amount of memory is actually saved when this
decoder is used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Andreas Rheinhardt
b9071a70fc avcodec/h261dec: Don't initialize unused VLCs
The H.261 decoder uses only the very first VLC of ff_h261_rl_tcoeff,
so only initialize this one. Saves 68448B from the .bss segment; in case
the decoder is actually used, this amount of memory is saved.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Andreas Rheinhardt
8f04988e46 avcodec/rl: Allow to create only a few VLC tables
It is not uncommon that only the first one is used; this is similar to
ff_init_2d_vlc_rl().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Andreas Rheinhardt
f741bd0674 avcodec/mpeg12enc, speedhqenc: Avoid redundant copies of tables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Nicolas Gaullier
c7016e35a6 avcodec/dolby_e: Split decoder/parser files 2021-01-25 13:19:48 +01:00
Nicolas Gaullier
0bf18db26a avcodec/dolby_e: Add a parser 2021-01-25 13:17:43 +01:00
Andreas Rheinhardt
ae5be6236f avcodec/tiff_common: Remove declarations of inexistent functions
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 00:23:17 +01:00
Andreas Rheinhardt
a82001c8cf avcodec/vp8data: Remove unused array
Unused since 748f921ad1.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 00:18:47 +01:00
Peter Ross
63be96414b avcodec/dvenc: dv100_weight_shift never used
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-24 09:35:12 +11:00
Marton Balint
257a83b969 avcodec/flashsv2enc: factorize updating block dimensions
The patch changes the init function to initialize block dimensions to fixed
64x64 instead of the previously used image width/height based value.

This should not cause any actual change in behaviour because block dimensions
are recalculated on every keyframe in optimum_block_width() and
optimum_block_height() functions and in the current code the result is always
64x64 regardless of the image dimensions used.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-23 20:13:39 +01:00
Haihao Xiang
b8cd37a59f qsv: dump more info in error, debug and verbose mode
Dump iopattern mode and the SDK error/warning desciptions for qsv based
filters and iopattern mode for qsvenc

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com
2021-01-23 16:10:16 +00:00
Xu Guangxin
7a5a5e68bf avcodec/qsvdec: refact, remove duplicate code for plugin loading
Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
2021-01-23 16:07:54 +00:00
Xu Guangxin
d78ecf10bd avcodec/qsvdec: refact, move qsvdec_other.c to qsvdec.c
Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
2021-01-23 16:07:27 +00:00
Xu Guangxin
399c1f9235 avcodec/qsvdec: refact, move qsvdec_h2645.c to qsvdec.c
Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
2021-01-23 16:06:37 +00:00
Xu Guangxin
e8df3808bd avcodec/qsvdec_h2645: refact, use DEFINE_QSV_DECODER to remove duplicate code
Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
2021-01-23 16:04:40 +00:00
Xu Guangxin
96915ac51b avcodec/qsvdec_other: refact, use DEFINE_QSV_DECODER to remove duplicate code
Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
2021-01-23 16:04:09 +00:00