Hi

2008/8/23 Michael Niedermayer <[EMAIL PROTECTED]>


> [...]
> > +static int mxf_write_essence_container_refs(AVFormatContext *s, int
> write)
> > +{
>
> > +    MXFContext *mxf = s->priv_data;
>
> unused
>
>
> > +    ByteIOContext *pb = s->pb;
> > +    AVStream *st;
> > +    int i, count = 0, j = 0;
>
> > +    int essence_container_ul_sign[32] = { 0 };
>
> the size 32, could be too small when more entries are added to
> ff_mxf_essence_container_uls and there are more than 32 streams.
>
>
> [...]
>

here is the new patch version 0.0.7 for this issue.
please review.
thanks.
-- 
Best wishes~
Index: libavformat/mxfenc.c
===================================================================
--- libavformat/mxfenc.c	(revision 14965)
+++ libavformat/mxfenc.c	(working copy)
@@ -245,6 +245,42 @@
     return uls;
 }
 
+static int mxf_write_essence_container_refs(AVFormatContext *s, int write)
+{
+    ByteIOContext *pb = s->pb;
+    AVStream *st;
+    int i, count = 0, j = 0;
+    int essence_container_ul_sign[1024] = { 0 };
+    const MXFCodecUL *codec_ul;
+
+    for (codec_ul = ff_mxf_essence_container_uls; codec_ul->id; codec_ul++) {
+        for (i = 0; i < s->nb_streams; i++) {
+            st = s->streams[i];
+            if (st->codec->codec_id == codec_ul->id) {
+                essence_container_ul_sign[count] = j;
+                count++;
+                break;
+            }
+        }
+        j++;
+        // considering WAV/AES3 frame wrapped, when get the first CODEC_ID_PCM_S16LE, break;
+        // this is a temporary method, when we can get  more information, modofy this.
+        if (codec_ul->id == CODEC_ID_PCM_S16LE)
+            break;
+    }
+
+    if (write) {
+        mxf_write_refs_count(pb, count);
+        for (i = 0; i < count; i++) {
+            put_buffer(pb, ff_mxf_essence_container_uls[essence_container_ul_sign[i]].uid, 16);
+        }
+        av_log(s,AV_LOG_DEBUG, "essence container count:%d\n", count);
+        for (i = 0; i < count; i++)
+            PRINT_KEY(s, "essence container ul:\n", ff_mxf_essence_container_uls[essence_container_ul_sign[i]].uid);
+    }
+    return count;
+}
+
 static void mxf_write_preface(AVFormatContext *s)
 {
     MXFContext *mxf = s->priv_data;
@@ -468,20 +504,6 @@
     put_be64(pb, st->duration);
 }
 
-static int mux_write_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    ByteIOContext *pb = s->pb;
-    AVStream *st = s->streams[pkt->stream_index];
-    MXFStreamContext *sc = st->priv_data;
-
-    put_buffer(pb, sc->track_essence_element_key, 16); // write key
-    klv_encode_ber_length(pb, pkt->size); // write length
-    put_buffer(pb, pkt->data, pkt->size); // write value
-
-    put_flush_packet(pb);
-    return 0;
-}
-
 static void mxf_write_sequence(AVFormatContext *s, int stream_index, enum MXFMetadataSetType type)
 {
     ByteIOContext *pb = s->pb;
@@ -612,8 +634,8 @@
     put_be32(pb, st->codec->height);
 
     mxf_write_local_tag(pb, 8, 0x320E);
-    put_be32(pb, st->codec->height * st->sample_aspect_ratio.den);
-    put_be32(pb, st->codec->width  * st->sample_aspect_ratio.num);
+    put_be32(pb, st->codec->height * st->codec->sample_aspect_ratio.den);
+    put_be32(pb, st->codec->width * st->codec->sample_aspect_ratio.num);
 
     // tmp write, will modified later
     mxf_write_local_tag(pb, 16, 0x3201);
@@ -773,6 +795,20 @@
     return -1;
 }
 
+static int mux_write_packet(AVFormatContext *s, AVPacket *pkt)
+{
+    ByteIOContext *pb = s->pb;
+    AVStream *st = s->streams[pkt->stream_index];
+    MXFStreamContext *sc = st->priv_data;
+
+    put_buffer(pb, sc->track_essence_element_key, 16); // write key
+    klv_encode_ber_length(pb, pkt->size); // write length
+    put_buffer(pb, pkt->data, pkt->size); // write value
+
+    put_flush_packet(pb);
+    return 0;
+}
+
 static void mxf_update_header_partition(AVFormatContext *s, int64_t footer_partition_offset)
 {
     MXFContext *mxf = s->priv_data;
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to