Commit Graph

221 Commits

Author SHA1 Message Date
Andreas Rheinhardt e79309fde6 libavformat/mux, mxfenc: Don't initialize unnecessarily
When no packet could be output, the interleavement functions
nevertheless initialized the packet destined for output (with the
exception of the data and size fields, making the initialization
pointless), although it will not be used at all. So remove the
initializations.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 01:24:56 +02:00
Andreas Rheinhardt 00aa6dea3f avformat/mux: Remove redundant resetting
Now that ff_interleave_add_packet() always returns blank packets, the
input packet to ff_interleave_packet_per_dts() will always be blank on
return as well (if supplied) and the same goes for interleave_packet()
in mux.c. Document these facts and remove the redundant resetting that
happened in av_interleaved_write_frame().

The last reference to the (long removed) destruct field that AVPackets
once had has been removed as well when updating the documentation of
ff_interleave_packet_per_dts().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 00:41:27 +02:00
Andreas Rheinhardt a43120b609 avformat/mux: Fix leak when adding packet to interleavement queue fails
When an error happened in ff_interleave_add_packet() when adding
a packet to the packet queue, said packet would not be unreferenced
in ff_interleave_add_packet(), but would be zeroed in
av_interleaved_write_frame(), which results in a memleak.

This has been fixed: ff_interleave_add_packet() now always unreferences
the input packet on error; as a result, it always returns blank packets
which has been documented. Relying on this a call to av_packet_unref()
in ff_audio_rechunk_interleave() can be removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-18 00:22:22 +02:00
Marton Balint 19b9f8996e avformat/avio: fix ff_rename to respect used protocol
Also simplify it and make it always log the error.

This fixes for example the image2 muxer when used with an URL which also
contains the protocol:

ffmpeg -f lavfi -i testsrc -vframes 10 -atomic_writing 1 file:out%d.png

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-19 22:17:04 +01:00
Marton Balint df993269ec avformat/avio: move ff_rename implementation from internal.h to avio.c
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-19 22:17:04 +01:00
James Almer ab9627223e Revert "avformat/utils: make ff_ntp_time() accept a timestamp as input argument"
Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-16 22:27:35 -03:00
James Almer 4e4ac20340 avformat/utils: make ff_ntp_time() accept a timestamp as input argument
Will be needed by the next patch.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-15 23:34:20 -03:00
Andriy Gelman 5e3229df4c avformat: Add max_probe_packets option
Allows user to set maximum number of buffered packets when
probing a codec. It was a hard-coded parameter before this commit.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-03 11:52:32 +01:00
Andreas Rheinhardt b6be2be765 avformat/utils: ensure that all packets in AVPacketList are reference counted
This is done so that its data is really owned by the packet.
This was already true for the current callers.

Signed-off-by: James Almer <jamrial@gmail.com>
2019-09-25 21:54:18 -03:00
Andreas Rheinhardt 8b1be6e5eb avformat/internal: Improve documentation of ff_packet_list_get
The documentation of ff_packet_list_get currently didn't match the
actual usage:
1. It said that the destination packet is supposed to be initialized.
But this makes no sense given that it will be overwritten completely and
flacenc, mp3enc and ttaenc ignored this.
2. ff_packet_list_get returns an int, although it can't fail in case the
packet list is not empty (for which there is an assert). Again, several
callers didn't check for any return value.
In both cases, the documentation has been adapted to match actual usage.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-18 22:53:00 +02:00
Andreas Rheinhardt 1147759552 avformat/mux: Use const AVPacket * in compare functions
There is no reason for these functions to modify the given packets at
all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-08-15 01:26:21 +02:00
Jun Zhao 4373bb411c lavf/avio: remove ffio_open2_wrapper function
Remove the function ffio_open2_wrapper, it's not being used anymore.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-07-21 10:05:40 +08:00
Steven Liu bb660800a5 avformat/utils: move mkdir_p to utils
Because it will be used by avformat/segment.c or other module which
need to automatically create sub-directories operation.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2018-09-25 21:57:49 +08:00
Vishwanath Dixit f09635f2a2 avformat/utils: function to get the formatted ntp time
This utility function creates 64-bit NTP time format as per the RFC
5905.
A simple explaination of 64-bit NTP time format is here
http://www.beaglesoft.com/Manual/page53.htm
2018-05-29 09:31:29 +05:30
Jun Zhao cdd107b965 lavf/aviobuf: add ff_get_chomp_line
Same as ff_get_line but strip the white-space characters in the
string tail.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-04-12 16:04:58 +08:00
James Almer 3a4d74c1ff avformat/utils: make AVPacketList helper functions shared
Based on a patch by Luca Barbato.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-04-04 00:15:37 -03:00
Josh de Kock 42d26145e9 lavf: move avpriv function definition to internal.h
Signed-off-by: Josh de Kock <josh@itanimul.li>
2018-04-02 02:16:14 +01:00
Josh de Kock d8ae40611b Revert "lavd: add new API for iterating input and output devices"
This reverts commit 0fd475704e.

Revert "lavd: fix iterating of input and output devices"

This reverts commit ce1d77a5e7.

Signed-off-by: Josh de Kock <josh@itanimul.li>
2018-03-31 23:26:31 +01:00
Michael Niedermayer 5735a390a6 avformat/internal: Document the freeing behavior of ff_alloc_extradata()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-03-07 20:37:33 +01:00
Marton Balint dcb2ef2211 avformat/aviobuf: add ff_read_line_to_bprint and ff_read_line_to_bprint_overwrite functions
To be able to read lines longer than a static buffer size.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-02-24 20:17:04 +01:00
Josh de Kock 0fd475704e lavd: add new API for iterating input and output devices
This also adds an avpriv function to register devices in
libavformat
2018-02-06 18:57:42 +00:00
Marton Balint ea3672b7d6 avformat: add url field to AVFormatContext
This will replace the 1024 character limited filename field. Compatiblity for
output contexts are provided by copying filename field to URL if URL is unset
and by providing an internal function for muxers to set both url and filename
at once.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-01-28 23:06:43 +01:00
Karthick Jeyapal e8f71ef338 avformat/hlsenc, utils: Moved is_http_proto from hlsenc to utils for re-use
Reviewed-by: Aman Gupta <aman@tmm1.net>
Reviewed-by: Steven Liu <lq@onvideo.cn>
2017-12-29 18:11:09 +08:00
wm4 86a13bf2ff lavc, lavf: move avformat static mutex from avcodec to avformat
It's completely absurd that libavcodec would care about libavformat
locking, but it was there because the lock manager was in libavcodec.

This is more stright forward. Changes ABI, but we don't require ABI
compatibility currently.
2017-12-26 02:50:00 +01:00
Aman Gupta 9e5e3236f4 avformat/internal: fix compile error with some versions of g++
Fixes #6926

Signed-off-by: Aman Gupta <aman@tmm1.net>
2017-12-23 12:36:22 -08:00
Aman Gupta 4c78bbd313 avformat/internal: log underlying error with ff_rename failure
Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-12-22 18:00:47 -08:00
James Almer d6d605eb05 avformat/mux: stop delaying writing the header
Every bitstream filter behaves as intended now, so there's no need to
wait for the first packet of every stream.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-12-06 15:43:59 -03:00
James Almer cd1ff3e45d avformat: move priv_pts from AVStream to an internal struct
It has no reason to be in a public header, even if defined as private.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-11-07 23:20:50 -03:00
wm4 66cf78e932 lavf: consider codec framerate for framerate detection
Fixes detection of some TV sample as 24.5 FPS. With the patch applied,
it's detected as 25 FPS.

This is enabled for mpegts only.
2017-06-07 11:08:06 +02:00
James Almer b8f26779d6 lavf: use the new bitstream filter for extracting extradata
This merges commits 8e2ea69135 and
096a8effa3 by Anton Khirnov, with the
following change:

- extract_extradata_check() is added to know if the codec is supported
by the bsf before trying to initialize it. This behaviour is similar to
the old AVCodecParser.split checks.

The FATE reference changes are due to the filtered out NAL units that
the old AVCodecParser.split implementation left alone.
Decoding is unchanged as the functions that parse extradata simply
ignored said unnecessary NAL units.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-04-07 17:16:17 -03:00
James Almer 40fa9d416a Revert "Merge commit '8e2ea691351c5079cdab245ff7bfa5c0f3e3bfe4'"
This reverts commit 1c193ac1f9, reversing
changes made to 7ebc9f8df4.

Several FATE tests started failing after this merge, so it's reverted
until it can be properly fixed.
2017-03-23 19:34:00 -03:00
James Almer 1c193ac1f9 Merge commit '8e2ea691351c5079cdab245ff7bfa5c0f3e3bfe4'
* commit '8e2ea691351c5079cdab245ff7bfa5c0f3e3bfe4':
  lavf: use the new bitstream filter for extracting extradata

Merged-by: James Almer <jamrial@gmail.com>
2017-03-23 16:52:42 -03:00
Paul Arzelier 65862f57ad avformat: Ignore ID3v2 tags if other tags are present e.g. vorbis
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-01-28 23:08:42 +01:00
Hendrik Leppkes 8fad4b4e25 Merge commit '785c25443b56adb6dbbb78d68cccbd9bd4a42e05'
* commit '785c25443b56adb6dbbb78d68cccbd9bd4a42e05':
  movenc: Apply offsets on timestamps when peeking into interleaving queues

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-11-13 22:57:02 +01:00
Rodger Combs a246fef163
lavf/mux: add avformat_init_output
This allows a consumer to run the muxer's init function without actually
writing the header, which is useful in chained muxers that support
automatic bitstream filtering.
2016-10-24 03:53:21 -05:00
Andreas Cadhalpun c8a6eb58d7 doc: fix spelling errors
Thanks to Mathieu Malaterre <malat@debian.org> for reporting the
Que/Queue typo. (https://bugs.debian.org/839542)

Reviewed-by: Lou Logan <lou@lrcd.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-10-21 23:58:47 +02:00
Anton Khirnov 8e2ea69135 lavf: use the new bitstream filter for extracting extradata
This also fixes a minor bug introduced in the codecpar conversion, where
the termination condition for extracting the extradata does not match
the actual extradata setting code. As a result, the packet durations
made up by lavf go back to their values before the codecpar conversion.
That is of little consequence since that code should eventually be
dropped completely.
2016-10-16 20:27:30 +02:00
Michael Niedermayer cb114ed464 avformat/mux: implement AVFMT_FLAG_SHORTEST
This will allow fixing several bugs with the -shortest option

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-11 23:17:31 +02:00
Clément Bœsch b2016189db lavf/utils: add some const to pointers parameters in a few functions 2016-08-17 16:17:42 +02:00
Jan Sebechlebsky 6a3515a5a4 avformat/utils: Add ff_format_output_open() function
Add ff_format_output_open utility function to wrap
io_open callback of AVFormatContext structure.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-07-16 01:29:44 +02:00
Jan Sebechlebsky 1732d89403 avformat/utils: Add ff_stream_encode_params_copy()
Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-07-16 01:15:00 +02:00
Martin Storsjö 785c25443b movenc: Apply offsets on timestamps when peeking into interleaving queues
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-06-28 14:16:06 +03:00
Rodger Combs af7e2734b9
lavf: update auto-bsf to new BSF API 2016-06-25 15:50:04 -05:00
Michael Niedermayer 46a60fe184 avformat: Fix ff_interleaved_peek()
Fixes assertion failures in movenc

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-25 03:04:55 +02:00
Matthieu Bouron b1e1da52fe Merge commit 'e1eb0fc960163402bbb4e630185790488f7d28ed'
* commit 'e1eb0fc960163402bbb4e630185790488f7d28ed':
  movenc: Use packets in interleaving queues for the duration at the end of fragments

Merged-by: Matthieu Bouron <matthieu.bouron@stupeflix.com>
2016-06-23 22:02:31 +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
Marton Balint 517fe64406 avformat/mux: do not call write_header multiple times if it fails the first time
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-06-20 00:27:26 +02:00
Martin Storsjö e1eb0fc960 movenc: Use packets in interleaving queues for the duration at the end of fragments
As long as caller only writes packets using av_interleaved_write_frame
with no manual flushing, this should allow us to always have accurate
durations at the end of fragments, since there should be at least
one queued packet in each stream (except for the stream where the
current packet is being written, but if the muxer itself does the
cutting of fragments, it also has info about the next packet for that
stream).

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-05-18 10:37:03 +03:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Paul B Mahol 323b8c95e4 avformat: add AVFormatContext to ff_get_extradata()
Needed for av_log() inside that function.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-04-14 18:21:08 +02:00