1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

182 Commits

Author SHA1 Message Date
Paul B Mahol
507fdcd1b0 avcodec/dnxhddec: ignore second flag for encoded field
And instead use previous field flag.

Fixes decoding files produced by non-compliant encoders.
2021-08-25 22:48:23 +02:00
maryam ebr
7150f95756 avcodec/dnxhddec: check and propagate function return value
Similar to CVE-2013-0868, here return value check for 'init_vlc' is needed.
crafted DNxHD data can cause unspecified impact.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-03 10:39:37 -03:00
Andreas Rheinhardt
b539ed3fd5 avcodec/dnxhddec: Mark decoder as init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-10 22:12:02 +02:00
Andreas Rheinhardt
a247ac640d avcodec: Constify AVCodecs
Given that the AVCodec.next pointer has now been removed, most of the
AVCodecs are not modified at all any more and can therefore be made
const (as this patch does); the only exceptions are the very few codecs
for external libraries that have a init_static_data callback.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:15 -03: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
Anton Khirnov
e15371061d lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bump
They are not properly namespaced and not intended for public use.
2021-01-01 14:14:57 +01:00
Anton Khirnov
1f4cf92cfb pthread_frame: merge the functionality for normal decoder init and init_thread_copy
The current design, where
- proper init is called for the first per-thread context
- first thread's private data is copied into private data for all the
  other threads
- a "fixup" function is called for all the other threads to e.g.
  allocate dynamically allocated data
is very fragile and hard to follow, so it is abandoned. Instead, the
same init function is used to init each per-thread context. Where
necessary, AVCodecInternal.is_copy can be used to differentiate between
the first thread and the other ones (e.g. for decoding the extradata
just once).
2020-04-10 15:24:54 +02:00
Andreas Rheinhardt
cc2a9509ce libavcodec, libpostproc: Remove outcommented START/STOP_TIMER
as well as includes of libavutil/timer.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-03-14 18:24:04 +01:00
Paul B Mahol
d01d606504 avcodec/dnxhddec: properly set colorspace 2020-01-29 09:42:14 +01:00
Ramiro Polla
c268712895 avcodec/dnxhddec: fix block alignment
blockdsp requires 32 byte alignment.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-12-26 13:57:50 -03:00
Paul B Mahol
5487560acf avcodec/dnxhddec: use init_get_bits8() 2018-12-03 19:44:49 +01:00
Paul B Mahol
237bbf6678 avcodec/dnxhddec: ask for samples with alpha 2018-09-06 13:47:48 +02:00
Michael Niedermayer
b2be76c0a4 avcodec/dnxhddec: Check dc vlc
Fixes: signed integer overflow: 1024 + 2147483640 cannot be represented in type 'int'
Fixes: 4671/clusterfuzz-testcase-minimized-6027464343027712

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>
2018-01-05 03:35:48 +01:00
Steven Robertson
c6a905b91d avcodec/dnxhddec: Do not overwrite colorspace if the container has set it.
The existing logic overrides container metadata even in cases where the
container metadata must be trusted (e.g. HDR). The original spec had no
provision for specifying color volume, so many files rely on the
assumption of Rec. 709.

An update to the spec included a 'clv' field for explicitly signaling
that the container should be trusted in an existing bitfield in the
frame header, but the default of 0 from old encoders forces Rec. 709,
which would break any HDR stream. Because there is no place in DNxHR for
specifying a transfer function, DNxHR HDR files must include
container-level color information.

This patch maintains the existing behavior of choosing the 709 over the
601 matrix when container-level information is missing, and allows
container-level information to win if present.

Signed-off-by: Steven Robertson <steven@strobe.cc>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-11-30 02:46:22 +01:00
Michael Niedermayer
296debd213 avcodec/dnxhddec: Move mb height check out of non hr branch
Fixes: out of array access
Fixes: poc.dnxhd

Found-by: Bingchang, Liu@VARAS of IIE
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-07-27 03:07:12 +02:00
James Almer
2b4cc8d1bb avcodec/dnxhddec: fix -Wformat warning raised by DJGPP
FF_ARRAY_ELEMS returns a size_t value.

Reviewed-by: ubitux
Signed-off-by: James Almer <jamrial@gmail.com>
2017-04-11 12:31:14 -03:00
Paul B Mahol
25e491b6f9 avcodec/dnxhddec: add support for very big resolutions
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-04-11 00:08:39 +02:00
Ronald S. Bultje
f800d6508d dnxhd: initialize DNXHDContext::avctx to each thread's respective one.
Otherwise all thread's private contexts have the avctx pointer set to
the AVCodecContext of the first thread, which means all writes to
ctx->avctx->* (in e.g. read_header) are effectively race conditions.

Fixes fate-dnxhd under tsan.
2017-03-31 08:26:23 -04:00
Clément Bœsch
549045254c Fix all -Wformat warnings raised by DJGPP 2017-03-29 14:49:29 +02:00
Clément Bœsch
46f4f8ad86 Merge commit '1263b2039eb5aaf1522e9de9f07c787ab30a5f50'
* commit '1263b2039eb5aaf1522e9de9f07c787ab30a5f50':
  Adjust printf conversion specifiers to match variable signedness

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-24 13:34:39 +01:00
Paul B Mahol
2c5839254d avcodec/dnxhddec: fix decoding of DNxHR HQX 10-bit
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-02-22 21:21:52 +01:00
Carl Eugen Hoyos
a8cb567e55 lavc: Remove CR/LF from avpriv_request_sample() calls. 2016-12-03 15:40:26 +01:00
Diego Biurrun
1263b2039e Adjust printf conversion specifiers to match variable signedness 2016-10-28 11:22:21 +02:00
Steven Robertson
e1be80aa11 libavcodec/dnxhd: Enable 12-bit DNxHR support.
10- and 12-bit DNxHR use the same DC coefficient decoding process and
VLC table, just with a different shift value. From SMPTE 2019-1:2016,
8.2.4 DC Coefficient Decoding:

"For 8-bit video sampling, the maximum value of η=11 and for
10-/12-bit video sampling, the maximum value of η=13."

A sample file will be uploaded to show that with this patch, things
decode correctly:
dnxhr_hqx_12bit_1080p_smpte_colorbars_davinci_resolve.mov

Signed-off-by: Steven Robertson <steven@strobe.cc>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-03 03:17:32 +02:00
James Almer
0c75bd8e3c avcodec/dnxhddata: move avpriv_dnxhd_parse_header_prefix to a header
It's a small and simple function that can be inlined.

This removes one private symbol and should reduce object dependencies with the next
major bump

Signed-off-by: James Almer <jamrial@gmail.com>
2016-07-25 12:19:39 -03:00
Mark Reid
41d7642a7b libavcodec/dnxhd: add dnxhr profiles
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-20 13:40:06 +02:00
Mark Reid
ed0dc14ebb libavcodec/dnxhd: add support more dnxhr header prefixes
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-16 15:39:28 +02:00
Mark Reid
8395b6eeaa libavcodec/dnxhd_parser: add parser and probe support raw 444 and dnxhr formats
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-14 19:17:36 +01:00
Michael Niedermayer
2ff61c3c1a avcodec/dnxhddec: Fix runtime error: left shift of negative value
Fixes: 2abd25478c62a675f335fac00b467023/asan_static-oob_10aff98_1227_8811480c6ef1e970a7977ceb7e5a9958.mxf

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-04 13:44:22 +01:00
Michael Niedermayer
55711e6fd0 avcodec/dnxhddec: Disable 12bit by default
The DC VLC table used is too small, fixing this requires a sample,
thus request a sample.
Some samples are said to work even though the table has the wrong size, thus
this is left enabled if the user enables experimental features.

Fixes: 2abd25478c62a675f335fac00b467023/asan_static-oob_10aff98_1227_8811480c6ef1e970a7977ceb7e5a9958.mxf

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Approved-by: kurosu
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-29 21:30:37 +01:00
Michael Niedermayer
cea9eb9520 avcodec/dnxhddec: Make mb_scan_index a fixed length array
Fixes null pointer dereference
Fixes: 5c9d1a6f74a12763fc7c9dd7834022b9/signal_sigsegv_11f78d9_1461_ecee3c5e7205457498e79b3ffaf21d0c.mxf

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-06 00:15:21 +01:00
Christophe Gisquet
96b165fae2 dnxhd: interleave AC levels and flags
This allows more efficient access to the array as the level and flags
are contiguous. Around 4% faster coefficient decoding.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-15 02:46:29 +02:00
Christophe Gisquet
71199ee907 dnxhddec: better support for 4:4:4
Profiles 1256 & 1270 (currently) signal at the frame header and MB
levels the colorspace used, either RGB or YUV. While a MB-level
varying colorspace is not supported, whether it is constant can be
tracked so as to determine the exact colorspace.

This requires having bitdepth and the ACT and 4:4:4 flags, in turn
needing the CID. Because setting those before having validated
enough things may result in invalid/unset DSP fucntions, setting
the bitdepth in the context is delayed.

It is not tested against a true RGB sequence, though.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-07 23:16:52 +02:00
Jeremy James
6f1ccca4ae dnxhd: add better support for CIDs 1270 to 1274
These are DNxHR profiles with the following properties:
- Variable size in a profile (property added in a previous commit),
  requiring variable-sized macroblock table;
- Variable bitdepth, up to 12 bits.
- Better validation of buffer sizes and positions

Signed-off-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-05 13:08:20 +02:00
Christophe Gisquet
66db504f03 dnxhd: add CID 1270
This a 4:4:4 10 bits profile, where image size is not fixed by the
profile, and which strays a bit outside the old frame header parsing
code.

Fixes ticket #4581 (DNxHR is not stricly supported, but that sequence is).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-05 12:58:40 +02:00
Jeremy James
118a3cd2c5 dnxhd: add decoder support for DNxHR
Signed-off-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-05 12:44:10 +02:00
Christophe Gisquet
1f4ff53aea dnxhddec: Introduce DNXHD_VARIABLE
Currently not used, but will be used to indicate that a CIDEntry field
is not set, because it is variable, and that checks should be adapted.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-05 12:44:00 +02:00
Christophe Gisquet
9139a7e84f dnxhddec: cleanup frame header parsing
Rely more on the actual syntax from the specs (also seen in the
encoder code).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-05 12:26:30 +02:00
Christophe Gisquet
74ef5449a6 dnxhddec: init scantable once permutation is set
Otherwise, the dsp may change without its permuation being applied.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-02 18:08:36 +02:00
Christophe Gisquet
c7e14a279f dnxhddec: use dequantization formula from specs
The current one, while correct, does not yield the best possible
results. The specificiations suggest another formula, which results
in quality gains in the decoded output from fate tests. This
justifies changing said formula.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-02 18:08:36 +02:00
Christophe Gisquet
7e4070d2e7 dnxhddec: initialize with mb-aligned dimensions
The coded size is a multiple of the macroblock size, which is 16.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-02 18:08:36 +02:00
Hendrik Leppkes
1342d7b2f9 Merge commit 'c49cbecbae5a42f4ca004197b0118cc50aaaca2e'
* commit 'c49cbecbae5a42f4ca004197b0118cc50aaaca2e':
  dnxhddec: Decode and use interlace mb flag

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-29 15:36:06 +02:00
Christophe Gisquet
c49cbecbae dnxhddec: Decode and use interlace mb flag
This bit is 1 in some samples, and seems to coincide with interlaced
mbs and CID1260. 2008 specs do not know about it, and maintain qscale
is 11 bits. This looks oversized, but may help larger bitdepths.

Currently, it leads to an obviously incorrect qscale value, meaning
its syntax is shifted by 1. However, reading 11 bits also leads to
obviously incorrect decoding: qscale seems to be 10 bits.

However, as most profiles still have 11bits qscale, the feature is
restricted to the CID1260 profile (this flag is dependent on
a higher-level flag located in the header).

The encoder writes 12 bits of syntax, last and first bits always 0,
which is now somewhat inconsistent with the decoder, but ends up with
the same effect (progressive + reserved bit).

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-29 14:33:01 +02:00
Vittorio Giovara
e94e651c76 dnxhddec: Enable frame threading
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-29 14:33:01 +02:00
Christophe Gisquet
578f721f5d dnxhddec: add my contributions
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-28 12:39:22 +02:00
Christophe Gisquet
6110a55b7d dnxhddec: reindent/cosmetics
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-28 12:25:56 +02:00
Christophe Gisquet
235381e674 dnxhddec: use unsafe bitstream reader
Each line is padded by the format, and errors are now reported and
stop the decoding. Around 5% speedup.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-28 01:00:58 +02:00
Christophe Gisquet
b8b8e82ea1 dnxhddec: check and report bitstream errors
This only occur when an overrun in coefficient decoding is
detected.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-27 21:57:58 +02:00
Christophe Gisquet
5c6e3a019c dnxhddec: simplify block parsing calls
Fewer arguments, less duplicated code.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-27 12:03:00 +02:00
Christophe Gisquet
8e8ed57ea7 dnxhddec: remove unused qscale parameter
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-27 12:03:00 +02:00