Commit Graph

223 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
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
Andreas Rheinhardt 8b83b52d0f avformat/nutenc: Fix indentation
Forgotten after 82beb46e65.
Also use loop-scope for iterators while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:19 +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 59c9dc82f4 avformat/avformat: Move AVOutputFormat internals out of public header
This commit does for AVOutputFormat what commit
20f9727018 did for AVCodec:
It adds a new type FFOutputFormat, moves all the internals
of AVOutputFormat to it and adds a now reduced AVOutputFormat
as first member.

This does not affect/improve extensibility of both public
or private fields for muxers (it is still a mess due to lavd).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:24:15 +01:00
Marvin Scholz 4bf8c9c2d8 avformat/nutenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Andreas Rheinhardt d78838414b avformat/utils: Move creation-time functions to mux_utils
Only used by muxers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:30:31 +02:00
Andreas Rheinhardt 107bdd97a9 avformat/mux: Move ff_choose_timebase to nutenc, its only user
(This function does not seem to abide by its documentation.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:27:09 +02:00
Martin Storsjö 4eb9232c6e libavformat: Split version.h
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:05:26 +02:00
Vittorio Giovara b9298dad94 nutdec: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:35 -03:00
Anton Khirnov 09b5d3fb44 lavc: deprecate channel count/layout changing side data
They are incompatible with the new channel layout scheme and no decoder
uses them.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:29 -03:00
Andreas Rheinhardt 33e6d57f01 avcodec/mpegaudiodata: Unavpriv mpa_bitrate and mpa_frequency tabs
These arrays have a size of 180 resp. six bytes. This does not
make it worthwhile to export them due to the overhead this occurs;
for x64 Elf/Linux/GNU: 2x2B version, 2x24B .dynsym, 24B .rela.dyn,
8B .got, 4B hash + twice the size of the name (here 20+23B).
Therefore these symbols are unavprived and duplicated for shared
builds.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:16:50 +01:00
Andreas Rheinhardt 40bdd8cc05 avformat: Avoid allocation for AVStreamInternal
Do this by allocating AVStream together with the data that is
currently in AVStreamInternal; or rather: Put AVStream at the
beginning of a new structure called FFStream (which encompasses
more than just the internal fields and is a proper context in its own
right, hence the name) and remove AVStreamInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 13:22:25 +02:00
Andreas Rheinhardt bc70684e74 avformat: Constify all muxer/demuxers
This is possible now that the next-API is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:06 -03:00
Anton Khirnov cea7c19cda lavf: move AVStream.*index_entries* to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header. Since there are some (semi-)public fields located after these,
even though this section is supposed to be private, keep some dummy
padding there until the next major bump to preserve ABI compatibility.
2020-10-28 14:59:28 +01:00
Andreas Rheinhardt f93bd30282 avformat/nutenc: Write size into right dynamic buffer
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-05 19:35:38 +02:00
Andreas Rheinhardt 781c7a6217 avformat/aviobuf, nutenc: Move ff_puv_v, ff_get_v_length to nutenc.c
and make it static again.

These functions have been moved from nutenc to aviobuf and internal.h
in f8280ff4c0 in order to use them in a
forthcoming patch in utils.c. Said patch never happened, so this commit
moves them back and makes them static, effectively reverting said
commit as well as f8280ff4c0 (which added
the ff-prefix to these functions).

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-05 19:28:28 +02:00
Andreas Rheinhardt 9b9a61ca77 avformat/nutenc: Add goto fail in nut_write_headers()
It allows to combine several ffio_free_dyn_buf().

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-05 19:17:13 +02:00
Andreas Rheinhardt 2ffa8be53b avformat/nutenc: Reuse dynamic buffers when possible
NUT uses variable-length integers in order to for length fields.
Therefore the NUT muxer often writes data into a dynamic buffer in order
to get the length of it, then writes the length field using the fewest
amount of bytes needed. To do this, a new dynamic buffer was opened,
used and freed for each element which involves lots of allocations. This
commit changes this: The dynamic buffers are now resetted and reused.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-05 19:06:18 +02:00
Andreas Rheinhardt 63a4cadd27 libavformat/nutenc: Remove redundant function parameter
calculate_checksum in put_packet() is always 1.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-05 18:47:52 +02:00
Andreas Rheinhardt a4a98f15b2 avformat/nutenc: Drop redundant frees
Should writing the header fail, the allocations already performed will
be freed during deinit so remove the frees in nut_write_header().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-03-14 22:07:27 +01:00
Marton Balint 4bf90e095b avformat: remove avio_flush() calls from the end of write_header functions
To make it consistent with other muxers.

The user can still control the generic flushing behaviour after write_header
(same way as after packets) using the -flush_packets option, the default
typically means to flush unless a non-streamed file output is used.

Therefore this change should have no adverse effect on streaming, even if it is
assumed that the first packet has a clean buffer, so small seekbacks within the
output buffer work even when the IO context is not seekable.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-07 21:51:45 +01:00
Michael Niedermayer e4fdeb3fce avformat/nutenc: Do not pass NULL to memcmp() in get_needed_flags()
This compared to the other suggestions is cleaner and easier to understand
keeping the condition in the if() simple.

This affects alot of fate tests.

See: [FFmpeg-devel] [PATCH 05/11] avformat/nutenc: Don't pass NULL to memcmp
See: [FFmpeg-devel] [PATCH]lavf/nutenc: Do not call memcmp() with NULL argument

Fixes: Ticket 7980

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-05 21:21:59 +01:00
James Almer 90e37adab7 avformat/nutenc: free all missing dynamic AVIOContext on header writing failure
Fixes part of ticket #8316

Signed-off-by: James Almer <jamrial@gmail.com>
2019-10-19 14:42:23 -03:00
James Almer 1d479300cb avformat/nutenc: don't allocate a dynamic AVIOContext if no index is going to be written
Fixes ticket #8295

Signed-off-by: James Almer <jamrial@gmail.com>
2019-10-18 20:53:10 -03:00
Michael Niedermayer 3a95b73abc avformat/nutenc: Document trailer index assert better
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-12-16 09:49:07 +01:00
Clément Bœsch bb9fdd9f61 Merge commit '07eea5a5ded1141632aefecfa59dcdc26de2d7ea'
* commit '07eea5a5ded1141632aefecfa59dcdc26de2d7ea':
  nut: Drop pointless TRACE level debug code

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-24 13:21:04 +01:00
Diego Biurrun 07eea5a5de nut: Drop pointless TRACE level debug code
The code has little usefulness and uses the __PRETTY_FUNCTION__ GNU extension.
2016-10-27 12:54:07 +02:00
Derek Buitenhuis 6f69f7a8bf Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
  lavf: replace AVStream.codec with AVStream.codecpar

This has been a HUGE effort from:
    - Derek Buitenhuis <derek.buitenhuis@gmail.com>
    - Hendrik Leppkes <h.leppkes@gmail.com>
    - wm4 <nfxjfg@googlemail.com>
    - Clément Bœsch <clement@stupeflix.com>
    - James Almer <jamrial@gmail.com>
    - Michael Niedermayer <michael@niedermayer.cc>
    - Rostislav Pehlivanov <atomnuker@gmail.com>

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-10 20:59:55 +01:00
Marton Balint 28fbdece79 avformat: use ff_standardize_creation_time for formats writing all format string metadata
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-03-03 01:37:18 +01:00
Derek Buitenhuis 14a69ae60c Merge commit 'dc6527ed908e4d330738f139074455ffbe56a2de'
FATE tests have been updated to patch. They do not differ in
any meaningful way.

* commit 'dc6527ed908e4d330738f139074455ffbe56a2de':
  nutenc: do not use AVCodecContext.frame_size

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-29 15:29:43 +00:00
Anton Khirnov 9200514ad8 lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.

In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.

There are multiple important problems with this approach:
    - the fields in AVCodecContext are in general one of
        * stream parameters
        * codec options
        * codec state
      However, it's not clear which ones are which. It is consequently
      unclear which fields are a demuxer allowed to set or a muxer allowed to
      read. This leads to erratic behaviour depending on whether decoding or
      encoding is being performed or not (and whether it uses the AVStream
      embedded codec context).
    - various synchronization issues arising from the fact that the same
      context is used by several different APIs (muxers/demuxers,
      parsers, bitstream filters and encoders/decoders) simultaneously, with
      there being no clear rules for who can modify what and the different
      processes being typically delayed with respect to each other.
    - avformat_find_stream_info() making it necessary to support opening
      and closing a single codec context multiple times, thus
      complicating the semantics of freeing various allocated objects in the
      codec context.

Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2016-02-23 17:01:58 +01:00
Anton Khirnov dc6527ed90 nutenc: do not use AVCodecContext.frame_size
It will in general not be available. Use block_align if known or fall
back to av_get_audio_frame_duration().
2016-02-22 11:28:00 +01:00
Michael Niedermayer 56c182c4d7 avformat/nutenc: implement deinit()
Should prevent some leaks if header writing fails

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-21 13:16:24 +01:00
Clément Bœsch 43ecec0f03 avformat: use AV_OPT_TYPE_BOOL in a bunch of places 2015-12-04 15:43:33 +01:00
Luca Barbato 1e7ff5ac69 nut: Use the correct codec_tag when multiple are available
Some codecs use the codec_tag to signal specific information and
picking the first one would lead to a broken file.

Bug-Id: 883
CC: libav-stable@libav.org

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-11-02 12:10:38 +01:00
Ganesh Ajjanagadde 7c8fcbbde3 avutil/tree: add additional const qualifier to the comparator
libc's qsort comparator has a const qualifier on both arguments. This
adds a missing const qualifier to exactly match the comparator API.

Existing usages of av_tree_find, av_tree_insert are appropriately
modified: type signature changes of the comparators, and removal of
unnecessary void * casts of function pointers.

Reviewed-by: Henrik Gramner <henrik@gramner.com>
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-24 20:38:07 -04:00
Michael Niedermayer 7ec5115409 avformat/nutenc: Omit AV_PKT_DATA_QUALITY_STATS when storing side data.
This side data does not serve or improve decoding the data, it thus
would semantically be metadata and not side data.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-25 18:39:17 +02:00
Michael Niedermayer d66b623ad0 avformat/nutenc: Fix writing strings larger than 2gb
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-10 16:26:58 +02:00
Michael Niedermayer 7f03f75ce7 Merge commit '8e32b1f0963d01d4f5d4803eb721f162e0d58d9a'
* commit '8e32b1f0963d01d4f5d4803eb721f162e0d58d9a':
  libavformat: Use ffio_free_dyn_buf where applicable

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-25 00:48:50 +01:00
Martin Storsjö 8e32b1f096 libavformat: Use ffio_free_dyn_buf where applicable
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 23:07:47 +02:00
Timothy Gu 510b39c213 nutdec: Remove unused variables
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-06 20:44:36 +01:00
Michael Niedermayer b44456c908 Merge commit '80a11de7dca315505bf203ce9c8c016e71724fd2'
* commit '80a11de7dca315505bf203ce9c8c016e71724fd2':
  nutenc: do not use has_b_frames

Conflicts:
	libavformat/nutenc.c
	tests/ref/lavf/nut
	tests/ref/seek/lavf-nut

Mostly not merged, this is simply not correct

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-27 17:52:06 +01:00
Anton Khirnov 80a11de7dc nutenc: do not use has_b_frames
It is unreliable, especially when the stream codec context is not the
encoding context. Use the codec descriptor properties instead.
2015-01-27 09:15:07 +01:00
Michael Niedermayer 3b537eab27 avformat/nutenc: store the actual r_frame_rate in the corresponding field if available
Fixes Ticket 3629 part3

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-14 02:12:49 +01:00
Michael Niedermayer dd3f1563d7 Merge commit 'b69183f65d0f6f4cd7a4e6c0deb57d59b0185aba'
* commit 'b69183f65d0f6f4cd7a4e6c0deb57d59b0185aba':
  nutenc: check for negative index rather than assert

Conflicts:
	libavformat/nutenc.c

Not merged, the assert is correct

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-22 00:09:00 +02:00
Vittorio Giovara b69183f65d nutenc: check for negative index rather than assert
CC: libav-stable@libav.org
Bug-Id: CID 703721
2014-10-21 14:37:48 +01:00
Michael Niedermayer 2d70282254 Merge commit 'd754ed41727b1fcbab335b510248a9758a73320c'
* commit 'd754ed41727b1fcbab335b510248a9758a73320c':
  riffenc: take an AVStream instead of an AVCodecContext

Conflicts:
	libavformat/nutenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-18 17:47:12 +02:00