Commit a010293a authored by bcoudurier's avatar bcoudurier

fix key frame offset with open gop

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@16999 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 6686ac5e
...@@ -840,8 +840,9 @@ static int mxf_write_index_table_segment(AVFormatContext *s) ...@@ -840,8 +840,9 @@ static int mxf_write_index_table_segment(AVFormatContext *s)
{ {
MXFContext *mxf = s->priv_data; MXFContext *mxf = s->priv_data;
ByteIOContext *pb = s->pb; ByteIOContext *pb = s->pb;
int i, j, k, ret, key_offset = 0; int i, j, k, ret;
int temporal_reordering = 0; 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); 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(AVFormatContext *s) ...@@ -900,8 +901,6 @@ static int mxf_write_index_table_segment(AVFormatContext *s)
put_be32(pb, mxf->edit_units_count); // num of entries put_be32(pb, mxf->edit_units_count); // num of entries
put_be32(pb, 11+(s->nb_streams-1)*4); // size of one entry put_be32(pb, 11+(s->nb_streams-1)*4); // size of one entry
for (i = 0; i < mxf->edit_units_count; i++) { for (i = 0; i < mxf->edit_units_count; i++) {
if (mxf->index_entries[i].flags & 0x40)
key_offset = 0;
if (temporal_reordering) { if (temporal_reordering) {
int temporal_offset = 0; int temporal_offset = 0;
for (j = i+1; j < mxf->edit_units_count; j++) { for (j = i+1; j < mxf->edit_units_count; j++) {
...@@ -920,7 +919,18 @@ static int mxf_write_index_table_segment(AVFormatContext *s) ...@@ -920,7 +919,18 @@ static int mxf_write_index_table_segment(AVFormatContext *s)
put_byte(pb, temporal_offset); put_byte(pb, temporal_offset);
} else } else
put_byte(pb, 0); 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); put_byte(pb, mxf->index_entries[i].flags);
// stream offset // stream offset
put_be64(pb, mxf->index_entries[i].offset - mxf->index_entries[0].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(AVFormatContext *s) ...@@ -928,7 +938,6 @@ static int mxf_write_index_table_segment(AVFormatContext *s)
if (mxf->index_entries[i].slice_offset[k]) if (mxf->index_entries[i].slice_offset[k])
put_be32(pb, mxf->index_entries[i].slice_offset[k]); put_be32(pb, mxf->index_entries[i].slice_offset[k]);
} }
key_offset--;
} }
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment