[FFmpeg-user] how to Convert H.264 NAL format to annex b
wqmffmpeg
wqmffmpeg at 163.com
Thu May 21 11:27:33 CEST 2015
Dear all
I hava a issue
I want to Convert H.264 NAL format to annex b according to NAL unit length size
there is a function below, but only works for NAL sizes 3-4
Anyone could shed a light to me?
------------------------------------------------------------
/* This only works for NAL sizes 3-4 */
status_t convertNal2AnnexB(uint8_t *dst, size_t dst_size,
uint8_t *src, size_t src_size, size_t nal_len_size)
{
size_t i = 0;
size_t nal_len = 0;
status_t status = OK;
CHECK_EQ(dst_size, src_size);
CHECK(nal_len_size == 3 || nal_len_size == 4);
while (src_size >= nal_len_size) {
nal_len = 0;
for( i = 0; i < nal_len_size; i++ ) {
nal_len = (nal_len << 8) | src[i];
dst[i] = 0;
}
dst[nal_len_size - 1] = 1;
if (nal_len > INT_MAX || nal_len > src_size) {
status = ERROR_MALFORMED;
break;
}
dst += nal_len_size;
src += nal_len_size;
src_size -= nal_len_size;
memcpy(dst, src, nal_len);
dst += nal_len;
src += nal_len;
src_size -= nal_len;
}
return status;
}
2015-05-21
wqmffmpeg
ffmpeg-user mailing list
ffmpeg-user at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
More information about the ffmpeg-user
mailing list