[FFmpeg-cvslog] r23939 - trunk/libavformat/mxfdec.c
reimar
subversion
Thu Jul 1 19:10:31 CEST 2010
Author: reimar
Date: Thu Jul 1 19:10:31 2010
New Revision: 23939
Log:
Change all functions referenced in the mxf_metadata_read_table to use the same
prototype and also always call them with exactly those arguments.
The previous way seems to have worked on all supported platforms, however
it was not strictly valid C and would crash e.g. with a compiler that
uses stdcall by default.
Also avoids warnings if -Wstrict-prototypes is used.
Modified:
trunk/libavformat/mxfdec.c
Modified: trunk/libavformat/mxfdec.c
==============================================================================
--- trunk/libavformat/mxfdec.c Thu Jul 1 18:28:38 2010 (r23938)
+++ trunk/libavformat/mxfdec.c Thu Jul 1 19:10:31 2010 (r23939)
@@ -140,9 +140,11 @@ enum MXFWrappingScheme {
Clip,
};
+typedef int MXFMetadataReadFunc(void *arg, ByteIOContext *pb, int tag, int size, UID uid);
+
typedef struct {
const UID key;
- int (*read)();
+ MXFMetadataReadFunc *read;
int ctx_size;
enum MXFMetadataSetType type;
} MXFMetadataReadTableEntry;
@@ -342,9 +344,9 @@ static int mxf_read_packet(AVFormatConte
return AVERROR_EOF;
}
-static int mxf_read_primer_pack(MXFContext *mxf)
+static int mxf_read_primer_pack(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
{
- ByteIOContext *pb = mxf->fc->pb;
+ MXFContext *mxf = arg;
int item_num = get_be32(pb);
int item_len = get_be32(pb);
@@ -374,8 +376,9 @@ static int mxf_add_metadata_set(MXFConte
return 0;
}
-static int mxf_read_cryptographic_context(MXFCryptoContext *cryptocontext, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_cryptographic_context(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
{
+ MXFCryptoContext *cryptocontext = arg;
if (size != 16)
return -1;
if (IS_KLV_KEY(uid, mxf_crypto_source_container_ul))
@@ -383,8 +386,9 @@ static int mxf_read_cryptographic_contex
return 0;
}
-static int mxf_read_content_storage(MXFContext *mxf, ByteIOContext *pb, int tag)
+static int mxf_read_content_storage(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
{
+ MXFContext *mxf = arg;
switch (tag) {
case 0x1901:
mxf->packages_count = get_be32(pb);
@@ -400,8 +404,9 @@ static int mxf_read_content_storage(MXFC
return 0;
}
-static int mxf_read_source_clip(MXFStructuralComponent *source_clip, ByteIOContext *pb, int tag)
+static int mxf_read_source_clip(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
{
+ MXFStructuralComponent *source_clip = arg;
switch(tag) {
case 0x0202:
source_clip->duration = get_be64(pb);
@@ -421,8 +426,9 @@ static int mxf_read_source_clip(MXFStruc
return 0;
}
-static int mxf_read_material_package(MXFPackage *package, ByteIOContext *pb, int tag)
+static int mxf_read_material_package(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
{
+ MXFPackage *package = arg;
switch(tag) {
case 0x4403:
package->tracks_count = get_be32(pb);
@@ -438,8 +444,9 @@ static int mxf_read_material_package(MXF
return 0;
}
-static int mxf_read_track(MXFTrack *track, ByteIOContext *pb, int tag)
+static int mxf_read_track(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
{
+ MXFTrack *track = arg;
switch(tag) {
case 0x4801:
track->track_id = get_be32(pb);
@@ -458,8 +465,9 @@ static int mxf_read_track(MXFTrack *trac
return 0;
}
-static int mxf_read_sequence(MXFSequence *sequence, ByteIOContext *pb, int tag)
+static int mxf_read_sequence(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
{
+ MXFSequence *sequence = arg;
switch(tag) {
case 0x0202:
sequence->duration = get_be64(pb);
@@ -481,8 +489,9 @@ static int mxf_read_sequence(MXFSequence
return 0;
}
-static int mxf_read_source_package(MXFPackage *package, ByteIOContext *pb, int tag)
+static int mxf_read_source_package(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
{
+ MXFPackage *package = arg;
switch(tag) {
case 0x4403:
package->tracks_count = get_be32(pb);
@@ -506,7 +515,7 @@ static int mxf_read_source_package(MXFPa
return 0;
}
-static int mxf_read_index_table_segment(MXFIndexTableSegment *segment, ByteIOContext *pb, int tag)
+static int mxf_read_index_table_segment(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
{
switch(tag) {
case 0x3F05: dprintf(NULL, "EditUnitByteCount %d\n", get_be32(pb)); break;
@@ -538,8 +547,9 @@ static void mxf_read_pixel_layout(ByteIO
ff_mxf_decode_pixel_layout(layout, &descriptor->pix_fmt);
}
-static int mxf_read_generic_descriptor(MXFDescriptor *descriptor, ByteIOContext *pb, int tag, int size, UID uid)
+static int mxf_read_generic_descriptor(void *arg, ByteIOContext *pb, int tag, int size, UID uid)
{
+ MXFDescriptor *descriptor = arg;
switch(tag) {
case 0x3F01:
descriptor->sub_descriptors_count = get_be32(pb);
@@ -852,7 +862,7 @@ static const MXFMetadataReadTableEntry m
{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL, 0, AnyType },
};
-static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child)(), int ctx_size, enum MXFMetadataSetType type)
+static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadFunc *read_child, int ctx_size, enum MXFMetadataSetType type)
{
ByteIOContext *pb = mxf->fc->pb;
MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf;
@@ -920,8 +930,12 @@ static int mxf_read_header(AVFormatConte
for (metadata = mxf_metadata_read_table; metadata->read; metadata++) {
if (IS_KLV_KEY(klv.key, metadata->key)) {
- int (*read)() = klv.key[5] == 0x53 ? mxf_read_local_tags : metadata->read;
- if (read(mxf, &klv, metadata->read, metadata->ctx_size, metadata->type) < 0) {
+ int res;
+ if (klv.key[5] == 0x53) {
+ res = mxf_read_local_tags(mxf, &klv, metadata->read, metadata->ctx_size, metadata->type);
+ } else
+ res = metadata->read(mxf, s->pb, 0, 0, NULL);
+ if (res < 0) {
av_log(s, AV_LOG_ERROR, "error reading header metadata\n");
return -1;
}
More information about the ffmpeg-cvslog
mailing list