Commit Graph

49 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
Andreas Rheinhardt f4167842c1 avformat/mux: Add flag for "not more than one stream of each type"
More exactly: Not more than one stream of each type for which
a default codec (i.e. AVOutputFormat.(audio|video|subtitle)_codec)
is set; for those types for which no such codec is set (or for
which no designated default codec in AVOutputFormat exists at all)
no streams are permitted.

Given that with this flag set the default codecs become more important,
they are now set explicitly to AV_CODEC_ID_NONE for "unset";
the earlier code relied on AV_CODEC_ID_NONE being equal to zero,
so that default static initialization set it accordingly;
but this is not how one is supposed to use an enum.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:19 +01:00
Andreas Rheinhardt 59c9dc82f4 avformat/avformat: Move AVOutputFormat internals out of public header
This commit does for AVOutputFormat what commit
20f9727018 did for AVCodec:
It adds a new type FFOutputFormat, moves all the internals
of AVOutputFormat to it and adds a now reduced AVOutputFormat
as first member.

This does not affect/improve extensibility of both public
or private fields for muxers (it is still a mess due to lavd).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:24:15 +01:00
Marvin Scholz 401508b24b avformat/cafenc: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
James Almer aa79d13f51 avformat/cafenc: derive Opus frame size from the relevant stream parameters
Use the stream duration as last resort, as an off-by-one result of the
"st->duration / (caf->packets - 1)" calculation can break playback on some
devices.
Also, don't write the sample_rate value propagated by encoders like libopus.
The sample rate of the audio fed to it is irrelevant after being encoded.

Fixes ticket #9930.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-24 12:16:15 -03:00
Andreas Rheinhardt d78838414b avformat/utils: Move creation-time functions to mux_utils
Only used by muxers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:30:31 +02:00
Vittorio Giovara eaad010f7b caf: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:31 -03:00
Andreas Rheinhardt d94b641b4a avformat/cafenc: Fix memleak when trailer is never written
Do this by using the AVStream's priv_data for the buffer holding
the packet size data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:58 +02:00
Andreas Rheinhardt 19a6b51fe6 avformat/cafenc: Don't segfault upon allocation error
If an array for the packet sizes could not be successfully reallocated
when writing a packet, the CAF muxer frees said array, but does not
reset the number of valid bytes. As a result, when the trailer is
written later, avio_write tries to read that many bytes from NULL,
which segfaults.

Fix this by not freeing the array in case of error; also, postpone
writing the packet data after having successfully (re)allocated the
array, so that even on allocation error the file can be correctly
finalized.

Also remove an unnecessary resetting of the number of size entries
used at the end.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:58 +02:00
Andreas Rheinhardt 42fe438482 avformat/cafenc: Fix potential integer overflow
(As long as avio_write() only accepts an int, it makes no sense
to try to support sizes that don't fit into an int.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:58 +02:00
Roman Beranek ed240db9e3 cafenc: fill in avg. packet size later if unknown
Frame size of Opus stream was previously presumed here to be 960 samples
(20ms), however sizes of 120, 240, 480, 1920, and 2880 are also allowed.
It can also alter on a per-packet basis and even multiple frames may be
present in a single packet according to the specification, for the sake
of simplicity however, let us assume that this doesn't occur.

Because the mFramesPerPacket field, representing the number of samples
per packet in the ffmpeg terminilogy, is the key factor in calculating
packet durations and all that follows from that (index, bitrate, ...),
it is crucial to get right.

Therefore, if the packet size is not available ahead of time (as it is in
the case of Opus), calculate an average from the stream duration once we
know how many packets there are and update the filed in the header.
2021-07-12 09:54:25 +02:00
Andreas Rheinhardt bc70684e74 avformat: Constify all muxer/demuxers
This is possible now that the next-API is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:06 -03:00
Andreas Rheinhardt ef3224c911 avformat/caf: Deduplicate codec tags list
Also saves a relocation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-23 10:14:26 +01:00
Marton Balint c05d82fa92 avformat: remove unneeded avio_flush() calls from the end of write_trailer functions
The IO context is always flushed by libavformat/mux.c after write_trailer is
called, so this change should have no effect at all.
2020-01-07 21:51:45 +01:00
Marton Balint 4bf90e095b avformat: remove avio_flush() calls from the end of write_header functions
To make it consistent with other muxers.

The user can still control the generic flushing behaviour after write_header
(same way as after packets) using the -flush_packets option, the default
typically means to flush unless a non-streamed file output is used.

Therefore this change should have no adverse effect on streaming, even if it is
assumed that the first packet has a clean buffer, so small seekbacks within the
output buffer work even when the IO context is not seekable.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-07 21:51:45 +01:00
Carl Eugen Hoyos d180fce6c7 lavf/cafenc: Only allow mono and stereo for Opus.
Found-by: James Almer
2017-10-17 23:00:07 +02:00
Carl Eugen Hoyos a3accd0c37 lavf/cafenc: Allow muxing opus.
QuickTime does not require the (unknown) kuki chunk for decoding.
2017-10-17 21:35:28 +02:00
Carl Eugen Hoyos b4093e60c5 lavf/caf: Support demuxing Opus.
Introduced in macOS High Sierra and iOS 11.
2017-09-20 03:31:48 +02: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 e274113292 lavc/cafenc: Allow QDMC muxing. 2016-06-19 18:51:39 +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
Marton Balint 28fbdece79 avformat: use ff_standardize_creation_time for formats writing all format string metadata
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2016-03-03 01:37:18 +01:00
Michael Niedermayer b480f0e37a avformat/cafenc: Move special casing of PCM codecs into ff_codec_caf_tags
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-07 01:21:12 +02:00
Carl Eugen Hoyos 1acb5ca02a Improve frame size calculation in caf muxer to fix adpcm_ms remuxing.
Fixes ticket #3645.
2014-05-30 07:26:18 +02:00
Carl Eugen Hoyos 2d56f0d054 Write the actual mp3 frame size when muxing into caf if available.
Fixes ticket #3648.
2014-05-26 20:28:07 +02:00
Carl Eugen Hoyos 4c49d0824a Fix alaw and mulaw muxing in caf.
Fixes ticket #3644.
2014-05-17 11:38:17 +02:00
Carl Eugen Hoyos 18e7e21e2f Enable muxing ac-3 in caf.
The files play fine with QuickTime.
2014-04-24 18:02:20 +02:00
Carl Eugen Hoyos fb5518cfb7 Force one stream in caf muxer.
Based on eeb975f5
2013-12-13 11:57:39 +01:00
Carl Eugen Hoyos 7f1b3c2ca6 Fix muxing QDM2 mono into caf. 2013-06-28 09:04:16 +02:00
Paul B Mahol c46400ddec cafenc: do not leak caf->pkt_sizes
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-02-22 13:52:43 +00:00
Paul B Mahol 9ef29af2e8 cafenc: do not include riff.h
ff_codec_get_tag() was moved to internal.h

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2012-12-05 20:44:28 +00:00
Carl Eugen Hoyos a5d4e94a97 Support iLBC in caf. 2012-11-19 10:19:50 +01:00
Paul B Mahol 7fe6f6e2b1 caf muxer: write metadata
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2012-10-26 03:12:45 +00:00
Paul B Mahol 73f9d2e887 cafenc: make .long_name match demuxer
While here reindent .codec_tag .

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2012-10-25 23:04:13 +00:00
Michael Niedermayer bb2f13c19f rename missed CodecID to AVCodecID
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-07 23:57:21 +02:00
Michael Niedermayer 7a72695c05 Merge commit '36ef5369ee9b336febc2c270f8718cec4476cb85'
* commit '36ef5369ee9b336febc2c270f8718cec4476cb85':
  Replace all CODEC_ID_* with AV_CODEC_ID_*
  lavc: add AV prefix to codec ids.

Conflicts:
	doc/APIchanges
	doc/examples/decoding_encoding.c
	doc/examples/muxing.c
	ffmpeg.c
	ffprobe.c
	ffserver.c
	libavcodec/8svx.c
	libavcodec/avcodec.h
	libavcodec/dnxhd_parser.c
	libavcodec/dvdsubdec.c
	libavcodec/error_resilience.c
	libavcodec/h263dec.c
	libavcodec/libvorbisenc.c
	libavcodec/mjpeg_parser.c
	libavcodec/mjpegenc.c
	libavcodec/mpeg12.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/pcm.c
	libavcodec/r210dec.c
	libavcodec/utils.c
	libavcodec/v210dec.c
	libavcodec/version.h
	libavdevice/alsa-audio-dec.c
	libavdevice/bktr.c
	libavdevice/v4l2.c
	libavformat/asfdec.c
	libavformat/asfenc.c
	libavformat/avformat.h
	libavformat/avidec.c
	libavformat/caf.c
	libavformat/electronicarts.c
	libavformat/flacdec.c
	libavformat/flvdec.c
	libavformat/flvenc.c
	libavformat/framecrcenc.c
	libavformat/img2.c
	libavformat/img2dec.c
	libavformat/img2enc.c
	libavformat/ipmovie.c
	libavformat/isom.c
	libavformat/matroska.c
	libavformat/matroskadec.c
	libavformat/matroskaenc.c
	libavformat/mov.c
	libavformat/movenc.c
	libavformat/mp3dec.c
	libavformat/mpeg.c
	libavformat/mpegts.c
	libavformat/mxf.c
	libavformat/mxfdec.c
	libavformat/mxfenc.c
	libavformat/nsvdec.c
	libavformat/nut.c
	libavformat/oggenc.c
	libavformat/pmpdec.c
	libavformat/rawdec.c
	libavformat/rawenc.c
	libavformat/riff.c
	libavformat/sdp.c
	libavformat/utils.c
	libavformat/vocenc.c
	libavformat/wtv.c
	libavformat/xmv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-07 22:45:46 +02:00
Paul B Mahol a6ef7b3a77 cafenc: replace deprecated av_dbl2int() 2012-01-23 17:18:13 +01:00
Paul B Mahol ba10207bbe Use more designated initializers.
Also remove some pointless NULL/0 assigments.

C++ code must be left as it is because named struct
initializers are not supported by C++ standard.
2011-12-30 20:00:53 +01:00
Carl Eugen Hoyos 05a267305d Support more codecs when muxing caf. 2011-08-22 09:35:58 +02:00
Carl Eugen Hoyos ef25e70de3 Stream-copying PureVoice into caf works fine. 2011-08-21 14:52:48 +02:00
Carl Eugen Hoyos 9b60b076fb Support muxing MP1, MP2 and MP3 in caf. 2011-08-01 00:58:49 +02:00
Carl Eugen Hoyos c6e0332f30 Explicitely fail for unsupported codecs when muxing caf. 2011-08-01 00:58:49 +02:00
Carl Eugen Hoyos b35477a2f2 Use av_get_bits_per_sample() for mBitsPerChannel in caf. 2011-08-01 00:58:49 +02:00
Carl Eugen Hoyos 88084eecdf Use little endian for caf codec tags. 2011-07-24 23:52:42 +02:00
Carl Eugen Hoyos 45ecc7a294 Support adpcm_ima_wav and adpcm_ms in caf. 2011-07-12 17:35:20 +02:00
Carl Eugen Hoyos 43e96d0466 Support gsm_ms in caf files. 2011-07-09 17:13:13 +02:00
Michael Niedermayer 976a8b2179 Merge remote-tracking branch 'qatar/master'
* qatar/master: (40 commits)
  H.264: template left MB handling
  H.264: faster fill_decode_caches
  H.264: faster write_back_*
  H.264: faster fill_filter_caches
  H.264: make filter_mb_fast support the case of unavailable top mb
  Do not include log.h in avutil.h
  Do not include pixfmt.h in avutil.h
  Do not include rational.h in avutil.h
  Do not include mathematics.h in avutil.h
  Do not include intfloat_readwrite.h in avutil.h
  Remove return statements following infinite loops without break
  RTSP: Doxygen comment cleanup
  doxygen: Escape '\' in Doxygen documentation.
  md5: cosmetics
  md5: use AV_WL32 to write result
  md5: add fate test
  md5: include correct headers
  md5: fix test program
  doxygen: Drop array size declarations from Doxygen parameter names.
  doxygen: Fix parameter names to match the function prototypes.
  ...

Conflicts:
	libavcodec/x86/dsputil_mmx.c
	libavformat/flvenc.c
	libavformat/oggenc.c
	libavformat/wtv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-07-04 00:45:21 +02:00
Carl Eugen Hoyos 6d721f714e Fix ff_mov_write_chan() so it can be used by other muxers. 2011-05-17 01:47:12 +02:00
Carl Eugen Hoyos 2c4ad1a37b Initial caf muxer. 2011-05-15 03:25:57 +02:00