MP4裸码流获取csd方式
int findVOS(void* data, int size)
{
char* p = (char*)data;
int startcode = 0, vosFound = 0;
for (int i = 0; (i < 200) && (i < size - 4); i++) {
startcode = (startcode << 8) | p[i];
if(startcode == 0x000001b0) {
WLOGI(myLog, "find VOS start code");
vosFound = 1;
}
if(startcode == 0x000001b6 && vosFound == 1) {
WLOGI(myLog, "find VOP start code");
return i - 3;
}
}
return 0;
}
H264裸码流获取csd方式
int findSPSNAL(void* data, int size)
{
char* p = (char*)data;
int startcode = 0, spsstart = 0, spsppsend = 0;
for (int i = 0; i < size; i++) {
startcode = (startcode << 8) | p[i];
if (startcode == 1) {
int naltype = (p[i + 1] & 0xF);
if (naltype == 7/*SPS_TYPE*/) {
spsstart = i - 3;
WLOGI(myLog, "Find SPS Pos %d", spsstart);
}
if ((spsstart != 0) && ((naltype == 5/*IDR_TYPE*/) || (naltype == 1/*SLICE_TYPE*/))) {
WLOGI(myLog, "Find NAL %d after SPS/PPS, Pos %d ", naltype, (i - 3));
spsppsend = i - 3;
break;
}
}
}
return spsppsend;
}