1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

44 Commits

Author SHA1 Message Date
Andreas Rheinhardt
45bfe8b838 avformat/avio: Move internal AVIOContext fields to avio_internal.h
Currently AVIOContext's private fields are all over AVIOContext.
This commit moves them into a new structure in avio_internal.h instead.
Said structure contains the public AVIOContext as its first element
in order to avoid having to allocate a separate AVIOContextInternal
which is costly for those use cases where one just wants to access
an already existing buffer via the AVIOContext-API.
For these cases ffio_init_context() can't fail and always returned zero,
which was typically not checked. Therefore it has been made to not
return anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +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
Marton Balint
1490a682dc avformat/mpjpegdec: make sure we seek back to the ensured buffer
It was possible for the old code to seek back before the most recently read
data if start of a new multipart was across read boundaries. Now we read some
small sections multiple times to avoid this, but that is OK.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-09 21:07:18 +02:00
Andreas Rheinhardt
dd81f73946 avformat/mpjpegdec: Remove redundant initializations
The AVPacket destined for a demuxer's output has already been
initialized before it reaches the demuxer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-02-11 00:15:19 +01: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
Moritz Barsnick
f76a899abc avformat/mpjpegdec: ensure seekback for latest chunk
Not only the first, but each latest chunk must be cached to allow
seekback after finding the mime boundary.

Fixes trac #5023 and #5921.

Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-12 13:21:50 +02:00
Moritz Barsnick
1ea44a55fe avformat/mpjpegdec: fix strict boundary search string
According to RFC1341, the multipart boundary indicated by the
Content-Type header must be prepended by CRLF + "--", and followed
by CRLF. In the case of strict MIME header boundary handling, the
"--" was forgotten to add.

Fixes trac #7921.

A side effect is that this coincidentally breaks enforcement of
strict MIME headers against servers running motion < 3.4.1, where
the boundary announcement in the HTTP headers incorrectly used the
prefix "--", which exactly matched this bug's behavior.

Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-12 13:21:50 +02:00
Moritz Barsnick
a3846fe69b avformat/mpjpegdec: fix finding multipart boundary parameter
The string matching function's return value was evaluated incorrectly.

Fixes trac #7920.

Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-12 13:21:50 +02:00
Andreas Rheinhardt
670fd3b0ec avformat/mpjpegdec: Avoid allocation of AVIOContext
Put an AVIOContext whose lifetime doesn't extend beyond the function where
it is allocated on the stack instead of allocating and freeing it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-06 20:00:59 +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
Mark Thompson
e7c0b44e74 lavf/mpjpegdec: Mark local variable static 2018-06-25 21:00:54 +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
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
Carl Eugen Hoyos
144ef773c7 Use correct msvc type specifiers for ptrdiff_t and size_t. 2016-03-09 14:00:22 +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
0028da36cd avformat/mpjpegdec: add AVFMT_NOTIMESTAMPS
there are no timestamps being set, thus do not attempt to collect any

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-21 20:07:50 +01:00
Alex Agranovsky
6dc1d5f87c lavf/mpjpeg: probe should not depend on Content-Length MIME header being present
Signed-off-by: Alex Agranovsky <alex@sighthound.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-21 20:07:50 +01:00
Alex Agranovsky
ddda2cc43c lavf/mpjpeg: do not include CRLF preceding boundary as part of the returned frame
Signed-off-by: Alex Agranovsky <alex@sighthound.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-14 13:48:33 +01:00
Alex Agranovsky
09b8e97ab6 lavf/mpjpeg: Trim quotes on MIME boundary, if present.
Fixes 5023

Signed-off-by: Alex Agranovsky <alex@sighthound.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-14 12:31:08 +01:00
Carl Eugen Hoyos
405abdbaee lavf/mpjpegdec: Do not call av_log() while probing. 2016-01-12 20:35:03 +01:00
Alex Agranovsky
7fd1c85e51 lavf/mpjpegdec: Fixed dereference after null check
Fixes Coverity CID 1341576

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-09 19:55:25 +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
Michael Niedermayer
9696a01f12 avformat/mpjpegdec: Fix "libavformat/mpjpegdec.c:269:9: warning: passing argument 3 of av_stristart from incompatible pointer type"
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-04 03:09:00 +01:00
James Almer
9ac5beaa86 avformat/mpjpegdec: fix mixed declarations and code 2015-12-03 01:39:47 -03:00
Alex Agranovsky
259c71c199 avformat/mpjpeg: utilize MIME boundary value to detect start of new frame
This code is disabled by default so not to regress endpoints sending invalid MIME, but can be enabled via AVOption 'strict_mime_boundary'

Signed-off-by: Alex Agranovsky <alex@sighthound.com>
2015-12-02 22:39:27 +01:00
Alex Agranovsky
79103f2199 avformat/mpjpeg: allow processing of MIME parts without Content-Length header
Fixes ticket 5023

Signed-off-by: Alex Agranovsky <alex@sighthound.com>
2015-12-02 22:37:32 +01:00
Hendrik Leppkes
b95b8e5a22 Merge commit '18f9308e6a96bbeb034ee5213a6d41e0b6c2ae74'
* commit '18f9308e6a96bbeb034ee5213a6d41e0b6c2ae74':
  mpjpeg: Cope with multipart lacking the initial CRLF

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-27 12:55:51 +01:00
Luca Barbato
18f9308e6a mpjpeg: Cope with multipart lacking the initial CRLF
Some server in the wild do not put the boundary at a newline
as rfc1347 7.2.1 states.
Cope with that by reading a line and if it is not empty reading
a second one.

Reported-By: bitingsock
2015-10-23 11:56:38 +02:00
Carl Eugen Hoyos
c52c78cc56 lavf/mpjpegdec: Return 0 if an allocation inside the probe function fails. 2015-10-22 11:19:45 +02:00
Alex Agranovsky
53e8bef25a mpjpeg: CRLF terminating a sequence of MIME headers should not cause an error
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-21 02:30:29 +02:00
Ganesh Ajjanagadde
9aaa54135c avformat/mpjpegdec: silence unused variable/function warnings
Silences a -Wunused-variable and -Wunused-function observed under GCC 5.2.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-09-16 16:29:51 -07:00
Clément Bœsch
c8370a17f5 avformat: fix style after recent commits 2015-09-14 17:42:56 +02:00
Alex Agranovsky
1de21215d4 mpjpegde: trim header name/value of MIME headers
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-14 17:13:14 +02:00
Alex Agranovsky
0572bd1a62 mpjpeg: probe should require same constraints as packet reader - both proper content-type and content-size must be present
return AVPROBE_SCORE_MAX, rather than random positive number on success

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-14 17:03:47 +02:00
Alex Agranovsky
276ab7c148 avformat/mpjpegdec: Allow mpjpeg headers parsing to succeed upon EOF, if required headers are present
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-13 03:08:50 +02:00
Michael Niedermayer
a57ee6cca1 Merge commit '8a26ae5f94e613dbf7eb8e3c60462e966e409cdc'
* commit '8a26ae5f94e613dbf7eb8e3c60462e966e409cdc':
  mpjpeg: Check stream allocation

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-28 13:41:44 +02:00
Luca Barbato
8a26ae5f94 mpjpeg: Check stream allocation
Bug-Id: CID 1308152
2015-06-28 10:27:19 +02:00
James Almer
b380337020 mpjpegdec: don't try to alloc an AVIOContext when probe is guaranteed to fail
The first check is done without the AVIOContext, so alloc it only if said check succeeds

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2015-06-09 10:07:11 +02:00
James Almer
1382add59d mpjpegdec: don't try to alloc an AVIOContext when probe is guaranteed to fail
The first check is done without the AVIOContext, so alloc it only if said check succeeds

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-06-08 18:26:42 -03:00
Michael Niedermayer
402b18afcc Merge commit 'caf7be30b11288c498fae67be4741bfbf083d977'
* commit 'caf7be30b11288c498fae67be4741bfbf083d977':
  mpjpgdec: free AVIOContext leak on early probe fail

Conflicts:
	libavformat/mpjpegdec.c

See: 34d278f983, this was mistakenly reimplemented, also see ffmpeg IRC log of today
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-08 22:15:28 +02:00
James Almer
34d278f983 mpjpegdec: fix memory leak in probe function
Signed-off-by: James Almer <jamrial@gmail.com>
2015-06-08 16:03:31 -03:00
Janne Grunau
caf7be30b1 mpjpgdec: free AVIOContext leak on early probe fail 2015-06-08 13:55:26 +02:00
Michael Niedermayer
8985e7c561 Merge commit '9b56ac74b170d12027fbc81f581a451a709f1105'
* commit '9b56ac74b170d12027fbc81f581a451a709f1105':
  mpjpeg: Initial implementation

Conflicts:
	Changelog
	libavformat/allformats.c
	libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-08 00:44:28 +02:00
Luca Barbato
9b56ac74b1 mpjpeg: Initial implementation
Support only streams with Content-Length.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-06-07 10:14:45 +02:00