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

108761 Commits

Author SHA1 Message Date
Andreas Rheinhardt
5d93c330f7 avcodec/mpegvideo: Move sprite-related fields to Mpeg4DecContext
Only used there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:56:17 +02:00
Andreas Rheinhardt
4209216ee8 avcodec/mpegvideodsp: Make MpegVideoDSP MPEG-4 only
It is only used by gmc/gmc1 which is only used by the MPEG-4
decoder, so move it to Mpeg4DecContext and rename it
to Mpeg4VideoDSP. Also compile it iff the MPEG-4 decoder is compiled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:56:17 +02:00
Andreas Rheinhardt
ac8afdb9b5 avcodec/mpegvideo_motion: Move mspel/gmc motion to mpeg4videodec.c
It is the only codec for which mcsel is ever set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:56:17 +02:00
Andreas Rheinhardt
eb1ce6e3c7 avcodec/mpv_reconstruct_mb_template: Optimize dead code away
None of the MPEG-1/2 codecs support frame threading,
so one can optimize the check for it away.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:32:28 +02:00
Andreas Rheinhardt
7d23b350c2 avcodec/mpeg12dec: Remove always-true check
mpeg12dec.c is a decoder-only file.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:29:05 +02:00
Andreas Rheinhardt
6fe4e8fab4 avcodec/mpegvideo: Split ff_mpv_reconstruct_mb() into de/encoder part
This has the advantage of not having to check for whether
a given MpegEncContext is actually a decoder or an encoder
context at runtime.

To do so, mpv_reconstruct_mb_internal() is moved into a new
template file that is included by both mpegvideo_enc.c
and mpegvideo_dec.c; the decoder-only code (mainly lowres)
are also moved to mpegvideo_dec.c. The is_encoder checks are
changed to #if IS_ENCODER in order to avoid having to include
headers for decoder-only functions in mpegvideo_enc.c.

This approach also has the advantage that it is easy to adapt
mpv_reconstruct_mb_internal() to using different structures
for decoders and encoders (e.g. the check for whether
a macroblock should be processed for the encoder or not
uses MpegEncContext elements that make no sense for decoders
and should not be part of their context).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:29:03 +02:00
Andreas Rheinhardt
9ca312d8ab avcodec/mpegvideo: Inline is_encoder in mpv_reconstruct_mb_internal()
Up until now, we inlined lowres_flag as well as is_mpeg12
independently (unless CONFIG_SMALL was true); this commit
changes this to instead inline mpv_reconstruct_mb_internal()
(at most) four times, namely once for encoders, once for decoders
using lowres and once for non-lowres mpeg-1/2 decoders and once
for non-lowres non-mpeg-1/2 decoders (mpeg-1/2 is not inlined
in case of CONFIG_SMALL). This is neutral performance-wise,
but proved beneficial size-wise: It saved 1776B of .text
for GCC 11 or 1344B for Clang 14 (both -O3 x64).

Notice that inlining is_mpeg12 for is_encoder would not really
be beneficial, as the encoder codepath does mostly not depend
on is_mpeg12 at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:21:33 +02:00
Andreas Rheinhardt
409c4723ec avcodec/mpegvideo: Make inlining is_mpeg12 more flexible
There are two types of checks for whether the current codec
is MPEG-1/2 in mpv_reconstruct_mb_internal(): Those that are
required for correctness and those that are not; an example
of the latter is "is_mpeg12 || (s->codec_id != AV_CODEC_ID_WMV2)".
The reason for the existence of such checks is that
mpv_reconstruct_mb_internal() has the av_always_inline attribute
and is_mpeg12 is usually inlined, so that in case we are dealing
with MPEG-1/2 the above check can be completely optimized away.

But is_mpeg12 is not always inlined: it is not in case
CONFIG_SMALL is true in which case is_mpeg12 is always zero,
so that the checks required for correctness need to check
out_format explicitly. This is currently done via a macro
in mpv_reconstruct_mb_internal(), so that the fact that
it is CONFIG_SMALL that determines this is encoded at two places.

This commit changes this by making is_mpeg12 a three-state:
DEFINITELY_MPEG12, MAY_BE_MPEG12 and NOT_MPEG12. In the second
case, one has to resort to check out_format, in the other cases
is_mpeg12 can be taken at face-value. This will allow to make
inlining is_mpeg12 more flexible in a future commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:09:11 +02:00
Andreas Rheinhardt
cab876f5f4 avcodec/mpegvideo: Ignore skip_idct for encoders
It is documented to be unused for encoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:09:11 +02:00
Andreas Rheinhardt
a5e59fec07 avcodec/ffv1: Move ffv1_template.c inclusion to dec/enc templates
Both the FFV1 decoder and encoder use a template of their own
to generate code multiple times. They also use a common template,
used by both decoder and encoder templates which is currently
instantiated in ffv1.h (and therefore also in ffv1.c, which
doesn't need it at all).

All these templates have the prerequisite that two macros
are defined, namely RENAME() and TYPE. The codec-specific
templates call the functions generated via the common template
via the RENAME() macro and therefore the macros used for
the common template must coincide with the macros used for
the codec-specific templates. But then it is better to not
instantiate the common template in ffv1.h, but in the codec
specific templates.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
f63c6c81d4 avcodec/mpegutils: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
678f1b1cf4 avcodec/mpegutils: Return early in ff_draw_horiz_band()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
85f02c300f avcodec/mpegvideo: Move VIDEO_FORMAT_* defines to mpeg12enc.c
Forgotten in f899e3b51b.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
9e32f2ebfd avcodec/h261: Use ptrdiff_t for stride
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
10dfbb0502 avcodec/mpegvideo: Reindent after the last commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
5ecf5b93dd avcodec/mpegvideo: Don't check for draw_horiz_band
Some parts of mpegvideo.c behave differently depending
upon whether AVCodecContext.draw_horiz_band is set or not.
This differing behaviour makes lots of FATE tests fail
and leads to garbage output, although setting this callback
is not supposed to change the output at all.

These checks have been added in commits
3994623df2 and
b68ab2609c. The commit messages
do not contain a real reason for adding the checks and it is
indeed a mystery to me. But removing these checks fixes
the FATE tests when one adds an (empty) draw_horiz_band
when using a codec that claims to support it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
5bcae5251f avcodec/vc1_block: Remove dead calls to ff_mpeg_draw_horiz_band()
The VC-1 decoders don't support draw_horiz_band at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
e0c01a62ad avcodec/(ffv1|h264|png|snow)dec: Remove comment out DRAW_HORIZ_BAND cap
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
James Almer
1f63225f2b avcodec/librav1e: support AV_CODEC_CAP_ENCODER_RECON_FRAME
This bumps the minimum required version to 0.5.0

Signed-off-by: James Almer <jamrial@gmail.com>
2022-10-19 11:15:38 -03:00
James Almer
f58f238936 avcodec/librav1e: export extradata on init()
librav1e provides a function to create extradata, so use it instead of
extracting the sequence header OBU from packets.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-10-19 10:13:37 -03:00
James Almer
d569958d29 avcodec/librav1e: support setting sample aspect ratio
Signed-off-by: James Almer <jamrial@gmail.com>
2022-10-19 10:13:37 -03:00
Andreas Rheinhardt
30e1f5ec77 avcodec/startcode: Avoid unaligned accesses
Up until now, ff_startcode_find_candidate_c() simply casts
an uint8_t* to uint64_t*/uint32_t* to read 64/32 bits at a time
in case HAVE_FAST_UNALIGNED is true. Yet this ignores the
alignment requirement of these types as well as effective type
rules of the C standard. This commit therefore replaces these
direct accesses with AV_RN64/32; this also improves
readability.

UBSan reported these unaligned accesses which happened in 233
FATE-tests involving H.264 and VC-1 (this has also been reported
in tickets #8138 and #8485); these tests are fixed by this commit.

The output of GCC with -O3 is unchanged for aarch64, loongarch,
ppc and x64 (as well as for arches like alpha for which
HAVE_FAST_UNALIGNED is never true in the first place).
There was only a slight difference for mips and arm.
I don't know about the speed impact of them.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-19 13:48:31 +02:00
Jan Ekström
b9058765d7 ffmpeg: Deprecate display rotation override with a metadata key
Now that we have proper options for defining display matrix
overrides, this should no longer be required.

fftools does not have its own versioning, so for now the define is
just set to 1 and disables the functionality if set to zero.
2022-10-19 11:53:52 +02:00
Jan Ekström
c889248647 ffmpeg: Add display_{rotation, hflip, vflip} options
This enables overriding the rotation as well as horizontal/vertical
flip state of a specific video stream on the input side.

Additionally, switch the singular test that was utilizing the rotation
metadata to instead override the input display rotation, thus leading
to the same result.
2022-10-19 11:53:52 +02:00
Andreas Rheinhardt
81bc4ef142 avcodec/msmpeg4data: Mark tables as hidden
This e.g. allows compilers to bake the "+ 256" offset
used to access ff_v2_dc_(lum|chroma)_table into
the general offset; for certain arches this is also necessary
in order to avoid building suboptimal code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-18 15:44:29 +02:00
Andreas Rheinhardt
c9d0ba9a60 avcodec/jpegtables: Mark jpegtables as hidden
These tables are not exported as avpriv symbols, but instead
included into every library using them. Therefore they
can be mark with the hidden elf visibility. For certain arches
this is necessary in order to avoid building suboptimal code;
for other arches it just allows the compiler to simplify accesses
like ff_mjpeg_bits_dc_luminance + 1 because the "+ 1" can be baked
into the offset.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-18 15:44:29 +02:00
Andreas Rheinhardt
ff2c37d449 fftools/ffmpeg_opt: Move stuff only used by ffmpeg_mux_init to it
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-18 14:19:11 +02:00
Anton Khirnov
c5d7b6f49b fftools/ffmpeg_mux: move muxing queue fields from OutputStream to MuxStream
They are private to the muxer and do not need to be visible outside of
it.
2022-10-18 14:19:11 +02:00
Anton Khirnov
f0cd68eea0 fftools/ffmpeg_mux: move bsf_ctx from OutputStream to MuxStream
It is private to the muxer and does not need to be visible outside of
it.
2022-10-18 14:19:11 +02:00
Anton Khirnov
2266e04834 fftools/ffmpeg_mux: embed OutputStream in a MuxStream
This is now possible since OutputStream is a child of OutputFile and the
code allocating it can access MuxStream. Avoids the overhead and extra
complexity of allocating two objects instead of one.

Similar to what was previously done for OutputFile/Muxer.
2022-10-18 14:19:11 +02:00
Anton Khirnov
709b47f8a4 fftools/ffmpeg: free output streams in of_close()
Output streams are now children of OutputFile, so it makes more sense to
free them there.
2022-10-18 14:19:11 +02:00
Anton Khirnov
fe304c0694 fftools/ffmpeg: remove a cleanup block at the end of transcode()
Some of it is already duplicated in ost_free() - those parts can be just
dropped. The rest is moved to ost_free(), as it properly belongs there.
2022-10-18 14:19:07 +02:00
Anton Khirnov
7ef7a22251 fftools/ffmpeg: remove the output_streams global
Replace it with an array of streams in each OutputFile. This is a more
accurate reflection of the actual relationship between OutputStream and
OutputFile. This is easier to handle and will allow further
simplifications in future commits.
2022-10-18 13:57:43 +02:00
Anton Khirnov
0baed07f74 fftools/ffmpeg_mux_init: pass Muxer to new_output_stream()
And intermediate functions. Will be useful in the following commit.
2022-10-18 13:57:43 +02:00
Anton Khirnov
18d96e8703 fftools/ffmpeg: reindent after previous commit 2022-10-18 13:57:43 +02:00
Anton Khirnov
2dcedd9af8 fftools/ffmpeg: move freeing an output stream into a separate function 2022-10-18 13:57:43 +02:00
Anton Khirnov
9f9bf8703b fftools/ffmpeg: move init_output_bsfs() to ffmpeg_mux
Bitstream filtering is done as a part of muxing, so this is the more
proper place for this.
2022-10-18 13:57:43 +02:00
Anton Khirnov
ee0a900e58 fftools/ffmpeg_mux: move sq_mux from OutputFile to Muxer
It is internal to ffmpeg_mux* and does not need to be visible to other
code.
2022-10-18 13:57:43 +02:00
Anton Khirnov
d6195c88e2 fftools/ffmpeg_mux: inline mux_free() into of_close()
mux_free() is no longer called from anywhere else.
2022-10-18 13:57:43 +02:00
Anton Khirnov
36ce335d46 fftools/ffmpeg_mux: inline of_muxer_init() into of_open()
A separate muxer init is no longer necessary, now that of_open() has
access to Muxer.
2022-10-18 13:57:43 +02:00
Anton Khirnov
a55ca682e2 fftools/ffmpeg_mux: allocate sq_pkt in setup_sync_queues()
This is now possible since setup_sync_queues() can interact with Muxer.
2022-10-18 13:57:43 +02:00
Anton Khirnov
65d106933a fftools/ffmpeg_mux: embed OutputFile in a Muxer
This is now possible since the code allocating OutputFile can see
sizeof(Muxer). Avoids the overhead and extra complexity of allocating
two objects instead of one.

Similar to what is done e.g. for AVStream/FFStream in lavf.
2022-10-18 13:57:43 +02:00
Anton Khirnov
24098c6c8d fftools/ffmpeg_mux: move Muxer and MuxStream to a new header
This will allow ffmpeg_mux_init.c to work with these structs.
2022-10-18 13:57:43 +02:00
Anton Khirnov
18d6c07267 fftools/ffmpeg_opt: move opening output files into a new file
ffmpeg_opt.c currently contains code for
- parsing the options provided on the command line
- opening and initializing input files based on these options
- opening and initializing output files based on these options

The code dealing with each of these is for the most part disjoint, so it
makes sense to move them to separate files. Beyond reducing the quite
considerable size of ffmpeg_opt.c, this will also allow exposing muxer
internals (currently private to ffmpeg_mux.c) to the initialization
code, thus removing the awkward separation currently in place.
2022-10-18 13:57:42 +02:00
Anton Khirnov
965bff37b6 fftools/ffmpeg: move some stream initialization code to ffmpeg_mux
The code in question is muxing-specific and so belongs there. This will
allow make some objects private to the muxer in future commits.
2022-10-18 13:57:42 +02:00
Anton Khirnov
731246ae8f fftools/ffmpeg_mux: drop the of_ prefix from of_submit_packet()
This function is now static.
2022-10-18 13:57:42 +02:00
Anton Khirnov
a7028d7fa8 fftools/ffmpeg_mux: rename submit_packet() to thread_submit_packet()
This is more descriptive, and the submit_packet() name will be reused in
following commits.
2022-10-18 13:57:42 +02:00
Anton Khirnov
d579a70291 fftools/ffmpeg: move output_packet() to ffmpeg_mux
This function is common to both transcoding and streamcopy, so it
properly belongs into the muxing code.
2022-10-18 13:57:42 +02:00
Anton Khirnov
072e3f710e fftools/ffmpeg_mux: do not unref a NULL packet
The packet submitted to of_submit_packet() may be NULL to signal EOF.
2022-10-18 13:57:42 +02:00
Peter Ross
3141dbb7ad avcodec: ViewQuest VQC decoder
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Peter Ross <pross@xvid.org>
2022-10-18 13:20:37 +11:00