Skip to content

Commit

Permalink
Include CamcorderProfile resolution in encoder capability test
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 472459423
  • Loading branch information
claincly authored and marcbaechinger committed Oct 19, 2022
1 parent ce0e3a4 commit 6e45824
Showing 1 changed file with 62 additions and 0 deletions.
Expand Up @@ -21,6 +21,7 @@
import static android.media.MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CQ;
import static android.media.MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR;

import android.media.CamcorderProfile;
import android.media.MediaCodecInfo;
import android.util.Pair;
import android.util.Range;
Expand Down Expand Up @@ -53,6 +54,44 @@ public class EncoderCapabilityAnalysisTest {
*/
private static final String FEATURE_EncodingStatistics = "encoding-statistics";

private static final String CAMCORDER_FORMAT_STRING = "%dx%d@%dfps:%dkbps";
private static final String CAMCORDER_TIMELAPSE_FORMAT_STRING = "timelapse_%dx%d@%dfps:%dkbps";
private static final String CAMCORDER_HIGH_SPEED_FORMAT_STRING = "highspeed_%dx%d@%dfps:%dkbps";

private static final ImmutableList<Integer> DEFINED_CAMCORDER_PROFILES =
ImmutableList.of(
CamcorderProfile.QUALITY_QCIF,
CamcorderProfile.QUALITY_CIF,
CamcorderProfile.QUALITY_480P,
CamcorderProfile.QUALITY_720P,
CamcorderProfile.QUALITY_1080P,
CamcorderProfile.QUALITY_QVGA,
CamcorderProfile.QUALITY_2160P,
CamcorderProfile.QUALITY_VGA,
CamcorderProfile.QUALITY_4KDCI,
CamcorderProfile.QUALITY_QHD,
CamcorderProfile.QUALITY_2K,
CamcorderProfile.QUALITY_8KUHD,
CamcorderProfile.QUALITY_TIME_LAPSE_QCIF,
CamcorderProfile.QUALITY_TIME_LAPSE_CIF,
CamcorderProfile.QUALITY_TIME_LAPSE_480P,
CamcorderProfile.QUALITY_TIME_LAPSE_720P,
CamcorderProfile.QUALITY_TIME_LAPSE_1080P,
CamcorderProfile.QUALITY_TIME_LAPSE_QVGA,
CamcorderProfile.QUALITY_TIME_LAPSE_2160P,
CamcorderProfile.QUALITY_TIME_LAPSE_VGA,
CamcorderProfile.QUALITY_TIME_LAPSE_4KDCI,
CamcorderProfile.QUALITY_TIME_LAPSE_QHD,
CamcorderProfile.QUALITY_TIME_LAPSE_2K,
CamcorderProfile.QUALITY_TIME_LAPSE_8KUHD,
CamcorderProfile.QUALITY_HIGH_SPEED_480P,
CamcorderProfile.QUALITY_HIGH_SPEED_720P,
CamcorderProfile.QUALITY_HIGH_SPEED_1080P,
CamcorderProfile.QUALITY_HIGH_SPEED_2160P,
CamcorderProfile.QUALITY_HIGH_SPEED_CIF,
CamcorderProfile.QUALITY_HIGH_SPEED_VGA,
CamcorderProfile.QUALITY_HIGH_SPEED_4KDCI);

@Test
public void logEncoderCapabilities() throws Exception {
ImmutableSet<String> supportedVideoMimeTypes = EncoderUtil.getSupportedVideoMimeTypes();
Expand Down Expand Up @@ -138,6 +177,7 @@ public void logEncoderCapabilities() throws Exception {

JSONObject resultJson = new JSONObject();
resultJson.put("encoder_capabilities", JSONObject.wrap(mimeTypeToEncoderInfo));
resultJson.put("camcorder_profiles_supported", getSupportedCamcorderProfileConfigurations());
AndroidTestUtil.writeTestSummaryToFile(
ApplicationProvider.getApplicationContext(),
/* testId= */ "encoderCapabilityAnalysisTest",
Expand Down Expand Up @@ -194,4 +234,26 @@ private static String rangeToString(@Nullable Range<Integer> range) {
private static String sizeToString(@Nullable Size size) {
return size == null ? "0x0" : Util.formatInvariant("%dx%d", size.getWidth(), size.getHeight());
}

private static ImmutableList<String> getSupportedCamcorderProfileConfigurations() {
ImmutableList.Builder<String> supportedConfigurations = new ImmutableList.Builder<>();
for (int profileIndex : DEFINED_CAMCORDER_PROFILES) {
if (CamcorderProfile.hasProfile(profileIndex)) {
CamcorderProfile profile = CamcorderProfile.get(profileIndex);
supportedConfigurations.add(
Util.formatInvariant(
profileIndex > CamcorderProfile.QUALITY_HIGH_SPEED_LOW
? CAMCORDER_HIGH_SPEED_FORMAT_STRING
: profileIndex > CamcorderProfile.QUALITY_TIME_LAPSE_LOW
? CAMCORDER_TIMELAPSE_FORMAT_STRING
: CAMCORDER_FORMAT_STRING,
profile.videoFrameWidth,
profile.videoFrameHeight,
profile.videoFrameRate,
// Converts bps to kbps.
profile.videoBitRate / 1000));
}
}
return supportedConfigurations.build();
}
}

0 comments on commit 6e45824

Please sign in to comment.