summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2008-08-31 01:48:02 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2008-08-31 01:48:02 +0000
commit064abb8aead9bd635029b66d410b201f7faeb56a (patch)
tree3b2d9e804026f225cd6706f93bd0576e8485f563 /libavformat
parent38573e8fb9f7fe80f6e762d4c39172e0b4581ad7 (diff)
simplify, pass AVStream directly instead of index
Originally committed as revision 15086 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mxfenc.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 2c6530a030..5e16a2b842 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -432,10 +432,9 @@ static void mxf_write_package(AVFormatContext *s, enum MXFMetadataSetType type)
}
}
-static void mxf_write_track(AVFormatContext *s, int stream_index, enum MXFMetadataSetType type)
+static void mxf_write_track(AVFormatContext *s, AVStream *st, enum MXFMetadataSetType type)
{
ByteIOContext *pb = s->pb;
- AVStream *st = s->streams[stream_index];
MXFStreamContext *sc = st->priv_data;
mxf_write_metadata_key(pb, 0x013b00);
@@ -444,12 +443,12 @@ static void mxf_write_track(AVFormatContext *s, int stream_index, enum MXFMetada
// write track uid
mxf_write_local_tag(pb, 16, 0x3C0A);
- mxf_write_uuid(pb, type == MaterialPackage ? Track : Track + TypeBottom, stream_index);
+ mxf_write_uuid(pb, type == MaterialPackage ? Track : Track + TypeBottom, st->index);
PRINT_KEY(s, "track uid", pb->buf_ptr - 16);
// write track id
mxf_write_local_tag(pb, 4, 0x4801);
- put_be32(pb, stream_index);
+ put_be32(pb, st->index);
// write track number
mxf_write_local_tag(pb, 4, 0x4804);
@@ -468,7 +467,7 @@ static void mxf_write_track(AVFormatContext *s, int stream_index, enum MXFMetada
// write sequence refs
mxf_write_local_tag(pb, 16, 0x4803);
- mxf_write_uuid(pb, type == MaterialPackage ? Sequence: Sequence + TypeBottom, stream_index);
+ mxf_write_uuid(pb, type == MaterialPackage ? Sequence: Sequence + TypeBottom, st->index);
}
static void mxf_write_common_fields(ByteIOContext *pb, AVStream *st)
@@ -483,17 +482,16 @@ static void mxf_write_common_fields(ByteIOContext *pb, AVStream *st)
put_be64(pb, st->duration);
}
-static void mxf_write_sequence(AVFormatContext *s, int stream_index, enum MXFMetadataSetType type)
+static void mxf_write_sequence(AVFormatContext *s, AVStream *st, enum MXFMetadataSetType type)
{
ByteIOContext *pb = s->pb;
- AVStream *st = s->streams[stream_index];
mxf_write_metadata_key(pb, 0x010f00);
PRINT_KEY(s, "sequence key", pb->buf_ptr - 16);
klv_encode_ber_length(pb, 80);
mxf_write_local_tag(pb, 16, 0x3C0A);
- mxf_write_uuid(pb, type == MaterialPackage ? Sequence: Sequence + TypeBottom, stream_index);
+ mxf_write_uuid(pb, type == MaterialPackage ? Sequence: Sequence + TypeBottom, st->index);
PRINT_KEY(s, "sequence uid", pb->buf_ptr - 16);
mxf_write_common_fields(pb, st);
@@ -501,13 +499,12 @@ static void mxf_write_sequence(AVFormatContext *s, int stream_index, enum MXFMet
// write structural component
mxf_write_local_tag(pb, 16 + 8, 0x1001);
mxf_write_refs_count(pb, 1);
- mxf_write_uuid(pb, type == MaterialPackage ? SourceClip: SourceClip + TypeBottom, stream_index);
+ mxf_write_uuid(pb, type == MaterialPackage ? SourceClip: SourceClip + TypeBottom, st->index);
}
-static void mxf_write_structural_component(AVFormatContext *s, int stream_index, enum MXFMetadataSetType type)
+static void mxf_write_structural_component(AVFormatContext *s, AVStream *st, enum MXFMetadataSetType type)
{
ByteIOContext *pb = s->pb;
- AVStream *st = s->streams[stream_index];
int i;
mxf_write_metadata_key(pb, 0x011100);
@@ -516,7 +513,7 @@ static void mxf_write_structural_component(AVFormatContext *s, int stream_index,
// write uid
mxf_write_local_tag(pb, 16, 0x3C0A);
- mxf_write_uuid(pb, type == MaterialPackage ? SourceClip: SourceClip + TypeBottom, stream_index);
+ mxf_write_uuid(pb, type == MaterialPackage ? SourceClip: SourceClip + TypeBottom, st->index);
PRINT_KEY(s, "structural component uid", pb->buf_ptr - 16);
mxf_write_common_fields(pb, st);
@@ -538,7 +535,7 @@ static void mxf_write_structural_component(AVFormatContext *s, int stream_index,
if (type == SourcePackage)
put_be32(pb, 0);
else
- put_be32(pb, stream_index);
+ put_be32(pb, st->index);
}
static void mxf_write_multi_descriptor(AVFormatContext *s)
@@ -591,10 +588,9 @@ static void mxf_write_generic_desc(ByteIOContext *pb, const MXFDescriptorWriteTa
put_buffer(pb, *sc->essence_container_ul, 16);
}
-static void mxf_write_mpegvideo_desc(AVFormatContext *s, const MXFDescriptorWriteTableEntry *desc_tbl, int stream_index)
+static void mxf_write_mpegvideo_desc(AVFormatContext *s, const MXFDescriptorWriteTableEntry *desc_tbl, AVStream *st)
{
ByteIOContext *pb = s->pb;
- AVStream *st = s->streams[stream_index];
mxf_write_generic_desc(pb, desc_tbl, st);
@@ -613,12 +609,10 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, const MXFDescriptorWrit
put_buffer(pb, ff_mxf_codec_uls->uid, 16);
}
-static void mxf_write_wav_desc(AVFormatContext *s, const MXFDescriptorWriteTableEntry *desc_tbl, int stream_index)
+static void mxf_write_wav_desc(AVFormatContext *s, const MXFDescriptorWriteTableEntry *desc_tbl, AVStream *st)
{
ByteIOContext *pb = s->pb;
- AVStream *st;
- st = s->streams[stream_index];
mxf_write_generic_desc(pb, desc_tbl, st);
// write audio sampling rate
@@ -653,14 +647,15 @@ static void mxf_build_structural_metadata(AVFormatContext *s, enum MXFMetadataSe
mxf_write_multi_descriptor(s);
for (i = 0; i < s->nb_streams; i++) {
- mxf_write_track(s, i, type);
- mxf_write_sequence(s, i, type);
- mxf_write_structural_component(s, i, type);
+ AVStream *st = s->streams[i];
+ mxf_write_track(s, st, type);
+ mxf_write_sequence(s, st, type);
+ mxf_write_structural_component(s, st, type);
if (type == SourcePackage) {
for (desc = mxf_descriptor_write_table; desc->write; desc++) {
if (s->streams[i]->codec->codec_id == desc->type) {
- desc->write(s, desc, i);
+ desc->write(s, desc, st);
break;
}
}