Is there more data? There is no more data if the next bit is the terminating * bit and all following bits are 0. */
| 266 | /* Is there more data? There is no more data if the next bit is the terminating |
| 267 | * bit and all following bits are 0. */ |
| 268 | bool SubByteReader::more_rbsp_data() const |
| 269 | { |
| 270 | auto posBytes = this->posInBufferBytes; |
| 271 | auto posBits = this->posInBufferBits; |
| 272 | auto terminatingBitFound = false; |
| 273 | if (posBits == 8) |
| 274 | { |
| 275 | posBytes++; |
| 276 | posBits = 0; |
| 277 | } |
| 278 | else |
| 279 | { |
| 280 | // Check the remainder of the current byte |
| 281 | unsigned char c = this->byteVector[posBytes]; |
| 282 | if (c & (1 << (7 - posBits))) |
| 283 | terminatingBitFound = true; |
| 284 | else |
| 285 | return true; |
| 286 | posBits++; |
| 287 | while (posBits != 8) |
| 288 | { |
| 289 | if (c & (1 << (7 - posBits))) |
| 290 | // Only zeroes should follow |
| 291 | return true; |
| 292 | posBits++; |
| 293 | } |
| 294 | posBytes++; |
| 295 | } |
| 296 | while (posBytes < (unsigned int)this->byteVector.size()) |
| 297 | { |
| 298 | unsigned char c = this->byteVector[posBytes]; |
| 299 | if (terminatingBitFound && c != 0) |
| 300 | return true; |
| 301 | else if (!terminatingBitFound && (c == 128)) |
| 302 | terminatingBitFound = true; |
| 303 | else |
| 304 | return true; |
| 305 | posBytes++; |
| 306 | } |
| 307 | if (!terminatingBitFound) |
| 308 | return true; |
| 309 | return false; |
| 310 | } |
| 311 | |
| 312 | bool SubByteReader::byte_aligned() const |
| 313 | { |