From 9024befc30159e036b1eaeb6a8aaabbe8159f3d0 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Fri, 16 Sep 2011 02:41:27 +0200
Subject: [PATCH 2/2] movenc: set alternative group for audio and subtitles
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
---
libavformat/movenc.c | 13 +++++++++++--
libavformat/movenc.h | 2 ++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index b1dafdb..0a741de 100644
|
a
|
b
|
static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st) |
| 1211 | 1211 | (version == 1) ? avio_wb32(pb, 104) : avio_wb32(pb, 92); /* size */ |
| 1212 | 1212 | ffio_wfourcc(pb, "tkhd"); |
| 1213 | 1213 | avio_w8(pb, version); |
| 1214 | | avio_wb24(pb, 0xf); /* flags (track enabled) */ |
| | 1214 | avio_wb24(pb, track->secondary ? 0x2 : 0xf); /* flags (first track enabled) */ |
| 1215 | 1215 | if (version == 1) { |
| 1216 | 1216 | avio_wb64(pb, track->time); |
| 1217 | 1217 | avio_wb64(pb, track->time); |
| … |
… |
static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st) |
| 1225 | 1225 | |
| 1226 | 1226 | avio_wb32(pb, 0); /* reserved */ |
| 1227 | 1227 | avio_wb32(pb, 0); /* reserved */ |
| 1228 | | avio_wb32(pb, 0x0); /* reserved (Layer & Alternate group) */ |
| | 1228 | avio_wb32(pb, track->alternative_group); /* reserved (Layer & Alternate group) */ |
| 1229 | 1229 | /* Volume, only for audio */ |
| 1230 | 1230 | if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO) |
| 1231 | 1231 | avio_wb16(pb, 0x0100); |
| … |
… |
static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, |
| 1807 | 1807 | { |
| 1808 | 1808 | int i; |
| 1809 | 1809 | int64_t pos = avio_tell(pb); |
| | 1810 | int not_first[AVMEDIA_TYPE_NB]={0}; |
| 1810 | 1811 | avio_wb32(pb, 0); /* size placeholder*/ |
| 1811 | 1812 | ffio_wfourcc(pb, "moov"); |
| 1812 | 1813 | |
| … |
… |
static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, |
| 1834 | 1835 | //mov_write_iods_tag(pb, mov); |
| 1835 | 1836 | for (i=0; i<mov->nb_streams; i++) { |
| 1836 | 1837 | if(mov->tracks[i].entry > 0) { |
| | 1838 | if(i < s->nb_streams){ |
| | 1839 | int codec_type= s->streams[i]->codec->codec_type; |
| | 1840 | if(codec_type==AVMEDIA_TYPE_AUDIO || codec_type==AVMEDIA_TYPE_SUBTITLE){ |
| | 1841 | mov->tracks[i].alternative_group= 1 + (codec_type==AVMEDIA_TYPE_SUBTITLE); |
| | 1842 | mov->tracks[i].secondary= not_first[codec_type]; |
| | 1843 | not_first[codec_type]= 1; |
| | 1844 | } |
| | 1845 | } |
| 1837 | 1846 | mov_write_trak_tag(pb, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL); |
| 1838 | 1847 | } |
| 1839 | 1848 | } |
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 610683f..4676983 100644
|
a
|
b
|
typedef struct MOVIndex { |
| 78 | 78 | #define MOV_TRACK_STPS 0x0002 |
| 79 | 79 | uint32_t flags; |
| 80 | 80 | int language; |
| | 81 | int alternative_group; |
| | 82 | int secondary; |
| 81 | 83 | int trackID; |
| 82 | 84 | int tag; ///< stsd fourcc |
| 83 | 85 | AVCodecContext *enc; |