Beispiel #1
0
int mxf_write_rip(MXFFile *mxfFile, MXFFilePartitions *partitions)
{
    uint32_t numPartitions;
    uint64_t len;
    uint8_t llen;
    MXFListIterator iter;

    numPartitions = (uint32_t)mxf_get_list_length(partitions);
    len = (4 + 8) * numPartitions + 4;

    CHK_ORET(mxf_write_k(mxfFile, &g_RandomIndexPack_key));
    CHK_ORET((llen = mxf_write_l(mxfFile, len)) != 0);

    mxf_initialise_list_iter(&iter, partitions);
    while (mxf_next_list_iter_element(&iter))
    {
        MXFPartition *partition = (MXFPartition*)mxf_get_iter_element(&iter);

        CHK_ORET(mxf_write_uint32(mxfFile, partition->bodySID));
        CHK_ORET(mxf_write_uint64(mxfFile, partition->thisPartition));
    }
    CHK_ORET(mxf_write_uint32(mxfFile, (uint32_t)(16 + llen + len)));

    return 1;
}
Beispiel #2
0
int mxf_fill_to_position(MXFFile *mxfFile, uint64_t position)
{
    int64_t filePos;
    uint64_t fillSize;
    uint8_t llen;

    CHK_ORET((filePos = mxf_file_tell(mxfFile)) >= 0);

    if ((uint64_t)filePos == position)
    {
        return 1;
    }

    CHK_ORET(((uint64_t)filePos <= position - mxf_get_min_llen(mxfFile) + mxfKey_extlen));

    CHK_ORET(mxf_write_k(mxfFile, &g_KLVFill_key));

    fillSize = position - filePos - mxfKey_extlen;
    llen = mxf_get_llen(mxfFile, fillSize);
    assert(fillSize >= llen);
    fillSize -= llen;

    CHK_ORET(mxf_write_l(mxfFile, fillSize));
    CHK_ORET(mxf_write_zeros(mxfFile, fillSize));

    return 1;
}
Beispiel #3
0
int mxf_allocate_space_to_kag(MXFFile *mxfFile, MXFPartition *partition, uint32_t size)
{
    int64_t filePos;
    uint64_t relativeFilePos;
    int64_t fillSize;
    uint8_t llen;

    assert(partition->kagSize > 0);

    if (size == 0 && partition->kagSize == 1)
    {
        return 1;
    }

    CHK_ORET((filePos = mxf_file_tell(mxfFile)) >= 0);
    CHK_ORET((uint64_t)filePos > partition->thisPartition);
    relativeFilePos = filePos + size - partition->thisPartition;

    if (size != 0 || (relativeFilePos % partition->kagSize) != 0)
    {
        CHK_ORET(mxf_write_k(mxfFile, &g_KLVFill_key));

        fillSize = (int64_t)size - mxfKey_extlen;
        if (partition->kagSize > 1)
        {
            fillSize += partition->kagSize - relativeFilePos % partition->kagSize;
        }

        if (fillSize >= 0)
        {
            llen = mxf_get_llen(mxfFile, fillSize);
        }
        else
        {
            llen = 0;
        }
        while (fillSize - llen < 0)
        {
            fillSize += partition->kagSize;
            if (fillSize >= 0)
            {
                llen = mxf_get_llen(mxfFile, fillSize);
            }
            else
            {
                llen = 0;
            }
        }
        fillSize -= llen;

        CHK_ORET(mxf_write_l(mxfFile, fillSize));
        CHK_ORET(mxf_write_zeros(mxfFile, fillSize));
    }

    return 1;
}
Beispiel #4
0
int do_write(MXFFile *mxfFile)
{
    memset(data, 0xaa, 256);

    CHK_ORET(mxf_file_write(mxfFile, NULL, 0) == 0);
    CHK_ORET(mxf_file_write(mxfFile, data, 0) == 0);
    CHK_ORET(mxf_file_write(mxfFile, data, 100) == 100);
    CHK_ORET(mxf_file_putc(mxfFile, 0xff));
    CHK_ORET(mxf_file_putc(mxfFile, 0xff));
    CHK_ORET(mxf_write_uint8(mxfFile, 0x0f));
    CHK_ORET(mxf_write_uint16(mxfFile, 0x0f00));
    CHK_ORET(mxf_write_uint32(mxfFile, 0x0f000000));
    CHK_ORET(mxf_write_uint64(mxfFile, 0x0f00000000000000LL));
    CHK_ORET(mxf_write_int8(mxfFile, -0x0f));
    CHK_ORET(mxf_write_int16(mxfFile, -0x0f00));
    CHK_ORET(mxf_write_int32(mxfFile, -0x0f000000));
    CHK_ORET(mxf_write_int64(mxfFile, -0x0f00000000000000LL));
    CHK_ORET(mxf_write_local_tag(mxfFile, 0xffaa));
    CHK_ORET(mxf_write_k(mxfFile, &someKey));
    CHK_ORET(mxf_write_l(mxfFile, 0x01) == 1);
    CHK_ORET(mxf_write_l(mxfFile, 0x80) == 2);
    CHK_ORET(mxf_write_l(mxfFile, 0x8000) == 3);
    CHK_ORET(mxf_write_l(mxfFile, 0x800000) == 4);
    CHK_ORET(mxf_write_l(mxfFile, 0x80000000) == 5);
    CHK_ORET(mxf_write_l(mxfFile, 0x8000000000LL) == 6);
    CHK_ORET(mxf_write_l(mxfFile, 0x800000000000LL) == 7);
    CHK_ORET(mxf_write_l(mxfFile, 0x80000000000000LL) == 8);
    CHK_ORET(mxf_write_l(mxfFile, 0x8000000000000000LL) == 9);
    CHK_ORET(mxf_write_kl(mxfFile, &someKey, 0xf100));
    CHK_ORET(mxf_write_fixed_l(mxfFile, 8, 0x10));
    CHK_ORET(mxf_write_fixed_l(mxfFile, 4, 0x10));
    CHK_ORET(mxf_write_fixed_kl(mxfFile, &someKey, 8, 0x1000));
    CHK_ORET(mxf_write_ul(mxfFile, &someUL));
    CHK_ORET(mxf_write_uid(mxfFile, &someUID));
    CHK_ORET(mxf_write_uuid(mxfFile, &someUUID));
    CHK_ORET(mxf_write_batch_header(mxfFile, 2, 16));
    CHK_ORET(mxf_write_array_header(mxfFile, 4, 32));

    return 1;
}
Beispiel #5
0
int mxf_allocate_space(MXFFile *mxfFile, uint32_t size)
{
    uint64_t fillSize;
    uint8_t llen;

    CHK_ORET(size >= (uint32_t)(mxf_get_min_llen(mxfFile) + mxfKey_extlen));

    CHK_ORET(mxf_write_k(mxfFile, &g_KLVFill_key));

    fillSize = size - mxfKey_extlen;
    llen = mxf_get_llen(mxfFile, fillSize);
    assert(fillSize >= llen);
    fillSize -= llen;

    CHK_ORET(mxf_write_l(mxfFile, fillSize));
    CHK_ORET(mxf_write_zeros(mxfFile, fillSize));

    return 1;
}