summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-04-27 17:40:16 -0700
committerJames Dong <jdong@google.com>2012-04-30 14:35:57 -0700
commita3cbc03f7c646ad9b05d24e72a6d306cb457807c (patch)
treed8083e9a24b1906469cf993d27267166b8365724 /media/libstagefright
parent99bbaff7853eab325bd87b315d532909206592b1 (diff)
downloadframeworks_av-a3cbc03f7c646ad9b05d24e72a6d306cb457807c.zip
frameworks_av-a3cbc03f7c646ad9b05d24e72a6d306cb457807c.tar.gz
frameworks_av-a3cbc03f7c646ad9b05d24e72a6d306cb457807c.tar.bz2
Removed software video encoders that are not OMX-based.
o related-to-bug: 5933287 Change-Id: I63635375e2bef00733b61adc3fa12c29df7e2155
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/Android.mk2
-rw-r--r--media/libstagefright/MediaCodecList.cpp5
-rwxr-xr-xmedia/libstagefright/OMXCodec.cpp6
-rw-r--r--media/libstagefright/codecs/avc/enc/AVCEncoder.cpp619
-rw-r--r--media/libstagefright/codecs/avc/enc/Android.mk2
-rw-r--r--media/libstagefright/codecs/m4v_h263/enc/Android.mk2
-rw-r--r--media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp487
-rw-r--r--media/libstagefright/include/AVCEncoder.h91
-rw-r--r--media/libstagefright/include/M4vH263Encoder.h81
9 files changed, 0 insertions, 1295 deletions
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
index 2169cac..e2e5091 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -91,8 +91,6 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_STATIC_LIBRARIES := \
libstagefright_color_conversion \
libstagefright_aacenc \
- libstagefright_avcenc \
- libstagefright_m4vh263enc \
libstagefright_matroska \
libstagefright_timedtext \
libvpx \
diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp
index c39aa77..9f6d4a3 100644
--- a/media/libstagefright/MediaCodecList.cpp
+++ b/media/libstagefright/MediaCodecList.cpp
@@ -61,11 +61,6 @@ MediaCodecList::MediaCodecList()
// These are currently still used by the video editing suite.
addMediaCodec(true /* encoder */, "AACEncoder", "audio/mp4a-latm");
- addMediaCodec(true /* encoder */, "AVCEncoder", "video/avc");
-
- addMediaCodec(true /* encoder */, "M4vH263Encoder");
- addType("video/3gpp");
- addType("video/mp4v-es");
addMediaCodec(
false /* encoder */, "OMX.google.raw.decoder", "audio/raw");
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index fb6491b..791e044 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -19,8 +19,6 @@
#include <utils/Log.h>
#include "include/AACEncoder.h"
-#include "include/AVCEncoder.h"
-#include "include/M4vH263Encoder.h"
#include "include/ESDS.h"
@@ -67,8 +65,6 @@ static sp<MediaSource> Make##name(const sp<MediaSource> &source, const sp<MetaDa
#define FACTORY_REF(name) { #name, Make##name },
FACTORY_CREATE_ENCODER(AACEncoder)
-FACTORY_CREATE_ENCODER(AVCEncoder)
-FACTORY_CREATE_ENCODER(M4vH263Encoder)
static sp<MediaSource> InstantiateSoftwareEncoder(
const char *name, const sp<MediaSource> &source,
@@ -80,8 +76,6 @@ static sp<MediaSource> InstantiateSoftwareEncoder(
static const FactoryInfo kFactoryInfo[] = {
FACTORY_REF(AACEncoder)
- FACTORY_REF(AVCEncoder)
- FACTORY_REF(M4vH263Encoder)
};
for (size_t i = 0;
i < sizeof(kFactoryInfo) / sizeof(kFactoryInfo[0]); ++i) {
diff --git a/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp b/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp
deleted file mode 100644
index 7533f07..0000000
--- a/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp
+++ /dev/null
@@ -1,619 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "AVCEncoder"
-#include <utils/Log.h>
-
-#include "AVCEncoder.h"
-
-#include "avcenc_api.h"
-#include "avcenc_int.h"
-#include "OMX_Video.h"
-
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/Utils.h>
-
-namespace android {
-
-static status_t ConvertOmxAvcProfileToAvcSpecProfile(
- int32_t omxProfile, AVCProfile* pvProfile) {
- ALOGV("ConvertOmxAvcProfileToAvcSpecProfile: %d", omxProfile);
- switch (omxProfile) {
- case OMX_VIDEO_AVCProfileBaseline:
- *pvProfile = AVC_BASELINE;
- return OK;
- default:
- ALOGE("Unsupported omx profile: %d", omxProfile);
- }
- return BAD_VALUE;
-}
-
-static status_t ConvertOmxAvcLevelToAvcSpecLevel(
- int32_t omxLevel, AVCLevel *pvLevel) {
- ALOGV("ConvertOmxAvcLevelToAvcSpecLevel: %d", omxLevel);
- AVCLevel level = AVC_LEVEL5_1;
- switch (omxLevel) {
- case OMX_VIDEO_AVCLevel1:
- level = AVC_LEVEL1_B;
- break;
- case OMX_VIDEO_AVCLevel1b:
- level = AVC_LEVEL1;
- break;
- case OMX_VIDEO_AVCLevel11:
- level = AVC_LEVEL1_1;
- break;
- case OMX_VIDEO_AVCLevel12:
- level = AVC_LEVEL1_2;
- break;
- case OMX_VIDEO_AVCLevel13:
- level = AVC_LEVEL1_3;
- break;
- case OMX_VIDEO_AVCLevel2:
- level = AVC_LEVEL2;
- break;
- case OMX_VIDEO_AVCLevel21:
- level = AVC_LEVEL2_1;
- break;
- case OMX_VIDEO_AVCLevel22:
- level = AVC_LEVEL2_2;
- break;
- case OMX_VIDEO_AVCLevel3:
- level = AVC_LEVEL3;
- break;
- case OMX_VIDEO_AVCLevel31:
- level = AVC_LEVEL3_1;
- break;
- case OMX_VIDEO_AVCLevel32:
- level = AVC_LEVEL3_2;
- break;
- case OMX_VIDEO_AVCLevel4:
- level = AVC_LEVEL4;
- break;
- case OMX_VIDEO_AVCLevel41:
- level = AVC_LEVEL4_1;
- break;
- case OMX_VIDEO_AVCLevel42:
- level = AVC_LEVEL4_2;
- break;
- case OMX_VIDEO_AVCLevel5:
- level = AVC_LEVEL5;
- break;
- case OMX_VIDEO_AVCLevel51:
- level = AVC_LEVEL5_1;
- break;
- default:
- ALOGE("Unknown omx level: %d", omxLevel);
- return BAD_VALUE;
- }
- *pvLevel = level;
- return OK;
-}
-
-inline static void ConvertYUV420SemiPlanarToYUV420Planar(
- uint8_t *inyuv, uint8_t* outyuv,
- int32_t width, int32_t height) {
-
- int32_t outYsize = width * height;
- uint32_t *outy = (uint32_t *) outyuv;
- uint16_t *outcb = (uint16_t *) (outyuv + outYsize);
- uint16_t *outcr = (uint16_t *) (outyuv + outYsize + (outYsize >> 2));
-
- /* Y copying */
- memcpy(outy, inyuv, outYsize);
-
- /* U & V copying */
- uint32_t *inyuv_4 = (uint32_t *) (inyuv + outYsize);
- for (int32_t i = height >> 1; i > 0; --i) {
- for (int32_t j = width >> 2; j > 0; --j) {
- uint32_t temp = *inyuv_4++;
- uint32_t tempU = temp & 0xFF;
- tempU = tempU | ((temp >> 8) & 0xFF00);
-
- uint32_t tempV = (temp >> 8) & 0xFF;
- tempV = tempV | ((temp >> 16) & 0xFF00);
-
- // Flip U and V
- *outcb++ = tempV;
- *outcr++ = tempU;
- }
- }
-}
-
-static int32_t MallocWrapper(
- void *userData, int32_t size, int32_t attrs) {
- return reinterpret_cast<int32_t>(malloc(size));
-}
-
-static void FreeWrapper(void *userData, int32_t ptr) {
- free(reinterpret_cast<void *>(ptr));
-}
-
-static int32_t DpbAllocWrapper(void *userData,
- unsigned int sizeInMbs, unsigned int numBuffers) {
- AVCEncoder *encoder = static_cast<AVCEncoder *>(userData);
- CHECK(encoder != NULL);
- return encoder->allocOutputBuffers(sizeInMbs, numBuffers);
-}
-
-static int32_t BindFrameWrapper(
- void *userData, int32_t index, uint8_t **yuv) {
- AVCEncoder *encoder = static_cast<AVCEncoder *>(userData);
- CHECK(encoder != NULL);
- return encoder->bindOutputBuffer(index, yuv);
-}
-
-static void UnbindFrameWrapper(void *userData, int32_t index) {
- AVCEncoder *encoder = static_cast<AVCEncoder *>(userData);
- CHECK(encoder != NULL);
- return encoder->unbindOutputBuffer(index);
-}
-
-AVCEncoder::AVCEncoder(
- const sp<MediaSource>& source,
- const sp<MetaData>& meta)
- : mSource(source),
- mMeta(meta),
- mNumInputFrames(-1),
- mPrevTimestampUs(-1),
- mStarted(false),
- mInputBuffer(NULL),
- mInputFrameData(NULL),
- mGroup(NULL) {
-
- ALOGI("Construct software AVCEncoder");
-
- mHandle = new tagAVCHandle;
- memset(mHandle, 0, sizeof(tagAVCHandle));
- mHandle->AVCObject = NULL;
- mHandle->userData = this;
- mHandle->CBAVC_DPBAlloc = DpbAllocWrapper;
- mHandle->CBAVC_FrameBind = BindFrameWrapper;
- mHandle->CBAVC_FrameUnbind = UnbindFrameWrapper;
- mHandle->CBAVC_Malloc = MallocWrapper;
- mHandle->CBAVC_Free = FreeWrapper;
-
- mInitCheck = initCheck(meta);
-}
-
-AVCEncoder::~AVCEncoder() {
- ALOGV("Destruct software AVCEncoder");
- if (mStarted) {
- stop();
- }
-
- delete mEncParams;
- delete mHandle;
-}
-
-status_t AVCEncoder::initCheck(const sp<MetaData>& meta) {
- ALOGV("initCheck");
- CHECK(meta->findInt32(kKeyWidth, &mVideoWidth));
- CHECK(meta->findInt32(kKeyHeight, &mVideoHeight));
- CHECK(meta->findInt32(kKeyFrameRate, &mVideoFrameRate));
- CHECK(meta->findInt32(kKeyBitRate, &mVideoBitRate));
-
- // XXX: Add more color format support
- CHECK(meta->findInt32(kKeyColorFormat, &mVideoColorFormat));
- if (mVideoColorFormat != OMX_COLOR_FormatYUV420Planar) {
- if (mVideoColorFormat != OMX_COLOR_FormatYUV420SemiPlanar) {
- ALOGE("Color format %d is not supported", mVideoColorFormat);
- return BAD_VALUE;
- }
- // Allocate spare buffer only when color conversion is needed.
- // Assume the color format is OMX_COLOR_FormatYUV420SemiPlanar.
- mInputFrameData =
- (uint8_t *) malloc((mVideoWidth * mVideoHeight * 3 ) >> 1);
- CHECK(mInputFrameData);
- }
-
- // XXX: Remove this restriction
- if (mVideoWidth % 16 != 0 || mVideoHeight % 16 != 0) {
- ALOGE("Video frame size %dx%d must be a multiple of 16",
- mVideoWidth, mVideoHeight);
- return BAD_VALUE;
- }
-
- mEncParams = new tagAVCEncParam;
- memset(mEncParams, 0, sizeof(mEncParams));
- mEncParams->width = mVideoWidth;
- mEncParams->height = mVideoHeight;
- mEncParams->frame_rate = 1000 * mVideoFrameRate; // In frames/ms!
- mEncParams->rate_control = AVC_ON;
- mEncParams->bitrate = mVideoBitRate;
- mEncParams->initQP = 0;
- mEncParams->init_CBP_removal_delay = 1600;
- mEncParams->CPB_size = (uint32_t) (mVideoBitRate >> 1);
-
- mEncParams->intramb_refresh = 0;
- mEncParams->auto_scd = AVC_ON;
- mEncParams->out_of_band_param_set = AVC_ON;
- mEncParams->poc_type = 2;
- mEncParams->log2_max_poc_lsb_minus_4 = 12;
- mEncParams->delta_poc_zero_flag = 0;
- mEncParams->offset_poc_non_ref = 0;
- mEncParams->offset_top_bottom = 0;
- mEncParams->num_ref_in_cycle = 0;
- mEncParams->offset_poc_ref = NULL;
-
- mEncParams->num_ref_frame = 1;
- mEncParams->num_slice_group = 1;
- mEncParams->fmo_type = 0;
-
- mEncParams->db_filter = AVC_ON;
- mEncParams->disable_db_idc = 0;
-
- mEncParams->alpha_offset = 0;
- mEncParams->beta_offset = 0;
- mEncParams->constrained_intra_pred = AVC_OFF;
-
- mEncParams->data_par = AVC_OFF;
- mEncParams->fullsearch = AVC_OFF;
- mEncParams->search_range = 16;
- mEncParams->sub_pel = AVC_OFF;
- mEncParams->submb_pred = AVC_OFF;
- mEncParams->rdopt_mode = AVC_OFF;
- mEncParams->bidir_pred = AVC_OFF;
- int32_t nMacroBlocks = ((((mVideoWidth + 15) >> 4) << 4) *
- (((mVideoHeight + 15) >> 4) << 4)) >> 8;
- uint32_t *sliceGroup = (uint32_t *) malloc(sizeof(uint32_t) * nMacroBlocks);
- for (int ii = 0, idx = 0; ii < nMacroBlocks; ++ii) {
- sliceGroup[ii] = idx++;
- if (idx >= mEncParams->num_slice_group) {
- idx = 0;
- }
- }
- mEncParams->slice_group = sliceGroup;
-
- mEncParams->use_overrun_buffer = AVC_OFF;
-
- // Set IDR frame refresh interval
- int32_t iFramesIntervalSec;
- CHECK(meta->findInt32(kKeyIFramesInterval, &iFramesIntervalSec));
- if (iFramesIntervalSec < 0) {
- mEncParams->idr_period = -1;
- } else if (iFramesIntervalSec == 0) {
- mEncParams->idr_period = 1; // All I frames
- } else {
- mEncParams->idr_period =
- (iFramesIntervalSec * mVideoFrameRate);
- }
- ALOGV("idr_period: %d, I-frames interval: %d seconds, and frame rate: %d",
- mEncParams->idr_period, iFramesIntervalSec, mVideoFrameRate);
-
- // Set profile and level
- // If profile and level setting is not correct, failure
- // is reported when the encoder is initialized.
- mEncParams->profile = AVC_BASELINE;
- mEncParams->level = AVC_LEVEL3_2;
- int32_t profile, level;
- if (meta->findInt32(kKeyVideoProfile, &profile)) {
- if (OK != ConvertOmxAvcProfileToAvcSpecProfile(
- profile, &mEncParams->profile)) {
- return BAD_VALUE;
- }
- }
- if (meta->findInt32(kKeyVideoLevel, &level)) {
- if (OK != ConvertOmxAvcLevelToAvcSpecLevel(
- level, &mEncParams->level)) {
- return BAD_VALUE;
- }
- }
-
-
- mFormat = new MetaData;
- mFormat->setInt32(kKeyWidth, mVideoWidth);
- mFormat->setInt32(kKeyHeight, mVideoHeight);
- mFormat->setInt32(kKeyBitRate, mVideoBitRate);
- mFormat->setInt32(kKeyFrameRate, mVideoFrameRate);
- mFormat->setInt32(kKeyColorFormat, mVideoColorFormat);
- mFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC);
- mFormat->setCString(kKeyDecoderComponent, "AVCEncoder");
- return OK;
-}
-
-status_t AVCEncoder::start(MetaData *params) {
- ALOGV("start");
- if (mInitCheck != OK) {
- return mInitCheck;
- }
-
- if (mStarted) {
- ALOGW("Call start() when encoder already started");
- return OK;
- }
-
- AVCEnc_Status err;
- err = PVAVCEncInitialize(mHandle, mEncParams, NULL, NULL);
- if (err != AVCENC_SUCCESS) {
- ALOGE("Failed to initialize the encoder: %d", err);
- return UNKNOWN_ERROR;
- }
-
- mGroup = new MediaBufferGroup();
- int32_t maxSize;
- if (AVCENC_SUCCESS !=
- PVAVCEncGetMaxOutputBufferSize(mHandle, &maxSize)) {
- maxSize = 31584; // Magic #
- }
- mGroup->add_buffer(new MediaBuffer(maxSize));
-
- mSource->start(params);
- mNumInputFrames = -2; // 1st two buffers contain SPS and PPS
- mStarted = true;
- mSpsPpsHeaderReceived = false;
- mReadyForNextFrame = true;
- mIsIDRFrame = 0;
-
- return OK;
-}
-
-status_t AVCEncoder::stop() {
- ALOGV("stop");
- if (!mStarted) {
- ALOGW("Call stop() when encoder has not started");
- return OK;
- }
-
- if (mInputBuffer) {
- mInputBuffer->release();
- mInputBuffer = NULL;
- }
-
- if (mGroup) {
- delete mGroup;
- mGroup = NULL;
- }
-
- if (mInputFrameData) {
- delete mInputFrameData;
- mInputFrameData = NULL;
- }
-
- PVAVCCleanUpEncoder(mHandle);
- mSource->stop();
- releaseOutputBuffers();
- mStarted = false;
-
- return OK;
-}
-
-void AVCEncoder::releaseOutputBuffers() {
- ALOGV("releaseOutputBuffers");
- for (size_t i = 0; i < mOutputBuffers.size(); ++i) {
- MediaBuffer *buffer = mOutputBuffers.editItemAt(i);
- buffer->setObserver(NULL);
- buffer->release();
- }
- mOutputBuffers.clear();
-}
-
-sp<MetaData> AVCEncoder::getFormat() {
- ALOGV("getFormat");
- return mFormat;
-}
-
-status_t AVCEncoder::read(
- MediaBuffer **out, const ReadOptions *options) {
-
- CHECK(!options);
- *out = NULL;
-
- MediaBuffer *outputBuffer;
- CHECK_EQ((status_t)OK, mGroup->acquire_buffer(&outputBuffer));
- uint8_t *outPtr = (uint8_t *) outputBuffer->data();
- uint32_t dataLength = outputBuffer->size();
-
- if (!mSpsPpsHeaderReceived && mNumInputFrames < 0) {
- // 4 bytes are reserved for holding the start code 0x00000001
- // of the sequence parameter set at the beginning.
- outPtr += 4;
- dataLength -= 4;
- }
-
- int32_t type;
- AVCEnc_Status encoderStatus = AVCENC_SUCCESS;
-
- // Combine SPS and PPS and place them in the very first output buffer
- // SPS and PPS are separated by start code 0x00000001
- // Assume that we have exactly one SPS and exactly one PPS.
- while (!mSpsPpsHeaderReceived && mNumInputFrames <= 0) {
- encoderStatus = PVAVCEncodeNAL(mHandle, outPtr, &dataLength, &type);
- if (encoderStatus == AVCENC_WRONG_STATE) {
- mSpsPpsHeaderReceived = true;
- CHECK_EQ(0, mNumInputFrames); // 1st video frame is 0
- } else {
- switch (type) {
- case AVC_NALTYPE_SPS:
- ++mNumInputFrames;
- memcpy((uint8_t *)outputBuffer->data(), "\x00\x00\x00\x01", 4);
- outputBuffer->set_range(0, dataLength + 4);
- outPtr += (dataLength + 4); // 4 bytes for next start code
- dataLength = outputBuffer->size() -
- (outputBuffer->range_length() + 4);
- break;
- case AVC_NALTYPE_PPS:
- ++mNumInputFrames;
- memcpy(((uint8_t *) outputBuffer->data()) +
- outputBuffer->range_length(),
- "\x00\x00\x00\x01", 4);
- outputBuffer->set_range(0,
- dataLength + outputBuffer->range_length() + 4);
- outputBuffer->meta_data()->setInt32(kKeyIsCodecConfig, 1);
- outputBuffer->meta_data()->setInt64(kKeyTime, 0);
- *out = outputBuffer;
- return OK;
- default:
- ALOGE("Nal type (%d) other than SPS/PPS is unexpected", type);
- return UNKNOWN_ERROR;
- }
- }
- }
-
- // Get next input video frame
- if (mReadyForNextFrame) {
- if (mInputBuffer) {
- mInputBuffer->release();
- mInputBuffer = NULL;
- }
- status_t err = mSource->read(&mInputBuffer, options);
- if (err != OK) {
- if (err != ERROR_END_OF_STREAM) {
- ALOGE("Failed to read input video frame: %d", err);
- }
- outputBuffer->release();
- return err;
- }
-
- if (mInputBuffer->size() - ((mVideoWidth * mVideoHeight * 3) >> 1) != 0) {
- outputBuffer->release();
- mInputBuffer->release();
- mInputBuffer = NULL;
- return UNKNOWN_ERROR;
- }
-
- int64_t timeUs;
- CHECK(mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs));
- outputBuffer->meta_data()->setInt64(kKeyTime, timeUs);
-
- // When the timestamp of the current sample is the same as
- // that of the previous sample, the encoding of the sample
- // is bypassed, and the output length is set to 0.
- if (mNumInputFrames >= 1 && mPrevTimestampUs == timeUs) {
- // Frame arrives too late
- mInputBuffer->release();
- mInputBuffer = NULL;
- outputBuffer->set_range(0, 0);
- *out = outputBuffer;
- return OK;
- }
-
- // Don't accept out-of-order samples
- CHECK(mPrevTimestampUs < timeUs);
- mPrevTimestampUs = timeUs;
-
- AVCFrameIO videoInput;
- memset(&videoInput, 0, sizeof(videoInput));
- videoInput.height = ((mVideoHeight + 15) >> 4) << 4;
- videoInput.pitch = ((mVideoWidth + 15) >> 4) << 4;
- videoInput.coding_timestamp = (timeUs + 500) / 1000; // in ms
- uint8_t *inputData = (uint8_t *) mInputBuffer->data();
-
- if (mVideoColorFormat != OMX_COLOR_FormatYUV420Planar) {
- CHECK(mInputFrameData);
- CHECK(mVideoColorFormat == OMX_COLOR_FormatYUV420SemiPlanar);
- ConvertYUV420SemiPlanarToYUV420Planar(
- inputData, mInputFrameData, mVideoWidth, mVideoHeight);
- inputData = mInputFrameData;
- }
- CHECK(inputData != NULL);
- videoInput.YCbCr[0] = inputData;
- videoInput.YCbCr[1] = videoInput.YCbCr[0] + videoInput.height * videoInput.pitch;
- videoInput.YCbCr[2] = videoInput.YCbCr[1] +
- ((videoInput.height * videoInput.pitch) >> 2);
- videoInput.disp_order = mNumInputFrames;
-
- encoderStatus = PVAVCEncSetInput(mHandle, &videoInput);
- if (encoderStatus == AVCENC_SUCCESS ||
- encoderStatus == AVCENC_NEW_IDR) {
- mReadyForNextFrame = false;
- ++mNumInputFrames;
- if (encoderStatus == AVCENC_NEW_IDR) {
- mIsIDRFrame = 1;
- }
- } else {
- if (encoderStatus < AVCENC_SUCCESS) {
- outputBuffer->release();
- return UNKNOWN_ERROR;
- } else {
- outputBuffer->set_range(0, 0);
- *out = outputBuffer;
- return OK;
- }
- }
- }
-
- // Encode an input video frame
- CHECK(encoderStatus == AVCENC_SUCCESS ||
- encoderStatus == AVCENC_NEW_IDR);
- dataLength = outputBuffer->size(); // Reset the output buffer length
- encoderStatus = PVAVCEncodeNAL(mHandle, outPtr, &dataLength, &type);
- if (encoderStatus == AVCENC_SUCCESS) {
- outputBuffer->meta_data()->setInt32(kKeyIsSyncFrame, mIsIDRFrame);
- CHECK(NULL == PVAVCEncGetOverrunBuffer(mHandle));
- } else if (encoderStatus == AVCENC_PICTURE_READY) {
- CHECK(NULL == PVAVCEncGetOverrunBuffer(mHandle));
- if (mIsIDRFrame) {
- outputBuffer->meta_data()->setInt32(kKeyIsSyncFrame, mIsIDRFrame);
- mIsIDRFrame = 0;
- ALOGV("Output an IDR frame");
- }
- mReadyForNextFrame = true;
- AVCFrameIO recon;
- if (PVAVCEncGetRecon(mHandle, &recon) == AVCENC_SUCCESS) {
- PVAVCEncReleaseRecon(mHandle, &recon);
- }
- } else {
- dataLength = 0;
- mReadyForNextFrame = true;
- }
- if (encoderStatus < AVCENC_SUCCESS) {
- outputBuffer->release();
- return UNKNOWN_ERROR;
- }
-
- outputBuffer->set_range(0, dataLength);
- *out = outputBuffer;
- return OK;
-}
-
-int32_t AVCEncoder::allocOutputBuffers(
- unsigned int sizeInMbs, unsigned int numBuffers) {
- CHECK(mOutputBuffers.isEmpty());
- size_t frameSize = (sizeInMbs << 7) * 3;
- for (unsigned int i = 0; i < numBuffers; ++i) {
- MediaBuffer *buffer = new MediaBuffer(frameSize);
- buffer->setObserver(this);
- mOutputBuffers.push(buffer);
- }
-
- return 1;
-}
-
-void AVCEncoder::unbindOutputBuffer(int32_t index) {
- CHECK(index >= 0);
-}
-
-int32_t AVCEncoder::bindOutputBuffer(int32_t index, uint8_t **yuv) {
- CHECK(index >= 0);
- CHECK(index < (int32_t) mOutputBuffers.size());
- int64_t timeUs;
- CHECK(mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs));
- mOutputBuffers[index]->meta_data()->setInt64(kKeyTime, timeUs);
-
- *yuv = (uint8_t *) mOutputBuffers[index]->data();
-
- return 1;
-}
-
-void AVCEncoder::signalBufferReturned(MediaBuffer *buffer) {
-}
-
-} // namespace android
diff --git a/media/libstagefright/codecs/avc/enc/Android.mk b/media/libstagefright/codecs/avc/enc/Android.mk
index ee31ab2..48923cf 100644
--- a/media/libstagefright/codecs/avc/enc/Android.mk
+++ b/media/libstagefright/codecs/avc/enc/Android.mk
@@ -2,8 +2,6 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- AVCEncoder.cpp \
- SoftAVCEncoder.cpp \
src/avcenc_api.cpp \
src/bitstream_io.cpp \
src/block.cpp \
diff --git a/media/libstagefright/codecs/m4v_h263/enc/Android.mk b/media/libstagefright/codecs/m4v_h263/enc/Android.mk
index e6aa563..484180d 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/Android.mk
+++ b/media/libstagefright/codecs/m4v_h263/enc/Android.mk
@@ -2,8 +2,6 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- M4vH263Encoder.cpp \
- SoftMPEG4Encoder.cpp \
src/bitstream_io.cpp \
src/combined_encode.cpp \
src/datapart_encode.cpp \
diff --git a/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp b/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp
deleted file mode 100644
index 20b0f8d..0000000
--- a/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "M4vH263Encoder"
-#include <utils/Log.h>
-
-#include "M4vH263Encoder.h"
-
-#include "mp4enc_api.h"
-#include "OMX_Video.h"
-
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/MediaBufferGroup.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/Utils.h>
-
-namespace android {
-
-static status_t ConvertOmxProfileLevel(
- MP4EncodingMode mode,
- int32_t omxProfile,
- int32_t omxLevel,
- ProfileLevelType* pvProfileLevel) {
- ALOGV("ConvertOmxProfileLevel: %d/%d/%d", mode, omxProfile, omxLevel);
- ProfileLevelType profileLevel;
- if (mode == H263_MODE) {
- switch (omxProfile) {
- case OMX_VIDEO_H263ProfileBaseline:
- if (omxLevel > OMX_VIDEO_H263Level45) {
- ALOGE("Unsupported level (%d) for H263", omxLevel);
- return BAD_VALUE;
- } else {
- ALOGW("PV does not support level configuration for H263");
- profileLevel = CORE_PROFILE_LEVEL2;
- break;
- }
- break;
- default:
- ALOGE("Unsupported profile (%d) for H263", omxProfile);
- return BAD_VALUE;
- }
- } else { // MPEG4
- switch (omxProfile) {
- case OMX_VIDEO_MPEG4ProfileSimple:
- switch (omxLevel) {
- case OMX_VIDEO_MPEG4Level0b:
- profileLevel = SIMPLE_PROFILE_LEVEL0;
- break;
- case OMX_VIDEO_MPEG4Level1:
- profileLevel = SIMPLE_PROFILE_LEVEL1;
- break;
- case OMX_VIDEO_MPEG4Level2:
- profileLevel = SIMPLE_PROFILE_LEVEL2;
- break;
- case OMX_VIDEO_MPEG4Level3:
- profileLevel = SIMPLE_PROFILE_LEVEL3;
- break;
- default:
- ALOGE("Unsupported level (%d) for MPEG4 simple profile",
- omxLevel);
- return BAD_VALUE;
- }
- break;
- case OMX_VIDEO_MPEG4ProfileSimpleScalable:
- switch (omxLevel) {
- case OMX_VIDEO_MPEG4Level0b:
- profileLevel = SIMPLE_SCALABLE_PROFILE_LEVEL0;
- break;
- case OMX_VIDEO_MPEG4Level1:
- profileLevel = SIMPLE_SCALABLE_PROFILE_LEVEL1;
- break;
- case OMX_VIDEO_MPEG4Level2:
- profileLevel = SIMPLE_SCALABLE_PROFILE_LEVEL2;
- break;
- default:
- ALOGE("Unsupported level (%d) for MPEG4 simple "
- "scalable profile", omxLevel);
- return BAD_VALUE;
- }
- break;
- case OMX_VIDEO_MPEG4ProfileCore:
- switch (omxLevel) {
- case OMX_VIDEO_MPEG4Level1:
- profileLevel = CORE_PROFILE_LEVEL1;
- break;
- case OMX_VIDEO_MPEG4Level2:
- profileLevel = CORE_PROFILE_LEVEL2;
- break;
- default:
- ALOGE("Unsupported level (%d) for MPEG4 core "
- "profile", omxLevel);
- return BAD_VALUE;
- }
- break;
- case OMX_VIDEO_MPEG4ProfileCoreScalable:
- switch (omxLevel) {
- case OMX_VIDEO_MPEG4Level1:
- profileLevel = CORE_SCALABLE_PROFILE_LEVEL1;
- break;
- case OMX_VIDEO_MPEG4Level2:
- profileLevel = CORE_SCALABLE_PROFILE_LEVEL2;
- break;
- case OMX_VIDEO_MPEG4Level3:
- profileLevel = CORE_SCALABLE_PROFILE_LEVEL3;
- break;
- default:
- ALOGE("Unsupported level (%d) for MPEG4 core "
- "scalable profile", omxLevel);
- return BAD_VALUE;
- }
- break;
- default:
- ALOGE("Unsupported MPEG4 profile (%d)", omxProfile);
- return BAD_VALUE;
- }
- }
-
- *pvProfileLevel = profileLevel;
- return OK;
-}
-
-inline static void ConvertYUV420SemiPlanarToYUV420Planar(
- uint8_t *inyuv, uint8_t* outyuv,
- int32_t width, int32_t height) {
-
- int32_t outYsize = width * height;
- uint32_t *outy = (uint32_t *) outyuv;
- uint16_t *outcb = (uint16_t *) (outyuv + outYsize);
- uint16_t *outcr = (uint16_t *) (outyuv + outYsize + (outYsize >> 2));
-
- /* Y copying */
- memcpy(outy, inyuv, outYsize);
-
- /* U & V copying */
- uint32_t *inyuv_4 = (uint32_t *) (inyuv + outYsize);
- for (int32_t i = height >> 1; i > 0; --i) {
- for (int32_t j = width >> 2; j > 0; --j) {
- uint32_t temp = *inyuv_4++;
- uint32_t tempU = temp & 0xFF;
- tempU = tempU | ((temp >> 8) & 0xFF00);
-
- uint32_t tempV = (temp >> 8) & 0xFF;
- tempV = tempV | ((temp >> 16) & 0xFF00);
-
- // Flip U and V
- *outcb++ = tempV;
- *outcr++ = tempU;
- }
- }
-}
-
-M4vH263Encoder::M4vH263Encoder(
- const sp<MediaSource>& source,
- const sp<MetaData>& meta)
- : mSource(source),
- mMeta(meta),
- mNumInputFrames(-1),
- mNextModTimeUs(0),
- mPrevTimestampUs(-1),
- mStarted(false),
- mInputBuffer(NULL),
- mInputFrameData(NULL),
- mGroup(NULL) {
-
- ALOGI("Construct software M4vH263Encoder");
-
- mHandle = new tagvideoEncControls;
- memset(mHandle, 0, sizeof(tagvideoEncControls));
-
- mInitCheck = initCheck(meta);
-}
-
-M4vH263Encoder::~M4vH263Encoder() {
- ALOGV("Destruct software M4vH263Encoder");
- if (mStarted) {
- stop();
- }
-
- delete mEncParams;
- delete mHandle;
-}
-
-status_t M4vH263Encoder::initCheck(const sp<MetaData>& meta) {
- ALOGV("initCheck");
- CHECK(meta->findInt32(kKeyWidth, &mVideoWidth));
- CHECK(meta->findInt32(kKeyHeight, &mVideoHeight));
- CHECK(meta->findInt32(kKeyFrameRate, &mVideoFrameRate));
- CHECK(meta->findInt32(kKeyBitRate, &mVideoBitRate));
-
- // XXX: Add more color format support
- CHECK(meta->findInt32(kKeyColorFormat, &mVideoColorFormat));
- if (mVideoColorFormat != OMX_COLOR_FormatYUV420Planar) {
- if (mVideoColorFormat != OMX_COLOR_FormatYUV420SemiPlanar) {
- ALOGE("Color format %d is not supported", mVideoColorFormat);
- return BAD_VALUE;
- }
- // Allocate spare buffer only when color conversion is needed.
- // Assume the color format is OMX_COLOR_FormatYUV420SemiPlanar.
- mInputFrameData =
- (uint8_t *) malloc((mVideoWidth * mVideoHeight * 3 ) >> 1);
- CHECK(mInputFrameData);
- }
-
- // XXX: Remove this restriction
- if (mVideoWidth % 16 != 0 || mVideoHeight % 16 != 0) {
- ALOGE("Video frame size %dx%d must be a multiple of 16",
- mVideoWidth, mVideoHeight);
- return BAD_VALUE;
- }
-
- mEncParams = new tagvideoEncOptions;
- memset(mEncParams, 0, sizeof(tagvideoEncOptions));
- if (!PVGetDefaultEncOption(mEncParams, 0)) {
- ALOGE("Failed to get default encoding parameters");
- return BAD_VALUE;
- }
-
- // Need to know which role the encoder is in.
- // XXX: Set the mode proper for other types of applications
- // like streaming or video conference
- const char *mime;
- CHECK(meta->findCString(kKeyMIMEType, &mime));
- CHECK(!strcmp(mime, MEDIA_MIMETYPE_VIDEO_MPEG4) ||
- !strcmp(mime, MEDIA_MIMETYPE_VIDEO_H263));
- if (!strcmp(mime, MEDIA_MIMETYPE_VIDEO_MPEG4)) {
- mEncParams->encMode = COMBINE_MODE_WITH_ERR_RES;
- } else {
- mEncParams->encMode = H263_MODE;
- }
- mEncParams->encWidth[0] = mVideoWidth;
- mEncParams->encHeight[0] = mVideoHeight;
- mEncParams->encFrameRate[0] = mVideoFrameRate;
- mEncParams->rcType = VBR_1;
- mEncParams->vbvDelay = (float)5.0;
-
- // Set profile and level
- // If profile and level setting is not correct, failure
- // is reported when the encoder is initialized.
- mEncParams->profile_level = CORE_PROFILE_LEVEL2;
- int32_t profile, level;
- if (meta->findInt32(kKeyVideoProfile, &profile) &&
- meta->findInt32(kKeyVideoLevel, &level)) {
- if (OK != ConvertOmxProfileLevel(
- mEncParams->encMode, profile, level,
- &mEncParams->profile_level)) {
- return BAD_VALUE;
- }
- }
-
- mEncParams->packetSize = 32;
- mEncParams->rvlcEnable = PV_OFF;
- mEncParams->numLayers = 1;
- mEncParams->timeIncRes = 1000;
- mEncParams->tickPerSrc = mEncParams->timeIncRes / mVideoFrameRate;
-
- mEncParams->bitRate[0] = mVideoBitRate;
- mEncParams->iQuant[0] = 15;
- mEncParams->pQuant[0] = 12;
- mEncParams->quantType[0] = 0;
- mEncParams->noFrameSkipped = PV_OFF;
-
- // Set IDR frame refresh interval
- int32_t iFramesIntervalSec;
- CHECK(meta->findInt32(kKeyIFramesInterval, &iFramesIntervalSec));
- if (iFramesIntervalSec < 0) {
- mEncParams->intraPeriod = -1;
- } else if (iFramesIntervalSec == 0) {
- mEncParams->intraPeriod = 1; // All I frames
- } else {
- mEncParams->intraPeriod =
- (iFramesIntervalSec * mVideoFrameRate);
- }
-
- mEncParams->numIntraMB = 0;
- mEncParams->sceneDetect = PV_ON;
- mEncParams->searchRange = 16;
- mEncParams->mv8x8Enable = PV_OFF;
- mEncParams->gobHeaderInterval = 0;
- mEncParams->useACPred = PV_ON;
- mEncParams->intraDCVlcTh = 0;
-
- mFormat = new MetaData;
- mFormat->setInt32(kKeyWidth, mVideoWidth);
- mFormat->setInt32(kKeyHeight, mVideoHeight);
- mFormat->setInt32(kKeyBitRate, mVideoBitRate);
- mFormat->setInt32(kKeyFrameRate, mVideoFrameRate);
- mFormat->setInt32(kKeyColorFormat, mVideoColorFormat);
-
- mFormat->setCString(kKeyMIMEType, mime);
- mFormat->setCString(kKeyDecoderComponent, "M4vH263Encoder");
- return OK;
-}
-
-status_t M4vH263Encoder::start(MetaData *params) {
- ALOGV("start");
- if (mInitCheck != OK) {
- return mInitCheck;
- }
-
- if (mStarted) {
- ALOGW("Call start() when encoder already started");
- return OK;
- }
-
- if (!PVInitVideoEncoder(mHandle, mEncParams)) {
- ALOGE("Failed to initialize the encoder");
- return UNKNOWN_ERROR;
- }
-
- mGroup = new MediaBufferGroup();
- int32_t maxSize;
- if (!PVGetMaxVideoFrameSize(mHandle, &maxSize)) {
- maxSize = 256 * 1024; // Magic #
- }
- ALOGV("Max output buffer size: %d", maxSize);
- mGroup->add_buffer(new MediaBuffer(maxSize));
-
- mSource->start(params);
- mNumInputFrames = -1; // 1st frame contains codec specific data
- mStarted = true;
-
- return OK;
-}
-
-status_t M4vH263Encoder::stop() {
- ALOGV("stop");
- if (!mStarted) {
- ALOGW("Call stop() when encoder has not started");
- return OK;
- }
-
- if (mInputBuffer) {
- mInputBuffer->release();
- mInputBuffer = NULL;
- }
-
- if (mGroup) {
- delete mGroup;
- mGroup = NULL;
- }
-
- if (mInputFrameData) {
- delete mInputFrameData;
- mInputFrameData = NULL;
- }
-
- CHECK(PVCleanUpVideoEncoder(mHandle));
-
- mSource->stop();
- mStarted = false;
-
- return OK;
-}
-
-sp<MetaData> M4vH263Encoder::getFormat() {
- ALOGV("getFormat");
- return mFormat;
-}
-
-status_t M4vH263Encoder::read(
- MediaBuffer **out, const ReadOptions *options) {
-
- *out = NULL;
-
- MediaBuffer *outputBuffer;
- CHECK_EQ((status_t)OK, mGroup->acquire_buffer(&outputBuffer));
- uint8_t *outPtr = (uint8_t *) outputBuffer->data();
- int32_t dataLength = outputBuffer->size();
-
- // Output codec specific data
- if (mNumInputFrames < 0) {
- if (!PVGetVolHeader(mHandle, outPtr, &dataLength, 0)) {
- ALOGE("Failed to get VOL header");
- return UNKNOWN_ERROR;
- }
- ALOGV("Output VOL header: %d bytes", dataLength);
- outputBuffer->meta_data()->setInt32(kKeyIsCodecConfig, 1);
- outputBuffer->set_range(0, dataLength);
- *out = outputBuffer;
- ++mNumInputFrames;
- return OK;
- }
-
- // Ready for accepting an input video frame
- status_t err = mSource->read(&mInputBuffer, options);
- if (OK != err) {
- if (err != ERROR_END_OF_STREAM) {
- ALOGE("Failed to read from data source");
- }
- outputBuffer->release();
- return err;
- }
-
- if (mInputBuffer->size() - ((mVideoWidth * mVideoHeight * 3) >> 1) != 0) {
- outputBuffer->release();
- mInputBuffer->release();
- mInputBuffer = NULL;
- return UNKNOWN_ERROR;
- }
-
- int64_t timeUs;
- CHECK(mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs));
-
- // When the timestamp of the current sample is the same as that
- // of the previous sample, encoding of the current sample is
- // bypassed, and the output length of the sample is set to 0
- if (mNumInputFrames >= 1 &&
- (mNextModTimeUs > timeUs || mPrevTimestampUs == timeUs)) {
- // Frame arrives too late
- outputBuffer->set_range(0, 0);
- *out = outputBuffer;
- mInputBuffer->release();
- mInputBuffer = NULL;
- return OK;
- }
-
- // Don't accept out-of-order samples
- CHECK(mPrevTimestampUs < timeUs);
- mPrevTimestampUs = timeUs;
-
- // Color convert to OMX_COLOR_FormatYUV420Planar if necessary
- outputBuffer->meta_data()->setInt64(kKeyTime, timeUs);
- uint8_t *inPtr = (uint8_t *) mInputBuffer->data();
- if (mVideoColorFormat != OMX_COLOR_FormatYUV420Planar) {
- CHECK(mInputFrameData);
- CHECK(mVideoColorFormat == OMX_COLOR_FormatYUV420SemiPlanar);
- ConvertYUV420SemiPlanarToYUV420Planar(
- inPtr, mInputFrameData, mVideoWidth, mVideoHeight);
- inPtr = mInputFrameData;
- }
- CHECK(inPtr != NULL);
-
- // Ready for encoding a video frame
- VideoEncFrameIO vin, vout;
- vin.height = ((mVideoHeight + 15) >> 4) << 4;
- vin.pitch = ((mVideoWidth + 15) >> 4) << 4;
- vin.timestamp = (timeUs + 500) / 1000; // in ms
- vin.yChan = inPtr;
- vin.uChan = vin.yChan + vin.height * vin.pitch;
- vin.vChan = vin.uChan + ((vin.height * vin.pitch) >> 2);
- unsigned long modTimeMs = 0;
- int32_t nLayer = 0;
- MP4HintTrack hintTrack;
- if (!PVEncodeVideoFrame(mHandle, &vin, &vout,
- &modTimeMs, outPtr, &dataLength, &nLayer) ||
- !PVGetHintTrack(mHandle, &hintTrack)) {
- ALOGE("Failed to encode frame or get hink track at frame %lld",
- mNumInputFrames);
- outputBuffer->release();
- mInputBuffer->release();
- mInputBuffer = NULL;
- return UNKNOWN_ERROR;
- }
- CHECK(NULL == PVGetOverrunBuffer(mHandle));
- if (hintTrack.CodeType == 0) { // I-frame serves as sync frame
- outputBuffer->meta_data()->setInt32(kKeyIsSyncFrame, 1);
- }
-
- ++mNumInputFrames;
- mNextModTimeUs = modTimeMs * 1000LL;
- outputBuffer->set_range(0, dataLength);
- *out = outputBuffer;
- mInputBuffer->release();
- mInputBuffer = NULL;
- return OK;
-}
-
-void M4vH263Encoder::signalBufferReturned(MediaBuffer *buffer) {
-}
-
-} // namespace android
diff --git a/media/libstagefright/include/AVCEncoder.h b/media/libstagefright/include/AVCEncoder.h
deleted file mode 100644
index 83e1f97..0000000
--- a/media/libstagefright/include/AVCEncoder.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef AVC_ENCODER_H_
-
-#define AVC_ENCODER_H_
-
-#include <media/stagefright/MediaBuffer.h>
-#include <media/stagefright/MediaSource.h>
-#include <utils/Vector.h>
-
-struct tagAVCHandle;
-struct tagAVCEncParam;
-
-namespace android {
-
-struct MediaBuffer;
-struct MediaBufferGroup;
-
-struct AVCEncoder : public MediaSource,
- public MediaBufferObserver {
- AVCEncoder(const sp<MediaSource> &source,
- const sp<MetaData>& meta);
-
- virtual status_t start(MetaData *params);
- virtual status_t stop();
-
- virtual sp<MetaData> getFormat();
-
- virtual status_t read(
- MediaBuffer **buffer, const ReadOptions *options);
-
- virtual void signalBufferReturned(MediaBuffer *buffer);
-
- // Callbacks required by the encoder
- int32_t allocOutputBuffers(unsigned int sizeInMbs, unsigned int numBuffers);
- void unbindOutputBuffer(int32_t index);
- int32_t bindOutputBuffer(int32_t index, uint8_t **yuv);
-
-protected:
- virtual ~AVCEncoder();
-
-private:
- sp<MediaSource> mSource;
- sp<MetaData> mFormat;
- sp<MetaData> mMeta;
-
- int32_t mVideoWidth;
- int32_t mVideoHeight;
- int32_t mVideoFrameRate;
- int32_t mVideoBitRate;
- int32_t mVideoColorFormat;
- int64_t mNumInputFrames;
- int64_t mPrevTimestampUs;
- status_t mInitCheck;
- bool mStarted;
- bool mSpsPpsHeaderReceived;
- bool mReadyForNextFrame;
- int32_t mIsIDRFrame; // for set kKeyIsSyncFrame
-
- tagAVCHandle *mHandle;
- tagAVCEncParam *mEncParams;
- MediaBuffer *mInputBuffer;
- uint8_t *mInputFrameData;
- MediaBufferGroup *mGroup;
- Vector<MediaBuffer *> mOutputBuffers;
-
-
- status_t initCheck(const sp<MetaData>& meta);
- void releaseOutputBuffers();
-
- AVCEncoder(const AVCEncoder &);
- AVCEncoder &operator=(const AVCEncoder &);
-};
-
-} // namespace android
-
-#endif // AVC_ENCODER_H_
diff --git a/media/libstagefright/include/M4vH263Encoder.h b/media/libstagefright/include/M4vH263Encoder.h
deleted file mode 100644
index dbe9fd0..0000000
--- a/media/libstagefright/include/M4vH263Encoder.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef M4V_H263_ENCODER_H_
-
-#define M4V_H263_ENCODER_H_
-
-#include <media/stagefright/MediaBuffer.h>
-#include <media/stagefright/MediaSource.h>
-
-struct tagvideoEncControls;
-struct tagvideoEncOptions;
-
-namespace android {
-
-struct MediaBuffer;
-struct MediaBufferGroup;
-
-struct M4vH263Encoder : public MediaSource,
- public MediaBufferObserver {
- M4vH263Encoder(const sp<MediaSource> &source,
- const sp<MetaData>& meta);
-
- virtual status_t start(MetaData *params);
- virtual status_t stop();
-
- virtual sp<MetaData> getFormat();
-
- virtual status_t read(
- MediaBuffer **buffer, const ReadOptions *options);
-
- virtual void signalBufferReturned(MediaBuffer *buffer);
-
-protected:
- virtual ~M4vH263Encoder();
-
-private:
- sp<MediaSource> mSource;
- sp<MetaData> mFormat;
- sp<MetaData> mMeta;
-
- int32_t mVideoWidth;
- int32_t mVideoHeight;
- int32_t mVideoFrameRate;
- int32_t mVideoBitRate;
- int32_t mVideoColorFormat;
- int64_t mNumInputFrames;
- int64_t mNextModTimeUs;
- int64_t mPrevTimestampUs;
- status_t mInitCheck;
- bool mStarted;
-
- tagvideoEncControls *mHandle;
- tagvideoEncOptions *mEncParams;
- MediaBuffer *mInputBuffer;
- uint8_t *mInputFrameData;
- MediaBufferGroup *mGroup;
-
- status_t initCheck(const sp<MetaData>& meta);
- void releaseOutputBuffers();
-
- M4vH263Encoder(const M4vH263Encoder &);
- M4vH263Encoder &operator=(const M4vH263Encoder &);
-};
-
-} // namespace android
-
-#endif // M4V_H263_ENCODER_H_