31 "<tt xml:lang=\"\" xmlns=\"http://www.w3.org/ns/ttml\" />";
53 ttml_stream->time_base = movenc_stream->
time_base;
67 for (
unsigned int i = 0;
i <
s->nb_streams;
i++) {
73 if (track == other_track ||
76 !other_track->
entry) {
90 *start_pts = picked_start;
91 else if (picked_start >= track->
end_pts)
92 *start_pts =
FFMIN(*start_pts, picked_start);
94 max_track_end_dts =
FFMAX(max_track_end_dts, picked_end);
97 *end_pts = max_track_end_dts;
111 unsigned int time_limited = 0;
117 start_ts = *out_start_ts;
118 end_ts = *out_start_ts + *out_duration;
131 if (
pkt->pts +
pkt->duration < start_ts) {
135 "Very late TTML packet in queue, dropping packet with "
136 "pts: %"PRId64
", duration: %"PRId64
"\n",
140 }
else if (
pkt->pts >= end_ts) {
152 if (
pkt->pts < start_ts) {
153 pkt->duration -= start_ts -
pkt->pts;
157 if (
pkt->pts +
pkt->duration > end_ts) {
182 "TTML packet writeout: pts: %"PRId64
" (%"PRId64
"), "
183 "duration: %"PRId64
"\n",
184 pkt->pts,
pkt->pts - start_ts,
pkt->duration);
185 if (
pkt->pts != pts_before ||
pkt->duration != duration_before) {
187 "Adjustments: pts: %"PRId64
", duration: %"PRId64
"\n",
188 pkt->pts - pts_before,
pkt->duration - duration_before);
194 pkt->dts =
pkt->pts = (
pkt->pts - start_ts);
197 pkt->stream_index = 0;
212 *out_start_ts = start_ts;
213 *out_duration = end_ts - start_ts;
260 start_ts = calculated_start;
261 duration = calculated_end - calculated_start;
263 "Calculated subtitle fragment start: %"PRId64
", "
264 "duration: %"PRId64
"\n",
277 goto generate_packet;
284 "Failed to generate a squashed TTML packet from the packet "
299 "Failed to create a TTML AVPacket from AVIO data: %s\n",
305 pkt->pts =
pkt->dts = start_ts;
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
#define i(width, name, range_min, range_max)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
static av_cold void cleanup(FlashSV2Context *s)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
Initialize a reference-counted packet from av_malloc()ed data.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
Convert valid timing fields (timestamps / durations) in a packet from one timebase to another.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
av_warn_unused_result int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define MOV_ISMV_TTML_TAG
Memory handling functions.
#define FF_MOV_FLAG_FRAGMENT
static int mov_init_ttml_writer(MOVTrack *track, AVFormatContext **out_ctx)
static int mov_write_ttml_document_from_queue(AVFormatContext *s, AVFormatContext *ttml_ctx, MOVTrack *track, AVPacket *pkt, int64_t *out_start_ts, int64_t *out_duration)
static const unsigned char empty_ttml_document[]
static void mov_calculate_start_and_end_of_other_tracks(AVFormatContext *s, MOVTrack *track, int64_t *start_pts, int64_t *end_pts)
int ff_mov_generate_squashed_ttml_packet(AVFormatContext *s, MOVTrack *track, AVPacket *pkt)
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
AVIOContext * pb
I/O context.
AVStream ** streams
A list of all streams in the file.
This structure stores compressed data.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
PacketList squashed_packet_queue
unsigned int squash_fragment_samples_to_one