Revision 73d0869a libavformat/mxfenc.c

View differences:

libavformat/mxfenc.c
176 176
    uint64_t timestamp;   ///< timestamp, as year(16),month(8),day(8),hour(8),minutes(8),msec/4(8)
177 177
    uint8_t slice_count;  ///< index slice count minus 1 (1 if no audio, 0 otherwise)
178 178
    int last_indexed_edit_unit;
179
    uint64_t first_edit_unit_offset;
180 179
    uint64_t *body_partition_offset;
181 180
    unsigned body_partitions_count;
182 181
    int last_key_index;  ///< index of last key frame
......
186 185
    int timecode_start;      ///< frame number computed from mpeg-2 gop header timecode
187 186
    int timecode_drop_frame; ///< time code use drop frame method frop mpeg-2 essence gop header
188 187
    int edit_unit_byte_count; ///< fixed edit unit byte count
188
    uint64_t body_offset;
189 189
} MXFContext;
190 190

  
191 191
static const uint8_t uuid_base[]            = { 0xAD,0xAB,0x44,0x24,0x2f,0x25,0x4d,0xc7,0x92,0xff,0x29,0xbd };
......
1151 1151
            }
1152 1152
            put_byte(pb, mxf->index_entries[i].flags);
1153 1153
            // stream offset
1154
            put_be64(pb, mxf->index_entries[i].offset - mxf->first_edit_unit_offset);
1154
            put_be64(pb, mxf->index_entries[i].offset);
1155 1155
            if (s->nb_streams > 1)
1156 1156
                put_be32(pb, mxf->index_entries[i].slice_offset);
1157 1157
        }
......
1235 1235

  
1236 1236
    // BodyOffset
1237 1237
    if (bodysid && mxf->edit_units_count && mxf->body_partitions_count) {
1238
        uint64_t partition_end = url_ftell(pb) + 8 + 4 + 16 + 8 +
1239
            16*mxf->essence_container_count;
1240
        put_be64(pb, partition_end + klv_fill_size(partition_end) +
1241
                 index_byte_count - mxf->first_edit_unit_offset);
1238
        put_be64(pb, mxf->body_offset);
1242 1239
    } else
1243 1240
        put_be64(pb, 0);
1244 1241

  
......
1715 1712
        }
1716 1713

  
1717 1714
        mxf_write_klv_fill(s);
1718
        mxf->index_entries[mxf->edit_units_count].offset = url_ftell(pb);
1715
        mxf->index_entries[mxf->edit_units_count].offset = mxf->body_offset;
1719 1716
        mxf->index_entries[mxf->edit_units_count].flags = flags;
1720
        if (!mxf->first_edit_unit_offset)
1721
            mxf->first_edit_unit_offset = mxf->index_entries[0].offset;
1722 1717
        mxf_write_system_item(s);
1723 1718

  
1719
        mxf->body_offset += KAG_SIZE; // size of system element
1720

  
1724 1721
        mxf->edit_units_count++;
1725 1722
    } else if (st->index == 1) {
1726
        uint64_t pos = url_ftell(pb);
1727
        mxf->index_entries[mxf->edit_units_count-1].slice_offset = pos +
1728
            klv_fill_size(pos) - mxf->index_entries[mxf->edit_units_count-1].offset;
1723
        mxf->index_entries[mxf->edit_units_count-1].slice_offset =
1724
            mxf->body_offset - mxf->index_entries[mxf->edit_units_count-1].offset;
1729 1725
    }
1730 1726

  
1731 1727
    mxf_write_klv_fill(s);
......
1734 1730
    put_buffer(pb, pkt->data, pkt->size); // write value
1735 1731

  
1736 1732
    put_flush_packet(pb);
1733

  
1734
    mxf->body_offset += 16+4+pkt->size + klv_fill_size(16+4+pkt->size);
1735

  
1737 1736
    return 0;
1738 1737
}
1739 1738

  

Also available in: Unified diff