-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parse NAL unit slice type to determine if a Video Frame is a keyframe…
… or not don't push several times identical AVCC tags related to #66
- Loading branch information
Showing
2 changed files
with
98 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.mangui.hls.demux { | ||
import flash.utils.ByteArray; | ||
public class ExpGolomb { | ||
private var _data : ByteArray; | ||
private var _bit : int; | ||
private var _curByte : uint; | ||
|
||
public function ExpGolomb(data : ByteArray) { | ||
_data = data; | ||
_bit = -1; | ||
} | ||
|
||
private function _readBit() : uint { | ||
var res : uint; | ||
if (_bit == -1) { | ||
// read next | ||
_curByte = _data.readByte(); | ||
_bit = 7; | ||
} | ||
res = _curByte & (1 << _bit) ? 1 : 0; | ||
_bit--; | ||
return res; | ||
} | ||
|
||
private function _readBits(nbBits : uint) : int { | ||
var val : int = 0; | ||
for (var i : uint = 0; i < nbBits; ++i) | ||
val = (val << 1) + _readBit(); | ||
return val; | ||
} | ||
|
||
public function readUE() : uint { | ||
var nbZero : uint = 0; | ||
while (_readBit() == 0) | ||
++nbZero; | ||
var x : uint = _readBits(nbZero); | ||
return x + (1 << nbZero) - 1; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters