mirror of
https://github.com/mpromonet/v4l2rtspserver
synced 2024-11-17 21:25:40 +00:00
try to fix DQT parsing
This commit is contained in:
parent
670f14ff23
commit
a46c6c1346
@ -45,18 +45,20 @@ void MJPEGVideoSource::afterGettingFrame(unsigned frameSize,unsigned numTruncate
|
|||||||
i+=length+2;
|
i+=length+2;
|
||||||
}
|
}
|
||||||
// DQT
|
// DQT
|
||||||
else if ( ( (i+5+64) < frameSize) && (fTo[i] == 0xFF) && (fTo[i+1] == 0xDB)) {
|
else if ((fTo[i] == 0xFF) && (fTo[i+1] == 0xDB)) {
|
||||||
int length = (fTo[i+2]<<8)|(fTo[i+3]);
|
int length = (fTo[i+2]<<8)|(fTo[i+3]);
|
||||||
LOG(DEBUG) << "DQT length:" << length;
|
LOG(DEBUG) << "DQT length:" << length;
|
||||||
|
|
||||||
unsigned int precision = (fTo[i+4]&0xf0)<<4;
|
unsigned int precision = (fTo[i+4]&0xf0)<<4;
|
||||||
unsigned int quantIdx = fTo[i+4]&0x0f;
|
unsigned int quantIdx = fTo[i+4]&0x0f;
|
||||||
unsigned int quantSize = length-4;
|
unsigned int quantSize = 64*(precision+1);
|
||||||
if (quantSize*quantIdx+quantSize <= sizeof(m_qTable)) {
|
if (quantSize*quantIdx+quantSize <= sizeof(m_qTable)) {
|
||||||
memcpy(m_qTable + quantSize*quantIdx, fTo + i + 5, quantSize);
|
if ( (i+5+length) < frameSize) {
|
||||||
LOG(DEBUG) << "Quantization table idx:" << quantIdx << " precision:" << precision << " size:" << quantSize << " total size:" << m_qTableSize;
|
memcpy(m_qTable + quantSize*quantIdx, fTo + i + 5, length);
|
||||||
if (quantSize*quantIdx+quantSize > m_qTableSize) {
|
LOG(DEBUG) << "Quantization table idx:" << quantIdx << " precision:" << precision << " size:" << quantSize << " total size:" << m_qTableSize;
|
||||||
m_qTableSize = quantSize*quantIdx+quantSize;
|
if (quantSize*quantIdx+quantSize > m_qTableSize) {
|
||||||
|
m_qTableSize = quantSize*quantIdx+quantSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user