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

291 Commits

Author SHA1 Message Date
Andreas Rheinhardt
4825d8a98d avformat/mpeg: Fix leaks of AVFormatContext and subtitle packets
If an error happens in vobsub_read_header() after allocating the
AVFormatContext intended to read the sub-file, both the AVFormatContext
as well as the data in the subtitles queues leaks. This has been fixed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-05 17:22:40 +01:00
Andreas Rheinhardt
bc3cf2bbd3 avformat/mpeg: Don't copy or leak string in AVBPrint
vobsub_read_header() uses an AVBPrint to write a string and up until
now, it collected the string stored in the AVBPrint via
av_bprint_finalize(), which might involve an allocation and copy of the
string. But this is unnecessary, as the lifetime of the returned string
does not exceed the lifetime of the AVBPrint. So use the string in the
AVBPrint directly.

This also makes it possible to easily fix a memleak: In certain error
situations, the string stored in the AVBPrint would not be freed (if it
was dynamically allocated). This has been fixed, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-05 17:22:40 +01:00
Andreas Rheinhardt
3f37880c05 avformat/mpeg: Make VobSub demuxer have its own context struct
When the VobSub demuxer was added, the fields it required were simply
added to the MpegDemuxContext (if the VobSub demuxer was selected at
all). The mpeg demuxer of course doesn't use these fields even if they
are there; and the VobSub demuxer doesn't use the old ones: It opens an
mpeg subdemuxer of its own and uses this where a mpeg demuxer is
required. Hence the two contexts can be split, saving memory.

Furthermore several headers can now be moved to the section that is
guarded by #if CONFIG_VOBSUB_DEMUXER (this even includes avassert.h
which was unguarded and has been added in 9cde9f70 despite not being
used in that patch).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-05 17:22:40 +01:00
Andreas Rheinhardt
262eef6b89 avformat/mpeg: Don't free unintialized pointer
In order to fix a potential memleak upon failure, 0b8956b2 made sure that
a buffer given by a pointer was freed upon error. But this pointer was
only initialized upon use and in several cases (Clang gives no fewer
than 13 -Wsometimes-uninitialized warnings) this meant that an
uninitialized pointer was used to free a buffer. So initialize the
pointer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-10-24 15:51:20 -03:00
Andreas Rheinhardt
c36eae65e4 avformat/mpeg: Add padding to extradata
Extradata is supposed to be padded with AV_INPUT_BUFFER_PADDING_SIZE bytes,
yet the VobSub demuxer used av_strdup for the allocation of extradata.
This has been changed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-10-24 19:45:17 +02:00
Steven Liu
0b8956b25c avformat/mpeg: move the header_str free into end label
fix CID: 1454875

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-10-22 10:54:36 +08:00
Steven Liu
f5263172de avformat/mpeg: check av_strdup() return value
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-10-19 06:54:12 +02:00
Andreas Rheinhardt
ffb32d35ee avformat/mpeg: Remove set-but-unused variable
Forgotten in 7da57875.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-10-08 10:41:43 +02:00
Paul B Mahol
7da57875b5 avformat/mpeg: better fix for MLP versus PCM-DVD misdetection 2019-10-05 11:15:42 +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
3aa6208db9 lavf: Constify AVInputFormat pointer. 2019-03-20 18:52:38 +01:00
Xiaofeng Wang
821791caa0 lavf/mpeg: fix indent
Signed-off-by: Xiaofeng Wang <xiaofeng.wang@bqvision.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-02-18 23:08:38 +01:00
Carl Eugen Hoyos
303439bc5f lavf/mpeg: Support demuxing HEVC in mpeg-ps. 2018-09-27 23:53:21 +02:00
Gyan Doshi
02741853d7 avformat: correct fdebug loglevel
fftools/cmdutils sets loglevel for fdebug to DEBUG but all fdebug output
except for two were emitted at TRACE.
2018-08-14 22:06:30 +05:30
Paul B Mahol
0995641202 avformat/mpeg: add missing check
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-04-01 21:08:16 +02:00
Paul B Mahol
1f7705e5b1 avformat/mpeg: fix logic failure
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-04-01 20:58:48 +02:00
Paul B Mahol
7643e27528 avformat/mpeg: fix detection and demuxing of raw AC3 in mpegps
Fixes #4889.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-04-01 20:53:43 +02:00
Paul B Mahol
52e97814a1 avformat/mpeg: fix PCM-DVD mis-detection as MLP
Fixes #6563.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-04-01 20:43:54 +02:00
Marton Balint
18ac642359 avformat: migrate to AVFormatContext->url
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-28 23:06:43 +01:00
James Almer
86be73c7c1 avformat/mpeg: zero initialize idx_pkt
Prevents use of uninitialized stack.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-23 19:37:21 -03:00
James Almer
4de591e6fb Merge commit '83548fe894cdb455cc127f754d09905b6d23c173'
* commit '83548fe894cdb455cc127f754d09905b6d23c173':
  lavf: fix usage of AVIOContext.seekable

Merged-by: James Almer <jamrial@gmail.com>
2017-03-21 17:02:30 -03:00
Carl Eugen Hoyos
a5c1c7a8b3 lavf/mpeg: Initialize a stack variable used by memcmp().
Silence a valgrind warning.

Fixes ticket #6160.
2017-02-21 02:15:08 +01:00
Michael Niedermayer
4e5049a230 avformat/mpeg: Adjust vid probe threshold to correct mis-detection
Fixes: _ij.mp3

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-11-23 00:54:45 +01:00
Anton Khirnov
83548fe894 lavf: fix usage of AVIOContext.seekable
It is supposed to be a flag. The only currently defined value is
AVIO_SEEKABLE_NORMAL, but other ones may be added in the future.
However all the current lavf code treats this field as a bool (mainly
for historical reasons).
Change all those cases to properly check for AVIO_SEEKABLE_NORMAL.
2016-09-30 16:54:33 +02: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
Diego Biurrun
0f40c90984 Drop pointless assert.h #includes 2016-05-03 15:45:10 +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
Carl Eugen Hoyos
fb9036b314 lavf/mpeg: Identify sub-stream ID 0xa1 as mlp.
Fixes ticket #4786.
Auto-detection seems difficult, patch mostly confirmed by
http://dvd-audio.sourceforge.net/spec/aob.shtml
2016-03-09 14:12:18 +01:00
Derek Buitenhuis
93629735d7 avformat: Add a protocol blacklisting API
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-03-04 16:13:42 +00: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
Nicolas George
cb14d30240 lavf/mpeg: use FFERROR_REDO instead of AVERROR(EAGAIN). 2015-12-03 19:16:12 +01:00
Hendrik Leppkes
c2f861ca42 Replace remaining occurances of av_free_packet with av_packet_unref 2015-10-27 14:35:30 +01:00
wm4
5c93e57f5c avformat/vobsub: do not attempt to check duplicate subtitles
Some .idx files actually contain duplicate subtitle events:

timestamp: 00:07:52:600, filepos: 00004e800
timestamp: 00:07:52:600, filepos: 00004f800

The second will be dropped, because it has same pts, duration, and text
(the text is just a dummy empty string; the real data is retrieved when
actually reading vobsub subtitle packets).

Dropping this is probably not intended/safe, so avoid it.

See trac issue #4872 for a sample. This patch doesn't fix decoding of
the sample, though.
2015-09-21 13:43:32 +02:00
wm4
a47ad06baf avformat/vobsub: compare correct packet stream IDs
The stream ID is essentially an arbitrary number defined by the .idx
file headers. They have to match the IDs in the .sub stream. The vobsub
demuxer assumed the IDs would just start from 0, increassing by 1 for
each stream. This is not correct. In the sample I had, the IDs were
starting from 1, leading to no subtitles being displayed at all.

Fix this by using the correct stream ID.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-21 12:55:13 +02:00
Clément Bœsch
af924fd9e4 avformat/subtitles: forward log context in ff_subtitles_queue_finalize() for logging 2015-09-10 21:40:07 +02:00
Carl Eugen Hoyos
9bd305be91 lavf/mpeg: Allow users to force audio codec MLP.
Fixes part of ticket #4786.
2015-08-20 12:19:00 +02:00
Carl Eugen Hoyos
ee8c18387d lavf/mpeg: Do not detect unknown audio in Hikvision streams as alaw. 2015-05-17 12:57:27 +02:00
Michael Niedermayer
57865a9747 avformat/mpeg: put timestamp trace av_logs under FF_DEBUG_TS
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-20 17:41:22 +02:00
Michael Niedermayer
40d552dae6 Merge commit '1a3eb042c704dea190c644def5b32c9cee8832b8'
* commit '1a3eb042c704dea190c644def5b32c9cee8832b8':
  Replace av_dlog with normal av_log at trace level

Conflicts:
	ffplay.c
	libavdevice/fbdev_dec.c
	libavfilter/avfilter.c
	libavfilter/internal.h
	libavfilter/setpts.c
	libavfilter/src_movie.c
	libavfilter/vf_crop.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_fieldorder.c
	libavformat/assdec.c
	libavformat/avidec.c
	libavformat/flvdec.c
	libavformat/http.c
	libavformat/ipmovie.c
	libavformat/isom.c
	libavformat/mov.c
	libavformat/mpegenc.c
	libavformat/mpegts.c
	libavformat/mpegtsenc.c
	libavformat/mux.c
	libavformat/mxfdec.c
	libavformat/nsvdec.c
	libavformat/oggdec.c
	libavformat/r3d.c
	libavformat/rtspdec.c
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-20 03:19:47 +02:00
Vittorio Giovara
1a3eb042c7 Replace av_dlog with normal av_log at trace level
This applies to every library where performance is not critical.
2015-04-19 12:41:59 +01:00
Rodger Combs
c69ff12dc3 lavf/mpeg: vobsub add an option to specify the .sub's URI
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-13 11:55:55 +02:00
Carl Eugen Hoyos
036079ce34 lavf/mpeg: Support alaw in Hikvision CCTV recordings.
Fixes a sample from ticket #4182.
2015-04-03 21:13:50 +02:00
Carl Eugen Hoyos
f8413f74a1 lavf/mpeg: Support more audio codecs in Hikvision CCTV recordings.
Fixes a sample from ticket #4182.
2015-04-03 21:13:50 +02:00
Paul B Mahol
ca8617a04d avformat/mpeg: remove unneeded #include, there are no assert() only av_assert*
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-01-31 08:57:06 +00:00
Michael Niedermayer
8d7d88135c avformat/mpeg: Avoid dead assignment
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-14 00:06:43 +01:00
Michael Niedermayer
74080ded96 avformat/mpeg: add commented out av_log() to probe
This is commonly needed for debugging mis-detections

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-06 22:38:38 +01:00
Michael Niedermayer
e15b29bb18 avformat/mpeg: do not count PES packets inside PES packets during probing
Fixes: misdetection of test2.mp3

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-06 22:34:10 +01:00
Michael Niedermayer
51ddaf6549 avformat/mpeg: fix memleak of sub_name on error
Fixes CID1254666

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-16 19:17:34 +01:00
Michael Niedermayer
ff03df6475 avformat/mpeg: Use av_find_input_format() instead of directly linking to the demuxer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-25 16:28:41 +02:00