summaryrefslogtreecommitdiff
path: root/libavcodec/libx264.c
Commit message (Collapse)AuthorAge
* lavc/libx264: support AV_CODEC_CAP_ENCODER_RECON_FRAMEAnton Khirnov2022-08-02
| | | | Bump the version requirement to 122, which introduced b_full_recon.
* avcodec: Make init-threadsafety the defaultAndreas Rheinhardt2022-07-18
| | | | | | | | | | | and remove FF_CODEC_CAP_INIT_THREADSAFE All our native codecs are already init-threadsafe (only wrappers for external libraries and hwaccels are typically not marked as init-threadsafe yet), so it is only natural for this to also be the default state. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Add FF_CODEC_CAP_NOT_INIT_THREADSAFEAndreas Rheinhardt2022-07-18
| | | | | | | This is in preparation of switching the default init-thread-safety to a codec being init-thread-safe. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/libx264: Avoid duplicating stringsAndreas Rheinhardt2022-07-01
| | | | | | Also removes some unchecked allocations. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/libx264.c: Fix possible UB by NULL pointer LHSMichael Goulet2022-06-20
| | | | It is UB to attempt to do pointer arithmetic on NULL pointer LHS, even if that pointer arithmetic ends up being "+= 0" (i.e. !!p == 0 if p == NULL).
* avcodec/libx264: Set min build version to 158 for msvcMatt Oliver2022-06-11
| | | | | | | | | | | | | | | | | | | | | | | Was "[PATCH] libx264: Do not explicitly set X264_API_IMPORTS" Setting X264_API_IMPORTS only affects msvc builds and it breaks linking to static builds (although is required for shared builds). This flag is set by x264 in its pkgconfig as required since build 158 (a615f027ed172e2dd5380e736d487aa858a0c4ff) from July 2019. So this patch updates configure to require a newer x264 build that correctly sets the imports flag. The min version requirement of 158 is applied for msvc builds only. This is also removing the check for 'libx264 without pkg-config' which was left for compatibility reasons about 7 years ago when the pkg-config check was introduced by commit e06263ef1e0e172b2c76070b3dc739411af08e82. Co-authored-by: softworkz <softworkz@hotmail.com> Signed-off-by: softworkz <softworkz@hotmail.com> Signed-off-by: Matt Oliver <protogonoi@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-05
| | | | | | | | | | | This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Rename AVCodecDefault->FFCodecDefaultAndreas Rheinhardt2022-03-21
| | | | | | | This structure is no longer declared in a public header, so using an FF-prefix is more appropriate. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-21
| | | | | | | | | | | | | | | | Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt2022-03-21
| | | | | | | | | | Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault. This reduces the amount of files that have to include internal.h (which comes with quite a lot of indirect inclusions), as e.g. most encoders don't need it. It is furthemore in preparation for moving the private part of AVCodec out of the public codec.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-16
| | | | | | | | 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>
* avcodec/libx26[45]: reindent after last commitLimin Wang2021-12-28
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/libx26[45]: add udu_sei option to import user data unregistered SEIsLimin Wang2021-12-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | Most of user data unregistered SEIs are privated data which defined by user/ encoder. currently, the user data unregistered SEIs found in input are forwarded as side-data to encoders directly, it'll cause the reencoded output including some useless UDU SEIs. I prefer to add one option to enable/disable it and default is off after I saw the patch by Andreas Rheinhardt: https://patchwork.ffmpeg.org/project/ffmpeg/patch/AM7PR03MB66607C2DB65E1AD49D975CF18F7B9@AM7PR03MB6660.eurprd03.prod.outlook.com/ How to test by cli: ffmpeg -y -f lavfi -i testsrc -c:v libx264 -frames:v 1 a.ts ffmpeg -y -i a.ts -c:v libx264 -udu_sei 1 b.ts ffmpeg -y -i a.ts -c:v libx264 -udu_sei 0 c.ts # check the user data unregistered SEIs, you'll see two UDU SEIs for b.ts. # and mediainfo will show with wrong encoding setting info ffmpeg -i b.ts -vf showinfo -f null - ffmpeg -i c.ts -vf showinfo -f null - This fixes tickets #9500 and #9557. Reviewed-by: "zhilizhao(赵志立)" <quinkblack@foxmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/libx264: Don't unnecessarily add in-band extradataAndreas Rheinhardt2021-12-21
| | | | | | | | | | | | The check here is meant to check for whether avcintra-class option (default value -1) has been set; yet it checks for the x264_param_t value where 0 is the default value (treated as "no avcintra-mode" by x264). This meant that in-band extradata has been added unnecessarily when using global headers; furthermore, the first output packet had two x264 SEIs. Reviewed-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/libx264: Simplify copying packet dataAndreas Rheinhardt2021-11-09
| | | | | | | | x264.h: "the payloads of all output NALs are guaranteed to be sequential in memory." Therefore we can omit the loop. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/libx264: Remove always-false checksAndreas Rheinhardt2021-11-09
| | | | | | | | Always false since this encoder was switched to encode2 and ff_alloc_packet() in 06484d0b8a7d4d1a694ba7ab277e2ec32d6558d7 and f2b20b7a8b6fcbcd8cc669f5211e4e2ed7d8e9f3. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/libx264: Check for overflow if necessaryAndreas Rheinhardt2021-11-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/libx264: fix sei payload leaks on errorJames Almer2021-11-04
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libx264: move sei_data_size out of the for loopJames Almer2021-10-20
| | | | | | Otherwise its value will be reset on each iteration. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libx264: copy unregistered data SEI messages to the input x264 pictureJames Almer2021-10-18
| | | | | | Fixes undefined behavior. Signed-off-by: James Almer <jamrial@gmail.com>
* libavcodec/libx264: add user data unregistered SEI encodingBrad Hards2021-10-18
| | | | | | | | | | | | | MISB ST 0604 and ST 2101 require user data unregistered SEI messages (precision timestamps and sensor identifiers) to be included. That currently isn't supported for libx264. This patch adds support for user data unregistered SEI messages in accordance with ISO/IEC 14496-10:2020(E) section D.1.7 (syntax) and D.2.7 (semantics). This code is based on a similar change for libx265 (commit 1f58503013720700a5adfd72c708e6275aefc165). Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-20
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/libx264: add support for setting chroma sample locationJan Ekström2021-08-29
|
* avcodec/libx264: leave full range flag unchanged if unknownJan Ekström2021-08-18
| | | | | | | | | 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
* {configure,avcodec/libx264}: remove separate x264_csp_bgr checkJan Ekström2021-07-12
| | | | | | We already require X264_BUILD >= 118, which includes an unconditional definition of X264_CSP_BGR in itself, thus making this check effectively always true.
* avcodec/libx264: Separate headers not supported in AVC-Intra modeLimin Wang2021-06-25
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/libx264: Add support for Sony XAVC Class 300 and 480Limin Wang2021-06-25
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/libx264: Avoid copying data, allow user-supplied buffersAndreas Rheinhardt2021-05-23
| | | | | | | | | | | 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>
* avcodec/libx264: Fix redundant setting of caps_internalAndreas Rheinhardt2021-05-14
| | | | | | | | Exists since 8a129077cc37202a00dd666bd5365c3f61ea2e80. 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>
* avcodec: Remove redundant freeing of extradata of encodersAndreas Rheinhardt2021-04-28
| | | | | | | | 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>
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-27
| | | | | | | | | | 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>
* avcodec: Remove deprecated AVCodecContext.coded_frameAndreas Rheinhardt2021-04-27
| | | | | | | | | | Deprecated in 40cf1bbacc6220a0aa6bed5c331871d43f9ce370. (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>
* avcodec: Remove private options from AVCodecContextAndreas Rheinhardt2021-04-27
| | | | | | | | | Several options that were too codec-specific were deprecated between 0e6c8532215790bbe560a9eea4f3cc82bb55cf92 and 0e9c4fe254073b209970df3e3cb84531bc388e99. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: Remove deprecated coder type optionsAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in be00ec832c519427cd92218abac77dafdc1d5487. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc: rename AV_CODEC_CAP_AUTO_THREADS->AV_CODEC_CAP_OTHER_THREADSAnton Khirnov2021-03-16
| | | | | | | | | | 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.
* lavc: replace internal use of AV_CODEC_CAP_AUTO_THREADS with an internal capAnton Khirnov2021-03-16
| | | | | | | | | | | | | | | | AV_CODEC_CAP_AUTO_THREADS was originally added in b4d44a45f9a 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.
* avcodec/libx264: Don't use init_static_data for newer versionsAndreas Rheinhardt2021-02-28
| | | | | | | | | | | 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>
* avcodec: move ff_alloc_a53_sei() to atsc_53James Almer2020-08-15
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libx264: fix chroma quantizer offset usageTakio Yamaoka2020-08-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 5764d38173661c29d954711dd5abfddf709e9ba4, and then b340bd8a58c32453172404a8e4240e3317e341da broke the value. Partially reverts commit b340bd8a58c32453172404a8e4240e3317e341da. Signed-off-by: Takio Yamaoka <y.takio@gmail.com>
* avcodec/libx264: call x264_param_cleanup() if availableJames Almer2020-07-17
| | | | | | | The documentation states it should be used to free any memory allocated by x264_param_parse(). Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libx264: check for param allocation failure error codeJames Almer2020-07-17
| | | | | | And return the proper AVERROR value. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libx264: use a function to parse x264optsJames Almer2020-07-17
| | | | | | This is needed for the following patch. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/internal: move packet related functions to their own headerJames Almer2020-06-02
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/libx264: misc style fixesJun Zhao2020-05-28
| | | | | | commit 4ed3a01d717 missed coding style fix. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avcodec/libx264: return error if unknown picture type encounteredLimin Wang2020-05-08
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/libx264: return immediately if encode_nals return 0Limin Wang2020-05-08
| | | | | | | | 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>
* libavcodec/libx264: fix reference frame computation based on levelJosh Brewster2020-04-29
| | | | | | | | | | | | | | | 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>
* avcodec/libx264: add a check for the prft AVCodecContext export_side_data flagJames Almer2020-02-22
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libx264: export Producer Reference Time as packet side dataJames Almer2020-01-15
| | | | | | Taken from Wallclock at the time the frame is submitted to the encoder. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libx264: use AV_OPT_TYPE_DICT for x264-paramsMarton Balint2020-01-01
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>