1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-
+
-
-
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
* Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <assert.h>
#import "OFLHADecompressingStream.h"
#import "OFKernelEventObserver.h"
#import "OFHuffmanTree.h"
#import "OFInvalidFormatException.h"
#import "OFNotOpenException.h"
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
-
+
|
@synthesize bytesConsumed = _bytesConsumed;
static OF_INLINE bool
tryReadBits(OFLHADecompressingStream *stream, uint16_t *bits, uint8_t count)
{
uint16_t ret = stream->_savedBits;
assert(stream->_savedBitsLength < count);
OFAssert(stream->_savedBitsLength < count);
for (uint_fast8_t i = stream->_savedBitsLength; i < count; i++) {
if OF_UNLIKELY (stream->_bitIndex == 8) {
if OF_LIKELY (stream->_bufferIndex <
stream->_bufferLength)
stream->_byte =
stream->_buffer[stream->_bufferIndex++];
|
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
-
+
-
+
|
- (int)fileDescriptorForReading
{
return ((id <OFReadyForReadingObserving>)_stream)
.fileDescriptorForReading;
}
- (bool)hasDataInReadBuffer
- (bool)lowlevelHasDataInReadBuffer
{
return (super.hasDataInReadBuffer || _stream.hasDataInReadBuffer ||
return (_stream.hasDataInReadBuffer ||
_bufferLength - _bufferIndex > 0);
}
- (void)close
{
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
|