Java Code Examples for com.google.android.exoplayer2.util.MimeTypes#VIDEO_H263

The following examples show how to use com.google.android.exoplayer2.util.MimeTypes#VIDEO_H263 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MatroskaExtractor.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Builds initialization data for a {@link Format} from FourCC codec private data.
 *
 * @return The codec mime type and initialization data. If the compression type is not supported
 *     then the mime type is set to {@link MimeTypes#VIDEO_UNKNOWN} and the initialization data
 *     is {@code null}.
 * @throws ParserException If the initialization data could not be built.
 */
private static Pair<String, List<byte[]>> parseFourCcPrivate(ParsableByteArray buffer)
    throws ParserException {
  try {
    buffer.skipBytes(16); // size(4), width(4), height(4), planes(2), bitcount(2).
    long compression = buffer.readLittleEndianUnsignedInt();
    if (compression == FOURCC_COMPRESSION_DIVX) {
      return new Pair<>(MimeTypes.VIDEO_DIVX, null);
    } else if (compression == FOURCC_COMPRESSION_H263) {
      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
      // bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
      int startOffset = buffer.getPosition() + 20;
      byte[] bufferData = buffer.data;
      for (int offset = startOffset; offset < bufferData.length - 4; offset++) {
        if (bufferData[offset] == 0x00
            && bufferData[offset + 1] == 0x00
            && bufferData[offset + 2] == 0x01
            && bufferData[offset + 3] == 0x0F) {
          // We've found the initialization data.
          byte[] initializationData = Arrays.copyOfRange(bufferData, offset, bufferData.length);
          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");
  }

  Log.w(TAG, "Unknown FourCC. Setting mimeType to " + MimeTypes.VIDEO_UNKNOWN);
  return new Pair<>(MimeTypes.VIDEO_UNKNOWN, null);
}
 
Example 2
Source File: MatroskaExtractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds initialization data for a {@link Format} from FourCC codec private data.
 *
 * <p>VC1 and H263 are the only supported compression types.
 *
 * @return The codec mime type and initialization data. If the compression type is not supported
 *     then the mime type is set to {@link MimeTypes#VIDEO_UNKNOWN} and the initialization data
 *     is {@code null}.
 * @throws ParserException If the initialization data could not be built.
 */
private static Pair<String, List<byte[]>> parseFourCcPrivate(ParsableByteArray buffer)
    throws ParserException {
  try {
    buffer.skipBytes(16); // size(4), width(4), height(4), planes(2), bitcount(2).
    long compression = buffer.readLittleEndianUnsignedInt();
    if (compression == FOURCC_COMPRESSION_DIVX) {
      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
      // bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
      int startOffset = buffer.getPosition() + 20;
      byte[] bufferData = buffer.data;
      for (int offset = startOffset; offset < bufferData.length - 4; offset++) {
        if (bufferData[offset] == 0x00
            && bufferData[offset + 1] == 0x00
            && bufferData[offset + 2] == 0x01
            && bufferData[offset + 3] == 0x0F) {
          // We've found the initialization data.
          byte[] initializationData = Arrays.copyOfRange(bufferData, offset, bufferData.length);
          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");
  }

  Log.w(TAG, "Unknown FourCC. Setting mimeType to " + MimeTypes.VIDEO_UNKNOWN);
  return new Pair<>(MimeTypes.VIDEO_UNKNOWN, null);
}
 
Example 3
Source File: MatroskaExtractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds initialization data for a {@link Format} from FourCC codec private data.
 *
 * <p>VC1 and H263 are the only supported compression types.
 *
 * @return The codec mime type and initialization data. If the compression type is not supported
 *     then the mime type is set to {@link MimeTypes#VIDEO_UNKNOWN} and the initialization data
 *     is {@code null}.
 * @throws ParserException If the initialization data could not be built.
 */
private static Pair<String, List<byte[]>> parseFourCcPrivate(ParsableByteArray buffer)
    throws ParserException {
  try {
    buffer.skipBytes(16); // size(4), width(4), height(4), planes(2), bitcount(2).
    long compression = buffer.readLittleEndianUnsignedInt();
    if (compression == FOURCC_COMPRESSION_DIVX) {
      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
      // bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
      int startOffset = buffer.getPosition() + 20;
      byte[] bufferData = buffer.data;
      for (int offset = startOffset; offset < bufferData.length - 4; offset++) {
        if (bufferData[offset] == 0x00
            && bufferData[offset + 1] == 0x00
            && bufferData[offset + 2] == 0x01
            && bufferData[offset + 3] == 0x0F) {
          // We've found the initialization data.
          byte[] initializationData = Arrays.copyOfRange(bufferData, offset, bufferData.length);
          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");
  }

  Log.w(TAG, "Unknown FourCC. Setting mimeType to " + MimeTypes.VIDEO_UNKNOWN);
  return new Pair<>(MimeTypes.VIDEO_UNKNOWN, null);
}
 
Example 4
Source File: MatroskaExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds initialization data for a {@link Format} from FourCC codec private data.
 *
 * @return The codec mime type and initialization data. If the compression type is not supported
 *     then the mime type is set to {@link MimeTypes#VIDEO_UNKNOWN} and the initialization data
 *     is {@code null}.
 * @throws ParserException If the initialization data could not be built.
 */
private static Pair<String, List<byte[]>> parseFourCcPrivate(ParsableByteArray buffer)
    throws ParserException {
  try {
    buffer.skipBytes(16); // size(4), width(4), height(4), planes(2), bitcount(2).
    long compression = buffer.readLittleEndianUnsignedInt();
    if (compression == FOURCC_COMPRESSION_DIVX) {
      return new Pair<>(MimeTypes.VIDEO_DIVX, null);
    } else if (compression == FOURCC_COMPRESSION_H263) {
      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
      // bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
      int startOffset = buffer.getPosition() + 20;
      byte[] bufferData = buffer.data;
      for (int offset = startOffset; offset < bufferData.length - 4; offset++) {
        if (bufferData[offset] == 0x00
            && bufferData[offset + 1] == 0x00
            && bufferData[offset + 2] == 0x01
            && bufferData[offset + 3] == 0x0F) {
          // We've found the initialization data.
          byte[] initializationData = Arrays.copyOfRange(bufferData, offset, bufferData.length);
          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");
  }

  Log.w(TAG, "Unknown FourCC. Setting mimeType to " + MimeTypes.VIDEO_UNKNOWN);
  return new Pair<>(MimeTypes.VIDEO_UNKNOWN, null);
}
 
Example 5
Source File: MatroskaExtractor.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds initialization data for a {@link Format} from FourCC codec private data.
 *
 * @return The codec mime type and initialization data. If the compression type is not supported
 *     then the mime type is set to {@link MimeTypes#VIDEO_UNKNOWN} and the initialization data
 *     is {@code null}.
 * @throws ParserException If the initialization data could not be built.
 */
private static Pair<String, List<byte[]>> parseFourCcPrivate(ParsableByteArray buffer)
    throws ParserException {
  try {
    buffer.skipBytes(16); // size(4), width(4), height(4), planes(2), bitcount(2).
    long compression = buffer.readLittleEndianUnsignedInt();
    if (compression == FOURCC_COMPRESSION_DIVX) {
      return new Pair<>(MimeTypes.VIDEO_DIVX, null);
    } else if (compression == FOURCC_COMPRESSION_H263) {
      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
      // bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
      int startOffset = buffer.getPosition() + 20;
      byte[] bufferData = buffer.data;
      for (int offset = startOffset; offset < bufferData.length - 4; offset++) {
        if (bufferData[offset] == 0x00
            && bufferData[offset + 1] == 0x00
            && bufferData[offset + 2] == 0x01
            && bufferData[offset + 3] == 0x0F) {
          // We've found the initialization data.
          byte[] initializationData = Arrays.copyOfRange(bufferData, offset, bufferData.length);
          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");
  }

  Log.w(TAG, "Unknown FourCC. Setting mimeType to " + MimeTypes.VIDEO_UNKNOWN);
  return new Pair<>(MimeTypes.VIDEO_UNKNOWN, null);
}
 
Example 6
Source File: MediaCodecVideoRenderer.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a maximum input size for a given codec, MIME type, width and height.
 *
 * @param codecInfo Information about the {@link MediaCodec} being configured.
 * @param sampleMimeType The format mime type.
 * @param width The width in pixels.
 * @param height The height in pixels.
 * @return A maximum input size in bytes, or {@link Format#NO_VALUE} if a maximum could not be
 *     determined.
 */
private static int getCodecMaxInputSize(
    MediaCodecInfo codecInfo, String sampleMimeType, int width, int height) {
  if (width == Format.NO_VALUE || height == Format.NO_VALUE) {
    // We can't infer a maximum input size without video dimensions.
    return Format.NO_VALUE;
  }

  // Attempt to infer a maximum input size from the format.
  int maxPixels;
  int minCompressionRatio;
  switch (sampleMimeType) {
    case MimeTypes.VIDEO_H263:
    case MimeTypes.VIDEO_MP4V:
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H264:
      if ("BRAVIA 4K 2015".equals(Util.MODEL) // Sony Bravia 4K
          || ("Amazon".equals(Util.MANUFACTURER)
              && ("KFSOWI".equals(Util.MODEL) // Kindle Soho
                  || ("AFTS".equals(Util.MODEL) && codecInfo.secure)))) { // Fire TV Gen 2
        // Use the default value for cases where platform limitations may prevent buffers of the
        // calculated maximum input size from being allocated.
        return Format.NO_VALUE;
      }
      // Round up width/height to an integer number of macroblocks.
      maxPixels = Util.ceilDivide(width, 16) * Util.ceilDivide(height, 16) * 16 * 16;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_VP8:
      // VPX does not specify a ratio so use the values from the platform's SoftVPX.cpp.
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H265:
    case MimeTypes.VIDEO_VP9:
      maxPixels = width * height;
      minCompressionRatio = 4;
      break;
    default:
      // Leave the default max input size.
      return Format.NO_VALUE;
  }
  // Estimate the maximum input size assuming three channel 4:2:0 subsampled input frames.
  return (maxPixels * 3) / (2 * minCompressionRatio);
}
 
Example 7
Source File: MediaCodecVideoRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a maximum input size for a given codec, mime type, width and height.
 *
 * @param codecInfo Information about the {@link MediaCodec} being configured.
 * @param sampleMimeType The format mime type.
 * @param width The width in pixels.
 * @param height The height in pixels.
 * @return A maximum input size in bytes, or {@link Format#NO_VALUE} if a maximum could not be
 *     determined.
 */
private static int getMaxInputSize(
    MediaCodecInfo codecInfo, String sampleMimeType, int width, int height) {
  if (width == Format.NO_VALUE || height == Format.NO_VALUE) {
    // We can't infer a maximum input size without video dimensions.
    return Format.NO_VALUE;
  }

  // Attempt to infer a maximum input size from the format.
  int maxPixels;
  int minCompressionRatio;
  switch (sampleMimeType) {
    case MimeTypes.VIDEO_H263:
    case MimeTypes.VIDEO_MP4V:
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H264:
      if ("BRAVIA 4K 2015".equals(Util.MODEL) // Sony Bravia 4K
          || ("Amazon".equals(Util.MANUFACTURER)
              && ("KFSOWI".equals(Util.MODEL) // Kindle Soho
                  || ("AFTS".equals(Util.MODEL) && codecInfo.secure)))) { // Fire TV Gen 2
        // Use the default value for cases where platform limitations may prevent buffers of the
        // calculated maximum input size from being allocated.
        return Format.NO_VALUE;
      }
      // Round up width/height to an integer number of macroblocks.
      maxPixels = Util.ceilDivide(width, 16) * Util.ceilDivide(height, 16) * 16 * 16;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_VP8:
      // VPX does not specify a ratio so use the values from the platform's SoftVPX.cpp.
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H265:
    case MimeTypes.VIDEO_VP9:
      maxPixels = width * height;
      minCompressionRatio = 4;
      break;
    default:
      // Leave the default max input size.
      return Format.NO_VALUE;
  }
  // Estimate the maximum input size assuming three channel 4:2:0 subsampled input frames.
  return (maxPixels * 3) / (2 * minCompressionRatio);
}
 
Example 8
Source File: MediaCodecVideoRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a maximum input size for a given codec, mime type, width and height.
 *
 * @param codecInfo Information about the {@link MediaCodec} being configured.
 * @param sampleMimeType The format mime type.
 * @param width The width in pixels.
 * @param height The height in pixels.
 * @return A maximum input size in bytes, or {@link Format#NO_VALUE} if a maximum could not be
 *     determined.
 */
private static int getMaxInputSize(
    MediaCodecInfo codecInfo, String sampleMimeType, int width, int height) {
  if (width == Format.NO_VALUE || height == Format.NO_VALUE) {
    // We can't infer a maximum input size without video dimensions.
    return Format.NO_VALUE;
  }

  // Attempt to infer a maximum input size from the format.
  int maxPixels;
  int minCompressionRatio;
  switch (sampleMimeType) {
    case MimeTypes.VIDEO_H263:
    case MimeTypes.VIDEO_MP4V:
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H264:
      if ("BRAVIA 4K 2015".equals(Util.MODEL) // Sony Bravia 4K
          || ("Amazon".equals(Util.MANUFACTURER)
              && ("KFSOWI".equals(Util.MODEL) // Kindle Soho
                  || ("AFTS".equals(Util.MODEL) && codecInfo.secure)))) { // Fire TV Gen 2
        // Use the default value for cases where platform limitations may prevent buffers of the
        // calculated maximum input size from being allocated.
        return Format.NO_VALUE;
      }
      // Round up width/height to an integer number of macroblocks.
      maxPixels = Util.ceilDivide(width, 16) * Util.ceilDivide(height, 16) * 16 * 16;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_VP8:
      // VPX does not specify a ratio so use the values from the platform's SoftVPX.cpp.
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H265:
    case MimeTypes.VIDEO_VP9:
      maxPixels = width * height;
      minCompressionRatio = 4;
      break;
    default:
      // Leave the default max input size.
      return Format.NO_VALUE;
  }
  // Estimate the maximum input size assuming three channel 4:2:0 subsampled input frames.
  return (maxPixels * 3) / (2 * minCompressionRatio);
}
 
Example 9
Source File: MediaCodecVideoRenderer.java    From K-Sonic with MIT License 4 votes vote down vote up
/**
 * Returns a maximum input size for a given mime type, width and height.
 *
 * @param sampleMimeType The format mime type.
 * @param width The width in pixels.
 * @param height The height in pixels.
 * @return A maximum input size in bytes, or {@link Format#NO_VALUE} if a maximum could not be
 *     determined.
 */
private static int getMaxInputSize(String sampleMimeType, int width, int height) {
  if (width == Format.NO_VALUE || height == Format.NO_VALUE) {
    // We can't infer a maximum input size without video dimensions.
    return Format.NO_VALUE;
  }

  // Attempt to infer a maximum input size from the format.
  int maxPixels;
  int minCompressionRatio;
  switch (sampleMimeType) {
    case MimeTypes.VIDEO_H263:
    case MimeTypes.VIDEO_MP4V:
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H264:
      if ("BRAVIA 4K 2015".equals(Util.MODEL)) {
        // The Sony BRAVIA 4k TV has input buffers that are too small for the calculated 4k video
        // maximum input size, so use the default value.
        return Format.NO_VALUE;
      }
      // Round up width/height to an integer number of macroblocks.
      maxPixels = Util.ceilDivide(width, 16) * Util.ceilDivide(height, 16) * 16 * 16;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_VP8:
      // VPX does not specify a ratio so use the values from the platform's SoftVPX.cpp.
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H265:
    case MimeTypes.VIDEO_VP9:
      maxPixels = width * height;
      minCompressionRatio = 4;
      break;
    default:
      // Leave the default max input size.
      return Format.NO_VALUE;
  }
  // Estimate the maximum input size assuming three channel 4:2:0 subsampled input frames.
  return (maxPixels * 3) / (2 * minCompressionRatio);
}
 
Example 10
Source File: MediaCodecVideoRenderer.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a maximum input size for a given codec, MIME type, width and height.
 *
 * @param codecInfo Information about the {@link MediaCodec} being configured.
 * @param sampleMimeType The format mime type.
 * @param width The width in pixels.
 * @param height The height in pixels.
 * @return A maximum input size in bytes, or {@link Format#NO_VALUE} if a maximum could not be
 *     determined.
 */
private static int getCodecMaxInputSize(
    MediaCodecInfo codecInfo, String sampleMimeType, int width, int height) {
  if (width == Format.NO_VALUE || height == Format.NO_VALUE) {
    // We can't infer a maximum input size without video dimensions.
    return Format.NO_VALUE;
  }

  // Attempt to infer a maximum input size from the format.
  int maxPixels;
  int minCompressionRatio;
  switch (sampleMimeType) {
    case MimeTypes.VIDEO_H263:
    case MimeTypes.VIDEO_MP4V:
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H264:
      if ("BRAVIA 4K 2015".equals(Util.MODEL) // Sony Bravia 4K
          || ("Amazon".equals(Util.MANUFACTURER)
              && ("KFSOWI".equals(Util.MODEL) // Kindle Soho
                  || ("AFTS".equals(Util.MODEL) && codecInfo.secure)))) { // Fire TV Gen 2
        // Use the default value for cases where platform limitations may prevent buffers of the
        // calculated maximum input size from being allocated.
        return Format.NO_VALUE;
      }
      // Round up width/height to an integer number of macroblocks.
      maxPixels = Util.ceilDivide(width, 16) * Util.ceilDivide(height, 16) * 16 * 16;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_VP8:
      // VPX does not specify a ratio so use the values from the platform's SoftVPX.cpp.
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H265:
    case MimeTypes.VIDEO_VP9:
      maxPixels = width * height;
      minCompressionRatio = 4;
      break;
    default:
      // Leave the default max input size.
      return Format.NO_VALUE;
  }
  // Estimate the maximum input size assuming three channel 4:2:0 subsampled input frames.
  return (maxPixels * 3) / (2 * minCompressionRatio);
}
 
Example 11
Source File: MediaCodecVideoRenderer.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a maximum input size for a given codec, MIME type, width and height.
 *
 * @param codecInfo Information about the {@link MediaCodec} being configured.
 * @param sampleMimeType The format mime type.
 * @param width The width in pixels.
 * @param height The height in pixels.
 * @return A maximum input size in bytes, or {@link Format#NO_VALUE} if a maximum could not be
 *     determined.
 */
private static int getCodecMaxInputSize(
    MediaCodecInfo codecInfo, String sampleMimeType, int width, int height) {
  if (width == Format.NO_VALUE || height == Format.NO_VALUE) {
    // We can't infer a maximum input size without video dimensions.
    return Format.NO_VALUE;
  }

  // Attempt to infer a maximum input size from the format.
  int maxPixels;
  int minCompressionRatio;
  switch (sampleMimeType) {
    case MimeTypes.VIDEO_H263:
    case MimeTypes.VIDEO_MP4V:
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H264:
      if ("BRAVIA 4K 2015".equals(Util.MODEL) // Sony Bravia 4K
          || ("Amazon".equals(Util.MANUFACTURER)
              && ("KFSOWI".equals(Util.MODEL) // Kindle Soho
                  || ("AFTS".equals(Util.MODEL) && codecInfo.secure)))) { // Fire TV Gen 2
        // Use the default value for cases where platform limitations may prevent buffers of the
        // calculated maximum input size from being allocated.
        return Format.NO_VALUE;
      }
      // Round up width/height to an integer number of macroblocks.
      maxPixels = Util.ceilDivide(width, 16) * Util.ceilDivide(height, 16) * 16 * 16;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_VP8:
      // VPX does not specify a ratio so use the values from the platform's SoftVPX.cpp.
      maxPixels = width * height;
      minCompressionRatio = 2;
      break;
    case MimeTypes.VIDEO_H265:
    case MimeTypes.VIDEO_VP9:
      maxPixels = width * height;
      minCompressionRatio = 4;
      break;
    default:
      // Leave the default max input size.
      return Format.NO_VALUE;
  }
  // Estimate the maximum input size assuming three channel 4:2:0 subsampled input frames.
  return (maxPixels * 3) / (2 * minCompressionRatio);
}