SEI user data not written as is (first byte missing, extra byte added at the end)
I am trying to write SEI user data of payload type USER_DATA_REGISTERED_ITU_T_T35. The code ends up using writeSEI from the SEICreativeIntentMeta class, but it skips the first byte of my payload and adds a extra byte at the end.
That function's code is:
// daniel.vt@samsung.com :: for the Creative Intent Meta Data Encoding ( seongnam.oh@samsung.com ) void writeSEI(const SPS&) { if (!cim) return;
int i = 0;
int payloadSize = m_payloadSize;
while (cim[i] == 0xFF)
{
i++;
payloadSize += cim[i];
WRITE_CODE(0xFF, 8, "payload_size");
}
WRITE_CODE(payloadSize, 8, "payload_size");
i++;
payloadSize += i;
for (; i < payloadSize; ++i)
WRITE_CODE(cim[i], 8, "creative_intent_metadata");
}
In my case, the first byte's payload is not 0xFF, so payloadSize stays at m_payloadSize. Then, somehow, i is incremented (from 0 to 1) so 1 is added to payloadSize, which seems wrong. Then, when writing the payload, writing starts at cim index 1, so the first byte of the payload is not written. Writing keeps going 1 item passed the end of the payload buffer.
Also I'm not sure why SEICreativeIntentMeta is used when the payloadType is set to USER_DATA_REGISTERED_ITU_T_T35.
This code works for me:
void writeSEI(const SPS&) { if (!cim) return;
int payloadSize = m_payloadSize;
WRITE_CODE(payloadSize, 8, "payload_size");
for (uint32_t i = 0; i < m_payloadSize; i++)
WRITE_CODE(cim[i], 8, "user_data");
}
Comments (5)
-
-
reporter Thank you for the reply! This could work for me, but just using m_payloadSize as the payload size, instead of the value of the first byte, would make more sense to me.
Also are all USER_DATA_REGISTERED_ITU_T_T35 payloads supposed to use cim? Sorry I don't know much about cim itself...
-
Account Deactivated -
assigned issue to
-
assigned issue to
-
Fix for this issue has been pushed into the stable branch of the repository. Please check if it works with your test case.
-
Account Deactivated - changed status to closed
- Log in to comment
It seems that there's a mixture between how the cim was originally designed and the intended usage of m_payloadSize. In the original code, the line
was
cim is supposed to include the payload size in the first byte(s), not only the payload data.