Take into account init data size for input buffer size
Issue: #2900 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=164110904
This commit is contained in:
parent
db99187381
commit
cb00b0209f
@ -477,7 +477,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||||||
Format oldFormat, Format newFormat) {
|
Format oldFormat, Format newFormat) {
|
||||||
return areAdaptationCompatible(codecIsAdaptive, oldFormat, newFormat)
|
return areAdaptationCompatible(codecIsAdaptive, oldFormat, newFormat)
|
||||||
&& newFormat.width <= codecMaxValues.width && newFormat.height <= codecMaxValues.height
|
&& newFormat.width <= codecMaxValues.width && newFormat.height <= codecMaxValues.height
|
||||||
&& newFormat.maxInputSize <= codecMaxValues.inputSize;
|
&& getMaxInputSize(newFormat) <= codecMaxValues.inputSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -854,18 +854,27 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a maximum input size for a given format.
|
* Returns a maximum input buffer size for a given format.
|
||||||
*
|
*
|
||||||
* @param format The format.
|
* @param format The format.
|
||||||
* @return A maximum input size in bytes, or {@link Format#NO_VALUE} if a maximum could not be
|
* @return A maximum input buffer size in bytes, or {@link Format#NO_VALUE} if a maximum could not
|
||||||
* determined.
|
* be determined.
|
||||||
*/
|
*/
|
||||||
private static int getMaxInputSize(Format format) {
|
private static int getMaxInputSize(Format format) {
|
||||||
if (format.maxInputSize != Format.NO_VALUE) {
|
if (format.maxInputSize != Format.NO_VALUE) {
|
||||||
// The format defines an explicit maximum input size.
|
// The format defines an explicit maximum input size. Add the total size of initialization
|
||||||
return format.maxInputSize;
|
// data buffers, as they may need to be queued in the same input buffer as the largest sample.
|
||||||
|
int totalInitializationDataSize = 0;
|
||||||
|
int initializationDataCount = format.initializationData.size();
|
||||||
|
for (int i = 0; i < initializationDataCount; i++) {
|
||||||
|
totalInitializationDataSize += format.initializationData.get(i).length;
|
||||||
|
}
|
||||||
|
return format.maxInputSize + totalInitializationDataSize;
|
||||||
|
} else {
|
||||||
|
// Calculated maximum input sizes are overestimates, so it's not necessary to add the size of
|
||||||
|
// initialization data.
|
||||||
|
return getMaxInputSize(format.sampleMimeType, format.width, format.height);
|
||||||
}
|
}
|
||||||
return getMaxInputSize(format.sampleMimeType, format.width, format.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user