Mark as keyframe if nal_type is 1, and slice_type is 2,4,7 or 9.
This commit is contained in:
parent
f7b7f54584
commit
f7473bd26a
1 changed files with 24 additions and 0 deletions
|
@ -455,9 +455,33 @@ namespace TS {
|
||||||
nalInfo = h265::analysePackets(parsedData, parsedSize);
|
nalInfo = h265::analysePackets(parsedData, parsedSize);
|
||||||
}
|
}
|
||||||
int dataOffset = 0;
|
int dataOffset = 0;
|
||||||
|
bool firstSlice = true;
|
||||||
for (std::deque<nalu::nalData>::iterator it = nalInfo.begin(); it != nalInfo.end(); it++){
|
for (std::deque<nalu::nalData>::iterator it = nalInfo.begin(); it != nalInfo.end(); it++){
|
||||||
if (pidToCodec[tid] == H264){
|
if (pidToCodec[tid] == H264){
|
||||||
switch (it->nalType){
|
switch (it->nalType){
|
||||||
|
case 0x01: {
|
||||||
|
if (firstSlice) {
|
||||||
|
firstSlice = false;
|
||||||
|
if (!isKeyFrame){
|
||||||
|
char * data = parsedData + dataOffset + 4;
|
||||||
|
Utils::bitstream bs;
|
||||||
|
for (size_t i = 1; i < 10 && i < it->nalSize; i++) {
|
||||||
|
if (i + 2 < it->nalSize && (memcmp(data + i, "\000\000\003", 3) == 0)) { //Emulation prevention bytes
|
||||||
|
bs.append(data + i, 2);
|
||||||
|
i += 2;
|
||||||
|
} else {
|
||||||
|
bs.append(data + i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bs.getExpGolomb();//Discard first_mb_in_slice
|
||||||
|
uint64_t sliceType = bs.getUExpGolomb();
|
||||||
|
if (sliceType == 2 || sliceType == 4 || sliceType == 7 || sliceType == 9){
|
||||||
|
isKeyFrame = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 0x05: {
|
case 0x05: {
|
||||||
isKeyFrame = true;
|
isKeyFrame = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue