[NJ-1436] OMX.PV.avcdec appears to be broken.
http://b/issue?id=2026091
Fix 2/2 : RIO-6062 Avoid port -reconfiguration in OMX components if possible
diff --git a/codecs_v2/omx/omx_amr/include/amr_dec.h b/codecs_v2/omx/omx_amr/include/amr_dec.h
index 365722e..cf5d586 100644
--- a/codecs_v2/omx/omx_amr/include/amr_dec.h
+++ b/codecs_v2/omx/omx_amr/include/amr_dec.h
@@ -51,8 +51,7 @@
OMX_BOOL AmrDecodeFrame(OMX_S16* aOutputBuffer,
OMX_U32* aOutputLength, OMX_U8** aInBuffer,
- OMX_U32* aInBufSize, OMX_S32* aIsFirstBuffer,
- OMX_BOOL* aResizeFlag);
+ OMX_U32* aInBufSize, OMX_S32* aIsFirstBuffer);
OMX_BOOL AmrDecodeSilenceFrame(OMX_S16* aOutputBuffer,
OMX_U32* aOutputLength);
diff --git a/codecs_v2/omx/omx_amr/include/omx_amr_component.h b/codecs_v2/omx/omx_amr/include/omx_amr_component.h
index 42fe4cb..52facda 100644
--- a/codecs_v2/omx/omx_amr/include/omx_amr_component.h
+++ b/codecs_v2/omx/omx_amr/include/omx_amr_component.h
@@ -40,6 +40,9 @@
#define NUMBER_INPUT_BUFFER_AMR 10
#define NUMBER_OUTPUT_BUFFER_AMR 9
+// we are assuming 16 bits per sample
+#define AMR_NB_OUTPUT_FRAME_SIZE_IN_BYTES 320
+#define AMR_WB_OUTPUT_FRAME_SIZE_IN_BYTES 640
class OpenmaxAmrAO : public OmxComponentAudio
{
diff --git a/codecs_v2/omx/omx_amr/src/amr_decode_frame.cpp b/codecs_v2/omx/omx_amr/src/amr_decode_frame.cpp
index 3f8a544..5df2689 100644
--- a/codecs_v2/omx/omx_amr/src/amr_decode_frame.cpp
+++ b/codecs_v2/omx/omx_amr/src/amr_decode_frame.cpp
@@ -275,13 +275,9 @@
/* Decode function for all the input formats */
OMX_BOOL OmxAmrDecoder::AmrDecodeFrame(OMX_S16* aOutputBuffer,
OMX_U32* aOutputLength, OMX_U8** aInBuffer,
- OMX_U32* aInBufSize, OMX_S32* aIsFirstBuffer,
- OMX_BOOL* aResizeFlag)
+ OMX_U32* aInBufSize, OMX_S32* aIsFirstBuffer)
{
OMX_BOOL Status = OMX_TRUE;
-
- *aResizeFlag = OMX_FALSE;
-
OMX_S32 ByteOffset, ii;
TXFrameType TxFrame;
@@ -528,13 +524,6 @@
(*aIsFirstBuffer)++;
- //After decoding the first frame, modify all the input & output port settings
- if (1 == *aIsFirstBuffer)
- {
- //Set the Resize flag to send the port settings changed callback
- *aResizeFlag = OMX_TRUE;
- }
-
return Status;
}
diff --git a/codecs_v2/omx/omx_amr/src/omx_amr_component.cpp b/codecs_v2/omx/omx_amr/src/omx_amr_component.cpp
index 8b7a741..04f4595 100644
--- a/codecs_v2/omx/omx_amr/src/omx_amr_component.cpp
+++ b/codecs_v2/omx/omx_amr/src/omx_amr_component.cpp
@@ -447,7 +447,6 @@
OMX_U32 OutputLength;
OMX_U8* pTempInBuffer;
OMX_U32 TempInLength;
- OMX_BOOL ResizeNeeded = OMX_FALSE;
OMX_BOOL DecodeReturn = OMX_FALSE;
OMX_U32 TempInputBufferSize = (2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
@@ -484,56 +483,7 @@
//Set the current timestamp to the output buffer timestamp
ipOutputBuffer->nTimeStamp = iCurrentTimestamp;
- // Copy the output buffer that was stored locally before dynamic port reconfiguration
- // in the new omx buffer received.
- if (OMX_TRUE == iSendOutBufferAfterPortReconfigFlag)
- {
- if ((ipTempOutBufferForPortReconfig)
- && (iSizeOutBufferForPortReconfig <= ipOutputBuffer->nAllocLen))
- {
- oscl_memcpy(ipOutputBuffer->pBuffer, ipTempOutBufferForPortReconfig, iSizeOutBufferForPortReconfig);
- ipOutputBuffer->nFilledLen = iSizeOutBufferForPortReconfig;
- ipOutputBuffer->nTimeStamp = iTimestampOutBufferForPortReconfig;
- }
- iSendOutBufferAfterPortReconfigFlag = OMX_FALSE;
-
- //Send the output buffer back only when it has become full
- if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
- {
- ReturnOutputBuffer(ipOutputBuffer, pOutPort);
- }
-
- //Free the temp output buffer
- if (ipTempOutBufferForPortReconfig)
- {
- oscl_free(ipTempOutBufferForPortReconfig);
- ipTempOutBufferForPortReconfig = NULL;
- iSizeOutBufferForPortReconfig = 0;
- }
-
- //Dequeue new output buffer if required to continue decoding the next frame
- if (OMX_TRUE == iNewOutBufRequired)
- {
- if (0 == (GetQueueNumElem(pOutputQueue)))
- {
- PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker OUT output buffer unavailable"));
- return;
- }
-
- ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
- if (NULL == ipOutputBuffer)
- {
- PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker Error, Output Buffer Dequeue returned NULL, OUT"));
- return;
- }
-
- ipOutputBuffer->nFilledLen = 0;
- iNewOutBufRequired = OMX_FALSE;
-
- ipOutputBuffer->nTimeStamp = iCurrentTimestamp;
- }
- }
}
/* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
@@ -576,8 +526,7 @@
(OMX_U32*) & OutputLength,
&(pTempInBuffer),
&TempInLength,
- &iFrameCount,
- &ResizeNeeded);
+ &iFrameCount);
//If decoder returned error, report it to the client via a callback
@@ -594,49 +543,6 @@
NULL);
}
- if (ResizeNeeded == OMX_TRUE)
- {
- if (0 != OutputLength)
- {
- iOutputFrameLength = OutputLength;
- }
-
- iResizePending = OMX_TRUE;
-
- /* Do not return the output buffer generated yet, store it locally
- * and wait for the dynamic port reconfig to complete */
- if ((NULL == ipTempOutBufferForPortReconfig))
- {
- ipTempOutBufferForPortReconfig = (OMX_U8*) oscl_malloc(sizeof(uint8) * OutputLength);
- if (NULL == ipTempOutBufferForPortReconfig)
- {
- PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker error, insufficient resources"));
- return;
- }
- }
-
- //Copy the omx output buffer to the temporary internal buffer
- oscl_memcpy(ipTempOutBufferForPortReconfig, pOutBuffer, OutputLength);
- iSizeOutBufferForPortReconfig = OutputLength;
-
- iTimestampOutBufferForPortReconfig = iCurrentTimestamp;
-
- iCurrentTimestamp += OMX_AMR_DEC_FRAME_INTERVAL;
- //Make this length 0 so that no output buffer is returned by the component
- OutputLength = 0;
-
- // send port settings changed event
- OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->CompHandle;
-
- (*(ipCallbacks->EventHandler))
- (pHandle,
- iCallbackData,
- OMX_EventPortSettingsChanged, //The command was completed
- OMX_PORT_OUTPUTPORT_INDEX,
- 0,
- NULL);
-
- }
ipOutputBuffer->nFilledLen += OutputLength;
@@ -709,7 +615,7 @@
* This may block the AO longer than required.
*/
if ((iTempInputBufferLength != 0 || GetQueueNumElem(pInputQueue) > 0)
- && (GetQueueNumElem(pOutputQueue) > 0) && (ResizeNeeded == OMX_FALSE))
+ && (GetQueueNumElem(pOutputQueue) > 0))
{
RunIfNotReady();
@@ -735,7 +641,6 @@
OMX_U32 OutputLength;
OMX_BOOL DecodeReturn = OMX_FALSE;
OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
- OMX_BOOL ResizeNeeded = OMX_FALSE;
if ((!iIsInputBufferEnded) || (iEndofStream))
{
@@ -772,56 +677,7 @@
//Set the current timestamp to the output buffer timestamp
ipOutputBuffer->nTimeStamp = iCurrentTimestamp;
- // Copy the output buffer that was stored locally before dynamic port reconfiguration
- // in the new omx buffer received.
- if (OMX_TRUE == iSendOutBufferAfterPortReconfigFlag)
- {
- if ((ipTempOutBufferForPortReconfig)
- && (iSizeOutBufferForPortReconfig <= ipOutputBuffer->nAllocLen))
- {
- oscl_memcpy(ipOutputBuffer->pBuffer, ipTempOutBufferForPortReconfig, iSizeOutBufferForPortReconfig);
- ipOutputBuffer->nFilledLen = iSizeOutBufferForPortReconfig;
- ipOutputBuffer->nTimeStamp = iTimestampOutBufferForPortReconfig;
- }
- iSendOutBufferAfterPortReconfigFlag = OMX_FALSE;
-
- //Send the output buffer back only when it has become full
- if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
- {
- ReturnOutputBuffer(ipOutputBuffer, pOutPort);
- }
-
- //Free the temp output buffer
- if (ipTempOutBufferForPortReconfig)
- {
- oscl_free(ipTempOutBufferForPortReconfig);
- ipTempOutBufferForPortReconfig = NULL;
- iSizeOutBufferForPortReconfig = 0;
- }
-
- //Dequeue new output buffer if required to continue decoding the next frame
- if (OMX_TRUE == iNewOutBufRequired)
- {
- if (0 == (GetQueueNumElem(pOutputQueue)))
- {
- PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO :DecodeWithMarker OUT output buffer unavailable"));
- return;
- }
-
- ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
- if (NULL == ipOutputBuffer)
- {
- PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker Error, Output Buffer Dequeue returned NULL, OUT"));
- return;
- }
-
- ipOutputBuffer->nFilledLen = 0;
- iNewOutBufRequired = OMX_FALSE;
-
- ipOutputBuffer->nTimeStamp = iCurrentTimestamp;
- }
- }
}
/* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
@@ -853,8 +709,7 @@
(OMX_U32*) & OutputLength,
&(ipFrameDecodeBuffer),
&(iInputCurrLength),
- &iFrameCount,
- &ResizeNeeded);
+ &iFrameCount);
//If decoder returned error, report it to the client via a callback
if ((OMX_FALSE == DecodeReturn) && (OMX_FALSE == iEndofStream))
@@ -870,54 +725,6 @@
NULL);
}
- if (ResizeNeeded == OMX_TRUE)
- {
- if (0 != OutputLength)
- {
- iOutputFrameLength = OutputLength;
-
- }
-
- iResizePending = OMX_TRUE;
-
- /* Do not return the output buffer generated yet, store it locally
- * and wait for the dynamic port reconfig to complete */
- if ((NULL == ipTempOutBufferForPortReconfig))
- {
- ipTempOutBufferForPortReconfig = (OMX_U8*) oscl_malloc(sizeof(uint8) * OutputLength);
- if (NULL == ipTempOutBufferForPortReconfig)
- {
- PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker error, insufficient resources"));
- return;
- }
- }
-
- //Copy the omx output buffer to the temporary internal buffer
- oscl_memcpy(ipTempOutBufferForPortReconfig, pOutBuffer, OutputLength);
- iSizeOutBufferForPortReconfig = OutputLength;
-
- iTimestampOutBufferForPortReconfig = iCurrentTimestamp;
-
- iCurrentTimestamp += OMX_AMR_DEC_FRAME_INTERVAL;
- //Make this length 0 so that no output buffer is returned by the component
- OutputLength = 0;
-
-
- // send port settings changed event
- OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->CompHandle;
-
- // set the flag to disable further processing until Client reacts to this
- // by doing dynamic port reconfiguration
-
- (*(ipCallbacks->EventHandler))
- (pHandle,
- iCallbackData,
- OMX_EventPortSettingsChanged, //The command was completed
- OMX_PORT_OUTPUTPORT_INDEX,
- 0,
- NULL);
-
- }
ipOutputBuffer->nFilledLen += OutputLength;
if (OutputLength > 0)
@@ -989,7 +796,7 @@
* This may block the AO longer than required.
*/
if ((iInputCurrLength != 0 || GetQueueNumElem(pInputQueue) > 0)
- && (GetQueueNumElem(pOutputQueue) > 0) && (ResizeNeeded == OMX_FALSE))
+ && (GetQueueNumElem(pOutputQueue) > 0))
{
RunIfNotReady();
}
@@ -1061,6 +868,8 @@
//Narrow band component does not support these band modes
return OMX_ErrorInvalidComponent;
}
+ // set the fixed frame size
+ iOutputFrameLength = AMR_NB_OUTPUT_FRAME_SIZE_IN_BYTES;
}
else if ((OMX_TRUE == iComponentRoleFlag) && (0 == oscl_strcmp((OMX_STRING)iComponentRole, (OMX_STRING)"audio_decoder.amrwb")))
{
@@ -1069,6 +878,9 @@
//Wide band component does not support these band modes
return OMX_ErrorInvalidComponent;
}
+
+ // set the fixed frame size
+ iOutputFrameLength = AMR_WB_OUTPUT_FRAME_SIZE_IN_BYTES;
}
//amr lib init
@@ -1155,7 +967,6 @@
OMX_U8* pOutBuffer = NULL;
OMX_U32 OutputLength;
- //OMX_BOOL ResizeNeeded = OMX_FALSE;
OMX_BOOL DecodeReturn;
diff --git a/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp b/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp
index d012d5c..b2e7d06 100644
--- a/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp
+++ b/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp
@@ -4198,6 +4198,63 @@
oscl_memcpy(&ipPorts[PortIndex]->PortParam.format.video, &pPortDef->format.video, sizeof(OMX_VIDEO_PORTDEFINITIONTYPE));
+ // adjust the minimum buffer size of the uncompressed format based on width and height that may have been set
+ // In case of decoder - output port contains uncompressed data - so outpu buffer size needs to be adjusted
+ // In case of encoder - input port contains uncompressed data - so input buffer size needs to be adjusted
+ // In both cases (encoder&decoder) - eCompressionFormat parameter on the appropriate port is set to OMX_VIDEO_CodingUnused
+
+ OMX_VIDEO_PORTDEFINITIONTYPE *videoformat = &(ipPorts[PortIndex]->PortParam.format.video);
+ if (videoformat->eCompressionFormat == OMX_VIDEO_CodingUnused)
+ {
+ // check if stride needs to be adjusted - stride should be at least the 16 byte aligned width
+ // WMV is special case that requires 4 bytes alignment
+
+ OMX_U32 min_stride = ((videoformat->nFrameWidth + 15) & (~15));
+ OMX_U32 min_sliceheight = ((videoformat->nFrameHeight + 15) & (~15));
+
+ if (oscl_strcmp("video/wmv", videoformat->cMIMEType) == 0)
+ {
+ min_stride = ((videoformat->nFrameWidth + 3) & (~3));
+ min_sliceheight = ((videoformat->nFrameHeight + 1) & (~1));
+ }
+
+
+ videoformat->nStride = min_stride;
+ videoformat->nSliceHeight = min_sliceheight;
+
+
+ // finally, compute the new minimum buffer size.
+
+ // Encoder components can have different formats - (rely on the client to provide the correct size)
+ if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex)
+ {
+ // Decoder components always output YUV420 format
+ ipPorts[PortIndex]->PortParam.nBufferSize = (videoformat->nSliceHeight * videoformat->nStride * 3) >> 1;
+
+ }
+
+ if (OMX_PORT_INPUTPORT_INDEX == PortIndex)
+ {
+ // Encoder components may have different formats
+ if (videoformat->eColorFormat == OMX_COLOR_Format24bitRGB888)
+ {
+ ipPorts[PortIndex]->PortParam.nBufferSize = videoformat->nSliceHeight * videoformat->nStride * 3;
+ }
+ else if (videoformat->eColorFormat == OMX_COLOR_Format12bitRGB444)
+ {
+ ipPorts[PortIndex]->PortParam.nBufferSize = videoformat->nSliceHeight * videoformat->nStride * 2;
+
+ }
+ else if (videoformat->eColorFormat == OMX_COLOR_FormatYUV420Planar)
+ {
+ ipPorts[PortIndex]->PortParam.nBufferSize = (videoformat->nSliceHeight * videoformat->nStride * 3) >> 1;
+
+ }
+
+ }
+
+ }
+
}
break;
diff --git a/codecs_v2/omx/omx_h264/include/omx_avc_component.h b/codecs_v2/omx/omx_h264/include/omx_avc_component.h
index d96a679..ddc110f 100644
--- a/codecs_v2/omx/omx_h264/include/omx_avc_component.h
+++ b/codecs_v2/omx/omx_h264/include/omx_avc_component.h
@@ -42,7 +42,8 @@
#define NAL_START_CODE_SIZE 4
-#define OUTPUT_BUFFER_SIZE_AVC 65536
+//qcif - output 176*144*3/2
+#define OUTPUT_BUFFER_SIZE_AVC 38016
#define NUMBER_INPUT_BUFFER_AVC 10
#define NUMBER_OUTPUT_BUFFER_AVC 2
diff --git a/codecs_v2/omx/omx_h264/src/avc_dec.cpp b/codecs_v2/omx/omx_h264/src/avc_dec.cpp
index b0d56b4..eef8002 100644
--- a/codecs_v2/omx/omx_h264/src/avc_dec.cpp
+++ b/codecs_v2/omx/omx_h264/src/avc_dec.cpp
@@ -254,9 +254,22 @@
aPortParam->format.video.nFrameWidth = crop_right - crop_left + 1;
aPortParam->format.video.nFrameHeight = crop_bottom - crop_top + 1;
- //if( (OldWidth != aPortParam->format.video.nFrameWidth) || (OldHeight != aPortParam->format.video.nFrameHeight))
- // FORCE RESIZE ALWAYS FOR SPS
- *aResizeFlag = OMX_TRUE;
+ OMX_U32 min_stride = ((aPortParam->format.video.nFrameWidth + 15) & (~15));
+ OMX_U32 min_sliceheight = ((aPortParam->format.video.nFrameHeight + 15) & (~15));
+
+
+ aPortParam->format.video.nStride = min_stride;
+ aPortParam->format.video.nSliceHeight = min_sliceheight;
+
+
+ // finally, compute the new minimum buffer size.
+
+ // Decoder components always output YUV420 format
+ aPortParam->nBufferSize = (aPortParam->format.video.nSliceHeight * aPortParam->format.video.nStride * 3) >> 1;
+
+
+ if ((OldWidth != aPortParam->format.video.nFrameWidth) || (OldHeight != aPortParam->format.video.nFrameHeight))
+ *aResizeFlag = OMX_TRUE;
(*iFrameCount)++;
diff --git a/codecs_v2/omx/omx_h264/src/omx_avc_component.cpp b/codecs_v2/omx/omx_h264/src/omx_avc_component.cpp
index fa6914d..a4fe0de 100644
--- a/codecs_v2/omx/omx_h264/src/omx_avc_component.cpp
+++ b/codecs_v2/omx/omx_h264/src/omx_avc_component.cpp
@@ -262,7 +262,9 @@
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nFrameWidth = 176;
+ ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nStride = 176;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nFrameHeight = 144;
+ ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nSliceHeight = 144;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nBitrate = 64000;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.xFramerate = (15 << 16);
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDir = OMX_DirOutput;
@@ -270,7 +272,7 @@
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferCountActual = NUMBER_OUTPUT_BUFFER_AVC
;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferCountMin = 1;
- ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferSize = 176 * 144 * 3 / 2; //Don't use OUTPUT_BUFFER_SIZE_AVC, just use QCIF (as default)
+ ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferSize = OUTPUT_BUFFER_SIZE_AVC; //just use QCIF (as default)
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.bEnabled = OMX_TRUE;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.bPopulated = OMX_FALSE;
@@ -573,7 +575,7 @@
}
//Do not proceed if the output buffer can't fit the YUV data
- if (ipOutputBuffer->nAllocLen < (OMX_U32)(((CurrWidth + 15)&(~15)) *((CurrHeight + 15)&(~15)) * 3 / 2))
+ if ((ipOutputBuffer->nAllocLen < (OMX_U32)(((CurrWidth + 15)&(~15)) *((CurrHeight + 15)&(~15)) * 3 / 2)) && (OMX_TRUE == ipAvcDec->iAvcActiveFlag))
{
ipOutputBuffer->nFilledLen = 0;
ReturnOutputBuffer(ipOutputBuffer, pOutPort);
@@ -783,7 +785,7 @@
}
//Do not proceed if the output buffer can't fit the YUV data
- if (ipOutputBuffer->nAllocLen < (OMX_U32)(((CurrWidth + 15)&(~15)) *((CurrHeight + 15)&(~15)) * 3 / 2))
+ if ((ipOutputBuffer->nAllocLen < (OMX_U32)(((CurrWidth + 15)&(~15)) *((CurrHeight + 15)&(~15)) * 3 / 2)) && (OMX_TRUE == ipAvcDec->iAvcActiveFlag))
{
ipOutputBuffer->nFilledLen = 0;
ReturnOutputBuffer(ipOutputBuffer, pOutPort);
diff --git a/codecs_v2/omx/omx_m4v/include/omx_mpeg4_component.h b/codecs_v2/omx/omx_m4v/include/omx_mpeg4_component.h
index 7f6a017..5b8911a 100644
--- a/codecs_v2/omx/omx_m4v/include/omx_mpeg4_component.h
+++ b/codecs_v2/omx/omx_m4v/include/omx_mpeg4_component.h
@@ -34,7 +34,8 @@
#define INPUT_BUFFER_SIZE_MP4 16000
-#define OUTPUT_BUFFER_SIZE_MP4 152064
+// qcif size - 176*144*3/2
+#define OUTPUT_BUFFER_SIZE_MP4 38016
#define NUMBER_INPUT_BUFFER_MP4 10
#define NUMBER_OUTPUT_BUFFER_MP4 2
diff --git a/codecs_v2/omx/omx_m4v/src/mpeg4_dec.cpp b/codecs_v2/omx/omx_m4v/src/mpeg4_dec.cpp
index 4789f2e..7551687 100644
--- a/codecs_v2/omx/omx_m4v/src/mpeg4_dec.cpp
+++ b/codecs_v2/omx/omx_m4v/src/mpeg4_dec.cpp
@@ -112,6 +112,21 @@
Mpeg4InitCompleteFlag = OMX_TRUE;
aPortParam->format.video.nFrameWidth = iDisplay_Width;
aPortParam->format.video.nFrameHeight = iDisplay_Height;
+
+ OMX_U32 min_stride = ((aPortParam->format.video.nFrameWidth + 15) & (~15));
+ OMX_U32 min_sliceheight = ((aPortParam->format.video.nFrameHeight + 15) & (~15));
+
+
+ aPortParam->format.video.nStride = min_stride;
+ aPortParam->format.video.nSliceHeight = min_sliceheight;
+
+
+ // finally, compute the new minimum buffer size.
+
+ // Decoder components always output YUV420 format
+ aPortParam->nBufferSize = (aPortParam->format.video.nSliceHeight * aPortParam->format.video.nStride * 3) >> 1;
+
+
if ((iDisplay_Width != OldWidth) || (iDisplay_Height != OldHeight))
*aResizeFlag = OMX_TRUE;
@@ -145,6 +160,20 @@
iDisplay_Height = display_height;
aPortParam->format.video.nFrameWidth = iDisplay_Width; // use non 16byte aligned values (display_width) for H263
aPortParam->format.video.nFrameHeight = iDisplay_Height; // like in the case of M4V (PVGetVideoDimensions also returns display_width/height)
+
+ OMX_U32 min_stride = ((aPortParam->format.video.nFrameWidth + 15) & (~15));
+ OMX_U32 min_sliceheight = ((aPortParam->format.video.nFrameHeight + 15) & (~15));
+
+
+ aPortParam->format.video.nStride = min_stride;
+ aPortParam->format.video.nSliceHeight = min_sliceheight;
+
+ // finally, compute the new minimum buffer size.
+
+ // Decoder components always output YUV420 format
+ aPortParam->nBufferSize = (aPortParam->format.video.nSliceHeight * aPortParam->format.video.nStride * 3) >> 1;
+
+
if ((iDisplay_Width != OldWidth) || (iDisplay_Height != OldHeight))
*aResizeFlag = OMX_TRUE;
@@ -180,6 +209,19 @@
aPortParam->format.video.nFrameWidth = iDisplay_Width;
aPortParam->format.video.nFrameHeight = iDisplay_Height;
+
+ OMX_U32 min_stride = ((aPortParam->format.video.nFrameWidth + 15) & (~15));
+ OMX_U32 min_sliceheight = ((aPortParam->format.video.nFrameHeight + 15) & (~15));
+
+
+ aPortParam->format.video.nStride = min_stride;
+ aPortParam->format.video.nSliceHeight = min_sliceheight;
+
+ // finally, compute the new minimum buffer size.
+
+ // Decoder components always output YUV420 format
+ aPortParam->nBufferSize = (aPortParam->format.video.nSliceHeight * aPortParam->format.video.nStride * 3) >> 1;
+
*aResizeFlag = OMX_TRUE;
}
FrameSize = (((iDisplay_Width + 15) >> 4) << 4) * (((iDisplay_Height + 15) >> 4) << 4);
diff --git a/codecs_v2/omx/omx_m4v/src/omx_mpeg4_component.cpp b/codecs_v2/omx/omx_m4v/src/omx_mpeg4_component.cpp
index 6eacccc..463cb02 100644
--- a/codecs_v2/omx/omx_m4v/src/omx_mpeg4_component.cpp
+++ b/codecs_v2/omx/omx_m4v/src/omx_mpeg4_component.cpp
@@ -337,7 +337,9 @@
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nFrameWidth = 176; //320; //176;
+ ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nStride = 176;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nFrameHeight = 144; //240; //144;
+ ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nSliceHeight = 144;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nBitrate = 64000;
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.xFramerate = (15 << 16);
ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDir = OMX_DirOutput;
@@ -540,7 +542,7 @@
}
//Do not proceed if the output buffer can't fit the YUV data
- if (ipOutputBuffer->nAllocLen < (OMX_U32)((((CurrWidth + 15) >> 4) << 4) *(((CurrHeight + 15) >> 4) << 4) * 3 / 2))
+ if ((ipOutputBuffer->nAllocLen < (OMX_U32)((((CurrWidth + 15) >> 4) << 4) *(((CurrHeight + 15) >> 4) << 4) * 3 / 2)) && (OMX_TRUE == ipMpegDecoderObject->Mpeg4InitCompleteFlag))
{
ipOutputBuffer->nFilledLen = 0;
ReturnOutputBuffer(ipOutputBuffer, pOutPort);
@@ -747,7 +749,7 @@
}
//Do not proceed if the output buffer can't fit the YUV data
- if (ipOutputBuffer->nAllocLen < (OMX_U32)((((CurrWidth + 15) >> 4) << 4) *(((CurrHeight + 15) >> 4) << 4) * 3 / 2))
+ if ((ipOutputBuffer->nAllocLen < (OMX_U32)((((CurrWidth + 15) >> 4) << 4) *(((CurrHeight + 15) >> 4) << 4) * 3 / 2)) && (OMX_TRUE == ipMpegDecoderObject->Mpeg4InitCompleteFlag))
{
ipOutputBuffer->nFilledLen = 0;
ReturnOutputBuffer(ipOutputBuffer, pOutPort);
diff --git a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp
index 8f6bf0c..b1159f7 100644
--- a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp
+++ b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp
@@ -1150,6 +1150,43 @@
}
+ // in case of WMA - config parser decodes config info and produces reliable numchannels and sampling rate
+ // set these values now to prevent unnecessary port reconfig
+ if (aInputs.iMimeType == PVMF_MIME_WMA)
+ {
+ // First get the structure
+ OMX_AUDIO_PARAM_PCMMODETYPE Audio_Pcm_Param;
+ Audio_Pcm_Param.nPortIndex = iOutputPortIndex; // we're looking for output port params
+ CONFIG_SIZE_AND_VERSION(Audio_Pcm_Param);
+
+ Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
+ if (Err != OMX_ErrorNone)
+ {
+ PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+ (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Problem negotiating PCM parameters with output port %d ", iOutputPortIndex));
+ return false;
+ }
+
+ // set the sampling rate obtained from config parser
+ Audio_Pcm_Param.nSamplingRate = iPCMSamplingRate; // can be set to 0 (if unknown)
+
+ // set number of channels obtained from config parser
+ Audio_Pcm_Param.nChannels = iNumberOfAudioChannels; // should be 1 or 2
+
+ // Now, set the parameters
+ Audio_Pcm_Param.nPortIndex = iOutputPortIndex; // we're looking for output port params
+ CONFIG_SIZE_AND_VERSION(Audio_Pcm_Param);
+
+ Err = OMX_SetParameter(iOMXDecoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
+ if (Err != OMX_ErrorNone)
+ {
+ PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+ (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Problem Setting PCM parameters with output port %d ", iOutputPortIndex));
+ return false;
+ }
+
+ }
+
// Codec specific info set/get: SamplingRate, formats etc.
// NOTE: iParamPort is modified in the routine below - it is loaded from the component output port values
diff --git a/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_node.cpp b/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_node.cpp
index 82e374c..f6d49e0 100644
--- a/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_node.cpp
+++ b/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_node.cpp
@@ -3636,7 +3636,7 @@
PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
- (0, "%s::EmptyBufferDoneProcessing: Release input buffer %x back to mempool", iName.Str(), pContext));
+ (0, "%s::EmptyBufferDoneProcessing: Release input buffer %x back to mempool - pointing to buffer %x", iName.Str(), pContext, aBuffer->pBuffer));
iInBufMemoryPool->deallocate((OsclAny *) pContext);
diff --git a/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp b/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp
index e864da1..f266a00 100644
--- a/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp
+++ b/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp
@@ -2170,8 +2170,11 @@
return false;
}
- //Set the input buffer size to the encoder component
- iParamPort.nBufferSize = iOMXComponentInputBufferSize;
+ //The input buffer size is a read-only parameter and the encoder component needs to adjust it.
+ // We (the client) determine the size of the buffers based on width/height -
+ // the component doesn't know width/height yet
+
+ //iParamPort.nBufferSize = iOMXComponentInputBufferSize;
// set the width and height of video frame and input framerate
@@ -3258,8 +3261,14 @@
return false;
}
- //Set the input buffer size to the encoder component
- iParamPort.nBufferSize = iOMXComponentInputBufferSize;
+ // The buffer size is a read only parameter. If the requested size is larger than what we wish to allocate -
+ // we'll allocate what the component desires
+
+ if (iParamPort.nBufferSize > iOMXComponentInputBufferSize)
+ {
+ iOMXComponentInputBufferSize = iParamPort.nBufferSize;
+ }
+
// set Encoding type