@@ -848,7 +848,9 @@ PVMFOMXEncNode::PVMFOMXEncNode(int32 aPriority) :
848
848
iVideoEncodeParam.iRVLCEnable = false ;
849
849
iVideoEncodeParam.iIFrameInterval = DEFAULT_I_FRAME_INTERVAL;
850
850
iVideoEncodeParam.iBufferDelay = (float )0.2 ;
851
- iVideoEncodeParam.iContentType = EI_H263;
851
+ iVideoEncodeParam.iShortHeader = false ;
852
+ iVideoEncodeParam.iDataPartitioning = false ;
853
+ iVideoEncodeParam.iResyncMarker = true ;
852
854
853
855
// set the default rate control type to variable bit rate control
854
856
// since it has better performance
@@ -2524,16 +2526,8 @@ bool PVMFOMXEncNode::SetMP4EncoderParameters()
2524
2526
2525
2527
// Set the parameters now
2526
2528
ErrCorrType.nPortIndex = iOutputPortIndex;
2527
- if (iVideoEncodeParam.iContentType == EI_M4V_STREAMING)
2528
- {
2529
- ErrCorrType.bEnableDataPartitioning = OMX_TRUE;
2530
- ErrCorrType.bEnableResync = OMX_TRUE;
2531
- }
2532
- else
2533
- {
2534
- ErrCorrType.bEnableDataPartitioning = OMX_FALSE;
2535
- ErrCorrType.bEnableResync = OMX_FALSE;
2536
- }
2529
+ ErrCorrType.bEnableDataPartitioning = ((iVideoEncodeParam.iDataPartitioning == true ) ? OMX_TRUE : OMX_FALSE);
2530
+ ErrCorrType.bEnableResync = ((iVideoEncodeParam.iResyncMarker == true ) ? OMX_TRUE : OMX_FALSE);
2537
2531
2538
2532
// extra parameters - hardcoded
2539
2533
ErrCorrType.bEnableHEC = OMX_FALSE;
@@ -4923,16 +4917,18 @@ OMX_ERRORTYPE PVMFOMXEncNode::FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aC
4923
4917
uint32 bufLen = (uint32) aBuffer->nFilledLen ;
4924
4918
4925
4919
// in case of mp4 streaming and the very 1st buffer, save vol header separately
4926
- if ((iOutFormat == PVMF_MIME_M4V) && (iVideoEncodeParam.iContentType == EI_M4V_STREAMING)
4927
- && (iFrameCounter == 1 ))
4920
+ if ((iOutFormat == PVMF_MIME_M4V) && (iFrameCounter == 1 ))
4928
4921
{
4929
4922
4930
4923
// save the first buffer since this is the VOL header
4931
-
4932
4924
uint refCounterSize = oscl_mem_aligned_size (sizeof (OsclRefCounterDA));
4933
4925
OsclMemoryFragment volHeader;
4926
+
4927
+ int vol_len = aBuffer->nFilledLen ;
4928
+ bool frameInVolHdr = CheckM4vVopStartCode (pBufdata, &vol_len);
4929
+
4934
4930
volHeader.ptr = NULL ;
4935
- volHeader.len = aBuffer-> nFilledLen ; // vol header size should be (28)
4931
+ volHeader.len = vol_len;
4936
4932
uint8* memBuffer = (uint8*)iAlloc.allocate (refCounterSize + volHeader.len );
4937
4933
oscl_memset (memBuffer, 0 , refCounterSize + volHeader.len );
4938
4934
OsclRefCounter* refCounter = OSCL_PLACEMENT_NEW (memBuffer, OsclRefCounterDA (memBuffer, (OsclDestructDealloc*) & iAlloc));
@@ -4945,9 +4941,17 @@ OMX_ERRORTYPE PVMFOMXEncNode::FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aC
4945
4941
// save in class variable
4946
4942
iVolHeader = OsclRefCounterMemFrag (volHeader, refCounter, volHeader.len );
4947
4943
4948
- // release the OMX buffer
4949
- iOutBufMemoryPool->deallocate (pContext);
4950
- return OMX_ErrorNone;
4944
+ if (frameInVolHdr == false )
4945
+ {
4946
+ // release the OMX buffer
4947
+ iOutBufMemoryPool->deallocate (pContext);
4948
+ return OMX_ErrorNone;
4949
+ }
4950
+ else // there is a frame in this buffer, update the pointer and continue to process it.
4951
+ {
4952
+ pBufdata += vol_len;
4953
+ bufLen -= vol_len;
4954
+ }
4951
4955
}
4952
4956
4953
4957
if (iFrameCounter == 1 )
@@ -5315,7 +5319,7 @@ bool PVMFOMXEncNode::QueueOutputBuffer(OsclSharedPtr<PVMFMediaDataImpl> &mediada
5315
5319
// Check if Fsi needs to be sent (VOL header)
5316
5320
if (sendYuvFsi)
5317
5321
{
5318
- if (iVideoEncodeParam. iContentType == EI_M4V_STREAMING )
5322
+ if (iOutFormat == PVMF_MIME_M4V )
5319
5323
{
5320
5324
mediaDataOut->setFormatSpecificInfo (iVolHeader);
5321
5325
@@ -8326,20 +8330,10 @@ OSCL_EXPORT_REF bool PVMFOMXEncNode::SetDataPartitioning(bool aDataPartitioning)
8326
8330
break ;
8327
8331
}
8328
8332
8329
- if (iVideoEncodeParam.iContentType == EI_H263 || iVideoEncodeParam.iContentType == EI_H264)
8330
- {
8331
- PVLOGGER_LOGMSG (PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
8332
- (0 , " PVMFOMXEncNode-%s::SetDataPartitioning: Error data partitioning not supported for H263 or H264" , iNodeTypeId));
8333
+ iVideoEncodeParam.iDataPartitioning = aDataPartitioning;
8333
8334
8334
- // ignore the error
8335
- return true ;
8336
- // return false;
8337
- }
8338
-
8339
- if (aDataPartitioning)
8340
- iVideoEncodeParam.iContentType = EI_M4V_STREAMING;
8341
- else
8342
- iVideoEncodeParam.iContentType = EI_M4V_DOWNLOAD;
8335
+ PVLOGGER_LOGMSG (PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
8336
+ (0 , " PVMFOMXEncNode-%s::SetDataPartitioning Called" , iNodeTypeId));
8343
8337
8344
8338
return true ;
8345
8339
}
@@ -8404,16 +8398,8 @@ OSCL_EXPORT_REF bool PVMFOMXEncNode::SetRVLC(bool aRVLC)
8404
8398
break ;
8405
8399
}
8406
8400
8407
- if (iVideoEncodeParam.iContentType == EI_H263 || iVideoEncodeParam.iContentType == EI_H264)
8408
- {
8409
- PVLOGGER_LOGMSG (PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
8410
- (0 , " PVMFOMXEncNode-%s::SetRVLC : RVLC not supported for H263 or H264" , iNodeTypeId));
8411
-
8412
- // ignore the error
8413
- return true ;
8414
- }
8415
-
8416
8401
iVideoEncodeParam.iRVLCEnable = aRVLC;
8402
+
8417
8403
return true ;
8418
8404
}
8419
8405
@@ -8443,7 +8429,7 @@ OSCL_EXPORT_REF bool PVMFOMXEncNode::GetVolHeader(OsclRefCounterMemFrag& aVolHea
8443
8429
return false ;
8444
8430
}
8445
8431
8446
- if ((iVideoEncodeParam. iContentType == EI_H263) || (iVideoEncodeParam. iContentType == EI_H264) )
8432
+ if (iOutFormat != PVMF_MIME_M4V )
8447
8433
{
8448
8434
PVLOGGER_LOGMSG (PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
8449
8435
(0 , " PVMFOMXEncNode-%s::GetVolHeader: Error - VOL header only for M4V encode" , iNodeTypeId));
@@ -8452,12 +8438,12 @@ OSCL_EXPORT_REF bool PVMFOMXEncNode::GetVolHeader(OsclRefCounterMemFrag& aVolHea
8452
8438
8453
8439
uint8 *ptr = (uint8 *) iVolHeader.getMemFragPtr ();
8454
8440
// If data partioning mode
8455
- if (iVideoEncodeParam.iContentType == EI_M4V_STREAMING )
8441
+ if (iVideoEncodeParam.iDataPartitioning == true )
8456
8442
{
8457
8443
ptr[iVolHeader.getMemFragSize () - 1 ] = 0x8F ;
8458
8444
}
8459
8445
// else combined mode
8460
- else if (iVideoEncodeParam. iContentType == EI_M4V_DOWNLOAD)
8446
+ else
8461
8447
{
8462
8448
ptr[iVolHeader.getMemFragSize () - 1 ] = 0x1F ;
8463
8449
}
@@ -8525,23 +8511,19 @@ PVMFStatus PVMFOMXEncNode::SetCodecType(PVMFFormatType aCodec)
8525
8511
8526
8512
if (aCodec == PVMF_MIME_H2631998)
8527
8513
{
8528
- iVideoEncodeParam.iContentType = EI_H263;
8529
8514
iOutFormat = PVMF_MIME_H2631998;
8530
8515
}
8531
8516
else if (aCodec == PVMF_MIME_H2632000)
8532
8517
{
8533
- iVideoEncodeParam.iContentType = EI_H263;
8534
8518
iOutFormat = PVMF_MIME_H2632000;
8535
8519
}
8536
8520
else if (aCodec == PVMF_MIME_M4V)
8537
8521
{
8538
- iVideoEncodeParam.iContentType = EI_M4V_STREAMING;
8539
8522
iOutFormat = PVMF_MIME_M4V;
8540
8523
}
8541
8524
else if (aCodec == PVMF_MIME_H264_VIDEO_RAW ||
8542
8525
aCodec == PVMF_MIME_H264_VIDEO_MP4)
8543
8526
{
8544
- iVideoEncodeParam.iContentType = EI_H264;
8545
8527
iOutFormat = aCodec;
8546
8528
}
8547
8529
else if (aCodec == PVMF_MIME_AMR_IETF ||
@@ -9920,3 +9902,38 @@ bool PVMFOMXEncNode::AVCAnnexBGetNALUnit(uint8 *bitstream, uint8 **nal_unit, int
9920
9902
9921
9903
return true ;
9922
9904
}
9905
+
9906
+ // ////////////////////////////////////////////////////////////////////////////////////////////////////////////
9907
+ bool PVMFOMXEncNode::CheckM4vVopStartCode (uint8* data, int * len)
9908
+ {
9909
+ int32 count = 0 ;
9910
+ int32 i = *len;
9911
+
9912
+ if (i < 4 ) // at least the size of frame header
9913
+ {
9914
+ return false ;
9915
+ }
9916
+ while (--i)
9917
+ {
9918
+ if ((count > 1 ) && (data[0 ] == 0x01 ) && (data[1 ] == 0xB6 ))
9919
+ {
9920
+ i += 2 ;
9921
+ break ;
9922
+ }
9923
+
9924
+ if (*data++)
9925
+ count = 0 ;
9926
+ else
9927
+ count++;
9928
+ }
9929
+
9930
+ // i is number of bytes left (including 00 00 01 B6)
9931
+ if (i > 0 )
9932
+ {
9933
+ *len = (*len - i - 1 ); // len before finding VOP start code
9934
+ return true ;
9935
+ }
9936
+
9937
+ return false ;
9938
+ }
9939
+
0 commit comments