1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-02 03:06:28 +02:00
Commit Graph

344 Commits

Author SHA1 Message Date
Jan Ekström
2f0113be3f avcodec/libx264: add support for setting chroma sample location 2021-08-29 15:05:37 +03:00
Jan Ekström
7ca71b79f2 avcodec/libx264: leave full range flag unchanged if unknown
By default the x264 full range flag is set to -1. By not setting
it to something else, we can let libx264 handle the RGB case.
Additionally, change the preference order to user-specified range
first, and then any fall-back logic left for the YUVJ pix_fmts.

Fixes the capture part of #9374
2021-08-18 12:09:37 +03:00
Jan Ekström
f32f56468c {configure,avcodec/libx264}: remove separate x264_csp_bgr check
We already require X264_BUILD >= 118, which includes an unconditional
definition of X264_CSP_BGR in itself, thus making this check
effectively always true.
2021-07-12 12:07:10 +03:00
Limin Wang
81bad080cd avcodec/libx264: Separate headers not supported in AVC-Intra mode
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-06-25 09:27:52 +08:00
Limin Wang
93da0869e6 avcodec/libx264: Add support for Sony XAVC Class 300 and 480
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-06-25 09:27:52 +08:00
Andreas Rheinhardt
9c4f2bc3bf avcodec/libx264: Avoid copying data, allow user-supplied buffers
Here the packet size is known before allocating the packet because
the encoder provides said information (and works with internal buffers
itself), so one can use this information to avoid the implicit use of
another intermediate buffer for the packet data; and by switching to
ff_get_encode_buffer() one can also allow user-supplied buffers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:57:43 +02:00
Andreas Rheinhardt
c9a79532e5 avcodec/libx264: Fix redundant setting of caps_internal
Exists since 8a129077cc.
Fixes a -Winitializer-overrides warning when building with Clang.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-14 13:58:02 +02:00
Andreas Rheinhardt
1c7f252783 avcodec: Remove redundant freeing of extradata of encoders
AVCodecContext.extradata is freed generically by libavcodec for
encoders, so it is unnecessary for an encoder to do it on its own.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-28 16:56:40 +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
11bc790893 avcodec: Remove deprecated AVCodecContext.coded_frame
Deprecated in 40cf1bbacc.
(The currently disabled filter vf_mcdeint and vf_uspp were users of
this field; they have not been changed, so that whoever wants to fix
them can see the state of these filters when they were disabled.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:12 -03:00
Andreas Rheinhardt
d85c41b572 avcodec: Remove private options from AVCodecContext
Several options that were too codec-specific were deprecated between
0e6c853221 and
0e9c4fe254.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:02 -03:00
Andreas Rheinhardt
78ce00428f avcodec: Remove deprecated coder type options
Deprecated in be00ec832c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:01 -03:00
Anton Khirnov
7d09579190 lavc: rename AV_CODEC_CAP_AUTO_THREADS->AV_CODEC_CAP_OTHER_THREADS
This cap is currently used to mark multithreading-capable codecs that
wrap external libraries with their own multithreading code. The name is
highly confusing for our API users, since libavcodec ALWAYS handles
thread_count=0 (see commit message in previous commit). Therefore rename
the cap and update its documentation to make its meaning clear.

The old name is kept deprecated until next+1 major bump.
2021-03-16 10:38:41 +01:00
Anton Khirnov
8a129077cc lavc: replace internal use of AV_CODEC_CAP_AUTO_THREADS with an internal cap
AV_CODEC_CAP_AUTO_THREADS was originally added in b4d44a45f9 to mark
codecs that spawn threads internally and are able to select an optimal
threads count by themselves (all such codecs are wrappers around
external libraries). It is used by lavc generic code to check whether it
should handle thread_count=0 itself or pass the zero directly to the
codec implementation. Within this meaning, it is clearly supposed to be
an internal cap rather than a public one, since from the viewpoint of a
libavcodec user, lavc ALWAYS handles thread_count=0. Whether it happens
in the generic code or within the codec internals is not a meaningful
difference for the caller.

External aspects of this flag will be dealt with in the following
commit.
2021-03-16 10:34:29 +01:00
Andreas Rheinhardt
f9b5cef1d3 avcodec/libx264: Don't use init_static_data for newer versions
x264 versions >= 153 can support multiple bitdepths; they also don't
export x264_bit_depth any more. The actual check whether a bitdepth
is supported is therefore performed at runtime in x264_encoder_open.
Ergo it is unnecessary to use init_static_data for these versions:
One can already set ff_libx264_encoder.pix_fmts to the value that
X264_init_static always sets it to.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-28 17:52:12 +01:00
James Almer
0de01da1d2 avcodec: move ff_alloc_a53_sei() to atsc_53
Signed-off-by: James Almer <jamrial@gmail.com>
2020-08-15 13:01:25 -03:00
Takio Yamaoka
cc6c56f5d9 avcodec/libx264: fix chroma quantizer offset usage
The default for the chromaoffset field in AVCodecContext
is zero, which until now always ended up overriding the
AVOption-set value, thus leading to the AVOption not working.

Additionally, the previous usage prevented the usage of
negative values, while both the variable as well as x264's
API would successfully handle such.

Thus, the default value of the AVOption is changed to match
the default of x264 (and what is currently the default for
the AVCodecContext chromaoffset field), and the checks are
changed to check for nonzero values.

This way:
1. the library default is still utilized if the value is zero.
2. both negative and positive values are correctly passed to
   x264.

For historical context, this was initially similarly
implemented in 5764d38173, and
then b340bd8a58 broke the
value.

Partially reverts commit b340bd8a58.

Signed-off-by: Takio Yamaoka <y.takio@gmail.com>
2020-08-06 13:09:23 +03:00
James Almer
890f2e960a avcodec/libx264: call x264_param_cleanup() if available
The documentation states it should be used to free any memory allocated
by x264_param_parse().

Signed-off-by: James Almer <jamrial@gmail.com>
2020-07-17 15:24:56 -03:00
James Almer
03ad76794e avcodec/libx264: check for param allocation failure error code
And return the proper AVERROR value.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-07-17 15:24:56 -03:00
James Almer
d1bd079d11 avcodec/libx264: use a function to parse x264opts
This is needed for the following patch.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-07-17 15:24:56 -03:00
James Almer
6e1903938b avcodec/internal: move packet related functions to their own header
Signed-off-by: James Almer <jamrial@gmail.com>
2020-06-02 19:02:12 -03:00
Jun Zhao
b63f502911 lavc/libx264: misc style fixes
commit 4ed3a01d71 missed coding style fix.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-05-28 15:56:06 +08:00
Limin Wang
8b07751123 avcodec/libx264: return error if unknown picture type encountered
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-08 06:42:25 +08:00
Limin Wang
f5e33514e7 avcodec/libx264: return immediately if encode_nals return 0
x264_encoder_encode can return 0 with nnal 0. As a result, encode_nals will
return 0. In this condition, it's better to return 0 immediately to avoid
the following unneeded pict_type and flags setting.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-08 06:42:25 +08:00
Josh Brewster
79f001675a libavcodec/libx264: fix reference frame computation based on level
The current implementation allows passing levels to libavcodec as
integers (such as "31" instead of "3.1").

However, in this case, the maximum reference frame value per level was
ignored because libavcodec converted the string to 310 instead of 31.

Since libx264 has correctly parsed the level to int
(x4->params.i_level_idc), we should rely on this value instead of
attempting to parse the level string on our own.

Signed-off-by: Josh Brewster <josh.brewster@protonmail.com>
Signed-off-by: Josh de Kock <josh@itanimul.li>
2020-04-29 12:01:14 +01:00
James Almer
3d4510384d avcodec/libx264: add a check for the prft AVCodecContext export_side_data flag
Signed-off-by: James Almer <jamrial@gmail.com>
2020-02-22 23:19:07 -03:00
James Almer
56c8856966 avcodec/libx264: export Producer Reference Time as packet side data
Taken from Wallclock at the time the frame is submitted to the encoder.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 23:34:20 -03:00
Marton Balint
dfea6d2e50 avcodec/libx264: use AV_OPT_TYPE_DICT for x264-params
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-01 20:41:34 +01:00
Carl Eugen Hoyos
87b7e141a6 lavc/x264: Use FF_CODEC_CAP_INIT_THREADSAFE if x264 is new.
Usage of strtok() was removed from x264, see also b02490a4
2019-10-01 22:07:11 +02:00
Guo, Yejun
104d44138b libavcodec/libx264: add a flag to output ROI warnings only once.
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
2019-09-24 17:22:15 +01:00
Carl Eugen Hoyos
434588596f lavc/x264: Also clean-up libx264rgb after init errors.
Missed in c180f0f6
2019-08-25 16:09:40 +02:00
Carl Eugen Hoyos
690cab3232 lavc/libx264: Cast cpb bit_rates to int64_t to avoid an integer overflow.
Fixes remaining part of ticket #8071 on next version bump.
2019-08-10 23:52:59 +02:00
Carl Eugen Hoyos
4b1687f23c lavc/libx264: Cast bit_rate to int64_t to avoid an integer overflow.
Fixes ticket #8071.
2019-08-10 23:29:58 +02:00
Carl Eugen Hoyos
57987deefc lavc/libx264: bit_rates > INT_MAX are not supported. 2019-08-10 23:27:58 +02: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
Jun Zhao
1e6338c2da lavc/libx264: Use avctx->framerate first for frame rate setting
perfer avctx->framerate first than use avctx->time_base when setting
the frame rate to encoder. 1/time_base is not the average frame rate
if the frame rate is not constant. In this case, we need to setting
avctx->framerate and avctx->time_base both, but avctx->framerate not
equal to 1/(avctx->time_base).

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-05-11 00:10:44 +08:00
Guo, Yejun
aceb9131c1 avcodec/libx264: add support for ROI-based encoding
This patch just enables the path from ffmpeg to libx264,
the more encoders can be added later.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2019-01-17 21:47:52 +00:00
Martin Storsjö
882ae091d4 libx264: Pass the reordered_opaque field through the encoder
libx264 does have a field for opaque data to pass along with frames
through the encoder, but it is a pointer, while the libavcodec
reordered_opaque field is an int64_t. Therefore, allocate an array
within the libx264 wrapper, where reordered_opaque values in flight
are stored, and pass a pointer to this array to libx264.

Update the public libavcodec documentation for the AVCodecContext
field to explain this usage, and add a codec capability that allows
detecting whether an encoder handles this field.

Signed-off-by: Martin Storsjö <martin@martin.st>
2018-11-05 15:52:14 +02:00
Marton Balint
b02490a497 avcodec/libx264: remove FF_CODEC_CAP_INIT_THREADSAFE flag
Libx264 uses strtok which is not thread safe. Strtok is used in
x264_param_default_preset in param_apply_tune in x264/common/base.c.
Therefore the flag must be removed.

x264 fixed the issue, once the fix is pushed to stable, an #if can be added
to re-enable the flag based on X264_BUILD number.

Fixes ticket #7446.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-24 23:18:37 +02:00
Carl Eugen Hoyos
81f25a1051 lavc/libx264: Support monochrome encoding. 2018-08-07 20:41:02 +02:00
James Almer
2f96190732 Merge commit 'c6558e8840fbb2386bf8742e4d68dd6e067d262e'
* commit 'c6558e8840fbb2386bf8742e4d68dd6e067d262e':
  x264: Support version 153

See
2a111c99a6
7e60c74329

Merged-by: James Almer <jamrial@gmail.com>
2017-12-27 21:11:10 -03:00
Luca Barbato
c6558e8840 x264: Support version 153
It has native simultaneus 8 and 10 bit support.
2017-12-27 15:59:45 +00:00
James Almer
7e60c74329 avcodec/libx264: set supported pix_fmts at runtime rather than build time
This partially reverts a change in behavior introduced in 2a111c99a6.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-12-26 19:41:04 -03:00
James Almer
2a111c99a6 avcodec/libx264: fix compilation with x264 builds >= 153
x264 now supports multibitdepth builds, with a slightly changed API to
request bitdepth during initialization.

Reviewed-by: Ricardo Constantino <wiiaboo@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-12-26 11:57:01 -03:00
James Almer
89f704caba avcodec/libx264: use the pixfmt descriptor to check for high bit depths
The x264_bit_depth constant has been removed in newer x264 builds.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-12-25 23:18:41 -03:00
wm4
b945fed629 avcodec: add metadata to identify wrappers and hardware decoders
Explicitly identify decoder/encoder wrappers with a common name. This
saves API users from guessing by the name suffix. For example, they
don't have to guess that "h264_qsv" is the h264 QSV implementation, and
instead they can just check the AVCodec .codec and .wrapper_name fields.

Explicitly mark AVCodec entries that are hardware decoders or most
likely hardware decoders with new AV_CODEC_CAPs. The purpose is allowing
API users listing hardware decoders in a more generic way. The proposed
AVCodecHWConfig does not provide this information fully, because it's
concerned with decoder configuration, not information about the fact
whether the hardware is used or not.

AV_CODEC_CAP_HYBRID exists specifically for QSV, which can have software
implementations in case the hardware is not capable.

Based on a patch by Philip Langdale <philipl@overt.org>.

Merges Libav commit 47687a2f8a.
2017-12-14 19:37:56 +01:00
wm4
47687a2f8a avcodec: add metadata to identify wrappers and hardware decoders
Explicitly identify decoder/encoder wrappers with a common name. This
saves API users from guessing by the name suffix. For example, they
don't have to guess that "h264_qsv" is the h264 QSV implementation, and
instead they can just check the AVCodec .codec and .wrapper_name fields.

Explicitly mark AVCodec entries that are hardware decoders or most
likely hardware decoders with new AV_CODEC_CAPs. The purpose is allowing
API users listing hardware decoders in a more generic way. The proposed
AVCodecHWConfig does not provide this information fully, because it's
concerned with decoder configuration, not information about the fact
whether the hardware is used or not.

AV_CODEC_CAP_HYBRID exists specifically for QSV, which can have software
implementations in case the hardware is not capable.

Based on a patch by Philip Langdale <philipl@overt.org>.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2017-12-14 16:58:45 +01:00
James Almer
bfab430856 Merge commit '94eed68ace9f2416af8457fcbf142b175928c06b'
* commit '94eed68ace9f2416af8457fcbf142b175928c06b':
  lavc: Drop deprecated options moved to private contexts

Merged-by: James Almer <jamrial@gmail.com>
2017-10-23 17:08:32 -03:00
James Almer
7bbe33b052 avcodec/libx264: add me_method alias to set X264Context->motion_est
Replaces the now dropped global option.

Addresses ticket #6771.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-10-23 15:36:36 -03:00
Vittorio Giovara
94eed68ace lavc: Drop deprecated options moved to private contexts
Deprecated in 10/2014 and 07/2015.
2017-03-23 10:09:17 +01:00