[FFmpeg-cvslog] r16999 - trunk/libavformat/mxfenc.c
bcoudurier
subversion
Thu Feb 5 08:47:40 CET 2009
Author: bcoudurier
Date: Thu Feb 5 08:47:39 2009
New Revision: 16999
Log:
fix key frame offset with open gop
Modified:
trunk/libavformat/mxfenc.c
Modified: trunk/libavformat/mxfenc.c
==============================================================================
--- trunk/libavformat/mxfenc.c Thu Feb 5 03:47:26 2009 (r16998)
+++ trunk/libavformat/mxfenc.c Thu Feb 5 08:47:39 2009 (r16999)
@@ -840,8 +840,9 @@ static int mxf_write_index_table_segment
{
MXFContext *mxf = s->priv_data;
ByteIOContext *pb = s->pb;
- int i, j, k, ret, key_offset = 0;
+ int i, j, k, ret;
int temporal_reordering = 0;
+ int last_key_index = 0, key_index = 0;
av_log(s, AV_LOG_DEBUG, "edit units count %d\n", mxf->edit_units_count);
@@ -900,8 +901,6 @@ static int mxf_write_index_table_segment
put_be32(pb, mxf->edit_units_count); // num of entries
put_be32(pb, 11+(s->nb_streams-1)*4); // size of one entry
for (i = 0; i < mxf->edit_units_count; i++) {
- if (mxf->index_entries[i].flags & 0x40)
- key_offset = 0;
if (temporal_reordering) {
int temporal_offset = 0;
for (j = i+1; j < mxf->edit_units_count; j++) {
@@ -920,7 +919,18 @@ static int mxf_write_index_table_segment
put_byte(pb, temporal_offset);
} else
put_byte(pb, 0);
- put_byte(pb, key_offset);
+ if (!(mxf->index_entries[i].flags & 0x33)) { // I frame
+ last_key_index = key_index;
+ key_index = i;
+ }
+ if (mxf->index_entries[i].flags & 0x10 && // backward prediction
+ !(mxf->index_entries[key_index].flags & 0x80)) { // open gop
+ put_byte(pb, last_key_index - i);
+ } else {
+ put_byte(pb, key_index - i); // key frame offset
+ if ((mxf->index_entries[i].flags & 0x20) == 0x20) // only forward
+ last_key_index = key_index;
+ }
put_byte(pb, mxf->index_entries[i].flags);
// stream offset
put_be64(pb, mxf->index_entries[i].offset - mxf->index_entries[0].offset);
@@ -928,7 +938,6 @@ static int mxf_write_index_table_segment
if (mxf->index_entries[i].slice_offset[k])
put_be32(pb, mxf->index_entries[i].slice_offset[k]);
}
- key_offset--;
}
return ret;
More information about the ffmpeg-cvslog
mailing list