mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
AvcAviTrack cleanup
This commit is contained in:
parent
5ebaafde6e
commit
6f41585e72
1 changed files with 7 additions and 18 deletions
|
|
@ -71,7 +71,6 @@ public class AvcAviTrack extends AviTrack{
|
||||||
maxPicCount = 1 << (spsData.picOrderCntLsbLength);
|
maxPicCount = 1 << (spsData.picOrderCntLsbLength);
|
||||||
posHalf = maxPicCount / 2; //Not sure why pics are 2x
|
posHalf = maxPicCount / 2; //Not sure why pics are 2x
|
||||||
negHalf = -posHalf;
|
negHalf = -posHalf;
|
||||||
//Not sure if this works after the fact
|
|
||||||
if (spsData.pixelWidthHeightRatio != pixelWidthHeightRatio) {
|
if (spsData.pixelWidthHeightRatio != pixelWidthHeightRatio) {
|
||||||
formatBuilder.setPixelWidthHeightRatio(spsData.pixelWidthHeightRatio);
|
formatBuilder.setPixelWidthHeightRatio(spsData.pixelWidthHeightRatio);
|
||||||
trackOutput.format(formatBuilder.build());
|
trackOutput.format(formatBuilder.build());
|
||||||
|
|
@ -106,7 +105,7 @@ public class AvcAviTrack extends AviTrack{
|
||||||
|
|
||||||
int getPicOrderCountLsb(byte[] peek) {
|
int getPicOrderCountLsb(byte[] peek) {
|
||||||
if (peek[3] != 1) {
|
if (peek[3] != 1) {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
final ParsableNalUnitBitArray in = new ParsableNalUnitBitArray(peek, 5, peek.length);
|
final ParsableNalUnitBitArray in = new ParsableNalUnitBitArray(peek, 5, peek.length);
|
||||||
//slide_header()
|
//slide_header()
|
||||||
|
|
@ -126,10 +125,10 @@ public class AvcAviTrack extends AviTrack{
|
||||||
//We skip IDR in the switch
|
//We skip IDR in the switch
|
||||||
if (spsData.picOrderCountType == 0) {
|
if (spsData.picOrderCountType == 0) {
|
||||||
int picOrderCountLsb = in.readBits(spsData.picOrderCntLsbLength);
|
int picOrderCountLsb = in.readBits(spsData.picOrderCntLsbLength);
|
||||||
Log.d("Test", "FrameNum: " + frame + " cnt=" + picOrderCountLsb);
|
//Log.d("Test", "FrameNum: " + frame + " cnt=" + picOrderCountLsb);
|
||||||
return picOrderCountLsb;
|
return picOrderCountLsb;
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -144,6 +143,10 @@ public class AvcAviTrack extends AviTrack{
|
||||||
case 3:
|
case 3:
|
||||||
case 4: {
|
case 4: {
|
||||||
final int picCount = getPicOrderCountLsb(peek);
|
final int picCount = getPicOrderCountLsb(peek);
|
||||||
|
if (picCount < 0) {
|
||||||
|
Log.d(AviExtractor.TAG, "Error getting PicOrder");
|
||||||
|
seekFrame(frame);
|
||||||
|
}
|
||||||
int delta = picCount - lastPicCount;
|
int delta = picCount - lastPicCount;
|
||||||
if (delta < negHalf) {
|
if (delta < negHalf) {
|
||||||
delta += maxPicCount;
|
delta += maxPicCount;
|
||||||
|
|
@ -167,18 +170,4 @@ public class AvcAviTrack extends AviTrack{
|
||||||
}
|
}
|
||||||
return super.newChunk(tag, size, input);
|
return super.newChunk(tag, size, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toString(byte[] buffer, int i, final int len) {
|
|
||||||
final StringBuilder sb = new StringBuilder((len - i) * 3);
|
|
||||||
while (i < len) {
|
|
||||||
String hex = Integer.toHexString(buffer[i] & 0xff);
|
|
||||||
if (hex.length() == 1) {
|
|
||||||
sb.append('0');
|
|
||||||
}
|
|
||||||
sb.append(hex);
|
|
||||||
sb.append(' ');
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue