Commit 6f41585e by Dustin

AvcAviTrack cleanup

parent 5ebaafde
...@@ -71,7 +71,6 @@ public class AvcAviTrack extends AviTrack{ ...@@ -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{ ...@@ -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{ ...@@ -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{ ...@@ -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{ ...@@ -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();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment