Commit Graph

119 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
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
Andreas Rheinhardt f104352b91 avformat/utils: Move ff_add_param_change to demux_utils.c
Only demuxers have a need to add side-data to a packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:42:46 +02:00
Vittorio Giovara 9ff843eb4a swf: 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:37 -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
Carl Eugen Hoyos 9f8c81efc5 lavf/swfdec: Allow decoding Nellymoser in swf.
Such files exist in the wild, see ticket #9153.
2021-03-20 18:52:55 +01:00
Michael Niedermayer 1957095e80 avformat/swfdec: Check outlen before allocation
Fixes: Timeout (too long -> 241ms)
Fixes: 29083/clusterfuzz-testcase-minimized-ffmpeg_dem_SWF_fuzzer-6273684478230528

The source of the magic number is
A very quick simulation of the best case compression for "compress"
below is not nice written code as i did not expect I or anyone else
would ever see it again

I would have preferred some nicer expression or course, but thats
what it seems to be asymptotically. For smaller amounts of data a
tighter bound is possible but i saw no nice way to consider that
and it seems also overkill to try to do it more fine grained for
just this

main(){
    int64_t bits = 0;
    int bank = 256;
    int bitbank = 8;
    for(unsigned i = 0; i<1024*1024*1024*4U-100000;) {
        int word_size = bank-255;
        i += word_size;
        bits += bitbank;

        if (!(bank & (bank-1)))
            bitbank ++;
        bank++;
        if (bitbank > 16) {
            printf("BEST %f \n", 8.0 * i / bits );
            bank = 256;
            bitbank = 8;
        }
    }
}

above assumes i remembered correctly how the algorithm works but the
value was close to what actual compession of zeros gave

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-08 22:08:49 +01:00
Marton Balint daac7f4d9c avformat/swf: add support for reading and writing VP6A and Flash Screen Video codecs
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-23 20:10:05 +01:00
Michael Niedermayer aea8d4061d avformat/swfdec: Allocate output buffer after reading input
Fixes: Timeout (>10sec -> 0.26sec)
Fixes: 27419/clusterfuzz-testcase-minimized-ffmpeg_dem_SWF_fuzzer-5678307361947648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-12-24 15:25:00 +01:00
Anton Khirnov 456b170bd7 lavf: move AVStream.{*skip_samples.*_discard_sample} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 14:56:20 +01:00
Andreas Rheinhardt 3f04c30372 avformat/swfdec: Reorder allocations/initializations
The earlier code would first attempt to allocate two buffers, then
attempt to allocate an AVIOContext, using one of the new buffers I/O
buffer, then check the allocations. On success, a z_stream that is used
in the AVIOContext's read_packet callback is initialized afterwards.

There are two problems with this: In case the allocation of the I/O
buffer fails avio_alloc_context() will be given a NULL read buffer
with a size > 0. This works right now, but it is fragile. The second
problem is that the z_stream used in the read_packet callback is not
functional when avio_alloc_context() is allocated (it might be that
avio_alloc_context() might already fill the buffer in the future). This
commit fixes both of these problems by reordering the operations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-23 17:09:01 +02:00
Andreas Rheinhardt 28dc0c20cc avformat/swfdec: Fix memleaks on error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-23 17:09:01 +02:00
Andreas Rheinhardt 913aa4204a avformat/swf: Separate mux and demux contexts
There was almost no overlap between them: The only field used by both
was an int named samples_per_frame. Therefore this commit separates
them.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-20 18:34:48 +02:00
Andreas Rheinhardt ef29e5bf42 avformat/swfdec: Avoid unnecessary skip
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-20 11:14:26 +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
Steven Liu 70c6e84069 avformat/swfdec: fix memleak when inflateInit failed
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-10-28 14:26:20 +08: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 7652af9df0 lavf/swfdec: Reduce score when auto-detecting swf files.
Not more than 32bit are tested.
2018-01-20 15:41:40 +01:00
Anton Khirnov 78a7af823b Use the new AVIOContext destructor.
(cherry picked from commit 6f554521af)
Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-01 02:16:33 -03:00
Moritz Barsnick 468c596a31 lavf: fix typos
Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-09 20:09:00 +02:00
Michael Niedermayer d7633ed7a5 avformat/swfdec: Fix memleak on error
Fixes: 9eb9cf5b8c26dd0fa7107ed0348dcc1f/signal_sigabrt_7ffff6ae7c37_8925_1f676b5229d009f2b56dfd9e149fa6ba.swf

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-22 01:29:51 +02:00
Michael Niedermayer a453bbb68f avformat/swfdec: Fix inflate() error code check
Fixes infinite loop
Fixes endless.poc

Found-by: 连一汉 <lianyihan@360.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-19 11:00:02 +02:00
Michael Niedermayer 2a3720bc22 avformat/swfdec: Move packet size check before side data allocation
Fixes memleak
Fixes: 9eb9cf5b8c26dd0fa7107ed0348dcc1f/signal_sigabrt_7ffff6ae7c37_8927_f14c2a6ae1ad0bbde2c94f1da50e7074.swf

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-19 03:05:52 +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 e816fe7401 Merge commit '7570c9e04f010c9b3bfdeb4338d330f2cdd25278'
* commit '7570c9e04f010c9b3bfdeb4338d330f2cdd25278':
  swfdec: support compressed swf

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-01-19 08:58:55 +01:00
Clément Bœsch 7570c9e04f swfdec: support compressed swf
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-01-11 15:32:56 -05:00
Hendrik Leppkes c2f861ca42 Replace remaining occurances of av_free_packet with av_packet_unref 2015-10-27 14:35:30 +01:00
Michael Niedermayer bd70303ead avformat/swfdec: Check return value of init_get_bits8()
Fixes: CID1322320

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-03 10:20:29 +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
Carl Eugen Hoyos 128e722bc1 lavf/swf: Fix auto-detection of compressed files.
Fixes auto-detection of compressed swf files as in
http://samples.ffmpeg.org/SWF/compressed-swf/
Reported by forum user Zard1096.
2015-08-04 21:34:00 +02:00
Michael Niedermayer 656e9a68c4 avformat/swfdec: Fix "}else" style
Found-by: durandal_170
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-08 12:06:17 +02:00
Michael Niedermayer 6a1204a1a4 avformat/swfdec: Do not error out on pixel format changes
Instead print an error and continue

Fixes Ticket4702

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-08 02:43:02 +02:00
Michael Niedermayer b7e506b3b9 avformat/swfdec: Check frame size rectangle in probe()
fixes probetest failure

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-21 21:10:20 +01:00
Michael Niedermayer c2430304df avformat/swfdec: Do not change the pixel format
This is currently not supported
Fixes part of Ticket 3539

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-07 00:39:52 +02:00
Michael Niedermayer 1c55d0ff32 avformat/swfdec: Use side data to communicate w/h changes to the decoder
Fixes reading from freed data
Fixes part of Ticket3539

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-02 13:37:07 +02: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 f5d039840a avformat/swfdec: clear 4 bytes at the end of a packet if they are not initialized
Fixes use of uninitialized memory
Fixes part of msan_uninit-mem_7f055dd0ab1b_9558_videopop_guitar_300k.swf
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-19 05:07:22 +01:00
Michael Niedermayer e72f5abbc6 avformat/swfdec: check avio_read() return code
Fixes use of uninitialized memory
Fixes part of msan_uninit-mem_7f055dd0ab1b_9558_videopop_guitar_300k.swf
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-19 05:07:13 +01:00
Michael Niedermayer fde74d1b9d avformat/swfdec: check avio_read() return code
Fixes use of uninitialized memory
Fixes msan_uninit-mem_7f90d9cce964_9558_videopop_guitar_300k.swf
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-19 01:49:07 +01:00
Michael Niedermayer 9225ebd50d avformat/swfdec: return AVPROBE_SCORE_MAX / 4 for unexpected versions
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-10 13:25:35 +01:00
Michael Niedermayer ff1d81b08c avformat/swfdec: check version and size during probing
Fixes probetest failure

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-06 12:44:02 +01:00
Clément Bœsch 580e228557 lavf/swfdec: remove 8-bit audio FIXME.
Implemented since 624fb5f9.
2013-02-21 00:59:31 +01:00
Clément Bœsch 624fb5f965 lavf/swfdec: support 8-bits PCM audio. 2013-02-20 21:49:23 +01:00
Clément Bœsch 9a0076f50c lavf/swfdec: factorize the creation of a new stream.
This also makes the changes of a3949fe11 applicable in both cases.
2013-02-20 21:49:23 +01:00
Michael Niedermayer 8dbc384f15 Merge commit 'd04c17c91363a6b15d1ac2d79c817f3d5e2998b3'
* commit 'd04c17c91363a6b15d1ac2d79c817f3d5e2998b3':
  swfdec: cosmetics: fix indentation

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-12 10:16:23 +01:00
Michael Niedermayer d276f28b7d swfdec: print warning when len is cliped
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-12 10:14:06 +01:00
Michael Niedermayer be5389d585 Merge commit 'e70c5b034c4787377e82cab2d5565486baec0c2a'
* commit 'e70c5b034c4787377e82cab2d5565486baec0c2a':
  swfdec: do better validation of tag length
  Make LOCAL_ALIGNED syntactically similar on all systems

Conflicts:
	libavformat/swfdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-12 09:55:56 +01:00