Commit Graph

82 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
Limin Wang c825de87c9 avformat/rtpdec: return value check for init_get_bits()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-01-30 13:26:35 +08:00
Andreas Rheinhardt 82d61a9ce3 avformat: Don't free old extradata before ff_alloc/get_extradata
These functions already free it themselves before they allocate the new
extradata.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-12 19:25:33 +01:00
Andreas Rheinhardt c1e439d7e9 avformat: Forward errors where possible
It is not uncommon to find code where the caller thinks to know better
what the return value should be than the callee. E.g. something like
"if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit
changes several instances of this to instead forward the actual error.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-12-12 19:25:33 +01:00
Olivier Maignial c29d81e736 avformat/rtpdec_mpeg4: Fix integer parameters size check in SDP fmtp line
=== PROBLEM ===

I was trying to record h264 + aac streams from an RTSP server to mp4 file. using this command line:
    ffmpeg -v verbose -y -i "rtsp://<ip>/my_resources" -codec copy -bsf:a aac_adtstoasc test.mp4

FFmpeg then fail to record audio and output this logs:
    [rtsp @ 0xcda1f0] The profile-level-id field size is invalid (40)
    [rtsp @ 0xcda1f0] Error parsing AU headers
    ...
    [rtsp @ 0xcda1f0] Could not find codec parameters for stream 1 (Audio: aac, 48000 Hz, 1 channels): unspecified sample format

In SDP provided by my RTSP server I had this fmtp line:
    a=fmtp:98 streamType=5; profile-level-id=40; mode=AAC-hbr; config=1188; sizeLength=13; indexLength=3; indexDeltaLength=3;

In FFmpeg code, I found a check introduced by commit 24130234cd. It disallows values greater than 32 for fmtp line parameters.
RFC-4566 (SDP: Session Description Protocol) do not give any limit of size on interger parameters given in an fmtp line.

However, In RFC-6416 (RTP Payload Format for MPEG-4 Audio/Visual Streams) give examples of "profile-level-id" values for AAC, up to 55.

=== FIX ===

As each parameter may have its own min and max values
I propose to introduce a range for each parameter.
For this patch I used RFC-3640 and ISO/IEC 14496-1 as reference for validity ranges.

This patch fix my problem and I now can record my RTSP AAC stream to mp4.
It has passed the full fate tests suite sucessfully.

Signed-off-by: Olivier Maignial <olivier.maignial@smile.fr>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-08-10 00:01:02 +02:00
Carl Eugen Hoyos dc77e64f2d lavf/rtpdec*: Constify all RTPDynamicProtocolHandler.
Reviewed-by: Muhammad Faiz
2018-02-14 01:14:35 +01:00
Clément Bœsch f4a39ceea0 Merge commit '24130234cd9dd733116d17b724ea4c8e12ce097a'
* commit '24130234cd9dd733116d17b724ea4c8e12ce097a':
  rtpdec_mpeg4: validate fmtp fields

Merged with fixed log message.

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-19 18:24:35 +01:00
Carl Eugen Hoyos ed491db3e5 lavf/rtpdec_mpeg4: Constify a function parameter.
Silences an "assignment discards ‘const’ qualifier" warning.
2017-02-11 16:19:37 +01:00
Luca Barbato 24130234cd rtpdec_mpeg4: validate fmtp fields 2016-08-23 18:58:10 +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
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
Vittorio Giovara 059a934806 lavc: Consistently prefix input buffer defines
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-07-27 15:24:59 +01:00
Michael Niedermayer 3130e5be92 Merge commit 'd594dbecce5f3af7f80bbf5bb1b516d740b69ccd'
* commit 'd594dbecce5f3af7f80bbf5bb1b516d740b69ccd':
  rtpdec: Rename the free method to close

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-25 00:58:39 +01:00
Michael Niedermayer fa80b76b11 Merge commit 'bb4a310bb85f43e62240145a656b1e5285b14239'
* commit 'bb4a310bb85f43e62240145a656b1e5285b14239':
  rtpdec: Don't free the payload context in the .free function

Conflicts:
	libavformat/rtpdec_latm.c
	libavformat/rtpdec_mpeg4.c
	libavformat/rtpdec_mpegts.c
	libavformat/rtpdec_xiph.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-25 00:25:12 +01:00
Michael Niedermayer d2a5c6f210 Merge commit 'ec96a89c3e507cf0fb1f2b159b28a53f2bad9a74'
* commit 'ec96a89c3e507cf0fb1f2b159b28a53f2bad9a74':
  rtpdec: Don't pass non-const pointers to fmtp attribute parsing functions

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-24 23:44:25 +01:00
Michael Niedermayer 499da717b8 Merge commit 'ac0e54fda9305cc7d149007f5b512bb8619f7c78'
* commit 'ac0e54fda9305cc7d149007f5b512bb8619f7c78':
  rtpdec: Add const to string parameters in internal fmtp parsing functions

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-24 23:38:19 +01:00
Michael Niedermayer 3804d73e46 Merge commit '5d8cae45737bed6239bd6b6e0698802dbe1463c8'
* commit '5d8cae45737bed6239bd6b6e0698802dbe1463c8':
  rtpdec: Get rid of all trivial .alloc/.free functions

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-24 22:55:20 +01:00
Michael Niedermayer 11fb625858 Merge commit '2b982e92f42a6e661d90b12b6592cd13cae496d4'
* commit '2b982e92f42a6e661d90b12b6592cd13cae496d4':
  rtpdec: Set need_parsing via a handler field

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-24 22:34:08 +01:00
Martin Storsjö d594dbecce rtpdec: Rename the free method to close
Many of these functions were named foo_free_context, and since
the functions no longer should free the context itself, only
allocated elements within it, the previous naming was slightly
misleading.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 23:07:50 +02:00
Martin Storsjö bb4a310bb8 rtpdec: Don't free the payload context in the .free function
This makes it more consistent with depacketizers that don't have any
.free function at all, where the payload context is freed by the
surrounding framework. Always free the context in the surrounding
framework, having the individual depacketizers only free any data
they've specifically allocated themselves.

This is similar to how this works for demuxer/muxers/codecs - a
component shouldn't free the priv_data that the framework has
allocated for it.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 23:07:35 +02:00
Martin Storsjö ec96a89c3e rtpdec: Don't pass non-const pointers to fmtp attribute parsing functions
This makes it clear that the individual parsing functions can't
touch the parsed out value.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 23:07:22 +02:00
Martin Storsjö ac0e54fda9 rtpdec: Add const to string parameters in internal fmtp parsing functions
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 23:07:18 +02:00
Michael Niedermayer 30c863fdfa Merge commit '3cd5828fc0007e6d056067444de053a34ddedd02'
* commit '3cd5828fc0007e6d056067444de053a34ddedd02':
  rtpdec: Add missing trailing commas

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-24 22:03:19 +01:00
Martin Storsjö 5d8cae4573 rtpdec: Get rid of all trivial .alloc/.free functions
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 16:24:19 +02:00
Martin Storsjö 2b982e92f4 rtpdec: Set need_parsing via a handler field
This avoids implementing a full function just to set this one
field.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 16:22:41 +02:00
Martin Storsjö 3cd5828fc0 rtpdec: Add missing trailing commas
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 16:20:02 +02:00
Michael Niedermayer 20f5a17956 Merge commit '44dc138ed29c4dfbaf57ebc774da4c75ef113ca4'
* commit '44dc138ed29c4dfbaf57ebc774da4c75ef113ca4':
  rtpdec_mpeg4: reassemble fragmented AAC frames

Conflicts:
	libavformat/rtpdec_mpeg4.c

See: fee2cc39be
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-22 01:59:44 +01:00
Gilles Chanteperdrix fee2cc39be avformat/rtpdec_mpeg4: reassemble fragmented AAC frames
Signed-off-by: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Reviewed-by: Thomas Volkert <silvo@gmx.net>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-22 00:56:18 +01:00
Gilles Chanteperdrix 44dc138ed2 rtpdec_mpeg4: reassemble fragmented AAC frames
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-21 23:38:07 +02:00
Gilles Chanteperdrix dcf969e98d rtpdec_mpeg4: add more verbose error logging
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-21 23:37:58 +02:00
Michael Niedermayer a0fe1a25fa Merge commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e'
* commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e':
  avformat: Don't anonymously typedef structs

Conflicts:
	libavformat/adtsenc.c
	libavformat/aiffenc.c
	libavformat/avidec.c
	libavformat/gif.c
	libavformat/iff.c
	libavformat/img2dec.c
	libavformat/jvdec.c
	libavformat/matroskadec.c
	libavformat/udp.c
	libavformat/wtvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-14 21:07:40 +01:00
Diego Biurrun daf8cf358a avformat: Don't anonymously typedef structs 2015-02-14 10:13:47 -08:00
Michael Niedermayer 3f56224a9a avformat/rtpdec_mpeg4: Use av_freep() to avoid leaving stale pointers in memory
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-24 13:14:07 +01:00
Michael Niedermayer 0051e3c233 avformat/rtpdec_mpeg4: Use av_freep() to avoid leaving stale extradata pointer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-15 15:48:35 +01:00
Michael Niedermayer 19b9e07ef5 Merge commit '0307cc2253e76772b1c645ac6117d08da87a147c'
* commit '0307cc2253e76772b1c645ac6117d08da87a147c':
  rtpdec: pass an AVFormatContext to ff_parse_fmtp()

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-09 23:40:13 +02:00
Anton Khirnov 0307cc2253 rtpdec: pass an AVFormatContext to ff_parse_fmtp()
Use it for logging, instead of NULL or the stream codec context.
2014-07-09 13:40:54 +00:00
Paul B Mahol a807c68253 avformat: use ff_alloc_extradata()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-10-13 20:13:38 +00:00
Michael Niedermayer 5c2ccf83df Merge commit '7abd35a1ffaecfd79fa07b801621ee11ab595c43'
* commit '7abd35a1ffaecfd79fa07b801621ee11ab595c43':
  avformat: Add av_cold attributes to init functions missing them

Conflicts:
	libavformat/rtpdec_xiph.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-06 10:19:56 +02:00
Diego Biurrun 7abd35a1ff avformat: Add av_cold attributes to init functions missing them 2013-05-05 18:33:04 +02:00
Michael Niedermayer 0a5da9cc14 Merge commit 'c6f1dc8e4cd967ae056698eafb891a08003c211c'
* commit 'c6f1dc8e4cd967ae056698eafb891a08003c211c':
  rtpdec: Move setting the parsing flags to the actual depacketizers
  rtpdec: Split handling of mpeg12 audio/video to a separate depacketizer

Conflicts:
	libavformat/rtpdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-21 14:02:01 +01:00
Michael Niedermayer c3f3c22563 Merge commit 'a717f9904227d7979473bad40c50eb40af41d01d'
* commit 'a717f9904227d7979473bad40c50eb40af41d01d':
  mpegts: Share the cleanup code between the demuxer and lavf-internal parser functions
  rtpdec_mpeg4: Return one AAC AU per AVPacket
  ppc: Include string.h for memset

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-21 13:45:36 +01:00
Martin Storsjö c6f1dc8e4c rtpdec: Move setting the parsing flags to the actual depacketizers
This gets rid of almost all the codec specific details from the
generic rtpdec code.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-20 18:20:42 +02:00
Martin Storsjö 21f5c24b80 rtpdec_mpeg4: Return one AAC AU per AVPacket
This makes the returned data valid to stream copy into other
containers as well, not only for decoding straight away.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-20 18:12:38 +02:00
Michael Niedermayer 5c7e9e16c9 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  lavc: Move vector_fmul_window to AVFloatDSPContext
  rtpdec_mpeg4: Check the remaining amount of data before reading

Conflicts:
	libavcodec/dsputil.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-16 12:38:41 +01:00
Michael Niedermayer 1459f34251 Merge commit '977d4a3b8a2dbc2fb5e747c7072485016c9cdfaa'
* commit '977d4a3b8a2dbc2fb5e747c7072485016c9cdfaa':
  rtpdec_mpeg4: Check the return value from malloc
  srtp: Mark a few variables as uninitialized

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-16 12:13:16 +01:00
Martin Storsjö a7ba324413 rtpdec_mpeg4: Check the remaining amount of data before reading
This fixes possible buffer overreads.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-16 11:12:39 +02:00
Martin Storsjö 977d4a3b8a rtpdec_mpeg4: Check the return value from malloc
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-15 23:18:33 +02:00
Michael Niedermayer bb3420d88e Merge commit '90c784cc13f6bf21a8eb69f3b88b50c7a70f6c59'
* commit '90c784cc13f6bf21a8eb69f3b88b50c7a70f6c59':
  rtpdec: Pass the sequence number to depacketizers
  configure: Make avconv depend on null, anull and resample filters

Conflicts:
	configure

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-21 17:46:43 +01:00