Commit Graph

23 Commits

Author SHA1 Message Date
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
Andreas Rheinhardt ba49acf143 avformat/mux_utils: Move ff_format_shift_data to new file for mux utils
It is only used by muxers. Given that it is not part of
the core muxing code and given that mux.c is already big enough,
it is moved to a new file for utility functions for muxing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:29:15 +02:00
Vittorio Giovara 525ccbe8f1 segafilm: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:37 -03:00
Marton Balint 26d6c81dc6 avformat/segafilmenc: use ff_format_shift_data for shifting
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-01-03 22:54:12 +01: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 37f5feccc6 avformat/segafilmenc: Avoid seek when writing header
Up until now, the Sega FILM muxer would first write all the packet data,
then shift the data (in the muxer's write_trailer function) by the amount
necessary to write the header at the front (which entails a seek to the
front), then seek back to the beginning and actually write the header.

This commit changes this: The dynamic buffer that is used to write the
sample table (containing information about each sample in the file) is
now used to write the complete header. This is possible because the size
of everything in the header except the sample table is known in advance.
Said buffer can then be used as one of the two temporary buffers used
for shifting which also reduces the amount one has to allocate for this.
Thereby the header will be written when shifting, so that the second
seek to the beginning is unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 17:10:06 +02:00
Andreas Rheinhardt 8a3329ffba avformat/segafilmenc: Don't store packet info in linked list
Up until now, the Sega FILM muxer would store some information about
each packet in a linked list. When writing the trailer, the information
in said linked list would be used to write a table in the file header.
Each entry in said table is 16 bytes long, but each entry of the linked
list is 32 bytes long (assuming 64 bit pointer and no padding).
Therefore it makes sense to remove the linked list and write the array
entries directly into a dynamic buffer while writing the packet (this is
possible because the table entries don't depend on any information not
available when writing the packet (the offset is not relative to the
beginning of the file, but to the end of the table). This also
simplifies writing the array at the end (there is no need to traverse a
linked list).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 17:02:24 +02:00
Andreas Rheinhardt 37ec33f42c avformat/segafilmenc: Simplify writing two bytes
Use avio_wb16() instead of avio_write() to write two zero bytes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 17:01:16 +02:00
Andreas Rheinhardt f71116deb5 avformat/segafilmenc: Remove write-only variable
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:59:32 +02:00
Andreas Rheinhardt da304e78b5 avformat/segafilmenc: Add deinit function
Prevents memleaks when the trailer is never written or when shifting the
data fails when writing the trailer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-02-25 19:57:16 +01:00
Andreas Rheinhardt ab44f0aee8 avformat/segafilmenc: Combine several checks
by moving them around.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-02-25 19:57:16 +01:00
Andreas Rheinhardt c790500644 avformat/segafilmenc: Remove redundant checks
If an audio stream is present, the Sega FILM muxer checks for its
compability with the container during init, so that the very same check
needn't be repeated during writing the trailer.

Essentially the same is true for the presence of a video stream: It has
already been checked during init. Furthermore, after the check for the
presence of a video stream succeeded, a pointer is set to point to the
video stream. Yet said pointer (which was NULL before) will be
derefenced anyway regardless of the result of the check. Coverity thus
complained about this in CID 1434155 and removing this pointless check
will also fix this issue.

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>
2020-02-22 20:45:45 +01:00
Andreas Rheinhardt 7b7b418277 avformat/segafilmenc: Remove AVClass
This muxer does not have any private options and so does not need a
private class.

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>
2020-02-15 22:11:56 +01:00
Andreas Rheinhardt 61e0d71946 avformat/movenc, segafilmenc: Remove unnecessary avio_tell()
When the faststart option for the mov/mp4 muxer is used, the current
position (i.e. the size of the already written data pre-shifting) was
evaluated twice: First in an initialization and then again later,
overwriting the first value without having ever touched it. So remove
the initialization.

Also, the clone of this code in the Sega FILM muxer behaves the same and
has been treated the same.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-01-17 20:17:55 +01:00
Andreas Rheinhardt 56a04b7c38 avformat/segafilmenc: Check early whether video is allowed
The current code only checks when writing the trailer whether the video
format and Codec ID are actually compatible with the container. At this
point, a lot of data will already have been written (in vain, of
course), so check during the init function instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-01-14 23:00:35 +01:00
Andreas Rheinhardt 30859c270f avformat/segafilmenc: Postpone check for existence of video stream
Up until now, the Sega FILM muxer complained if the first stream wasn't a
video stream that there is no video stream at all which is of course
nonsense. So postpone this check.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-01-14 23:00:35 +01:00
Andreas Rheinhardt 8ae026d74f avformat/segafilmenc: Fix undefined left shift of 1 by 31 places
by changing the type to unsigned.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-01-14 23:00:35 +01:00
Marton Balint f4a8ea7ff6 avformat: remove more unneeded avio_flush() calls
These instances are simply redundant or present because avio_flush() used to be
required before doing a seekback. That is no longer the case, aviobuf code does
the flush automatically on seek.

This only affects code which is either disabled for streaming IO contexts or
does no seekbacks after the flush, so this change should have no adverse effect
on streaming.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-07 21:51:45 +01:00
Steven Liu d92b2296f8 avformat/segafilmenc: remove unneeded code
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-10-22 10:51:30 +08:00
Gyan Doshi 0683ad709b avformat/segafilmenc - set keyframe bit correctly
As per
https://web.archive.org/web/20020803104640/http://www.pcisys.net:80/~melanson/codecs/film-format.txt,

the top bit of the info1 chunk is set as 1 for inter-coded frames and 0
otherwise.
2018-05-08 13:29:15 +05:30
Carl Eugen Hoyos 4d1d7263d8 lavf/segafilmenc: Do not mix variable declaration and code.
Fixes two warnings: ISO C90 forbids mixed declarations and code
2018-04-10 00:50:01 +02:00
Misty De Meo 187ff5a108 Add Sega FILM muxer
Signed-off-by: Josh de Kock <josh@itanimul.li>
2018-04-05 22:04:30 +01:00