aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-09-18 13:23:36 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-09-18 13:32:55 +0200
commitb7e7d8cdaf3aafd9b79daa8f6ed827d05e3f8548 (patch)
treefe49680e5686614c81dc0b959372f1c7c042d1db /libavformat
parent394a73cad2ed0933a68f10ee720a641c7192fa15 (diff)
parente7bf085b78586a04b918f4e76587779d04674700 (diff)
downloadffmpeg-b7e7d8cdaf3aafd9b79daa8f6ed827d05e3f8548.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: movenc: Add an option for omitting the tfhd base offset Conflicts: libavformat/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/movenc.c23
-rw-r--r--libavformat/movenc.h1
-rw-r--r--libavformat/version.h2
3 files changed, 18 insertions, 8 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 763a43ec99..276138c118 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -53,6 +53,7 @@ static const AVOption options[] = {
{ "frag_custom", "Flush fragments on caller requests", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_CUSTOM}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "isml", "Create a live smooth streaming feed (for pushing to a publishing point)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_ISML}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "faststart", "Run a second pass to put the index (moov atom) at the beginning of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FASTSTART}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+ { "omit_tfhd_offset", "Omit the base data offset in tfhd atoms", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_OMIT_TFHD_OFFSET}, 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_INT, {.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},
@@ -2511,8 +2512,8 @@ static int mov_write_mfhd_tag(AVIOContext *pb, MOVMuxContext *mov)
return 0;
}
-static int mov_write_tfhd_tag(AVIOContext *pb, MOVTrack *track,
- int64_t moof_offset)
+static int mov_write_tfhd_tag(AVIOContext *pb, MOVMuxContext *mov,
+ MOVTrack *track, int64_t moof_offset)
{
int64_t pos = avio_tell(pb);
uint32_t flags = MOV_TFHD_DEFAULT_SIZE | MOV_TFHD_DEFAULT_DURATION |
@@ -2522,6 +2523,8 @@ static int mov_write_tfhd_tag(AVIOContext *pb, MOVTrack *track,
} else {
flags |= MOV_TFHD_DEFAULT_FLAGS;
}
+ if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET)
+ flags &= ~MOV_TFHD_BASE_DATA_OFFSET;
/* Don't set a default sample size, the silverlight player refuses
* to play files with that set. Don't set a default sample duration,
@@ -2566,7 +2569,8 @@ static uint32_t get_sample_flags(MOVTrack *track, MOVIentry *entry)
(MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES | MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC);
}
-static int mov_write_trun_tag(AVIOContext *pb, MOVTrack *track, int moof_size)
+static int mov_write_trun_tag(AVIOContext *pb, MOVMuxContext *mov,
+ MOVTrack *track, int moof_size)
{
int64_t pos = avio_tell(pb);
uint32_t flags = MOV_TRUN_DATA_OFFSET;
@@ -2591,8 +2595,13 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVTrack *track, int moof_size)
avio_wb24(pb, flags);
avio_wb32(pb, track->entry); /* sample count */
- avio_wb32(pb, moof_size + 8 + track->data_offset +
- track->cluster[0].pos); /* data offset */
+ if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET &&
+ !(mov->flags & FF_MOV_FLAG_SEPARATE_MOOF) &&
+ track->track_id != 1)
+ avio_wb32(pb, 0); /* Later tracks follow immediately after the previous one */
+ else
+ avio_wb32(pb, moof_size + 8 + track->data_offset +
+ track->cluster[0].pos); /* data offset */
if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS)
avio_wb32(pb, get_sample_flags(track, &track->cluster[0]));
@@ -2687,8 +2696,8 @@ static int mov_write_traf_tag(AVIOContext *pb, MOVMuxContext *mov,
avio_wb32(pb, 0); /* size placeholder */
ffio_wfourcc(pb, "traf");
- mov_write_tfhd_tag(pb, track, moof_offset);
- mov_write_trun_tag(pb, track, moof_size);
+ mov_write_tfhd_tag(pb, mov, track, moof_offset);
+ mov_write_trun_tag(pb, mov, track, moof_size);
if (mov->mode == MODE_ISM) {
mov_write_tfxd_tag(pb, track);
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index a54646fea6..b98c7f768a 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -182,6 +182,7 @@ typedef struct MOVMuxContext {
#define FF_MOV_FLAG_FRAG_CUSTOM 32
#define FF_MOV_FLAG_ISML 64
#define FF_MOV_FLAG_FASTSTART 128
+#define FF_MOV_FLAG_OMIT_TFHD_OFFSET 256
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
diff --git a/libavformat/version.h b/libavformat/version.h
index e7d9417b9c..fb82f3483d 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 55
-#define LIBAVFORMAT_VERSION_MINOR 17
+#define LIBAVFORMAT_VERSION_MINOR 18
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \