Commit Graph

121 Commits

Author SHA1 Message Date
Andreas Rheinhardt b800327f4c avformat/avformat: Add FFInputFormat, hide internals of AVInputFormat
This commit does for AVInputFormat what commit
59c9dc82f4 did for AVOutputFormat:
It adds a new type FFInputFormat, moves all the internals
of AVInputFormat to it and adds a now reduced AVInputFormat
as first member.

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

This is possible since 50f34172e0
(which removed the last usage of an internal field of AVInputFormat
in fftools).

(Hint: tools/probetest.c accesses the internals of FFInputFormat
as well, but given that it is a testing tool this is not considered
a problem.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-07 08:53:31 -03: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 dda471bd85 avformat/rawdec: Don't include avcodec.h
Possible since 2850584876.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-05 09:40:06 +02:00
Anton Khirnov 2850584876 lavf/rawdec: stop setting codec context framerate
Demuxers are not supposed to do this.
2023-05-05 14:49:40 +02:00
Anton Khirnov ba4b73c977 lavf/rawdec: set avg_frame_rate
Timestamps in two FATE H.264 conformance tests now start at 1 instead
of 0, which also happens in some other H.264 tests before this commit
and so is not a big issue.
Conversely, timestamps in some HEVC conformance tests start from a
smaller value now.
Ideally this should be addressed later in a more general way.

h264-conformance-frext-frext2_panasonic_b no longer requires -vsync
passthrough.
2023-04-13 15:34:07 +02:00
Andreas Rheinhardt 2b41463b87 avformat/internal: Don't include avcodec.h
The general demuxing API uses parsers and decoders. Therefore
FFStream contains pointers to AVCodecContexts and
AVCodecParserContext and lavf/internal.h includes lavc/avcodec.h.

Yet actually only a few files files really use these; and it is best
when this number stays small. Therefore this commit uses opaque
structs in lavf/internal.h for these contexts and stops including
avcodec.h.
This also avoids including lavc/codec_desc.h implicitly. All other
headers are implicitly included as now (mostly through codec.h).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-26 03:02:50 +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 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 cd3d7b0f8f avformat/rawdec: Make ff_raw_data_read_header() static
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-08 22:59:14 +02:00
Andreas Rheinhardt 2934a4b9a5 Remove unnecessary avassert.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:30 +02:00
Andreas Rheinhardt 7ca0931fe1 avformat/rawdec: Deduplicate AVClasses based upon ff_rawvideo_options
The child_class_next API relied on different (de)muxers to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 16:03:18 +02:00
Andreas Rheinhardt 6a055bf036 avformat/rawdec: Deduplicate AVClasses based upon ff_raw_options
The child_class_next API relied on different (de)muxers to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 16:03:18 +02:00
James Almer b9c5fdf602 avformat: move AVStream.{parser,need_parsing} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-05-07 09:27:21 -03: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
Carl Eugen Hoyos 7ab5192260 lavf/rawdec: Return a low score if the mjpeg probe function detected one frame.
Fixes ticket #9026.
2020-12-11 00:23:41 +01:00
Michael Niedermayer 71a822fa35 avformat/rawdec: fix identifier names
Fixes: out of array access
Fixes: 22686/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5121369624018944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-06-06 00:25:00 +02:00
Andreas Rheinhardt c1e439d7e9 avformat: Forward errors where possible
It is not uncommon to find code where the caller thinks to know better
what the return value should be than the callee. E.g. something like
"if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit
changes several instances of this to instead forward the actual error.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-12 19:25:33 +01:00
Michael Niedermayer f6d1b18b3d avformat/rawdec: Make the raw packet size configurable
This allows testing parsers with a wider range of input packet sizes.
Which is important and usefull for regression testing, some of our
parsers in fact to not work if the packet size is changed from 1024

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-07-17 23:18:50 +02:00
Carl Eugen Hoyos 4d8875ec23 lavf: Constify the probe function argument.
Reviewed-by: Lauri Kasanen
Reviewed-by: Tomas Härdin
2019-03-21 11:42:17 +01:00
Carl Eugen Hoyos 271a00043e lavf/rawdec: Do not mark streams from raw subtitle demuxers as data streams.
Improves "ffmpeg -i" output for raw dvbsub files.
2018-11-28 22:51:37 +01:00
Carl Eugen Hoyos 251f0bcb7b lavf/rawdec: Also probe the last byte of mjpeg streams.
Fixes ticket #6957.
2018-01-21 03:46:40 +01:00
wm4 5d76674756 lavf: make avio_read_partial() public
Main use-case is proxying avio through a foreign I/O layer and a custom
AVIO context, without losing latency and performance characteristics.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>

Merged from Libav commit 173b56218f.
2017-09-01 17:56:33 +02:00
Michael Niedermayer 4888932c4d avformat: Fix max value of AV_OPT_TYPE_VIDEO_RATE
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-09 10:35:13 +02:00
Michael Niedermayer a2e6c785ce avformat/rawdec: Fix avg_framerate for h264
The framerate is 25 which is a fixed default and is wrong undo the 1 line
change which caused this regression
Only the avg_frame rate setting is removed
The timebase update is not done as there was a objection (see ML)
Fixes Ticket 5444

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-07 14:08:13 +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
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
Hendrik Leppkes 7f5af80ba4 Merge commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457'
* commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457':
  avpacket: Replace av_free_packet with av_packet_unref

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-27 14:28:56 +01:00
Luca Barbato ce70f28a17 avpacket: Replace av_free_packet with av_packet_unref
`av_packet_unref` matches the AVFrame ref-counted API and can be used as
a drop in replacement.

Deprecate `av_free_packet`.
2015-10-26 18:00:55 +01:00
Carl Eugen Hoyos 2c2d1624a2 lavf: Remove duplicated latm demuxer.
The demuxer used to demux loas files for which a dedicated demuxer exists.
2015-10-15 01:11:17 +02:00
Carl Eugen Hoyos 1f2c474cb2 lavf/vc1dec: Autodetect raw vc-1 streams.
Move the demuxer into its own file.
2015-10-14 16:40:57 +02:00
Carl Eugen Hoyos 32a6d37a6b lavf/mlpdec: Simplify mlp/thd probe function.
Move the demuxers into their own file.
2015-10-03 22:40:27 +02:00
Carl Eugen Hoyos d89820002a lavf/shortendec: Autodetect raw Shorten streams.
Move the demuxer into its own file.
2015-10-03 21:48:16 +02:00
Carl Eugen Hoyos da767f06f5 lavf/rawdec: Autodetect raw TrueHD streams. 2015-10-02 03:15:04 +02:00
Carl Eugen Hoyos aea5db97f7 lavf/rawdec: Autodetect raw mlp streams. 2015-10-01 19:58:10 +02:00
wm4 4c6beaed92 rawdec: fix mjpeg probing buffer size check
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-30 00:06:15 +02:00
wm4 bf51fcd304 rawdec: fix mjpeg probing
There can be other headers than "Content-Type:" (in this case, a
"Content-Length:" header was following), so checking for a trailing
newline is wrong.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-29 23:50:46 +02:00
Vittorio Giovara 059a934806 lavc: Consistently prefix input buffer defines
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:59 +01:00
Michael Niedermayer dc265e2b6b avformat/rawdec: Make ff_raw_data_read_header() non static
This is similar to the raw video read header

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-05 01:45:49 +01:00
Luca Barbato 4f5906a1d7 latm: Do not give a score for a single instance
Bug-Id: 773
CC: libav-stable@libav.org
2014-12-07 13:15:03 +01:00
wm4 f41cf2e09e avformat/rawdec: raw formats have no timestamps
Some raw demuxers already had AVFMT_NOTIMESTAMPS set. Add it for all the
others.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-24 19:58:26 +01:00
Michael Niedermayer 2b37864e7f Merge commit '2d6e58497e76836604364b037df9b00ba3d75b69'
* commit '2d6e58497e76836604364b037df9b00ba3d75b69':
  lavf: switch to AVCodecContext.framerate for demuxing

Conflicts:
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-15 18:19:58 +02:00
Michael Niedermayer 0f0f626048 avformat/rawdec: Increase probe score when "Content-Type: image/jpeg" is found at the file start
Based-on code by: Carl Eugen Hoyos and Andrey Utkin
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-10 14:42:19 +02:00
Michael Niedermayer b45a451dbe avformat/rawdec: mark raw vc1 and mjpeg as having no timestamps
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-10 14:21:24 +02:00
Michael Niedermayer 2d3842f541 avformat: add mjpeg_probe()
Fixes Ticket3679

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-09 17:52:44 +02:00
Michael Niedermayer 4210cbf193 Merge commit 'f66d0c57b13c1b7102e1e353237af178960dd3c5'
* commit 'f66d0c57b13c1b7102e1e353237af178960dd3c5':
  latm: Add a probe function

Conflicts:
	libavformat/rawdec.c

See: 47818b2a67
See: 097f668047
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-04 00:19:35 +02:00
Luca Barbato f66d0c57b1 latm: Add a probe function 2014-05-03 18:51:17 +02:00
Nicolas George 276fcbde6c lavf: data muxer and demuxer.
Allow to use tools designed to work with demuxers, muxers
and packets (for example ffmpeg itself) to process raw byte
streams (like aviocat).
2013-05-01 11:56:34 +02:00
Paul B Mahol 4c76600a8c rawdec: make use of AV_OPT_TYPE_VIDEO_RATE
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-04-05 15:42:24 +00:00
Anton Khirnov 85a5bc054c lavf: remove disabled FF_API_R_FRAME_RATE cruft 2013-03-11 18:23:50 +01:00