1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

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.

Originally committed as revision 23939 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Reimar Döffinger 2010-07-01 17:10:31 +00:00
parent 6eabaef4b8
commit 39bb30f664

View File

@ -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(AVFormatContext *s, AVPacket *pkt)
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(MXFContext *mxf, void *metadata_set)
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_context(MXFCryptoContext *cryptocontext, ByteI
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(MXFContext *mxf, ByteIOContext *pb, int tag)
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(MXFStructuralComponent *source_clip, ByteIOConte
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(MXFPackage *package, ByteIOContext *pb, int
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 *track, ByteIOContext *pb, int tag)
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 *sequence, ByteIOContext *pb, int tag)
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(MXFPackage *package, ByteIOContext *pb, int t
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(ByteIOContext *pb, MXFDescriptor *descriptor)
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 mxf_metadata_read_table[] = {
{ { 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(AVFormatContext *s, AVFormatParameters *ap)
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;
}