mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Include CamcorderProfile resolution in encoder capability test
PiperOrigin-RevId: 472459423 (cherry picked from commit 3f6a59f0f776e160aa88e69af69aa5749f594f2a)
This commit is contained in:
parent
0ac950321e
commit
18188ebe01
@ -21,6 +21,7 @@ import static android.media.MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CBR_
|
||||
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;
|
||||
@ -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();
|
||||
@ -138,6 +177,7 @@ public class EncoderCapabilityAnalysisTest {
|
||||
|
||||
JSONObject resultJson = new JSONObject();
|
||||
resultJson.put("encoder_capabilities", JSONObject.wrap(mimeTypeToEncoderInfo));
|
||||
resultJson.put("camcorder_profiles_supported", getSupportedCamcorderProfileConfigurations());
|
||||
AndroidTestUtil.writeTestSummaryToFile(
|
||||
ApplicationProvider.getApplicationContext(),
|
||||
/* testId= */ "encoderCapabilityAnalysisTest",
|
||||
@ -194,4 +234,26 @@ public class EncoderCapabilityAnalysisTest {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user