Commit Graph

283 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
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
Michael Niedermayer ba0c3d1db4 avformat/avienc: Check video dimensions
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-07-12 21:55:22 +02:00
Andreas Rheinhardt 533836b8e0 avformat/utils: Move ff_get_packet_palette() to rawutils.c
ff_get_packet_palette() and ff_reshuffle_raw_rgb() belong together:
E.g. the former takes the return value of the latter as argument.
So move ff_get_packet_palette() to rawutils.c (which consists solely
of ff_reshuffle_raw_rgb()).
Also add a separate header for these two functions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:29:32 +02:00
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 3d53cefb49 avcodec/raw: Reduce number of avpriv symbols
libavcodec currently exports four avpriv symbols that deal with
PixelFormatTags: avpriv_get_raw_pix_fmt_tags, avpriv_find_pix_fmt,
avpriv_pix_fmt_bps_avi and avpriv_pix_fmt_bps_mov. The latter two are
lists of PixelFormatTags, the former returns such a list and the second
searches a list for a pixel format that matches a given fourcc; only
one of the aforementioned three lists is ever searched.

Yet for avpriv_pix_fmt_bps_avi, avpriv_pix_fmt_bps_mov and
avpriv_find_pix_fmt the overhead of exporting these functions actually
exceeds the size of said objects (at least for ELF; the following numbers
are for x64 Ubuntu 20.10):
The code size of avpriv_find_pix_fmt is small (GCC 10.2 37B, Clang 11 41B),
yet exporting it adds a 20B string for the name alone to the exporting
as well as to each importing library; there is more: Four bytes in the
exporting libraries .gnu.hash; two bytes each for the exporting as well
as each importing libraries .gnu.version; 24B in the exporting as well
as each importing libraries .dynsym; 16B+24B for an entry in .plt as
well as the accompanying relocation entry in .rela.plt for each
importing library.

The overhead for the lists is similar: The strings are 23B and the
.plt+.rela.plt pair is replaced by 8B+24B for an entry in .got and
a relocation entry in .rela.dyn. These lists have a size of 80 resp.
72 bytes.

Yet for ff_raw_pix_fmt_tags, exporting it is advantageous compared to
duplicating it into libavformat and potentially libavdevice. Therefore
this commit replaces all library uses of the four symbols with a single
function that is exported for shared builds. It has an enum parameter
to choose the desired list besides the parameter for the fourcc. New
lists can be supported with new enum values.

Unfortunately, avpriv_get_raw_pix_fmt_tags could not be removed, as the
fourcc2pixfmt tool uses the table of raw pix fmts. No other user of this
function remains.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:16:49 +01:00
Andreas Rheinhardt f660b8d1de avformat/avienc: Avoid allocating AVPacket
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-03 20:56:12 +02:00
Andreas Rheinhardt 5eafbf0b08 avformat/avienc: Simplify writing padding
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:59 +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
James Almer 9e92fd97d0 avformat/avienc: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-17 15:06:48 -03:00
Andreas Rheinhardt 09e6d3a026 avformat/avienc, wtvenc: Deduplicate codec tags list
Also saves relocations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-23 11:30:57 +01:00
Gyan Doshi 1ec2b3de5a avformat/riffenc: indicate storage of flipped RGB bitmaps
Some legacy applications such as AVI2MVE expect raw RGB bitmaps
to be stored bottom-up, whereas our RIFF BITMAPINFOHEADER assumes
they are always stored top-down and thus write a negative value
for height. This can prevent reading of these files.

Option flipped_raw_rgb added to AVI and Matroska muxers
which will write positive value for height when enabled.

Note that the user has to flip the bitmaps beforehand using other
means such as the vflip filter.
2020-07-15 20:52:01 +05:30
Andreas Rheinhardt b49af89e03 avformat/avienc: Use AV_STRINGIFY for compile time constant
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
Michael Niedermayer 3595878281 libavformat/avienc: Check bits per sample for PAL8
Fixes: assertion failure
Fixes: Ticket 8172

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-02-27 18:26:25 +01:00
Marton Balint f4a8ea7ff6 avformat: remove more unneeded avio_flush() calls
These instances are simply redundant or present because avio_flush() used to be
required before doing a seekback. That is no longer the case, aviobuf code does
the flush automatically on seek.

This only affects code which is either disabled for streaming IO contexts or
does no seekbacks after the flush, so this change should have no adverse effect
on streaming.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-07 21:51:45 +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
Andreas Rheinhardt b78227e168 avformat/avienc: Remove superfluous header
04d2540c added intreadwrite.h to avienc.c, although there was (and is)
no need to do so. The inclusion seems to be a mistake as this commit
added a AV_WL32 to avidec.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-25 23:27:02 +02:00
James Almer a581bb66ea avformat/avienc: add deinit function
Fixes ticket #8302

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-10-21 17:20:20 -03:00
Tobias Rapp 26c0c84784 avformat/avienc: fix fields-per-frame value for interlaced video streams
Writes one set of field framing information for progressive streams and
two sets for interlaced streams. Fixes ticket #6383.

Unfortunately the OpenDML v1.02 document is not very specific on what
value to use for start_line when frame data is not coming from a
capturing device, so this is just using 0/1 depending on the field order
as a best-effort guess.

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2017-11-27 09:13:05 +01:00
Aleksandr Slobodeniuk 0aa8fa963f avformat/riff.h : remove unused function parameter "const AVCodecTag *tags" of "void ff_put_bmp_header()"
Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-02 15:26:25 +02:00
Tobias Rapp 8bf9572e9a avformat: remove obsolete commented-out DEBUG define
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2017-07-07 11:57:39 -04:00
Clément Bœsch e3287077ec Merge commit '67deba8a416d818f3d95aef0aa916589090396e2'
* commit '67deba8a416d818f3d95aef0aa916589090396e2':
  Use avpriv_report_missing_feature() where appropriate

Merged-by: Clément Bœsch <cboesch@gopro.com>
2017-03-31 10:40:34 +02:00
James Almer 4de591e6fb Merge commit '83548fe894cdb455cc127f754d09905b6d23c173'
* commit '83548fe894cdb455cc127f754d09905b6d23c173':
  lavf: fix usage of AVIOContext.seekable

Merged-by: James Almer <jamrial@gmail.com>
2017-03-21 17:02:30 -03:00
Tobias Rapp e65db4ce59 avformat/avienc: add reserve_index_space option
Allows the user to reserve space for the ODML master index. A sufficient
sized master index in the AVI header avoids storing follow-up master
indexes within the 'movi' data later. If the option is omitted or zero
the index size is estimated from output duration and bitrate.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2017-01-31 09:00:23 +01:00
Diego Biurrun 67deba8a41 Use avpriv_report_missing_feature() where appropriate 2016-11-08 17:54:34 +01:00
Anton Khirnov 83548fe894 lavf: fix usage of AVIOContext.seekable
It is supposed to be a flag. The only currently defined value is
AVIO_SEEKABLE_NORMAL, but other ones may be added in the future.
However all the current lavf code treats this field as a bool (mainly
for historical reasons).
Change all those cases to properly check for AVIO_SEEKABLE_NORMAL.
2016-09-30 16:54:33 +02:00
James Almer 1582e306a4 avformat/avlanguage: make av_convert_lang_to() internal
The header was never installed and the function is only used in libavformat

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-07-19 21:43:14 -03:00
Michael Niedermayer 9d5894b239 avformat/avienc: Fix memleaks on errors
Fixes CID1361951

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-22 02:14:33 +02:00
Michael Niedermayer ea88dc3e8e avformat/avienc: Rename reshuffles return variable to ensure it is not mixed up
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-22 02:14:33 +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
Mats Peterson bdc798cc8d lavf/avienc: Clear whole tag in avi_add_ientry()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-13 16:26:39 +01:00
Mats Peterson 77bc3e1944 lavf/avienc: Add xxpc entries to index
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-13 16:06:09 +01:00
Mats Peterson 9ee5b40964 avformat/avienc: factor out avi_add_ientry()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-13 16:06:09 +01:00
Mats Peterson e1aa88dc09 lavf/avienc: Palette changing code only concerns AV_PIX_FMT_PAL8
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-08 15:33:17 +01:00
Michael Niedermayer 40aeff5f02 avformat/avienc: Remove unneeded seekable tests
Reviewed-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-06 12:21:02 +01:00
Michael Niedermayer e0f5f9267a avformat/avienc: assert that bits_per_coded_sample is within the supported range (out of array access otherwise)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-05 18:18:07 +01:00
Mats Peterson 2df0bbaca5 lavf/avienc: Add support for palette side data
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-05 18:05:47 +01: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
Michael Niedermayer bb629792a2 avformat/avienc: Fix assertion failure with 256 palette entries
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-21 03:30:50 +01:00
Mats Peterson a51d82b85c lavf/avienc: Add palette after BITMAPINFOHEADER
lavf/riffenc: Write space for palette
tests/ref/vsynth: Update 1 bpp files for pal8

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-21 03:30:50 +01:00
Reto Kromer f8d685270e avienc: Remove unused variable 'ret'
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
2016-02-20 15:45:28 -08:00
Michael Niedermayer 7ac962af38 avformat/avienc: Store pal8 palette
This can be made more efficient, but first and the main goal of this change is to
store it at all

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-19 15:47:33 +01:00
Michael Niedermayer 9dd4dcde9c avformat/avienc: Use avi_write_packet_internal() to store raw rgb in a more spec compliant way
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-18 21:26:50 +01:00
Michael Niedermayer 07c7e71d20 avformat/avienc: Split avi_write_packet_internal() out
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-18 14:40:06 +01:00
Tobias Rapp 1416370027 avformat/avienc: add muxer option "write_channel_mask"
Allow writing an empty channel mask into the wave format header. Useful
if the input file contains an unknown channel layout.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-12 14:39:28 +02:00
Ronald S. Bultje 229843aa35 Replace av_dlog with ff_dlog.
ff_dlog checks compilability, and is non-public. av_dlog is deprecated
and no longer exists if FF_API_DLOG=0.
2015-08-18 10:24:01 -04:00
Roman Savchenko e85d91da48 avformat/avienc: Correct possible dereference of null
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-29 00:04:41 +02:00
Michael Niedermayer 17264cd281 avformat/avienc: Avoid float usage
reduces risk for rounding differences between platforms

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-23 23:42:51 +02:00