Commit Graph

6 Commits

Author SHA1 Message Date
Michael Niedermayer 7bba0dd638 avcodec/frame_thread_encoder: Free AVCodecContext structure on error during init
Fixes: MemLeak
Fixes: 8281
Fixes: PoC_option158.jpg
Fixes: CVE-2020-22037

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-17 10:34:10 +02:00
Andreas Rheinhardt 3f6e715336 avcodec/frame_thread_encoder: Avoid dictionaries
avcodec_open2() allows to provide options via an AVDictionary;
but it is also allowed to set options by simply setting the value
of the AVCodecContext or via the AVOptions API if the codec has
a private class. Any options provided via an AVDictionary have already
been applied before ff_frame_thread_init(), so in order to copy
all the options from the main AVCodecContext and its private context,
it is enough to av_opt_copy() these options.

The current code does this, but it does more: It also copies the
user-provided AVDictionary and uses it for the initialization of
each of the worker-AVCodecContexts. This is completely unnecessary,
because said options have already been copied from the main context.

Furthermore, these options were also examined to decide if frame
threading should be used for huffman encoding in case this would incur
nondeterminism. This is wrong, because options not set via
an AVDictionary are ignored. Instead inspect the values stored in the
contexts directly. (In order to maintain the current behaviour, the
default value of the "non_deterministic" option has been changed to false,
because the absence of an entry with said key in the AVDictionary
had the consequence of disallowing nondeterminism.)

Finally, the AVDictionary has been removed from the signature of
ff_frame_thread_encoder_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-06-08 12:52:50 +02:00
Andreas Rheinhardt 76d428e090 avcodec/frame_thread_encoder: Avoid creating reference to frame
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-16 22:11:53 +01:00
Timothy Gu 44304ae322 all: Add missing header guards 2016-01-28 19:49:48 -08:00
Michael Niedermayer 097a909ea1 frame_thread_encoder: pass private options
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-29 04:26:36 +02:00
Michael Niedermayer fde1bc64ad lavc: add frame multithreading capability (currently intra only)
Compared to the decoder side, this code is able to change both the
delay and the number of threads seamlessly during encoding. Also
any idle thread can pick up tasks, the strict round robin in order
limit is gone too.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-06-23 01:38:47 +02:00