Commit Graph

32 Commits

Author SHA1 Message Date
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