Commit 4a485daa authored by Hendrik Leppkes's avatar Hendrik Leppkes

Merge commit '4f7723cb'

* commit '4f7723cb':
  movenc: Add an option for skipping writing the mfra/tfra/mfro trailer
Merged-by: 's avatarHendrik Leppkes <h.leppkes@gmail.com>
parents 55a424c5 4f7723cb
......@@ -72,6 +72,7 @@ static const AVOption options[] = {
{ "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "skip_trailer", "Skip writing the mfra/tfra/mfro trailer for fragmented files", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_TRAILER}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
{ "skip_iods", "Skip writing iods atom.", offsetof(MOVMuxContext, iods_skip), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
{ "iods_audio_profile", "iods audio profile atom.", offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM},
......@@ -3934,6 +3935,20 @@ static int mov_add_tfra_entries(AVIOContext *pb, MOVMuxContext *mov, int tracks,
return 0;
}
static void mov_prune_frag_info(MOVMuxContext *mov, int tracks, int max)
{
int i;
for (i = 0; i < mov->nb_streams; i++) {
MOVTrack *track = &mov->tracks[i];
if ((tracks >= 0 && i != tracks) || !track->entry)
continue;
if (track->nb_frag_info > max) {
memmove(track->frag_info, track->frag_info + (track->nb_frag_info - max), max * sizeof(*track->frag_info));
track->nb_frag_info = max;
}
}
}
static int mov_write_tfdt_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
......@@ -4119,8 +4134,16 @@ static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks,
if (mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX))
mov_write_sidx_tags(pb, mov, tracks, moof_size + 8 + mdat_size);
if ((ret = mov_add_tfra_entries(pb, mov, tracks, moof_size + 8 + mdat_size)) < 0)
return ret;
if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX ||
!(mov->flags & FF_MOV_FLAG_SKIP_TRAILER) ||
mov->ism_lookahead) {
if ((ret = mov_add_tfra_entries(pb, mov, tracks, moof_size + 8 + mdat_size)) < 0)
return ret;
if (!(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX) &&
mov->flags & FF_MOV_FLAG_SKIP_TRAILER) {
mov_prune_frag_info(mov, tracks, mov->ism_lookahead + 1);
}
}
return mov_write_moof_tag_internal(pb, mov, tracks, moof_size);
}
......@@ -6150,7 +6173,7 @@ static int mov_write_trailer(AVFormatContext *s)
avio_seek(pb, end, SEEK_SET);
avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
mov_write_mfra_tag(pb, mov);
} else {
} else if (!(mov->flags & FF_MOV_FLAG_SKIP_TRAILER)) {
avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
mov_write_mfra_tag(pb, mov);
}
......
......@@ -240,6 +240,7 @@ typedef struct MOVMuxContext {
#define FF_MOV_FLAG_WRITE_COLR (1 << 15)
#define FF_MOV_FLAG_WRITE_GAMA (1 << 16)
#define FF_MOV_FLAG_USE_MDTA (1 << 17)
#define FF_MOV_FLAG_SKIP_TRAILER (1 << 18)
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment