Commit Graph

110 Commits

Author SHA1 Message Date
Andreas Rheinhardt 073251316e avformat: Make init function out of write_header functions if possible
Also mark them as av_cold while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:20 +01:00
Andreas Rheinhardt a24bccc238 avformat/mux: Add flag for "only default codecs allowed"
AVOutputFormat has default codecs for audio, video and subtitle
and often these are the only codecs of this type allowed.
So add a flag to AVOutputFormat so that this can be checked generically.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:19 +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
Anton Khirnov 08bebeb1be Revert "all: Don't set AVClass.item_name to its default value"
Some callers assume that item_name is always set, so this may be
considered an API break.

This reverts commit 0c6203c97a.
2024-01-20 10:34:48 +01:00
Andreas Rheinhardt 0c6203c97a all: Don't set AVClass.item_name to its default value
Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9;
also avoids relocations.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-12-22 15:12:33 +01:00
Paul B Mahol ff72256235 avformat/gif: use last frame duration 2023-05-20 13:06:38 +02: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
Andreas Rheinhardt d5a0eba8a2 av(format|device): Add const to muxer packet data pointers
The packets given to muxers need not be writable,
so it is best to access them via const uint8_t*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-09 19:37:53 +02:00
Andreas Rheinhardt 2934a4b9a5 Remove unnecessary avassert.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:30 +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
Paul B Mahol 02333fe394 avformat/gif: abort early if nothing was written yet
Fixes crash when writting trailer without any previous packets.
2019-05-29 10:57:18 +02:00
Paul B Mahol 280b432464 avformat/gif: extend description 2018-12-13 18:58:48 +01:00
Paul B Mahol faca28c264 avcodec: rewrite gif muxing and encoding
Now "-c copy" works.
Update FATE files.

Demuxer only split file into packets, no data is trimmed.
Encoder & muxer currently expect completely another format
where muxer writes stuff like disposal method which should
be really encoder job.
With this patch muxer only modifies delay between two packets.
Codec copy need to have same behavior between demuxer and
muxer to work correctly.

Fixes #6640.
2018-12-13 18:58:48 +01:00
Paul B Mahol 6a20876b62 avformat/gif: simplify signature writing 2018-12-10 21:13:15 +01:00
James Almer a447b75de8 avformat: replace all uses of av_copy_packet()
Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-25 21:26:38 -03:00
James Almer afe674734b avformat/gif: use av_packet_alloc()
Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-23 02:18:47 -03: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
Hendrik Leppkes c2f861ca42 Replace remaining occurances of av_free_packet with av_packet_unref 2015-10-27 14:35:30 +01: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
Clément Bœsch 5f9986f597 avformat/gif: use first packet palette as global for PAL8
This will allow the payload in PAL8 packets to not contain 768B of local
palette (which is not LZW compressed).
2015-02-14 20:48:50 +01:00
Clément Bœsch adb9b235b6 avformat/gif: simplify gif_image_write_header() prototype 2015-02-14 20:48:50 +01:00
Diego Biurrun daf8cf358a avformat: Don't anonymously typedef structs 2015-02-14 10:13:47 -08:00
Carl Eugen Hoyos 87f2999641 Force gif aspect ratio multiplication to 64bit.
Avoids a possible integer overflow.
2014-04-05 01:13:47 +02:00
Carl Eugen Hoyos 45782a98b6 Write aspect ratio when muxing gif. 2014-04-02 09:49:30 +02:00
Clément Bœsch c37b0daf33 avformat/gif: fix final_delay unit in documentation. 2013-11-07 20:30:43 +01:00
Clément Bœsch 7308439158 lavf: Don't explicitly flush after each written packet in muxers
Since 596e5d4783, this is not necessary anymore. It also allows to
actually disable the flushing, improving write performance (but
possibly giving worse latency in real-time streaming).

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-09-16 22:17:33 +03:00
Eugene Dzhurinsky 09f59d6adf avformat/gif: Do not write GIF89a header if loop is set to -1.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-10 01:18:59 +02:00
Michael Niedermayer 8870cf7c0e avformat/gif: remove unneeded doxygen comment
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-24 15:36:54 +02:00
Clément Bœsch 67cc31d6c7 lavf/gif: add final_delay option. 2013-04-20 00:11:04 +02:00
Clément Bœsch 6189ff3679 lavf/gif: avoid forward declaration. 2013-04-19 12:11:10 +02:00
Clément Bœsch a7c5b7a676 lavf/gif: correct the delay after the first frame.
To define accurately the delay between two frames, it is necessary to
have both available. Before this commit, the first frame had a delay of
0; while in practice the problem is not visible in most situation, it is
problematic with low frame rate and large scene change.

This commit notably fixes output generated with commands such as:

  ffmpeg -i big_buck_bunny_1080p_h264.mov
     -vf "select='gt(scene,0.4)',scale=320:-1,setpts=N/TB"
     -frames:v 5 -y out.gif

Also, to avoid odd loop delays, the N-1 delay is duplicated for the last
frame.
2013-04-19 12:02:19 +02:00
Clément Bœsch 7e57adb464 lavf/gif: fix timing.
pkt->duration can not be used since the values are only based on frame
rate.
2013-04-19 02:15:57 +02:00
Clément Bœsch 13478b270a gif: use only one graphic control extension block per image.
The encoder now doesn't produce any extra graphic control extension
block anymore. Only the image is encoded, and the muxer writing
its own GCE containing notably the timing information now includes the
optional palette transmitted through packet side data.

This commit avoid setting clashes between the two GCE, and reduce the
size of the generated file with pal8 output.
2013-04-19 02:10:59 +02:00
Clément Bœsch 9db1c6455e lavf/gif: support only GIF codec. 2013-04-18 13:53:47 +02:00
Clément Bœsch 01367b0fca lavf/gif: merge gif_write_{packet,video}.
Avoid a pointless split.
2013-04-18 13:42:26 +02:00
Clément Bœsch b7a3f14360 lavf/gif: trim unnecessarily long netscape ext code.
Extension description comments are now placed along the avio calls, the
always defined macro removed, and the always true loop_count check as
well (loop option is bound to 0-65535).
2013-04-18 13:42:14 +02:00
Clément Bœsch 0a0e6877ff lavf/gif: remove unused fields. 2013-04-18 13:40:45 +02:00
Clément Bœsch 28f9858c91 lavf/gif: simplify streams type checking. 2013-04-18 13:40:45 +02:00
Clément Bœsch b6408ffc45 lavf/gif: fix assert in avio API after dfb3231. 2013-04-18 01:13:17 +02:00
Clément Bœsch 91a5b4d480 gif: remove outdated comments. 2013-04-18 00:43:38 +02:00
Clément Bœsch dfb323109c lavf/gif: simplify palette writing. 2013-04-18 00:24:25 +02:00
Clément Bœsch 7b972d82b6 gif: reindent after previous commits. 2013-04-18 00:24:25 +02:00
Clément Bœsch 635389ccfa Cleanse GIF muxer and encoder.
This commit removes the badly duplicated code between the encoder and
the muxer. That may sound surprising, but the encoder is now responsible
from the encoding of the picture when muxing to a .gif file. It also
does not require anymore a manual user intervention such as a -pix_fmt
rgb24 to work properly. To summarize, output gif are now easier to
generate, code is saner and simpler, and files are smaller (thanks to
the lzw encoding which was unused so far with the default .gif output).
We can certainly make things even better, but this is the first step.

FATE is updated because of the output being produced by the encoder and
not the muxer (no lzw in the muxer), and in the seek test only the size
mismatches.

Fixes Ticket #2262
2013-04-18 00:24:25 +02:00
Clément Bœsch 8de9bb6e5e lavf: remove some flushing in write_packet muxers callbacks.
Since 4f112a8e3, this is not necessary anymore. Also, it allows to
actually disable the flushing.
2013-04-14 21:16:53 +02:00
Michael Niedermayer 580a0600ef Merge remote-tracking branch 'qatar/master'
* qatar/master:
  Move misplaced file author information where it belongs

Conflicts:
	libavcodec/adpcm.c
	libavcodec/adpcmenc.c
	libavcodec/gif.c
	libavcodec/x86/dsputilenc_mmx.c
	libavcodec/x86/fmtconvert_init.c
	libavformat/au.c
	libavformat/gif.c
	libavformat/mov.c
	libavformat/nsvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-11 15:56:18 +02:00
Diego Biurrun ac9362c5d9 Move misplaced file author information where it belongs 2013-04-11 02:42:11 +02:00
Michael Niedermayer ac627b3d38 Merge commit '716d413c13981da15323c7a3821860536eefdbbb'
* commit '716d413c13981da15323c7a3821860536eefdbbb':
  Replace PIX_FMT_* -> AV_PIX_FMT_*, PixelFormat -> AVPixelFormat

Conflicts:
	doc/examples/muxing.c
	ffmpeg.h
	ffmpeg_filter.c
	ffmpeg_opt.c
	ffplay.c
	ffprobe.c
	libavcodec/8bps.c
	libavcodec/aasc.c
	libavcodec/aura.c
	libavcodec/avcodec.h
	libavcodec/avs.c
	libavcodec/bfi.c
	libavcodec/bmp.c
	libavcodec/bmpenc.c
	libavcodec/c93.c
	libavcodec/cscd.c
	libavcodec/cyuv.c
	libavcodec/dpx.c
	libavcodec/dpxenc.c
	libavcodec/eatgv.c
	libavcodec/escape124.c
	libavcodec/ffv1.c
	libavcodec/flashsv.c
	libavcodec/fraps.c
	libavcodec/h264.c
	libavcodec/huffyuv.c
	libavcodec/iff.c
	libavcodec/imgconvert.c
	libavcodec/indeo3.c
	libavcodec/kmvc.c
	libavcodec/libopenjpegdec.c
	libavcodec/libopenjpegenc.c
	libavcodec/libx264.c
	libavcodec/ljpegenc.c
	libavcodec/mjpegdec.c
	libavcodec/mjpegenc.c
	libavcodec/motionpixels.c
	libavcodec/mpeg12.c
	libavcodec/mpeg12enc.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo_enc.c
	libavcodec/pamenc.c
	libavcodec/pcxenc.c
	libavcodec/pgssubdec.c
	libavcodec/pngdec.c
	libavcodec/pngenc.c
	libavcodec/pnm.c
	libavcodec/pnmdec.c
	libavcodec/pnmenc.c
	libavcodec/ptx.c
	libavcodec/qdrw.c
	libavcodec/qpeg.c
	libavcodec/qtrleenc.c
	libavcodec/raw.c
	libavcodec/rawdec.c
	libavcodec/rl2.c
	libavcodec/sgidec.c
	libavcodec/sgienc.c
	libavcodec/snowdec.c
	libavcodec/snowenc.c
	libavcodec/sunrast.c
	libavcodec/targa.c
	libavcodec/targaenc.c
	libavcodec/tiff.c
	libavcodec/tiffenc.c
	libavcodec/tmv.c
	libavcodec/truemotion2.c
	libavcodec/utils.c
	libavcodec/vb.c
	libavcodec/vp3.c
	libavcodec/wnv1.c
	libavcodec/xl.c
	libavcodec/xwddec.c
	libavcodec/xwdenc.c
	libavcodec/yop.c
	libavdevice/v4l2.c
	libavdevice/x11grab.c
	libavfilter/avfilter.c
	libavfilter/avfilter.h
	libavfilter/buffersrc.c
	libavfilter/drawutils.c
	libavfilter/formats.c
	libavfilter/src_movie.c
	libavfilter/vf_ass.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_fade.c
	libavfilter/vf_format.c
	libavfilter/vf_hflip.c
	libavfilter/vf_lut.c
	libavfilter/vf_overlay.c
	libavfilter/vf_pad.c
	libavfilter/vf_scale.c
	libavfilter/vf_transpose.c
	libavfilter/vf_yadif.c
	libavfilter/video.c
	libavfilter/vsrc_testsrc.c
	libavformat/movenc.c
	libavformat/mxf.h
	libavformat/utils.c
	libavformat/yuv4mpeg.c
	libavutil/imgutils.c
	libavutil/pixdesc.c
	libswscale/input.c
	libswscale/output.c
	libswscale/swscale_internal.h
	libswscale/swscale_unscaled.c
	libswscale/utils.c
	libswscale/x86/swscale_template.c
	libswscale/x86/yuv2rgb.c
	libswscale/x86/yuv2rgb_template.c
	libswscale/yuv2rgb.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-08 21:06:57 +02:00
Anton Khirnov 716d413c13 Replace PIX_FMT_* -> AV_PIX_FMT_*, PixelFormat -> AVPixelFormat 2012-10-08 07:13:26 +02:00
Michael Niedermayer f276a490f0 Merge commit '3f7fd59d151a2773f0e2e93e56b6b13ec6e5334b'
* commit '3f7fd59d151a2773f0e2e93e56b6b13ec6e5334b':
  avformat: fix typo in avformat_close_input
  mp3enc: write Xing TOC
  mp3enc: support MPEG-2 and MPEG-2.5 in Xing header.
  mp3enc: downgrade some errors in writing Xing frame to warnings
  lavf: flush the output AVIOContext in av_write_trailer().
  lavf: cosmetics, reformat av_write_trailer().
  avio: flush the internal buffer in avio_close()
  Enhance doc on asyncts audiofilter
  cmdutils: avoid setting data pointers to invalid values in alloc_buffer()
  libavcodec: remove av_destruct_packet_nofree()

Conflicts:
	libavcodec/avpacket.c
	libavformat/mp3enc.c
	libavformat/nutenc.c
	libavformat/utils.c
	libavformat/version.h
	tests/ref/lavf/voc
	tests/ref/lavf/voc_s16

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-16 14:24:11 +02:00