1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-07 11:13:41 +02:00
Commit Graph

268 Commits

Author SHA1 Message Date
Timo Rothenpieler
e006680d8e avcodec/nvenc: add option to control subsampling of packed rgb input 2023-10-09 20:17:44 +02:00
Andreas Rheinhardt
f58038d498 avcodec/avcodec: Avoid codec_desc.h, codec_par.h inclusions
Instead, use forward declarations; and in order not to affect
any user include these headers for them, but not internally.
This has the advantage of removing implicit inclusions of these
headers from almost all files providing codecs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-03 01:59:07 +02:00
Andreas Rheinhardt
423b6a7e49 avutil/imgutils: Add wrapper for av_image_copy() to avoid casts
av_image_copy() accepts const uint8_t* const * as source;
lots of user have uint8_t* const * and therefore either
cast (the majority) or copy the array of pointers.

This commit changes this by adding a static inline wrapper
for av_image_copy() that casts between the two types
so that we do not need to add casts everywhere else.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 09:42:27 +02:00
Andreas Rheinhardt
8238bc0b5e avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* defines
These defines are also used in other contexts than just AVCodecContext
ones, e.g. in libavformat. Furthermore, given that these defines are
public, the AV-prefix is the right one, so deprecate (and not just move)
the FF-macros.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:39:02 +02:00
James Almer
0231df505d avcodec/utils: move ff_add_cpb_side_data() to encoder code
It's only used by encoders, so move it to prevent wrong usage.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-09-06 10:27:45 -03:00
Aleksoid
7eb0d9e905 avcodec/nvenc: add option to limit slice size 2023-08-22 23:46:11 +02:00
Andreas Rheinhardt
2d7c1479c2 avcodec/nvenc: Remove always-true check
nvenc_store_frame_data() is always called with frame != NULL
(checked at the beginning of nvenc_send_frame());
in fact, frame is dereferenced unconditionally after the block
guarded by the check for frame. Therefore Coverity complains
about this in issue #1538295.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-02 18:31:59 +02:00
Zhao Zhili
7eeef72c67 avcodec/nvenc: set idrPeriod to gopLength unconditionally
When intra_refresh is enabled, gopLength is equal to
NVENC_INFINITE_GOPLENGTH. gopLength should be 1 at least.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-07-07 13:39:26 +02:00
Zhao Zhili
0d0c39832f avcodec/nvenc: fix intraRefreshPeriod setting
Regression since 99dfdb45. intraRefreshPeriod access cc->gopLength,
which has been overwritten to NVENC_INFINITE_GOPLENGTH before.

Fixes #10445.
2023-07-07 13:39:26 +02:00
Ricardo Monteiro
99dfdb45a8 avcodec/nvenc: let preset decide default gop size
Default GOP size is now set by preset and tuning info. This GOP size is only overwriten if -g value is provided.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2023-06-22 19:33:09 +02:00
Timo Rothenpieler
16fdb48e0d avcodec/nvenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE 2023-06-16 22:10:42 +02:00
Timo Rothenpieler
6c418ae25e Revert "lavc/nvenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE"
The implementation is flawed in that the frame opaque data is not in
fact correctly reordered along with the packets, but is being output in
packet input order, just like the dts are.

This reverts commit 3553809703.
2023-06-16 22:10:42 +02:00
Timo Rothenpieler
ac7c265b33 Revert "avcodec/nvenc: fix b-frame DTS behavior with fractional framerates"
This reverts commit 9a245bdf5d.

This commit basically broke all samples with fractional framerates,
rather than fixing them.
I at this point do not understand the original issue anymore, and I'm
not sure how this slipped my initial testing.
All my test samples must have happened to have a simple timebase.

The actual dts values pretty much always are just a simple chain of
1,2,3,4,5,... Or maybe slightly bigger steps. Each increase by one means
an advance in time by one unit of the timebase.
So a fractional framerate/timebase is already not an issue.

So with this patch applied, the calculation might end up substracting
huge values (1001 is a common one) from the dts, which would be an
offset of that many frames, not of that many fractions of a second.
This broke at least muxing into mp4, if the sample happened to have a
fractional framerate.

I do not thing the original issue this patch tried to fix existed in the
first place, so it can be reverted without further consequences.
2023-06-15 00:59:02 +02:00
Timo Rothenpieler
d2b46c1ef7 avcodec/nvenc: stop using deprecated rc modes with SDK 12.1 2023-06-01 23:47:14 +02:00
Anton Khirnov
7d1d61cc5f lavc: deprecate AVCodecContext.ticks_per_frame
For encoding, this field is entirely redundant with
AVCodecContext.framerate.

For decoding, this field is entirely redundant with
AV_CODEC_PROP_FIELDS.
2023-05-15 10:56:18 +02:00
James Almer
2f561ba953 avcodec: use the new AVFrame interlace flags in all decoders and encoders
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 18:14:02 -03:00
Kyle Manning
9a245bdf5d avcodec/nvenc: fix b-frame DTS behavior with fractional framerates
When using fractional framerates (or any fraction with a numerator != 1),
DTS values for packets would be calculated incorrectly.

Signed-off-by: Kyle Manning <tt2468@irltoolkit.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2023-04-03 11:59:36 +02:00
Timo Rothenpieler
7a8560cb22 avcodec/nvenc: avoid failing b_ref_mode check when unset 2023-03-10 13:17:21 +01:00
Zhao Zhili
21101d9eb1 avcodec/nvenc: fix potential NULL pointer dereference
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2023-02-28 19:16:52 +01:00
Anton Khirnov
bdc76f467f lavu/frame: deprecate reordered_opaque
It is only used in libavcodec, where it's been superseded by
AV_CODEC_CAP_COPY_OPAQUE.
2023-02-04 13:40:20 +01:00
Anton Khirnov
3553809703 lavc/nvenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE 2023-01-29 09:23:17 +01:00
Timo Rothenpieler
9ca139b2aa avcodec/nvenc: fix vbv buffer size in cq mode
The CQ calculation gets thrown off and behaves very nonsensical
if it isn't set to 0.
2022-12-08 12:31:02 +01:00
Timo Rothenpieler
45216e33e2 avcodec/nvenc: notify users about rc_lookahead clipping 2022-12-05 21:21:41 +01:00
Timo Rothenpieler
ac0f42d893 avcodec/nvenc: explicitly disable lookahead if lacking sufficient surfaces
It could already be enabled by the preset, so it needs explicitly
disabled in this case.
2022-12-05 21:21:41 +01:00
Timo Rothenpieler
eb1e359a14 avcodec/nvenc: use provided constant for max extradata size 2022-11-15 01:32:56 +01:00
Timo Rothenpieler
c7a60124e3 avcodec/nvenc: add forgotten X2RGB10 formats to 10-bit-list 2022-11-14 23:10:20 +01:00
Timo Rothenpieler
939273d3b4 avcodec/nvenc: remove unsupported AV1 High Profile 2022-11-10 15:26:43 +01:00
Timo Rothenpieler
e7fbdda64e avcodec/nvenc: fix AV1 darWidth/Height calculation
nvenc uses the darWidth/Height fields for the AV1 render_width/height
instead, so a different calculation is needed.
2022-11-10 14:51:31 +01:00
Timo Rothenpieler
aa3d98227e avcodec/nvenc: don't queue and offset dts for AV1
dts != pts is actually a spec violation for AV1, given it has no
reordering in the classical sense.

We don't really need the whole timestamp queue in this case and can just
pass through the timestamp as is for both dts and pts.
2022-11-06 00:53:02 +01:00
Timo Rothenpieler
6362b8cd19 avcodec/nvenc: set correct "sei" payload type for AV1 2022-11-05 21:18:36 +01:00
Timo Rothenpieler
5c288a44ad avcodec/nvenc: add AV1 encoding support
The encoder seems to be trading blows with hevc_nvenc.
In terms of quality at low bitrate cbr settings, it seems to
outperform it even. It produces fewer artifacts and the ones it
does produce are less jarring to my perception.

At higher bitrates I had a hard time finding differences between
the two encoders in terms of subjective visual quality.

Using the 'slow' preset, av1_nvenc outperformed hevc_nvenc in terms
of encoding speed by 75% to 100% while performing above tests.

Needless to say, it always massively outperformed h264_nvenc in terms
of quality for a given bitrate, while also being slightly faster.
2022-11-05 21:17:37 +01:00
Timo Rothenpieler
28680e2f41 avcodec/nvenc: only set b_ref_mode when explicitly requested 2022-11-05 18:35:33 +01:00
Timo Rothenpieler
12733c0cbd avcodec/nvenc: remove unused slice offset querying 2022-11-01 17:42:54 +01:00
Timo Rothenpieler
b710698790 avcodec/nvenc: hardcode color characteristics for internal RGB2YUV conversion
nvenc does not appear to use these values as inputs for its built in RGB
to YUV conversion, but instead sets them on the output as-is.

Testing indicates the input is expected to be sRGB, with the output
ending up as limited range bt.470.
2022-08-06 22:23:33 +02:00
Timo Rothenpieler
85bc6b5abf avcodec/nvenc: add support for additional (10 bit) RGB pixel formats 2022-07-05 18:27:37 +02:00
Martin Storsjö
a78f136f3f configure: Use a separate config_components.h header for $ALL_COMPONENTS
This avoids unnecessary rebuilds of most source files if only the
list of enabled components has changed, but not the other properties
of the build, set in config.h.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:12:49 +02:00
Anton Khirnov
587545c9e0 lavc/nvenc: switch to the new FIFO API 2022-02-07 00:31:23 +01:00
Timo Rothenpieler
0b13c34a65 avcodec/nvenc: zero-initialize NV_ENC_REGISTER_RESOURCE struct 2022-01-10 15:41:50 +01:00
Limin Wang
0c8741f819 avcodec/nvenc: add udu_sei option to import user data unregistered SEIs
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-12-25 14:12:26 +01:00
Andreas Rheinhardt
1ea3650823 Replace all occurences of av_mallocz_array() by av_calloc()
They do the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 01:03:52 +02:00
Limin Wang
75001ae844 avcodec/nvenc: add constrainedFrame encoding support
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-09-06 14:25:26 +02:00
Limin Wang
3756525a59 avcodec/nvenc: add single slice intra refresh support
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-09-06 14:13:00 +02:00
Limin Wang
e6bd5171ac avcodec/nvenc: add intra refresh support
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-09-06 14:12:57 +02:00
Limin Wang
85489e0308 avcodec/nvenc: make number of slices per frame configurable
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-09-06 13:33:53 +02:00
Timo Rothenpieler
00b579890d avcodec/nvenc: always set qp cr/cb offsets 2021-08-09 15:16:58 +02:00
Timo Rothenpieler
ac0408522a avcodec/nvenc: make aware of SDK 11.1 driver requirements 2021-08-08 02:00:38 +02:00
Ricardo Monteiro
e56f6e59b6 avcodec/nvenc: add chroma qp offset support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-08-08 01:56:32 +02:00
Andreas Rheinhardt
2934a4b9a5 Remove unnecessary avassert.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:30 +02:00
Timo Rothenpieler
8bcce5673a avcodec/nvenc: add option to disable all extra SEI data
With these triggering a lot of crashes recently, an option to globally
disable all of them is added as a tool to work around those crashes in
case the SEI data is not needed by the user.

Also re-enables s12m for hevc_nvenc, since the issue is not specifically
with that, but it affects all SEI data.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2021-06-06 22:01:56 +02:00
Timo Rothenpieler
57de80673c avcodec/nvenc: extract sei data prep into own function 2021-06-04 18:40:17 +02:00