Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…orks_av into marshmallow
  • Loading branch information
Unknown authored and Unknown committed Sep 5, 2017
2 parents b942159 + da01958 commit 9ba4ad6
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 42 deletions.
2 changes: 1 addition & 1 deletion drm/mediadrm/plugins/clearkey/InitDataParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ android::status_t InitDataParser::parsePssh(const Vector<uint8_t>& initData,
memcpy(&keyIdCount, &initData[readPosition], sizeof(keyIdCount));
keyIdCount = ntohl(keyIdCount);
readPosition += sizeof(keyIdCount);
if (readPosition + (keyIdCount * kKeyIdSize) !=
if (readPosition + ((uint64_t)keyIdCount * kKeyIdSize) !=
initData.size() - sizeof(uint32_t)) {
return android::ERROR_DRM_CANNOT_HANDLE;
}
Expand Down
34 changes: 31 additions & 3 deletions media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ int Virtualizer_getParameter (EffectContext *pContext,
void *pParam,
uint32_t *pValueSize,
void *pValue);
int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue);
int Equalizer_setParameter (EffectContext *pContext,
void *pParam,
uint32_t valueSize,
void *pValue);
int Equalizer_getParameter (EffectContext *pContext,
void *pParam,
uint32_t *pValueSize,
Expand Down Expand Up @@ -2473,12 +2476,17 @@ int Equalizer_getParameter(EffectContext *pContext,
// Inputs:
// pEqualizer - handle to instance data
// pParam - pointer to parameter
// valueSize - value size
// pValue - pointer to value

//
// Outputs:
//
//----------------------------------------------------------------------------
int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){
int Equalizer_setParameter (EffectContext *pContext,
void *pParam,
uint32_t valueSize,
void *pValue) {
int status = 0;
int32_t preset;
int32_t band;
Expand All @@ -2490,6 +2498,10 @@ int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue)
//ALOGV("\tEqualizer_setParameter start");
switch (param) {
case EQ_PARAM_CUR_PRESET:
if (valueSize < sizeof(int16_t)) {
status = -EINVAL;
break;
}
preset = (int32_t)(*(uint16_t *)pValue);

//ALOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset);
Expand All @@ -2500,6 +2512,10 @@ int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue)
EqualizerSetPreset(pContext, preset);
break;
case EQ_PARAM_BAND_LEVEL:
if (valueSize < sizeof(int16_t)) {
status = -EINVAL;
break;
}
band = *pParamTemp;
level = (int32_t)(*(int16_t *)pValue);
//ALOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
Expand All @@ -2515,6 +2531,10 @@ int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue)
break;
case EQ_PARAM_PROPERTIES: {
//ALOGV("\tEqualizer_setParameter() EQ_PARAM_PROPERTIES");
if (valueSize < sizeof(int16_t)) {
status = -EINVAL;
break;
}
int16_t *p = (int16_t *)pValue;
if ((int)p[0] >= EqualizerGetNumPresets()) {
status = -EINVAL;
Expand All @@ -2523,6 +2543,13 @@ int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue)
if (p[0] >= 0) {
EqualizerSetPreset(pContext, (int)p[0]);
} else {
if (valueSize < (2 + FIVEBAND_NUMBANDS) * sizeof(int16_t)) {
android_errorWriteLog(0x534e4554, "37563371");
ALOGE("\tERROR Equalizer_setParameter() EQ_PARAM_PROPERTIES valueSize %d < %d",
(int)valueSize, (int)((2 + FIVEBAND_NUMBANDS) * sizeof(int16_t)));
status = -EINVAL;
break;
}
if ((int)p[1] != FIVEBAND_NUMBANDS) {
status = -EINVAL;
break;
Expand Down Expand Up @@ -3308,7 +3335,8 @@ int Effect_command(effect_handle_t self,

*(int *)pReplyData = android::Equalizer_setParameter(pContext,
(void *)p->data,
p->data + p->psize);
p->vsize,
p->data + p->psize);
}
if(pContext->EffectType == LVM_VOLUME){
//ALOGV("\tVolume_command cmdCode Case: EFFECT_CMD_SET_PARAM start");
Expand Down
4 changes: 3 additions & 1 deletion media/libstagefright/MPEG4Extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2668,8 +2668,10 @@ status_t MPEG4Extractor::parseITunesMetaData(off64_t offset, size_t size) {
int32_t delay, padding;
if (sscanf(mLastCommentData,
" %*x %x %x %*x", &delay, &padding) == 2) {
if (mLastTrack == NULL)
if (mLastTrack == NULL) {
delete[] buffer;
return ERROR_MALFORMED;
}

mLastTrack->meta->setInt32(kKeyEncoderDelay, delay);
mLastTrack->meta->setInt32(kKeyEncoderPadding, padding);
Expand Down
23 changes: 19 additions & 4 deletions media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,28 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {
mSignalledError = true;
return;
}

// Need to check if header contains new info, e.g., width/height, etc.
VopHeaderInfo header_info;
uint8_t *bitstreamTmp = bitstream;
if (PVDecodeVopHeader(
mHandle, &bitstreamTmp, &timestamp, &tmp,
&header_info, &useExtTimestamp,
outHeader->pBuffer) != PV_TRUE) {
ALOGE("failed to decode vop header.");

notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
mSignalledError = true;
return;
}
if (handlePortSettingsChange()) {
return;
}

// The PV decoder is lying to us, sometimes it'll claim to only have
// consumed a subset of the buffer when it clearly consumed all of it.
// ignore whatever it says...
if (PVDecodeVideoFrame(
mHandle, &bitstream, &timestamp, &tmp,
&useExtTimestamp,
outHeader->pBuffer) != PV_TRUE) {
if (PVDecodeVopBody(mHandle, &tmp) != PV_TRUE) {
ALOGE("failed to decode video frame.");

notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
Expand Down
18 changes: 13 additions & 5 deletions media/libstagefright/codecs/m4v_h263/dec/src/vop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* and limitations under the License.
* -------------------------------------------------------------------
*/
#include "log/log.h"

#include "mp4dec_lib.h"
#include "bitstream.h"
#include "vlc_decode.h"
Expand Down Expand Up @@ -1336,8 +1338,7 @@ PV_STATUS DecodeShortHeader(VideoDecData *video, Vop *currVop)
}
tmpvar = BitstreamReadBits16(stream, 9);

video->displayWidth = (tmpvar + 1) << 2;
video->width = (video->displayWidth + 15) & -16;
int tmpDisplayWidth = (tmpvar + 1) << 2;
/* marker bit */
if (!BitstreamRead1Bits(stream))
{
Expand All @@ -1350,14 +1351,21 @@ PV_STATUS DecodeShortHeader(VideoDecData *video, Vop *currVop)
status = PV_FAIL;
goto return_point;
}
video->displayHeight = tmpvar << 2;
video->height = (video->displayHeight + 15) & -16;
int tmpDisplayHeight = tmpvar << 2;
int tmpHeight = (tmpDisplayHeight + 15) & -16;
int tmpWidth = (tmpDisplayWidth + 15) & -16;

if (video->height * video->width > video->size)
if (tmpHeight * tmpWidth > video->size)
{
// This is just possibly "b/37079296".
ALOGE("b/37079296");
status = PV_FAIL;
goto return_point;
}
video->displayWidth = tmpDisplayWidth;
video->width = tmpWidth;
video->displayHeight = tmpDisplayHeight;
video->height = tmpHeight;

video->nTotalMB = video->width / MB_SIZE * video->height / MB_SIZE;

Expand Down
28 changes: 12 additions & 16 deletions media/libstagefright/codecs/m4v_h263/enc/src/mp4enc_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ OSCL_EXPORT_REF Bool PVInitVideoEncoder(VideoEncControls *encoderControl, Vid
|| (size_t)(size + (size >> 1)) > SIZE_MAX / sizeof(PIXEL)) {
goto CLEAN_UP;
}
video->currVop->yChan = (PIXEL *)M4VENC_MALLOC(sizeof(PIXEL) * (size + (size >> 1))); /* Memory for currVop Y */
video->currVop->allChan = video->currVop->yChan = (PIXEL *)M4VENC_MALLOC(sizeof(PIXEL) * (size + (size >> 1))); /* Memory for currVop Y */
if (video->currVop->yChan == NULL) goto CLEAN_UP;
video->currVop->uChan = video->currVop->yChan + size;/* Memory for currVop U */
video->currVop->vChan = video->currVop->uChan + (size >> 2);/* Memory for currVop V */
Expand All @@ -791,7 +791,7 @@ OSCL_EXPORT_REF Bool PVInitVideoEncoder(VideoEncControls *encoderControl, Vid

video->prevBaseVop = (Vop *) M4VENC_MALLOC(sizeof(Vop)); /* Memory for Previous Base Vop */
if (video->prevBaseVop == NULL) goto CLEAN_UP;
video->prevBaseVop->yChan = (PIXEL *) M4VENC_MALLOC(sizeof(PIXEL) * (size + (size >> 1))); /* Memory for prevBaseVop Y */
video->prevBaseVop->allChan = video->prevBaseVop->yChan = (PIXEL *) M4VENC_MALLOC(sizeof(PIXEL) * (size + (size >> 1))); /* Memory for prevBaseVop Y */
if (video->prevBaseVop->yChan == NULL) goto CLEAN_UP;
video->prevBaseVop->uChan = video->prevBaseVop->yChan + size; /* Memory for prevBaseVop U */
video->prevBaseVop->vChan = video->prevBaseVop->uChan + (size >> 2); /* Memory for prevBaseVop V */
Expand All @@ -808,7 +808,7 @@ OSCL_EXPORT_REF Bool PVInitVideoEncoder(VideoEncControls *encoderControl, Vid
{
video->nextBaseVop = (Vop *) M4VENC_MALLOC(sizeof(Vop)); /* Memory for Next Base Vop */
if (video->nextBaseVop == NULL) goto CLEAN_UP;
video->nextBaseVop->yChan = (PIXEL *) M4VENC_MALLOC(sizeof(PIXEL) * (size + (size >> 1))); /* Memory for nextBaseVop Y */
video->nextBaseVop->allChan = video->nextBaseVop->yChan = (PIXEL *) M4VENC_MALLOC(sizeof(PIXEL) * (size + (size >> 1))); /* Memory for nextBaseVop Y */
if (video->nextBaseVop->yChan == NULL) goto CLEAN_UP;
video->nextBaseVop->uChan = video->nextBaseVop->yChan + size; /* Memory for nextBaseVop U */
video->nextBaseVop->vChan = video->nextBaseVop->uChan + (size >> 2); /* Memory for nextBaseVop V */
Expand All @@ -825,7 +825,7 @@ OSCL_EXPORT_REF Bool PVInitVideoEncoder(VideoEncControls *encoderControl, Vid
{
video->prevEnhanceVop = (Vop *) M4VENC_MALLOC(sizeof(Vop)); /* Memory for Previous Enhancement Vop */
if (video->prevEnhanceVop == NULL) goto CLEAN_UP;
video->prevEnhanceVop->yChan = (PIXEL *) M4VENC_MALLOC(sizeof(PIXEL) * (size + (size >> 1))); /* Memory for Previous Ehancement Y */
video->prevEnhanceVop->allChan = video->prevEnhanceVop->yChan = (PIXEL *) M4VENC_MALLOC(sizeof(PIXEL) * (size + (size >> 1))); /* Memory for Previous Ehancement Y */
if (video->prevEnhanceVop->yChan == NULL) goto CLEAN_UP;
video->prevEnhanceVop->uChan = video->prevEnhanceVop->yChan + size; /* Memory for Previous Enhancement U */
video->prevEnhanceVop->vChan = video->prevEnhanceVop->uChan + (size >> 2); /* Memory for Previous Enhancement V */
Expand Down Expand Up @@ -1196,39 +1196,35 @@ OSCL_EXPORT_REF Bool PVCleanUpVideoEncoder(VideoEncControls *encoderControl)

if (video->currVop)
{
if (video->currVop->yChan)
if (video->currVop->allChan)
{
video->currVop->yChan -= offset;
M4VENC_FREE(video->currVop->yChan);
M4VENC_FREE(video->currVop->allChan);
}
M4VENC_FREE(video->currVop);
}

if (video->nextBaseVop)
{
if (video->nextBaseVop->yChan)
if (video->nextBaseVop->allChan)
{
video->nextBaseVop->yChan -= offset;
M4VENC_FREE(video->nextBaseVop->yChan);
M4VENC_FREE(video->nextBaseVop->allChan);
}
M4VENC_FREE(video->nextBaseVop);
}

if (video->prevBaseVop)
{
if (video->prevBaseVop->yChan)
if (video->prevBaseVop->allChan)
{
video->prevBaseVop->yChan -= offset;
M4VENC_FREE(video->prevBaseVop->yChan);
M4VENC_FREE(video->prevBaseVop->allChan);
}
M4VENC_FREE(video->prevBaseVop);
}
if (video->prevEnhanceVop)
{
if (video->prevEnhanceVop->yChan)
if (video->prevEnhanceVop->allChan)
{
video->prevEnhanceVop->yChan -= offset;
M4VENC_FREE(video->prevEnhanceVop->yChan);
M4VENC_FREE(video->prevEnhanceVop->allChan);
}
M4VENC_FREE(video->prevEnhanceVop);
}
Expand Down
1 change: 1 addition & 0 deletions media/libstagefright/codecs/m4v_h263/enc/src/mp4lib_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef struct tagBitstream

typedef struct tagVOP
{
PIXEL *allChan; /* [yuv]Chan point into this buffer */
PIXEL *yChan; /* The Y component */
PIXEL *uChan; /* The U component */
PIXEL *vChan; /* The V component */
Expand Down
30 changes: 24 additions & 6 deletions media/libstagefright/omx/GraphicBufferSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,12 @@ GraphicBufferSource::GraphicBufferSource(
mIsPersistent = true;
}
mConsumer->setDefaultBufferSize(bufferWidth, bufferHeight);
// Note that we can't create an sp<...>(this) in a ctor that will not keep a
// reference once the ctor ends, as that would cause the refcount of 'this'
// dropping to 0 at the end of the ctor. Since all we need is a wp<...>
}

status_t GraphicBufferSource::init() {
// Note that we can't create an sp<...>(this) in a method that will not keep a
// reference once the method ends, as that may cause the refcount of 'this'
// dropping to 0 at the end of the method. Since all we need is a wp<...>
// that's what we create.
wp<BufferQueue::ConsumerListener> listener = static_cast<BufferQueue::ConsumerListener*>(this);
sp<IConsumerListener> proxy;
Expand All @@ -186,10 +189,9 @@ GraphicBufferSource::GraphicBufferSource(
if (mInitCheck != NO_ERROR) {
ALOGE("Error connecting to BufferQueue: %s (%d)",
strerror(-mInitCheck), mInitCheck);
return;
}

CHECK(mInitCheck == NO_ERROR);
return mInitCheck;
}

GraphicBufferSource::~GraphicBufferSource() {
Expand Down Expand Up @@ -471,6 +473,12 @@ void GraphicBufferSource::suspend(bool suspend) {
} else if (err != OK) {
ALOGW("suspend: acquireBuffer returned err=%d", err);
break;
} else if (item.mBuf < 0 ||
item.mBuf >= BufferQueue::NUM_BUFFER_SLOTS) {
// Invalid buffer index
ALOGW("suspend: corrupted buffer index (%d)",
item.mBuf);
break;
}

++mNumBufferAcquired;
Expand Down Expand Up @@ -522,6 +530,10 @@ bool GraphicBufferSource::fillCodecBuffer_l() {
// now what? fake end-of-stream?
ALOGW("fillCodecBuffer_l: acquireBuffer returned err=%d", err);
return false;
} else if (item.mBuf < 0 || item.mBuf >= BufferQueue::NUM_BUFFER_SLOTS) {
// Invalid buffer index
ALOGW("fillCodecBuffer_l: corrupted buffer index (%d)", item.mBuf);
return false;
}

mNumBufferAcquired++;
Expand Down Expand Up @@ -875,8 +887,14 @@ void GraphicBufferSource::onFrameAvailable(const BufferItem& /*item*/) {
BufferItem item;
status_t err = mConsumer->acquireBuffer(&item, 0);
if (err == OK) {
if (item.mBuf < 0 ||
item.mBuf >= BufferQueue::NUM_BUFFER_SLOTS) {
// Invalid buffer index
ALOGW("onFrameAvailable: corrupted buffer index (%d)",
item.mBuf);
return;
}
mNumBufferAcquired++;

// If this is the first time we're seeing this buffer, add it to our
// slot table.
if (item.mGraphicBuffer != NULL) {
Expand Down
6 changes: 1 addition & 5 deletions media/libstagefright/omx/GraphicBufferSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ class GraphicBufferSource : public BufferQueue::ConsumerListener {

virtual ~GraphicBufferSource();

// We can't throw an exception if the constructor fails, so we just set
// this and require that the caller test the value.
status_t initCheck() const {
return mInitCheck;
}
status_t init();

// Returns the handle to the producer side of the BufferQueue. Buffers
// queued on this will be received by GraphicBufferSource.
Expand Down
2 changes: 1 addition & 1 deletion media/libstagefright/omx/OMXNodeInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ status_t OMXNodeInstance::createGraphicBufferSource(
usageBits,
bufferConsumer);

if ((err = bufferSource->initCheck()) != OK) {
if ((err = bufferSource->init()) != OK) {
return err;
}
setGraphicBufferSource(bufferSource);
Expand Down

0 comments on commit 9ba4ad6

Please sign in to comment.