From d3b8bde2f14f78109a892e57f544bf840cf6d4fc Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Tue, 4 Oct 2011 11:44:25 -0700 Subject: movenc: Rudimentary IODs support. --- libavformat/movenc.c | 39 ++++++++++++++++++++++++++++----------- libavformat/movenc.h | 3 +++ 2 files changed, 31 insertions(+), 11 deletions(-) (limited to 'libavformat') diff --git a/libavformat/movenc.c b/libavformat/movenc.c index d1076c34c4..0463528362 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -46,6 +46,9 @@ static const AVOption options[] = { { "movflags", "MOV muxer flags", offsetof(MOVMuxContext, flags), AV_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, { "rtphint", "Add RTP hint tracks", 0, AV_OPT_TYPE_CONST, {.dbl = FF_MOV_FLAG_RTP_HINT}, 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, {.dbl = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, + { "iods_audio_profile", "iods audio profile atom.", offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.dbl = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM}, + { "iods_video_profile", "iods video profile atom.", offsetof(MOVMuxContext, iods_video_profile), AV_OPT_TYPE_INT, {.dbl = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM}, { NULL }, }; @@ -1407,21 +1410,34 @@ static int mov_write_trak_tag(AVIOContext *pb, MOVTrack *track, AVStream *st) return updateSize(pb, pos); } -#if 0 -/* TODO: Not sorted out, but not necessary either */ static int mov_write_iods_tag(AVIOContext *pb, MOVMuxContext *mov) { - avio_wb32(pb, 0x15); /* size */ + int i, has_audio = 0, has_video = 0; + int64_t pos = avio_tell(pb); + int audio_profile = mov->iods_audio_profile; + int video_profile = mov->iods_video_profile; + for (i = 0; i < mov->nb_streams; i++) { + if(mov->tracks[i].entry > 0) { + has_audio |= mov->tracks[i].enc->codec_type == AVMEDIA_TYPE_AUDIO; + has_video |= mov->tracks[i].enc->codec_type == AVMEDIA_TYPE_VIDEO; + } + } + if (audio_profile < 0) + audio_profile = 0xFF - has_audio; + if (video_profile < 0) + video_profile = 0xFF - has_video; + avio_wb32(pb, 0x0); /* size */ ffio_wfourcc(pb, "iods"); avio_wb32(pb, 0); /* version & flags */ - avio_wb16(pb, 0x1007); - avio_w8(pb, 0); - avio_wb16(pb, 0x4fff); - avio_wb16(pb, 0xfffe); - avio_wb16(pb, 0x01ff); - return 0x15; + putDescr(pb, 0x10, 7); + avio_wb16(pb, 0x004f); + avio_w8(pb, 0xff); + avio_w8(pb, 0xff); + avio_w8(pb, audio_profile); + avio_w8(pb, video_profile); + avio_w8(pb, 0xff); + return updateSize(pb, pos); } -#endif static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov) { @@ -1829,7 +1845,8 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, } mov_write_mvhd_tag(pb, mov); - //mov_write_iods_tag(pb, mov); + if (mov->mode != MODE_MOV && !mov->iods_skip) + mov_write_iods_tag(pb, mov); for (i=0; inb_streams; i++) { if(mov->tracks[i].entry > 0) { mov_write_trak_tag(pb, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL); diff --git a/libavformat/movenc.h b/libavformat/movenc.h index 9b14f24b7a..5ca5631c5a 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -112,6 +112,9 @@ typedef struct MOVMuxContext { int flags; int rtp_flags; + int iods_skip; + int iods_video_profile; + int iods_audio_profile; } MOVMuxContext; #define FF_MOV_FLAG_RTP_HINT 1 -- cgit v1.2.3