Commit Graph

194 Commits

Author SHA1 Message Date
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
Andreas Rheinhardt 18e75f493d avcodec/mpegvideo: Remove write-only [fb]_code
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-13 19:49:29 +01:00
Andreas Rheinhardt 746e7102be avcodec/mpegvideo: Move encoder-only stuff to a new header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-13 19:49:29 +01:00
Andreas Rheinhardt 9856f6a443 avcodec/mpeg12.h: Move encoder-only stuff into a new header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-13 19:49:29 +01:00
Andreas Rheinhardt 24a654c6c9 avcodec/mpegvideo: Use offset instead of pointer for vbv_delay
An offset has the advantage of not needing to be updated
when the buffer is reallocated. Furthermore, the way the pointer
is currently updated is undefined behaviour in case the pointer
is not already set (i.e. when not encoding MPEG-1/2), because
it calculates the nonsense NULL - s->pb.buf.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-29 19:30:25 +01:00
Andreas Rheinhardt aeb83322aa avcodec/mpegvideo: Move frame_rate_index to (Mpeg1|MPEG12Enc)Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-29 19:30:24 +01:00
Andreas Rheinhardt 4bbfe02ca0 avcodec/mpegvideo: Move gop_picture_number to MPEG12EncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-29 18:34:31 +01:00
Andreas Rheinhardt 5256658af5 avcodec/mpeg12enc: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-29 18:34:30 +01:00
Andreas Rheinhardt d3a2d06633 avcodec/mpeg12enc: Return early if no Sequence Header is written
Allows to avoid one level of indentation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-29 18:34:30 +01:00
Andreas Rheinhardt f05ba7b169 avcodec/mpeg12enc: Use stack variable for aspect_ratio_info
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-29 18:34:30 +01:00
Andreas Rheinhardt 8abc192236 avcodec/mpeg12enc: Inline constants
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 16:28:56 +01:00
Andreas Rheinhardt c037f3fc7d avcodec/mpeg12enc: Partially inline whether codec is MPEG-1
MPEG-1 only supports 4:2:0, so one can optimize away the checks
for whether one encodes MPEG-1 in codepaths that encode 4:2:2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 16:28:55 +01:00
Andreas Rheinhardt d91b5020ec avcodec/mpeg12enc: Also inline chroma subsampling
ff_mpeg1_encode_mb() contains two inlined calls to
mpeg1_encode_mb_internal(); these calls are supposed
to inline the properties depending upon the color space
used. Yet inlining vertical chroma subsampling (which
allows to remove complete branches and blocks depending
upon them) has been forgotten.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 16:28:55 +01:00
Andreas Rheinhardt f899e3b51b avcodec/mpeg12enc: Move options-related fields to MPEG12EncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 16:28:55 +01:00
Andreas Rheinhardt 4989ad4c76 avcodec/mpeg12enc: Add custom context, move mpeg2_frame_rate_ext to it
It is only used here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 16:28:55 +01:00
Andreas Rheinhardt ac49439e77 avcodec/mpeg12enc: Simplify check for A53 closed captions
The a53_cc option is only useful and meaningful for MPEG-2,
yet it was accidentally added for all mpegvideo-based encoders.
This means that it is possible for a53_cc to be set for other
encoders as well.
This commit changes this and reroutes a53_cc to the dummy field
in MpegEncContext for all codecs for which it is not supported.
This allows to avoid a check for the current codec in mpeg12enc.c.

Also add a compile-time check for whether the MPEG-2 encoder is
available while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 16:28:55 +01: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 ef6a9e5e31 avutil/buffer: Switch AVBuffer API to size_t
Announced in 14040a1d91.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:13 -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 7d9afb46f2 avcodec/mpegvideo: Deprecate bframe opts for encoders not supporting them
MPEG-1/2/4 are the only mpegvideo based encoders that support bframes;
yet even the encoders not supporting bframes have options that only make
sense for an encoder that supports bframes; setting any of these options
for such an encoder has no impact on the encoded outcome (but setting
b_strategy to two slows down encoding considerably). So deprecate these
options.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-10 04:21:21 +02:00
Andreas Rheinhardt 6c2cc205f6 avcodec/mpegvideo: Deprecate duplicate matrix opt for unsupported codecs
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-10 04:17:44 +02:00
Andreas Rheinhardt 2de159fcf1 avcodec/mpegvideo: Deprecate a53cc option for encoders != MPEG-2
The MPEG-2 encoder is the only mpegvideo-based encoder that supports
embedding a53 side data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-10 04:16:54 +02:00
Andreas Rheinhardt 42c895ef5c avcodec/mpegvideo: Deprecate mpeg_quant option for codecs != MPEG-4
mpeg_quant may only be set for MPEG-4 and MPEG-2, yet for the latter
it is no option as the code acts as if it were always set.
So deprecate the option for all codecs for which it makes no sense.

Furthermore, given that the code already errors out if the option is set
for a codec that doesn't support it we can restrict the range of
the option for all these codecs without breaking something. This means
that the checks for whether mpeg_quant is set for these codecs can be
removed as soon as AVCodecContext.mpeg_quant is removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-10 03:56:39 +02:00
Andreas Rheinhardt bf61cbb7fc avcodec/mpeg12enc: Perform size/level/profile checks earlier
This has the advantage that one does not waste some allocations
if one errors out because of these checks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-10 03:54:45 +02:00
Andreas Rheinhardt d5c7e5cb65 avcodec/mpeg12enc: Move MPEG-1/2 dimension checks to mpeg12enc
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-10 03:53:54 +02:00
Andreas Rheinhardt c81b8e04aa Avoid intermediate bitcount for number of bytes in PutBitContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-30 12:36:32 +02:00
Andreas Rheinhardt 44bb776f13 avcodec/mpegvideo_enc: Make mpv_encode_defaults thread-safe
This is a prerequisite for making any encoder that uses
ff_mpv_encode_init() init-threadsafe; it already makes the AMV,
the MJPEG and the MPEG-1/2 encoders init-threadsafe.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Andreas Rheinhardt f741bd0674 avcodec/mpeg12enc, speedhqenc: Avoid redundant copies of tables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-25 14:51:53 +01:00
Andreas Rheinhardt 6e8fcd9c56 avcodec/mpeg12: Don't initialize encoder-only parts of RLTable
ff_mpeg12_init_vlcs() currently initializes index_run, max_level and
max_run of ff_rl_mpeg1/2; yet the only user of these fields is the
MPEG-1/2 encoder which already initializes these tables on its own.
So remove the initializations in ff_mpeg12_init_vlcs(); this also
simplifies making ff_mpeg12_init_vlcs() thread-safe.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-31 11:11:59 +01:00
Andreas Rheinhardt 628d02a611 avcodec/speedhqenc: Call correct function
Up until now, the SpeedHQ encoder called a wrong function for init:
void ff_init_uni_ac_vlc(const uint8_t huff_size_ac[256],
                        uint8_t *uni_ac_vlc_len);
Yet the first argument actually used is of type RLTable; the size of
said struct is less than 256 if the size of a pointer is four, leading
to an access beyond the end of the RLTable.

This commit fixes this by calling the actually intended function:
init_uni_ac_vlc() from mpeg12enc.c. It was intended to use this
function [1], yet doing so was forgotten when the patch was actually
applied.

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-July/266187.html

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-11 02:20:05 +01:00
Andreas Rheinhardt 4e26520039 avcodec/mpeg12enc: Disallow using MPEG-2 intra VLC table for mpeg1video
Using MPEG-2 intra VLC tables is spec-incompliant for MPEG-1 and given
that an MPEG-1 bitstream can't signal whether MPEG-2 intra VLC tables
have been used the output is broken. Therefore this option is removed
immediately without any deprecation period.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-02 15:38:15 +01:00
Andreas Rheinhardt 3de3d2f5e2 avcodec/mpeg12enc: Reindentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-11-25 01:08:42 +01:00
Andreas Rheinhardt bf5bfcdbd3 avcodec/mpeg12enc: Use ff_thread_once() for static initializations
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-11-25 01:05:26 +01:00
Andreas Rheinhardt ef3c1670d4 avcodec/mpeg12enc: Always initialize MPEG-2 intra VLC table lengths
The MPEG-1/2 encoders initialize several tables once during the first
time one of the encoders is initialized; the table for MPEG-2 intra VLC
lengths is only initialized if it is used for this encoder instance.
This implies that if the first MPEG-1/2 encoder to be initialized does
not use it, it will never be initialized even if a later encoder
instance makes use of them. Fix this by initializing this table
unconditionally.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-11-25 01:01:05 +01:00
Anton Khirnov 717503f716 put_bits: make avpriv_align_put_bits() inline
This function is so extremely simple that it is preferable to make it
inline rather than deal with all the complications arising from it being
an exported symbol.

Keep avpriv_align_put_bits() around until the next major bump to
preserve ABI compatibility.
2020-10-28 13:53:23 +01:00
Limin Wang ad49dd7694 avcodec/mpeg12enc: support mpeg2 encoder const level
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-08-14 22:48:05 +08:00
Limin Wang dd76226842 avcodec/mpeg12enc: support mpeg2 encoder const profile
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-06-01 07:05:32 +08:00
Limin Wang 0032ca45ff avcodec/mpeg12enc: return more specific error codes for encode_init()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-09 09:33:49 +08:00
Limin Wang 1726eefec6 avcodec/mpeg12enc: Use FF_PROFILE_MPEG2_xxx macros
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-01 22:57:29 +08:00
Paul B Mahol d64cbd4fda remove CHAR_MIN/CHAR_MAX usage
It is not needed at all.
2020-03-17 22:46:36 +01:00
Michael Niedermayer 39ff027fd8 avcodec/mpeg12enc: Add FF_CODEC_CAP_INIT_CLEANUP
Fixes: Multiple memleaks
Fixes: ffmpeg-memory-leak

Found-by: Francis Provencher <francis@protekresearchlab.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-11 22:43:14 +02:00
Mathieu Duponchelle 6cfa173303 mpeg12enc: Use Closed Captions if available
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-03-16 00:02:23 +01:00
Marton Balint ce6ce595cf avcodec/mpeg12enc: add support for specifying video_format in the sequence_display_extension
In a recent commit the default was changed from 0 (component) to 5
(unspecified), however some standards require using 0. With this option, the
user will be able to do so.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-02-13 00:13:21 +01:00
James Almer 700da852b5 Merge commit '4c0588b4562abad5540f6a5435c62828de9e4fdf'
* commit '4c0588b4562abad5540f6a5435c62828de9e4fdf':
  mpeg2enc: Don't mark all streams as component video

Merged-by: James Almer <jamrial@gmail.com>
2017-11-11 01:24:55 -03:00
Mark Thompson 4c0588b456 mpeg2enc: Don't mark all streams as component video
Since there is no information about the source format, "unspecified"
is the correct value to write here.

All tests using the MPEG-2 encoder are updated, as this changes the
header on all outputs.
2017-08-20 15:14:37 +01:00
Clément Bœsch 8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Marton Balint 5e555f9300 mpeg12enc: always write closed gops for intra only outputs
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-02-22 19:08:56 -05:00
Derek Buitenhuis 9938697c1c Merge commit 'd749615333084e62c9fcc480d1ae466369fdf14f'
* commit 'd749615333084e62c9fcc480d1ae466369fdf14f':
  lavc: Move timecode_frame_start to codec private options

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-01-31 12:28:04 +00:00
Vittorio Giovara d749615333 lavc: Move timecode_frame_start to codec private options
This option is only used by mpeg2.
It is a very codec-specific option, so deprecate the global variant.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-01-21 15:33:19 -05:00