[FFmpeg-soc] mxfenc.c version 0.0.5

zhentan feng spyfeng at gmail.com
Sun Aug 3 16:58:15 CEST 2008


Hi

2008/8/3 Michael Niedermayer <michaelni at gmx.at>

> On Sat, Aug 02, 2008 at 11:26:38PM +0800, zhentan feng wrote:
> > Hi,
> > I fixed the bugs and modified some structs according to the former
> reviews,
> > and test the code by valgrind and elminated the mem leaks.
> >
> > here is new version attached below.
> [...]
> > #define DEBUG
> >
> > #include "libavutil/random.h"
> > #include "avformat.h"
> > #include "libavcodec/bytestream.h"
> >
>
> > typedef uint8_t UID[16];
> > typedef uint8_t UMID[32];
> >
> > enum MXFMetadataSetType {
> >     MaterialPackage,
> >     SourcePackage,
> > };
> >
> > typedef struct {
> >     UID key;
> >     offset_t offset;
> >     uint64_t length;
> > } KLVPacket;
> >
> > typedef struct {
> >     UID uid;
> >     unsigned matching_len;
> >     enum CodecID id;
> > } MXFCodecUL;
>
> These are also in mxf.c, maybe its time to factor out common things into a
> common header?


IIRC,Baptiste said he will extract the common code.
And I am also glad to do that.


>
> [...]
> > typedef struct {
> >     UID *identification;
> >     UID *content_storage;
> >     UID **package;
> >     UID **track;
> >     UID *mul_desc;
> >     UID **sub_desc;
> > } MXFReferenceContext;
>
> several of these seem to have a constant size and so dont need
> av_mallocz & av_free.
> And the ones that exist per stream (that is * nb_streams) could be in
> MXFStreamContext
>
> umm, I thought so but the story is a little complicated.
we can factorize  track refs, sequences refs into MXFStreamContext,

however,
**track are refereces in package, package number is not equal nb_streams.
**sub_desc are references in multiple descriptor set which number is not
equal nb_streams ethier.

we must write them before writing tracks, sequences sets.
you can check the function mxf_build_structural_metadata().



>
> [...]
> > static int klv_encode_ber_length(ByteIOContext *pb, uint64_t len)
> > {
> >     // Determine the best BER size
> >     int size = 0;
> >     uint64_t tmp = len;
> >     if (len < 128) {
> >         //short form
> >         put_byte(pb, len);
> >         return 1;
> >     }
> >
>
> >     while (tmp) {
> >         tmp >>= 8;
> >         size ++;
> >     }
>
> size= av_log2(tmp)>>3;
>

Reimar.Doeffinge mentioned this former.
but the type of len is uint64_t,
it seems don't compatible with av_log2() param.
Is it necessary to implement av_log2_64bit() in common.h?

>
>
> [...]
> > static int mxf_write_primer_pack(AVFormatContext *s)
> > {
> >     ByteIOContext *pb = s->pb;
> >     const MXFLocalTagPair *local_tag_batch;
> >     int local_tag_number, i = 0;
> >
> >     local_tag_number = sizeof(mxf_local_tag_batch) /
> sizeof(MXFLocalTagPair);
> >
> >     put_buffer(pb, primer_pack_key, 16);
> >     klv_encode_ber_length(pb, local_tag_number * 18 + 8);
> >
> >     put_be32(pb, local_tag_number); // local_tag num
> >     put_be32(pb, 18); // item size, always 18 according to the specs
> >
>
> >     for (local_tag_batch = mxf_local_tag_batch; i < local_tag_number;
> local_tag_batch++, i++) {
> >         put_be16(pb, local_tag_batch->local_tag);
> >         put_buffer(pb, local_tag_batch->uid, 16);
> >     }
>
> for(i=0; i < local_tag_number; i++) {
>    put_be16(pb, mxf_local_tag_batch[i].local_tag);
>    ...
>
> modified.

-- 
Best wishes~



More information about the FFmpeg-soc mailing list