1
0
Fork 0
Commit Graph

88 Commits

Author SHA1 Message Date
Andreas Rheinhardt 790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
Andreas Rheinhardt 687a287e14 avcodec/mmaldec: Avoid using AVCodec.pix_fmts
It is entirely unnecessary to use it given that all decoders
here share the same set of supported pixel formats. So just
hardcode this list.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 08:16:25 +01:00
Anton Khirnov 08bebeb1be Revert "all: Don't set AVClass.item_name to its default value"
Some callers assume that item_name is always set, so this may be
considered an API break.

This reverts commit 0c6203c97a.
2024-01-20 10:34:48 +01:00
Andreas Rheinhardt 0c6203c97a all: Don't set AVClass.item_name to its default value
Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9;
also avoids relocations.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-12-22 15:12:33 +01:00
Zhao Zhili e8a49b1424 avcodec/mmaldec: Fix build error
Fix #10670.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-11-22 21:02:04 +08: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
James Almer 132271c54e avcodec/mmaldec: remove FF_CODEC_CAP_SETS_PKT_DTS flag
It has no effect on receive_frame() decoders.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-11 14:26:43 -03: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
Andreas Rheinhardt 48286d4d98 avcodec/codec_internal: Add macro to set AVCodec.long_name
It reduces typing: Before this patch, there were 105 codecs
whose long_name-definition exceeded the 80 char line length
limit. Now there are only nine of them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:42:57 +02:00
Andreas Rheinhardt 6aad1204cc avcodec: Add FF_CODEC_CAP_NOT_INIT_THREADSAFE
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>
2022-07-18 19:58:56 +02:00
Andreas Rheinhardt 4243da4ff4 avcodec/codec_internal: Use union for FFCodec decode/encode callbacks
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>
2022-04-05 20:02:37 +02:00
Andreas Rheinhardt 20f9727018 avcodec/codec_internal: Add FFCodec, hide internal part of AVCodec
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>
2022-03-21 01:33:09 +01:00
Andreas Rheinhardt a688f3c13c avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.h
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>
2022-03-21 01:33:09 +01:00
Andreas Rheinhardt 7fe5c7f02d avcodec/mmaldec: Deduplicate AVClasses
Possible now that the child_class_next API is gone.

Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-12 16:56:04 +01:00
Andreas Rheinhardt 9644ee224f avcodec/mmaldec: Avoid creating unnecessary reference, simplify code
ffmal_add_packet() basically duplicated the logic in
av_packet_make_refcounted() with the added twist that it always
created a reference even if one is already available.
This commit stops doing this.

Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-12 16:55:33 +01:00
Ho Ming Shun dd779749f0 avcodec/mmaldec: fix pointer type warning
Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Ho Ming Shun <cyph1984@gmail.com>
2021-12-12 16:55:13 +01:00
Ho Ming Shun 6f0e8b998a avcodec/mmaldec: re-use AVPacket for extra_data
extra_data and normal packets (from ff_decode_get_packet) processing do
not overlap, thus we can re-use the spare AVPacket to send to
ffmmal_add_packet.

Furthermore, this removes allocation of AVPacket on the stack and stops
using deprecated av_init_packet.

Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Ho Ming Shun <cyph1984@gmail.com>
2021-12-12 16:55:06 +01:00
Ho Ming Shun b54377b3a7 avcodec/mmaldec: use decoupled dataflow
MMAL is an fundamentally an asynchronous decoder, which was a bad fit
for the legacy dataflow API. Often multiple packets are enqueued before
a flood of frames are returned from MMAL.

The previous lockstep dataflow meant that any delay in returning packets
from the VPU would cause ctx->queue_decoded_frames to grow with no way
of draining the queue.

Testing this with mpv streaming from a live RTSP source visibly reduced
latency introduced by frames waiting in queue_decoded_frames from
roughly 2s to 0.

Tested-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Ho Ming Shun <cyph1984@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-12 16:54:43 +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 6e30b35b85 avutil/frame: Remove deprecated AVFrame.pkt_pts field
Deprecated in 32c8359093.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:13 -03:00
rcombs eabf5e6d6b All: update names in copyright headers 2021-01-20 01:02:56 -06:00
Mark Thompson cd322794ee lavc: Mark hw_config pointer arrays as const
They are read-only just like the HWConfig structures they point to.
2020-11-08 18:54:42 +00:00
James Almer c56d787fe3 avcodec/decode: move the ff_decode_frame_props() prototype to the proper header
Signed-off-by: James Almer <jamrial@gmail.com>
2020-08-20 13:17:50 -03:00
Mark Thompson 2594f6a362 lavc: Rename hwaccel.h to hwconfig.h
This already applied to decoders as well as hwaccels, and adding encoder
support was going to make the name even more inaccurate.
2020-04-26 18:38:25 +01: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
Mark Thompson da4e02b196 lavc: Delete all fake hwaccels
They are now unused.
2017-11-26 21:41:14 +00:00
Mark Thompson 758fbc54fe lavc: Add hardware config metadata for decoders supporting hardware output
This includes a pointer to the associated hwaccel for decoders using
hwaccels - these will be used later to implement the hwaccel setup
without needing a global list.

Also added is a new file listing all hwaccels as external declarations -
this will be used later to generate the hwaccel list at configure time.
2017-11-26 21:35:53 +00:00
James Almer f3f1bbc6a8 Merge commit '04f691cd4fb7d226e54df886a21ba201cb5019f4'
* commit '04f691cd4fb7d226e54df886a21ba201cb5019f4':
  mmal: Add missing .item_name to AVClass declaration

Merged-by: James Almer <jamrial@gmail.com>
2017-11-01 20:21:35 -03:00
Diego Biurrun 04f691cd4f mmal: Add missing .item_name to AVClass declaration 2017-06-13 13:30:34 +02:00
Clément Bœsch b853d6aa5b Merge commit 'd82d5379caca21005d8906829b35361c4a65408e'
* commit 'd82d5379caca21005d8906829b35361c4a65408e':
  mmaldec: initialize refcount using atomic_init()

Merged-by: Clément Bœsch <u@pkh.me>
2017-04-08 14:52:30 +02:00
Clément Bœsch 67e370ee52 lavc: fix usages of av_get_codec_tag_string() 2017-03-29 14:49:29 +02:00
Clément Bœsch 82d6179a88 Merge commit '8385ba53f115401a67a4748c0d107769ebfb2941'
* commit '8385ba53f115401a67a4748c0d107769ebfb2941':
  mmaldec: convert to stdatomic

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-22 18:01:51 +01:00
Wan-Teh Chang d82d5379ca mmaldec: initialize refcount using atomic_init()
This is how we initialize refcount in libavutil/buffer.c.

Signed-off-by: Wan-Teh Chang <wtc@google.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-12-02 12:16:26 -05:00
Hendrik Leppkes 3f9137c57d Merge commit '32c8359093d1ff4f45ed19518b449b3ac3769d27'
* commit '32c8359093d1ff4f45ed19518b449b3ac3769d27':
  lavc: export the timestamps when decoding in AVFrame.pts

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-10-07 13:03:36 +02:00
Anton Khirnov 8385ba53f1 mmaldec: convert to stdatomic 2016-10-02 19:35:12 +02:00
Jens Ziller bc7066fd5d libavcodec/mmaldec.c: set AVFrame interlaced_frame and top_field_first, AVCodecContext framerate
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-12 01:14:07 +02:00
Anton Khirnov 32c8359093 lavc: export the timestamps when decoding in AVFrame.pts
Currently it's exported as AVFrame.pkt_pts, which is also the only use
for that field. The reason it is done like this is that lavc used to
export various codec-specific "timing" information in AVFrame.pts, which
is not done anymore.

Since it is confusing to the callers to have a separate field which is
used only for decoder timestamps and nothing else, deprecate pkt_pts and
use just AVFrame.pts everywhere.
2016-06-21 19:54:42 +02:00
Clément Bœsch d16aefee5c lavc/mmaldec: reduce some diffs with Libav missed in previous skipped merges 2016-06-21 13:35:36 +02:00
Clément Bœsch ba5100ce84 Merge commit '74beead9bd596180bcac6108548fc0a86d8eb4ae'
* commit '74beead9bd596180bcac6108548fc0a86d8eb4ae':
  mmaldec: limit internal buffering

See 14a90c9ef0

The introduction of the MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS check is
merged.

Merged-by: Clément Bœsch <clement@stupeflix.com>
2016-06-21 13:32:57 +02:00
Derek Buitenhuis f4c88eef95 Merge commit 'b8e899f4bf5f09900aa71552112d32a5566b6baf'
* commit 'b8e899f4bf5f09900aa71552112d32a5566b6baf':
  mmaldec: Use imgutils.h for copying frames

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-05-11 19:15:14 +01:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
wm4 74beead9bd mmaldec: limit internal buffering
This uses a new MMAL feature, which limits the number of extra frames
that can be buffered within the decoder. VIDEO_MAX_NUM_CALLBACKS can
be defined as positive or negative number. Positive numbers are
absolute, and can lead to deadlocks if the user underestimates the
number of required buffers. Negative numbers specify the number of extra
buffers, e.g. -1 means no extra buffer, (-1-N) means N extra buffers.

Set a gratuitous default of -11 (N=10). This is much lower than the
firmware default, which appears to be 96.

This is backwards compatible, but needs a symbol only present in newer
firmware headers. (It's an enum item, so it requires a check in
configure.)

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-04-30 08:31:08 +02:00
wm4 45a954f5aa mmaldec: print the MMAL format FourCC automatically
Slight simplification. The result is the same. Also, change the
wording of the message as requested in patch review.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-04-30 08:29:13 +02:00
wm4 ce589940c2 mmaldec: send only a single EOS packet on flushing
Fixes apparent mmal_port_disable() freezes in ffmmal_stop_decoder() when
calling ffmmal_decode() with flush semantics a large number of times in
a row.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-04-30 08:26:22 +02:00
wm4 46aaad78c3 mmaldec: correct package buffering accounting
The assert in ffmmal_stop_decoder() could trigger sometimes. The
packets_buffered counter was indeed not correctly maintained, and
packets were not subtracted from it if they were still in the waiting
queue.

For some reason, this happened especially with VC-1.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-04-30 08:19:58 +02:00
wm4 9a382f3639 mmaldec: add vc1 decoding support
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-04-30 08:19:53 +02:00
Julian Scheel d52208e8d5 mmaldec: Add mpeg2 decoding support
Register mmaldec as mpeg2 decoder. Supporting mpeg2 in mmaldec is just a
matter of setting the correct MMAL_ENCODING on the input port. To ease the
addition of further supported mmal codecs a macro is introduced to generate
the decoder and decoder class structs.

Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-04-30 08:11:13 +02:00
Julian Scheel 2689bb115c mmaldec: Fix avpriv_atomic_get usage
There is no avpriv_atomic_get, instead avpriv_atomic_int_get is to be used for
integers. This fixes building mmaldec.

Signed-off-by: Julian Scheel <julian@jusst.de>
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-04-30 08:00:58 +02:00
Michael Niedermayer 366ba2dee1 mmaldec: Use av_assert0() instead of assert()
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-04-30 08:00:02 +02:00
Martin Storsjö b8e899f4bf mmaldec: Use imgutils.h for copying frames
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-04-12 13:50:54 +03:00