Commit Graph

207 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
Marton Balint
98f6c59f4f avformat/electronicarts: add option to return alpha channel in the main video stream in VP6A codec
VP6 alpha in EA format is a second VP6 encoded video stream where only the Y
component is used and is interpreted as the alpha channel of the first VP6
stream. The alpha VP6 stream is muxed separately from the main VP6 stream, has
its own stream headers and packet headers. In theory the two streams might not
even have the same resolution (although most likely that is not something that
is seen or supported in the wild), but the format is capable of doing it.

Merged VP6 alpha (also known as the VP6A codec) means that a packet of the
video stream contains the corresponding packet of both VP6 substreams like
this:

{OffsetOfAlpha, DataPacket, AlphaDataPacket}

So data and alpha data of a frame is merged to a single packet, this is how VP6
video with alpha is muxed in FLV and SWF.

The first approach is more like how the demuxer sees data in the EA format,
unfortunately it is different to what the FLV or SWF format expects, so -
having no better place for it in the framework - I decided to do an optional
format conversion in the EA demuxer.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-11-22 22:59:51 +01:00
Marton Balint
bd5ea78556 avformat/electronicarts: set packet_read in one place
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-11-22 22:54:27 +01:00
Marton Balint
29d1d3e2e8 avformat/electronicarts: fix EOF check
Similar to feof(), avio_feof() is only true after an actual overread.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-11-22 22:54:27 +01:00
Vittorio Giovara
c2e7f5b285 electronicarts: 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:32 -03: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
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
Michael Niedermayer
59bb9dc2a6 avformat/electronicarts: Clear partial_packet on error
Fixes: Infinite loop
Fixes: 30165/clusterfuzz-testcase-minimized-ffmpeg_dem_EA_fuzzer-6224642371092480

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-02-12 23:42:16 +01:00
Michael Niedermayer
d03f0ec9a1 avformat/electronicarts: More chunk_size checks
Fixes: Timeout
Fixes: 26909/clusterfuzz-testcase-minimized-ffmpeg_dem_EA_fuzzer-6489496553783296

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-01-29 19:36:46 +01:00
Michael Niedermayer
857aba7c45 avformat/electronicarts: Check for EOF in each iteration of the loop in ea_read_packet()
Fixes: timeout(>20sec -> 1ms)
Fixes: 26526/clusterfuzz-testcase-minimized-ffmpeg_dem_EA_fuzzer-5672328069120000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-25 09:05:01 +01:00
Michael Niedermayer
6a2df7ca26 avformat/electronicarts: change non failure return of read_header() to 0
This matches the documentation, but makes no functional difference

Found-by: James Almer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-08 00:06:53 +02:00
Michael Niedermayer
39a98623ed avformat/electronicarts: Check if there are any streams
Fixes: Assertion failure (invalid stream index)
Fixes: 25120/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6565251898933248

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-07 23:05:25 +02:00
Andreas Rheinhardt
6a67d518d6 avformat: Remove unnecessary av_packet_unref()
Since bae8844e the packet will always be unreferenced when a demuxer
returns an error, so that a lot of calls to av_packet_unref() in lots of
demuxers are now redundant and can be removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-02-10 22:41:38 +01:00
Michael Niedermayer
c4de49edc4 avformat/electronicarts: If no packet has been read at the end do not treat it as if theres a packet
Fixes: Assertion failure
Fixes: 17770/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5700606668308480

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-01 22:16:20 +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
Andreas Cadhalpun
8812d047bc electronicarts: prevent overflow during block alignment calculation
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2017-01-29 01:20:52 +01:00
Andreas Cadhalpun
ad5807f8aa avformat: fix overflows during bit rate calculation
The bit_rate field has type int64_t since commit
7404f3bdb9.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-12-14 01:06:55 +01:00
Clément Bœsch
8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00
Vittorio Giovara
41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +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
c2f861ca42 Replace remaining occurances of av_free_packet with av_packet_unref 2015-10-27 14:35:30 +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
Peter Ross
cdfc61de4e libavformat/electronicarts: also demux mpeg audio layer 2
Signed-off-by: Peter Ross <pross@xvid.org>

http://wiki.multimedia.cx/index.php?title=Electronic_Arts_SCxl
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-22 12:08:05 +02:00
Paul B Mahol
6debfce6a3 avformat/electronicarts: fix demuxing of certain eam files
Such files have gaps between header chunks.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-10-22 11:01:00 +02:00
Paul B Mahol
0d7c027483 avformat/electronicarts: support ADPCM PSX
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-10-22 11:01:00 +02:00
Peter Ross
803bdc5469 electronicarts: demux alpha stream
Electronic Arts VP6 files may contain two video streams: one for the
primary video stream and another for the alpha mask. The file format
uses identical data structures for both streams.

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-25 12:45:09 +02:00
Peter Ross
a2517fca1e electronicarts: move video stream properties into dedicated structure
This is required for the alpha stream demux patch.

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-25 12:45:00 +02:00
Stephan Vedder
b368428fc0 avformat/electronicarts: Fixed ea_probe function to accept vp6a videos
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-23 03:34:33 +02:00
Paul B Mahol
6dfa70f272 Correct few "ffmpeg" typos
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2014-08-24 11:05:42 +00:00
Michael Niedermayer
3e07a056a8 Merge commit 'cb7b1a2dfb547ab78342a7a9d5cd729d77d90421'
* commit 'cb7b1a2dfb547ab78342a7a9d5cd729d77d90421':
  electronicarts: set the framerate for TGQ/TQI

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-22 21:00:06 +02:00
Michael Niedermayer
ce1059d5c9 Merge commit '7b6aae23e12f41cdfac7f1069debfe44d9a3d136'
* commit '7b6aae23e12f41cdfac7f1069debfe44d9a3d136':
  electronicarts: read the framerate for MAD

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-22 20:50:16 +02:00
Michael Niedermayer
350dd85345 Merge commit '4d6c5152849e23a4cc0f6a6ac2880c01ebcd301b'
* commit '4d6c5152849e23a4cc0f6a6ac2880c01ebcd301b':
  electronicarts: do not fail on zero-sized chunks

Conflicts:
	libavformat/electronicarts.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-22 19:01:26 +02:00
Anton Khirnov
cb7b1a2dfb electronicarts: set the framerate for TGQ/TQI
It is hardcoded to 15fps.
2014-08-22 11:15:20 +00:00
Anton Khirnov
7b6aae23e1 electronicarts: read the framerate for MAD 2014-08-22 11:15:20 +00:00
Anton Khirnov
4d6c515284 electronicarts: do not fail on zero-sized chunks
At least one FATE sample contains such chunks and happens to work simply
by accident (due to find_stream_info() swallowing the error).

CC: libav-stable@libav.org
2014-08-22 11:15:20 +00:00
James Almer
d34ec64a22 replace calls to url_feof() with avio_feof()
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-08 00:48:38 +02:00
Michael Niedermayer
28ee7757f5 Merge commit 'd92024f18fa3d69937cb2575f3a8bf973df02430'
* commit 'd92024f18fa3d69937cb2575f3a8bf973df02430':
  lavf: more correct printf format specifiers

Conflicts:
	libavformat/asfdec.c
	libavformat/cafdec.c
	libavformat/dxa.c
	libavformat/framecrcenc.c
	libavformat/hnm.c
	libavformat/iff.c
	libavformat/mov.c
	libavformat/mxfdec.c
	libavformat/rmdec.c
	libavformat/rpl.c
	libavformat/smacker.c
	libavformat/xmv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-11 21:05:34 +01:00
Diego Biurrun
d92024f18f lavf: more correct printf format specifiers 2014-03-11 13:13:41 +01:00
Michael Niedermayer
55328d5f72 avformat/electronicarts: detect endianness by comparing sizes instead of using an arbitrary threshold
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-21 14:09:45 +01:00
Michael Niedermayer
587e3c3426 avformat/electronicarts: use 64bit variable for avio_tell() result
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-21 13:48:15 +01:00
Michael Niedermayer
f9b89b61f8 avformat/electronicarts: check chunksize more completely in probe()
Fixes probetest failure

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-11 21:31:56 +01:00
Michael Niedermayer
20769d9349 avformat/electronicarts: check chunk size.
Fix infinite loop

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-11 19:51:12 +01:00
Michael Niedermayer
7057cc861d Merge commit 'a9221e39600a31ee13e736e9e47743cde23f0280'
* commit 'a9221e39600a31ee13e736e9e47743cde23f0280':
  electronicarts: Add more sanity checking for the number of channels

Note: This check is probably unnecessary
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-29 23:52:07 +02:00
Martin Storsjö
a9221e3960 electronicarts: Add more sanity checking for the number of channels
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-09-29 19:58:41 +03:00
Michael Niedermayer
eeeb3c8fa3 Merge commit 'f7e616959aff8706edccdae763c24c897c449f6f'
* commit 'f7e616959aff8706edccdae763c24c897c449f6f':
  electronicarts: Check packet sizes before reading

Conflicts:
	libavformat/electronicarts.c

See: fb1ea777b3
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-23 14:27:09 +02:00