Commit Graph

65 Commits

Author SHA1 Message Date
James Almer 65ddc74988 avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUT
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
Anton Khirnov 1e7d2007c3 all: use designated initializers for AVOption.unit
Makes it robust against adding fields before it, which will be useful in
following commits.

Majority of the patch generated by the following Coccinelle script:

@@
typedef AVOption;
identifier arr_name;
initializer list il;
initializer list[8] il1;
expression tail;
@@
AVOption arr_name[] = { il, { il1,
- tail
+ .unit = tail
}, ...  };

with some manual changes, as the script:
* has trouble with options defined inside macros
* sometimes does not handle options under an #else branch
* sometimes swallows whitespace
2024-02-14 14:53:41 +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
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 66b691f99f avcodec/internal: Move ff_get_buffer() to decode.h
Only used by decoders (encoders have ff_encode_alloc_frame()).

Also clean up the other headers a bit while removing now redundant
internal.h inclusions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-27 14:14:56 +02:00
Andreas Rheinhardt 21b23ceab3 avcodec: Make init-threadsafety the default
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>
2022-07-18 20:04:59 +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 ce7dbd0481 avcodec/codec_internal: Make FFCodec.decode use AVFrame*
This increases type-safety by avoiding conversions from/through void*.
It also avoids the boilerplate "AVFrame *frame = data;" line
for non-subtitle decoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 19:54:09 +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
Vittorio Giovara 353e4d4219 libfdk-aac: convert to new channel layout API
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:42 -03:00
Martin Storsjö c69b1a12bb libfdk-aacdec: Flush delayed samples at the end
The fdk-aac decoder can return decoded audio data with a delay.
(Whether it does this or not depends on the options set; by default
it does add some delay.) Previously, this delay was handled by
adjusting the timestamps of the decoded frames, but the last delayed
samples weren't returned.

Set the AV_CODEC_CAP_DELAY flag to indicate that the caller should
flush remaining samples at the end. Also trim off the corresponding
amount of samples at the start instead of adjusting timestamps.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-02-03 23:57:57 +02:00
Martin Storsjö 340a78afeb libfdk-aacdec: Add an option for setting the decoder's DRC album mode
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-02-03 23:51:47 +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
Martin Storsjö e8cbdb9adb libfdk-aacdec: Allow explicitly disabling the DRC reference level option
Previously, it was always left in the automatic mode, if the option
was set to the only special (negative) value. Now there's two separate
special values for this option, -1 for automatic (metadata based)
and -2 for explicitly disabled.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-02-11 11:40:13 +02:00
Martin Storsjö 5835adee24 libfdk-aacdec: Use the decoder's default level limiter settings
It was disabled by default in 2dbd35b00c
as it added delay, but now we compensate for the delay properly
by offsetting timestamps.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-02-11 11:40:09 +02:00
Martin Storsjö 0f2b6594fc libfdk-aacdec: Apply the decoder's output delay on timestamps
The delay is normally zero when the level limiter is disabled,
but if enabled, there's a small delay.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-02-11 11:39:44 +02:00
James Almer 1b98bfb932 Merge commit '2a9e1c122eed66be1b26b747342b848300b226c7'
* commit '2a9e1c122eed66be1b26b747342b848300b226c7':
  libfdk-aac: Don't use defined() in a #define

Merged-by: James Almer <jamrial@gmail.com>
2018-09-13 23:16:18 -03:00
Martin Storsjö 2a9e1c122e libfdk-aac: Don't use defined() in a #define
MSVC expands the preprocessor directives differently, making the
version check fail in the previous form.

Clang can warn about this with -Wexpansion-to-defined (not currently
enabled by default):
warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

Signed-off-by: Martin Storsjö <martin@martin.st>
2018-09-13 22:11:50 +03:00
James Almer 94d98330ed Merge commit '2edaafe5b93832715781851dfe2663da228a05ad'
* commit '2edaafe5b93832715781851dfe2663da228a05ad':
  libfdk-aacdec: Allow setting the new dynamic range control effect setting

Merged-by: James Almer <jamrial@gmail.com>
2018-09-11 14:13:14 -03:00
James Almer 203bbaccfa Merge commit 'ffb9b7a6bab6c6bfd3dd9a7c32e3724209824999'
* commit 'ffb9b7a6bab6c6bfd3dd9a7c32e3724209824999':
  libfdk-aac: Consistently use a proper version check macro for detecting features

Merged-by: James Almer <jamrial@gmail.com>
2018-09-11 14:11:39 -03:00
Martin Storsjö 2edaafe5b9 libfdk-aacdec: Allow setting the new dynamic range control effect setting
This is a new setting in FDK v2.

Signed-off-by: Martin Storsjö <martin@martin.st>
2018-09-05 22:40:50 +03:00
Martin Storsjö ffb9b7a6ba libfdk-aac: Consistently use a proper version check macro for detecting features
The previous version checks checked explicitly for the version
where the version define was added to the installed headers,
making an "#ifdef AACDECODER_LIB_VL0" enough. Now that we have
a need for more diverse version checks than this, convert all checks
to such checks.

Signed-off-by: Martin Storsjö <martin@martin.st>
2018-09-05 22:40:46 +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 e621b1ca64 Merge commit '97cfe1d8bd1968143e2ba9aa46ebe9504a835e24'
* commit '97cfe1d8bd1968143e2ba9aa46ebe9504a835e24':
  Convert all AVClass struct declarations to designated initializers.

Merged-by: James Almer <jamrial@gmail.com>
2017-11-01 20:05:09 -03:00
Michael Niedermayer f61265571d libfdk-aacdec: Correct buffer_size parameter
The timeDataSize argument to aacDecoder_DecodeFrame() seems undocumented
and until 2016 04 (203e3f28fbebec7011342017fafc2a0bda0ce530) unused.
After that commit libfdk-aacdec interprets it as size in sample units
and memsets that on error.

FFmpeg as well as others (like GStreamer) did interpret it as size in
bytes.

Fixes: 1442/clusterfuzz-testcase-minimized-4540199973421056 (This requires recent libfdk to reproduce)

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Martin Storsjö <martin@martin.st>
2017-06-13 22:08:44 +03:00
Diego Biurrun 97cfe1d8bd Convert all AVClass struct declarations to designated initializers. 2017-06-12 11:01:10 +02:00
Michael Niedermayer ca6776a993 avcodec/libfdk-aacdec: Correct buffer_size parameter
the timeDataSize argument to aacDecoder_DecodeFrame() seems undocumented and until
2016 04 (203e3f28fbebec7011342017fafc2a0bda0ce530) unused.
after that commit libfdk-aacdec interprets it as size in sample units and memsets that on error.
FFmpeg as well as others (like GStreamer) did interpret it as size in bytes

Fixes: 1442/clusterfuzz-testcase-minimized-4540199973421056 (This requires recent libfdk to reproduce)

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-28 03:08:33 +02:00
Michael Niedermayer 325ee610ba avcodec/libfdk-aacdec: Remove unused variable
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-04 11:26:14 +02:00
Vittorio Giovara b0d94324d2 libfdk-aacdec: Remove unused variable 2015-08-31 15:24:30 +02:00
Hendrik Leppkes e721cb8d8b Merge commit 'f34b152eb7b7e8d2aee57c710a072cf74173fbe1'
* commit 'f34b152eb7b7e8d2aee57c710a072cf74173fbe1':
  libfdk-aacdec: Clean up properly if the init fails

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-08-18 09:09:55 +02:00
Hendrik Leppkes 4cf4831ae7 Merge commit '1b90433f79de857550d4d8c35c89fbe954920594'
* commit '1b90433f79de857550d4d8c35c89fbe954920594':
  libfdk-aacdec: Always decode into an intermediate buffer

Conflicts:
	libavcodec/libfdk-aacdec.c

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-08-18 09:05:54 +02:00
Hendrik Leppkes 9dc30d0811 Merge commit '87de6ddb7b7674e329d5c96677bd8685bc7f7855'
* commit '87de6ddb7b7674e329d5c96677bd8685bc7f7855':
  libfdk-aacdec: Bump the max number of channels to 8

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-08-18 09:02:15 +02:00
Martin Storsjö f34b152eb7 libfdk-aacdec: Clean up properly if the init fails
Previously most of the error paths leaked.

Also add FF_CODEC_CAP_INIT_THREADSAFE while adding caps_internal;
this decoder wrapper doesn't have any static data that is initialized.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-08-16 00:18:00 +03:00
Martin Storsjö 1b90433f79 libfdk-aacdec: Always decode into an intermediate buffer
For ADTS streams, the output format (number of channels, frame size)
can change at any point (with the latest version of fdk-aac, the decoder
seems to change format after a handful of frames, not outputting the
right format immediately, for cases that worked fine with the earlier
version of the lib).

Previously, the decoder decoded straight into the output frame once the
number of channels and frame size was known. This obviously does not
work if the number of channels or frame size changes.

The alternative would be to allocate the AVFrame with the maximum number
of channels and frame size, and change them afterward decoding into it,
but that may cause confusion to users e.g. of the get_buffer callback.
This solution should be more robust.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-08-16 00:17:49 +03:00
Martin Storsjö 87de6ddb7b libfdk-aacdec: Bump the max number of channels to 8
In the latest version of fdk-aac, the decoder can output up to 8
channels; take this into account when preallocating buffers that
need to fit the output from any packet.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-08-16 00:17:46 +03:00
Michael Niedermayer 444e9874a7 Merge commit 'def97856de6021965db86c25a732d78689bd6bb0'
* commit 'def97856de6021965db86c25a732d78689bd6bb0':
  lavc: AV-prefix all codec capabilities

Conflicts:
	cmdutils.c
	ffmpeg.c
	ffplay.c
	libavcodec/8svx.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.c
	libavcodec/adpcm.c
	libavcodec/alac.c
	libavcodec/atrac3plusdec.c
	libavcodec/bink.c
	libavcodec/dnxhddec.c
	libavcodec/dvdec.c
	libavcodec/dvenc.c
	libavcodec/ffv1dec.c
	libavcodec/ffv1enc.c
	libavcodec/fic.c
	libavcodec/flacdec.c
	libavcodec/flacenc.c
	libavcodec/flvdec.c
	libavcodec/fraps.c
	libavcodec/frwu.c
	libavcodec/gifdec.c
	libavcodec/h261dec.c
	libavcodec/hevc.c
	libavcodec/iff.c
	libavcodec/imc.c
	libavcodec/libopenjpegdec.c
	libavcodec/libvo-aacenc.c
	libavcodec/libvorbisenc.c
	libavcodec/libvpxdec.c
	libavcodec/libvpxenc.c
	libavcodec/libx264.c
	libavcodec/mjpegbdec.c
	libavcodec/mjpegdec.c
	libavcodec/mpegaudiodec_float.c
	libavcodec/msmpeg4dec.c
	libavcodec/mxpegdec.c
	libavcodec/nvenc_h264.c
	libavcodec/nvenc_hevc.c
	libavcodec/pngdec.c
	libavcodec/qpeg.c
	libavcodec/ra288.c
	libavcodec/rv10.c
	libavcodec/s302m.c
	libavcodec/sp5xdec.c
	libavcodec/takdec.c
	libavcodec/tiff.c
	libavcodec/tta.c
	libavcodec/utils.c
	libavcodec/v210dec.c
	libavcodec/vp6.c
	libavcodec/vp9.c
	libavcodec/wavpack.c
	libavcodec/yop.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 22:50:18 +02:00
Vittorio Giovara def97856de lavc: AV-prefix all codec capabilities
Express bitfields more simply.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:58 +01:00
Michael Niedermayer cf729b2489 avcodec/libfdk-aacdec: Change conceal_method to int, its accessed via AVOption as int
This fixes depending on implementation defined behavior

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-02 04:08:09 +01:00
Michael Niedermayer 3fd3647fdc Merge commit '2dbd35b00c6433e587d5f44d5dbc8972ebbaa88e'
* commit '2dbd35b00c6433e587d5f44d5dbc8972ebbaa88e':
  libfdk-aacdec: Make sure decoding doesn't add any extra delay in the latest version of fdk-aac

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-08 17:36:48 +01:00
Martin Storsjö 2dbd35b00c libfdk-aacdec: Make sure decoding doesn't add any extra delay in the latest version of fdk-aac
The latest version added support for a new option for enabling
a signal level limiter, which adds some extra delay. In fdk-aac, this
is enabled by default, but disable it by default here since we'd rather
have zero-delay decoding.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-01-08 13:58:43 +02:00
Michael Niedermayer 66daf3b811 Merge commit 'c7921a480467876ece06566e0efd8f6bce9d1903'
* commit 'c7921a480467876ece06566e0efd8f6bce9d1903':
  libfdk-aacdec: Fix a boundary check

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-11 01:46:11 +01:00
Martin Storsjö c7921a4804 libfdk-aacdec: Fix a boundary check
This avoids potential out of bounds writes, with potential future
versions of the library.

Bug-Id: CID 1254945
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-12-10 22:51:42 +02:00
Martin Storsjö 28396d17ff libfdk-aacdec: Support building with the latest version of fdk-aac
The latest fdk-aac code drop (from android 5.0) changed the channel
layout enums (changing the value of existing enum constants), and
renamed the option for downmixing.

The failsafe comparison between ctype and FF_ARRAY_ELEMS(channel_counts)
can trigger warnings (-Wtautological-constant-out-of-range-compare)
when building with the old FDK AAC releases, where it can't be
out of range with the enum values used there.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2014-11-10 09:43:57 +02:00
Martin Storsjö b44a242c3d libfdk-aacdec: Support building with the latest version of fdk-aac
The latest fdk-aac code drop (from android 5.0) changed the channel
layout enums (changing the value of existing enum constants), and
renamed the option for downmixing.

The failsafe comparison between ctype and FF_ARRAY_ELEMS(channel_counts)
can trigger warnings (-Wtautological-constant-out-of-range-compare)
when building with the old FDK AAC releases, where it can't be
out of range with the enum values used there.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-10 02:46:46 +01:00
Michael Niedermayer 45fed258ee Merge commit '66e9f839536238945fbfe9d2041b6891cb150e45'
* commit '66e9f839536238945fbfe9d2041b6891cb150e45':
  libfdk-aacdec: Enable Dynamic Range Control Metadata Support

Conflicts:
	libavcodec/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-17 20:45:43 +02:00
Michael Niedermayer e18fc35a07 avcodec/libfdk-aacdec: use av_feeep() to avoid leaving stale pointers in memory
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-17 20:36:14 +02:00
Michael Niedermayer 5a1aa55905 Merge commit 'b01a2204b5cff7bb920f42fda1bb0103f450fe93'
* commit 'b01a2204b5cff7bb920f42fda1bb0103f450fe93':
  libfdk-aacdec: Enable Decoder Downmix including Downmix Metadata Support

Conflicts:
	libavcodec/libfdk-aacdec.c
	libavcodec/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-17 20:35:43 +02:00