Merge "Use advertised h264 encoding parameters by default if the profile is not baseline"
This commit is contained in:
@@ -1136,10 +1136,69 @@ status_t StagefrightRecorder::checkVideoEncoderCapabilities() {
|
||||
clipVideoFrameRate();
|
||||
clipVideoFrameWidth();
|
||||
clipVideoFrameHeight();
|
||||
setDefaultProfileIfNecessary();
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
// Set to use AVC baseline profile if the encoding parameters matches
|
||||
// CAMCORDER_QUALITY_LOW profile; this is for the sake of MMS service.
|
||||
void StagefrightRecorder::setDefaultProfileIfNecessary() {
|
||||
LOGV("setDefaultProfileIfNecessary");
|
||||
|
||||
camcorder_quality quality = CAMCORDER_QUALITY_LOW;
|
||||
|
||||
int64_t durationUs = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"duration", mCameraId, quality) * 1000000LL;
|
||||
|
||||
int fileFormat = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"file.format", mCameraId, quality);
|
||||
|
||||
int videoCodec = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"vid.codec", mCameraId, quality);
|
||||
|
||||
int videoBitRate = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"vid.bps", mCameraId, quality);
|
||||
|
||||
int videoFrameRate = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"vid.fps", mCameraId, quality);
|
||||
|
||||
int videoFrameWidth = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"vid.width", mCameraId, quality);
|
||||
|
||||
int videoFrameHeight = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"vid.height", mCameraId, quality);
|
||||
|
||||
int audioCodec = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"aud.codec", mCameraId, quality);
|
||||
|
||||
int audioBitRate = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"aud.bps", mCameraId, quality);
|
||||
|
||||
int audioSampleRate = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"aud.hz", mCameraId, quality);
|
||||
|
||||
int audioChannels = mEncoderProfiles->getCamcorderProfileParamByName(
|
||||
"aud.ch", mCameraId, quality);
|
||||
|
||||
if (durationUs == mMaxFileDurationUs &&
|
||||
fileFormat == mOutputFormat &&
|
||||
videoCodec == mVideoEncoder &&
|
||||
videoBitRate == mVideoBitRate &&
|
||||
videoFrameRate == mFrameRate &&
|
||||
videoFrameWidth == mVideoWidth &&
|
||||
videoFrameHeight == mVideoHeight &&
|
||||
audioCodec == mAudioEncoder &&
|
||||
audioBitRate == mAudioBitRate &&
|
||||
audioSampleRate == mSampleRate &&
|
||||
audioChannels == mAudioChannels) {
|
||||
if (videoCodec == VIDEO_ENCODER_H264) {
|
||||
LOGI("Force to use AVC baseline profile");
|
||||
setParamVideoEncoderProfile(OMX_VIDEO_AVCProfileBaseline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
status_t StagefrightRecorder::checkAudioEncoderCapabilities() {
|
||||
clipAudioBitRate();
|
||||
clipAudioSampleRate();
|
||||
|
||||
@@ -174,6 +174,7 @@ private:
|
||||
void clipAudioBitRate();
|
||||
void clipAudioSampleRate();
|
||||
void clipNumberOfAudioChannels();
|
||||
void setDefaultProfileIfNecessary();
|
||||
|
||||
StagefrightRecorder(const StagefrightRecorder &);
|
||||
StagefrightRecorder &operator=(const StagefrightRecorder &);
|
||||
|
||||
@@ -1295,13 +1295,6 @@ status_t OMXCodec::setupAVCEncoderParameters(const sp<MetaData>& meta) {
|
||||
h264type.nAllowedPictureTypes =
|
||||
OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
|
||||
|
||||
h264type.nSliceHeaderSpacing = 0;
|
||||
h264type.nBFrames = 0; // No B frames support yet
|
||||
h264type.nPFrames = setPFramesSpacing(iFramesInterval, frameRate);
|
||||
if (h264type.nPFrames == 0) {
|
||||
h264type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI;
|
||||
}
|
||||
|
||||
// Check profile and level parameters
|
||||
CodecProfileLevel defaultProfileLevel, profileLevel;
|
||||
defaultProfileLevel.mProfile = h264type.eProfile;
|
||||
@@ -1312,8 +1305,14 @@ status_t OMXCodec::setupAVCEncoderParameters(const sp<MetaData>& meta) {
|
||||
h264type.eLevel = static_cast<OMX_VIDEO_AVCLEVELTYPE>(profileLevel.mLevel);
|
||||
|
||||
if (h264type.eProfile == OMX_VIDEO_AVCProfileBaseline) {
|
||||
h264type.nSliceHeaderSpacing = 0;
|
||||
h264type.bUseHadamard = OMX_TRUE;
|
||||
h264type.nRefFrames = 1;
|
||||
h264type.nBFrames = 0;
|
||||
h264type.nPFrames = setPFramesSpacing(iFramesInterval, frameRate);
|
||||
if (h264type.nPFrames == 0) {
|
||||
h264type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI;
|
||||
}
|
||||
h264type.nRefIdx10ActiveMinus1 = 0;
|
||||
h264type.nRefIdx11ActiveMinus1 = 0;
|
||||
h264type.bEntropyCodingCABAC = OMX_FALSE;
|
||||
|
||||
Reference in New Issue
Block a user