[FFmpeg-soc] mxfenc.c version 0.0.5
Michael Niedermayer
michaelni at gmx.at
Sun Aug 3 05:45:09 CEST 2008
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?
[...]
> 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
[...]
> 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;
[...]
> 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);
...
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20080803/166fe666/attachment.pgp>
More information about the FFmpeg-soc
mailing list