Merge pull request #3863 from drhill/dev-v2_mkvDIVX
add h263 format support in fourcc codecID
This commit is contained in:
commit
51405c9959
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.extractor.mkv;
|
|||||||
import android.support.annotation.IntDef;
|
import android.support.annotation.IntDef;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Pair;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
@ -219,6 +220,7 @@ public final class MatroskaExtractor implements Extractor {
|
|||||||
private static final int LACING_EBML = 3;
|
private static final int LACING_EBML = 3;
|
||||||
|
|
||||||
private static final int FOURCC_COMPRESSION_VC1 = 0x31435657;
|
private static final int FOURCC_COMPRESSION_VC1 = 0x31435657;
|
||||||
|
private static final int FOURCC_COMPRESSION_DIVX = 0x58564944;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A template for the prefix that must be added to each subrip sample. The 12 byte end timecode
|
* A template for the prefix that must be added to each subrip sample. The 12 byte end timecode
|
||||||
@ -1711,13 +1713,9 @@ public final class MatroskaExtractor implements Extractor {
|
|||||||
nalUnitLengthFieldLength = hevcConfig.nalUnitLengthFieldLength;
|
nalUnitLengthFieldLength = hevcConfig.nalUnitLengthFieldLength;
|
||||||
break;
|
break;
|
||||||
case CODEC_ID_FOURCC:
|
case CODEC_ID_FOURCC:
|
||||||
initializationData = parseFourCcVc1Private(new ParsableByteArray(codecPrivate));
|
Pair<String, List<byte[]>> pair = parseFourCcPrivate(new ParsableByteArray(codecPrivate));
|
||||||
if (initializationData != null) {
|
mimeType = pair.first;
|
||||||
mimeType = MimeTypes.VIDEO_VC1;
|
initializationData = pair.second;
|
||||||
} else {
|
|
||||||
Log.w(TAG, "Unsupported FourCC. Setting mimeType to " + MimeTypes.VIDEO_UNKNOWN);
|
|
||||||
mimeType = MimeTypes.VIDEO_UNKNOWN;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case CODEC_ID_THEORA:
|
case CODEC_ID_THEORA:
|
||||||
// TODO: This can be set to the real mimeType if/when we work out what initializationData
|
// TODO: This can be set to the real mimeType if/when we work out what initializationData
|
||||||
@ -1932,21 +1930,21 @@ public final class MatroskaExtractor implements Extractor {
|
|||||||
/**
|
/**
|
||||||
* Builds initialization data for a {@link Format} from FourCC codec private data.
|
* Builds initialization data for a {@link Format} from FourCC codec private data.
|
||||||
* <p>
|
* <p>
|
||||||
* VC1 is the only supported compression type.
|
* VC1 and H263 are the only supported compression types.
|
||||||
*
|
*
|
||||||
* @return The initialization data for the {@link Format}, or null if the compression type is
|
* @return A pair object with the first object being the codec mime type
|
||||||
* not VC1.
|
* and the second object the initialization data for the {@link Format},
|
||||||
|
* or null if the compression type is not a currently supported type (VC1 or H263).
|
||||||
* @throws ParserException If the initialization data could not be built.
|
* @throws ParserException If the initialization data could not be built.
|
||||||
*/
|
*/
|
||||||
private static List<byte[]> parseFourCcVc1Private(ParsableByteArray buffer)
|
private static Pair<String, List<byte[]>> parseFourCcPrivate(ParsableByteArray buffer)
|
||||||
throws ParserException {
|
throws ParserException {
|
||||||
try {
|
try {
|
||||||
buffer.skipBytes(16); // size(4), width(4), height(4), planes(2), bitcount(2).
|
buffer.skipBytes(16); // size(4), width(4), height(4), planes(2), bitcount(2).
|
||||||
long compression = buffer.readLittleEndianUnsignedInt();
|
long compression = buffer.readLittleEndianUnsignedInt();
|
||||||
if (compression != FOURCC_COMPRESSION_VC1) {
|
if (compression == FOURCC_COMPRESSION_DIVX) {
|
||||||
return null;
|
return new Pair<>(MimeTypes.VIDEO_H263, null);
|
||||||
}
|
} else if (compression == FOURCC_COMPRESSION_VC1) {
|
||||||
|
|
||||||
// Search for the initialization data from the end of the BITMAPINFOHEADER. The last 20
|
// Search for the initialization data from the end of the BITMAPINFOHEADER. The last 20
|
||||||
// bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
|
// bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
|
||||||
int startOffset = buffer.getPosition() + 20;
|
int startOffset = buffer.getPosition() + 20;
|
||||||
@ -1956,14 +1954,17 @@ public final class MatroskaExtractor implements Extractor {
|
|||||||
&& bufferData[offset + 2] == 0x01 && bufferData[offset + 3] == 0x0F) {
|
&& bufferData[offset + 2] == 0x01 && bufferData[offset + 3] == 0x0F) {
|
||||||
// We've found the initialization data.
|
// We've found the initialization data.
|
||||||
byte[] initializationData = Arrays.copyOfRange(bufferData, offset, bufferData.length);
|
byte[] initializationData = Arrays.copyOfRange(bufferData, offset, bufferData.length);
|
||||||
return Collections.singletonList(initializationData);
|
return new Pair<>(MimeTypes.VIDEO_VC1, Collections.singletonList(initializationData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw new ParserException("Failed to find FourCC VC1 initialization data");
|
||||||
|
}
|
||||||
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
throw new ParserException("Error parsing FourCC private data");
|
||||||
|
}
|
||||||
|
|
||||||
throw new ParserException("Failed to find FourCC VC1 initialization data");
|
Log.w(TAG, "Unknown FourCC. Setting mimeType to " + MimeTypes.VIDEO_UNKNOWN);
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
return new Pair<>(MimeTypes.VIDEO_UNKNOWN, null);
|
||||||
throw new ParserException("Error parsing FourCC VC1 codec private");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user