Ich habe da ein kurioses Problemchen.
Mir ist aufgefallen, dass ich den FrameCounter noch gar nicht für HEVC erweitert hatte, jedoch habe ich einen alten Code-Schnipsel, den ich nie committed hatte, in den RecoveryDaten einer kaputten Platte gefunden:
Code
#include <stdio.h>
int framecountOfRawH265(const QString &input, const bool list, const bool noprogress)
{
Q_UNUSED(noprogress);
Q_UNUSED(list);
FILE *inp;
fopen_s(&inp, input.toLocal8Bit(), "rb");
bool start = true; // parser state
quint32 currentPattern = 0; // current code wor
int framecount = 0; // iterate through byte stream
while(true) {
int b = fgetc(inp); // read next byte
if (b == EOF) { // quit at end of byte stream
break;
}
// track 32-bit code word
currentPattern = (currentPattern | quint32(b)) << 8; // remove first byte, append last byte
if (currentPattern == 0x00000100) {
if (start) {
int type = fgetc(inp); // read next byte (nalu type)
if (type == EOF) { // quit at end of byte stream
break;
}
type >>= 1; // ignore reserved bit
if (type == 1 || type == 19) {
framecount++;
}
currentPattern = 0; // reset current pattern
}
start = !start;
}
}
fclose(inp);
return framecount;
}
Alles anzeigen
Schon mal schön ist, dass der Code auf ein paar H.265 raw files rauswerfe immer anscheinend die richtige Frameanzahl rauswirft.
Frage ist nur warum.
Finde spontan nichts im Netz was rechtfertigt warum ich:
a. nach '0x00000100' suche als Anfang einer nul unit
b. nur type 1 und 19 nal units zähle.
-> Sieht da irgendwer warum das Sinn macht was ich da tue?
Cu Selur