| 186 | } |
| 187 | |
| 188 | QByteArray FileSourceAnnexBFile::getFrameData(pairUint64 startEndFilePos) |
| 189 | { |
| 190 | // Get all data for the frame (all NAL units in the raw format with start codes). |
| 191 | // We don't need to convert the format to the mp4 ISO format. The ffmpeg decoder can also accept raw NAL units. |
| 192 | // When the extradata is set as raw NAL units, the AVPackets must also be raw NAL units. |
| 193 | QByteArray retArray; |
| 194 | |
| 195 | auto start = startEndFilePos.first; |
| 196 | auto end = startEndFilePos.second; |
| 197 | |
| 198 | // Seek the source file to the start position |
| 199 | this->seek(start); |
| 200 | |
| 201 | // Retrieve NAL units (and repackage them) until we reached out end position |
| 202 | while (end > this->bufferStartPosInFile + this->posInBuffer) |
| 203 | { |
| 204 | auto nalData = getNextNALUnit(); |
| 205 | |
| 206 | int headerOffset = 0; |
| 207 | if (nalData.at(0) == (char)0 && nalData.at(1) == (char)0) |
| 208 | { |
| 209 | if (nalData.at(2) == (char)0 && nalData.at(3) == (char)1) |
| 210 | headerOffset = 4; |
| 211 | else if (nalData.at(2) == (char)1) |
| 212 | headerOffset = 3; |
| 213 | } |
| 214 | assert(headerOffset > 0); |
| 215 | if (headerOffset == 3) |
| 216 | retArray.append((char)0); |
| 217 | |
| 218 | DEBUG_ANNEXBFILE("FileSourceAnnexBFile::getFrameData Load NAL - size " << nalData.length()); |
| 219 | retArray += nalData; |
| 220 | } |
| 221 | |
| 222 | return retArray; |
| 223 | } |
| 224 | |
| 225 | bool FileSourceAnnexBFile::updateBuffer() |
| 226 | { |
no test coverage detected