1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-08-24 18:31:50 +02:00
Commit Graph

179 Commits

Author SHA1 Message Date
Clément Bœsch
be6f6fce2e Merge commit 'cdcfa97dc49d83b5eefd0a651db6bb0a6f98e8f2'
* commit 'cdcfa97dc49d83b5eefd0a651db6bb0a6f98e8f2':
  libavformat: Fix a faulty api deprecation guard in prepare_input_packet

Merged-by: Clément Bœsch <u@pkh.me>
2017-04-26 16:30:01 +02:00
Muhammad Faiz
9f030ee00f avformat: do not use AVFrame accessor
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
2017-04-23 14:30:53 +07:00
Michael Niedermayer
8779ec91b2 avformat/mux: Check return code of av_packet_split_side_data()
Fixes CID1403225

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-30 16:30:14 +02:00
Clément Bœsch
549045254c Fix all -Wformat warnings raised by DJGPP 2017-03-29 14:49:29 +02:00
Clément Bœsch
cd4d6cba12 lavf: fix usages of av_get_codec_tag_string() 2017-03-29 14:49:29 +02:00
wm4
d682ae70b4 avcodec, avformat: deprecate anything related to side data merging
This patch deprecates anything that has to do with merging/splitting
side data. Automatic side data merging (and splitting), as well as all
API symbols involved in it, are removed completely.

Two FF_API_ defines are dedicated to deprecating API symbols related to
this: FF_API_MERGE_SD_API removes av_packet_split/merge_side_data in
libavcodec, and FF_API_LAVF_KEEPSIDE_FLAG deprecates
AVFMT_FLAG_KEEP_SIDE_DATA in libavformat.

Since it was claimed that changing the default from merging side data to
not doing it is an ABI change, there are two additional FF_API_ defines,
which stop using the side data merging/splitting by default (and remove
any code in avformat/avcodec doing this): FF_API_MERGE_SD in libavcodec,
and FF_API_LAVF_MERGE_SD in libavformat.

It is very much intended that FF_API_MERGE_SD and FF_API_LAVF_MERGE_SD
are quickly defined to 0 in the next ABI bump, while the API symbols are
retained for a longer time for the sake of compatibility.
AVFMT_FLAG_KEEP_SIDE_DATA will (very much intentionally) do nothing for
most of the time it will still be defined. Keep in mind that no code
exists that actually tries to unset this flag for any reason, nor does
such code need to exist. Code setting this flag explicitly will work as
before. Thus it's ok for AVFMT_FLAG_KEEP_SIDE_DATA to do nothing once
side data merging has been removed from libavformat.

In order to avoid that anyone in the future does this incorrectly, here
is a small guide how to update the internal code on bumps:

- next ABI bump (probably soon):
  - define FF_API_LAVF_MERGE_SD to 0, and remove all code covered by it
  - define FF_API_MERGE_SD to 0, and remove all code covered by it
- next API bump (typically two years in the future or so):
  - define FF_API_LAVF_KEEPSIDE_FLAG to 0, and remove all code covered
    by it
  - define FF_API_MERGE_SD_API to 0, and remove all code covered by it

This forces anyone who actually wants packet side data to temporarily
use deprecated API to get it all. If you ask me, this is batshit fucked
up crazy, but it's how we roll. Making AVFMT_FLAG_KEEP_SIDE_DATA to be
set by default was rejected as an ABI change, so I'm going all the way
to get rid of this once and for all.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-21 06:13:45 +01:00
Martin Storsjö
cdcfa97dc4 libavformat: Fix a faulty api deprecation guard in prepare_input_packet
This seems to have been added by mistake in 11de006b, by not
noticing the negation for the existing condition. This block does
not contain any code that accesses the codec field in AVStream.

This function is meant to serve as a complement to compute_pkt_fields2,
which is guarded by FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-12-15 12:01:48 +02:00
Rodger Combs
f8e3ebde56
lavf/mux: don't warn about missing timestamps on attached pictures 2016-11-14 01:45:02 -06: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
James Almer
75a13115cd avformat/mux: remove unnecessary autobsf hack
autobsf has been ported to the new bsf API.

Signed-off-by: James Almer <jamrial@gmail.com>
2016-11-05 22:42:23 -03:00
Michael Niedermayer
9e58812519 avformat/mux: split side data before internal auto BSF
The bitstream filters do not work with merged in side data

This leaves the input packet split if it is being split.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-11-04 22:12:59 -03:00
James Almer
6005c7e656 Revert "avformat/mux: split side data earlier in av_write_frame and av_interleaved_write_frame"
This reverts commit fba2a8a254.

The changes were right for av_write_frame() but not for av_interleaved_write_frame().
The following commit will fix this in a simpler way.

Signed-off-by: James Almer <jamrial@gmail.com>
2016-11-04 21:59:48 -03:00
James Almer
fba2a8a254 avformat/mux: split side data earlier in av_write_frame and av_interleaved_write_frame
Similarly, merge it back before returning.

Fixes ticket #5927.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-11-04 17:13:43 -03:00
Carl Eugen Hoyos
db23fde784 lavf/mux: Add missing CR/LF to error messages. 2016-11-04 12:23:47 +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
Rodger Combs
1f6d7eb470
lavf: add a flag to enable/disable automatic bitstream filtering
This is mostly useful for muxers that wrap other muxers, such as dashenc
and segment. The actual duplicated bitstream filtering is largely harmless,
but delaying the header can cause problems when the muxer intended the header
to be written to a separate file.
2016-09-12 21:50:32 -05: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
Jan Sebechlebsky
2fc9a3eb7a avformat/mux: Restore original ts in write_packet on error
Restore original timestamps in write_packet() if the
actual write operation was not successfull. This allows
to pass the same packet to nonblocking muxer repeatedly
without corrupting the timestamps.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-22 12:59:54 +02:00
Michael Niedermayer
3af1aba2be avformat/mux: Fix some codecpar non uses
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-21 03:02:24 +02:00
Michael Niedermayer
a2c90d5f98 avformat/mux: Apply auto bsfs in av_write_frame() too
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-14 17:51:57 +02:00
Michael Niedermayer
de9674c5ea avformat/mux: Factor do_packet_auto_bsf() out
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-14 17:51:57 +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
Matthieu Bouron
5d75e46677 Merge commit 'db7968bff4851c2be79b15b2cb2ae747424d2fca'
* commit 'db7968bff4851c2be79b15b2cb2ae747424d2fca':
  avio: Allow custom IO users to get labels for the output bytestream

Merged-by: Matthieu Bouron <matthieu.bouron@stupeflix.com>
2016-06-23 15:59:44 +02:00
Clément Bœsch
a444a50510 Merge commit '11de006babf735aafa3462d43dd2c02bb6ac6e2f'
* commit '11de006babf735aafa3462d43dd2c02bb6ac6e2f':
  Combine deprecation guards where appropriate

Merged-by: Clément Bœsch <clement@stupeflix.com>
2016-06-22 17:36:42 +02:00
Marton Balint
e07b8d68f5 avformat/mux: do not call write_packet with a flush packet if header is not written
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-06-20 00:27:26 +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
Marton Balint
9da27fb579 avformat/mux: factorize header writing code
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-06-13 22:43:22 +02:00
Marton Balint
301ead1313 avformat/mux: call deinit if write_header fails
Docs clearly states that av_write_trailer should only be called if
avformat_write_header was successful, therefore we have to deinit if we return
failure.

Signed-off-by: Marton Balint <cus@passwd.hu>
2016-06-13 22:43:22 +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
Martin Storsjö
db7968bff4 avio: Allow custom IO users to get labels for the output bytestream
This allows callers with avio write callbacks to get the bytestream
positions that correspond to keyframes, suitable for live streaming.

In the simplest form, a caller could expect that a header is written
to the bytestream during the avformat_write_header, and the data
output to the avio context during e.g. av_write_frame corresponds
exactly to the current packet passed in.

When combined with av_interleaved_write_frame, and with muxers that
do buffering (most muxers that do some sort of fragmenting or
clustering), the mapping from input data to bytestream positions
is nontrivial.

This allows callers to get directly information about what part
of the bytestream is what, without having to resort to assumptions
about the muxer behaviour.

One keyframe/fragment/block can still be split into multiple (if
they are larger than the aviocontext buffer), which would call
the callback with e.g. AVIO_DATA_MARKER_SYNC_POINT, followed by
AVIO_DATA_MARKER_UNKNOWN for the second time it is called with
the following data.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-05-18 10:36:45 +03:00
Diego Biurrun
11de006bab Combine deprecation guards where appropriate
Some code blocks use multiple bits of deprecated API.
2016-05-13 15:14:30 +02:00
Diego Biurrun
b7e64fba7f Reduce the scope of some variables
This avoids unused variable warnings after the next version bump.
Also drop a trace level av_log() call that is in the way.
2016-05-11 12:21:25 +02:00
Diego Biurrun
0f40c90984 Drop pointless assert.h #includes 2016-05-03 15:45:10 +02:00
Michael Niedermayer
c84ba07db4 avformat/mux: Check that deinit is set before calling it
Fixes null pointer dereference

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-24 12:07:37 +02:00
Derek Buitenhuis
af9cac1be1 Merge commit '33d18982fa03feb061c8f744a4f0a9175c1f63ab'
* commit '33d18982fa03feb061c8f744a4f0a9175c1f63ab':
  lavc: add a new bitstream filtering API

Conversions-by: Hendrik Leppkes <h.leppkes@gmail.com>
Conversions-by: Derek Buitenguis <derek.buitenhuis@gmail.com>
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-17 18:47:40 +01: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
Ronald S. Bultje
6d8ab358a3 lavf: allow BSFs to drop packets.
If pkt->size == 0 && pkt->side_data_elems == 0 after bsf->filter()
returns, the packet is considered dropped.
2016-03-11 11:19:10 -05:00
Stefano Sabatini
dedcb3c5a5 lavf/mux: do not fail in case of non strictly monotonically increasing DTS values for data packets
Consistent with what we already do with subtitles since ac08c5c0ad.
2016-02-26 10:18:09 +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
Derek Buitenhuis
895b888f16 Merge commit '521dc78366c6ea54b7b69426dab302a57231f81e'
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-01-27 16:56:22 +00:00
Matt Oliver
b66ac803fa avformat/mux: Fix error when writing uncoded frames.
commit "avpacket: Deprecate av_dup_packet" broke the use
av_interleaved_write_uncoded_frame as any input uncoded frame has an
invalid packet size that will crash when av_packet_ref tries to allocate
'size' new memory. Since the packet is a temporary created within mux.c
itself it can be used directly without needing a new ref.

Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2016-01-27 17:16:43 +11:00
Anton Khirnov
521dc78366 mux: drop the warning about global headers
The AVStream codec context is often not (and should not be) the actual
encoding context, so this warning will be spurious in many cases.
2016-01-12 09:12:24 +01:00
Rodger Combs
1f9139b07b lavf: add automatic bitstream filtering; bump version
This solves the problem discussed in https://ffmpeg.org/pipermail/ffmpeg-devel/2015-September/179238.html
by allowing AVCodec::write_header to be delayed until after packets have been
run through required bitstream filters in order to generate global extradata.

It also provides a mechanism by which a muxer can add a bitstream filter to a
stream automatically, rather than prompting the user to do so.
2015-12-28 08:40:35 -06:00
Michael Niedermayer
0106a20aea avformat/mux: Rename compute_pkt_fields2(), the name is absolutely terrible
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-12 23:06:32 +01:00
Hendrik Leppkes
611c22140a Merge commit '8de1ee9f725aa3c550f425bd3120bcd95d5b2ea8'
* commit '8de1ee9f725aa3c550f425bd3120bcd95d5b2ea8':
  lavf: deprecate compute_pkt_fields2

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-11-11 14:37:48 +01:00
Anton Khirnov
8de1ee9f72 lavf: deprecate compute_pkt_fields2
All encoders set pts and dts properly now (and have been doing that for
a while), so there is no good reason to do any timestamp guessing in the
muxer.

The newly added AVStreamInternal will be later used for storing all the
private fields currently living in AVStream.
2015-11-09 07:50:55 +01:00
Hendrik Leppkes
87a6f532b4 Merge commit '9b56d5c11488656254e9aed8d964ef2b7c2ff5e6'
* commit '9b56d5c11488656254e9aed8d964ef2b7c2ff5e6':
  avpacket: Deprecate av_dup_packet

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-29 14:16:44 +01:00