Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3626dda authored by Chih-Chung Chang's avatar Chih-Chung Chang
Browse files

Speed up thumbnail generation.

We accept a tolerance parameter while decoding. We also tell the
stagefright decoder to jump so we can move to the new frame faster.

Change-Id: Iede3c1f909f1c42b2d5a53c782083367b00f62fb
parent 08b82bdd
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -230,7 +230,9 @@ typedef enum
 *
 * @param    pContext:        (OUT)    Context of the decoder
 * @param    pStreamHandler:    (IN)    Pointer to a video stream description
 * @param    pSrcInterface:    (IN)    Pointer to the M4READER_DataInterface structure that must
 * @param    pGlobalInterface:  (IN)    Pointer to the M4READER_GlobalInterface structure that must
 *                                       be used by the decoder to read data from the stream
 * @param    pDataInterface:    (IN)    Pointer to the M4READER_DataInterface structure that must
 *                                       be used by the decoder to read data from the stream
 * @param    pAccessUnit        (IN)    Pointer to an access unit (allocated by the caller)
 *                                      where the decoded data are stored
@@ -243,7 +245,8 @@ typedef enum
*/
typedef M4OSA_ERR  (M4DECODER_create_fct)    (M4OSA_Context *pContext,
                                                 M4_StreamHandler *pStreamHandler,
                                                 M4READER_DataInterface *pSrcInterface,
                                                 M4READER_GlobalInterface *pGlobalInterface,
                                                 M4READER_DataInterface *pDataInterface,
                                                 M4_AccessUnit *pAccessUnit,
                                                 M4OSA_Void* pUserData);

@@ -313,6 +316,8 @@ typedef M4OSA_ERR (M4DECODER_setOption_fct)(M4OSA_Context context, M4OSA_Option
 *                                    OUT:Time of the last decoded frame (in ms)
 * @param   bJump:      (IN)        0 if no jump occured just before this call
 *                                  1 if a a jump has just been made
 * @param   tolerance:      (IN)        We may decode an earlier frame within the tolerance.
 *                                      The time difference is specified in milliseconds.
 *
 * @return    M4NO_ERROR                 there is no error
 * @return    M4ERR_PARAMETER            at least one parameter is not properly set
@@ -320,7 +325,7 @@ typedef M4OSA_ERR (M4DECODER_setOption_fct)(M4OSA_Context context, M4OSA_Option
 ************************************************************************
*/
typedef M4OSA_ERR  (M4DECODER_decode_fct)    (M4OSA_Context context, M4_MediaTime* pTime,
                                                 M4OSA_Bool bJump);
                                                 M4OSA_Bool bJump, M4OSA_UInt32 tolerance);

/**
 ************************************************************************
@@ -363,4 +368,3 @@ typedef struct _M4DECODER_VideoInterface
} M4DECODER_VideoInterface;

#endif /*__M4DECODER_COMMON_H__*/
+5 −14
Original line number Diff line number Diff line
@@ -5583,8 +5583,8 @@ static M4OSA_ERR M4MCS_intPrepareVideoDecoder( M4MCS_InternalContext *pC )
#endif /* M4VSS_ENABLE_EXTERNAL_DECODERS ? */

        err = pC->m_pVideoDecoder->m_pFctCreate(&pC->pViDecCtxt,
            &pC->pReaderVideoStream->m_basicProperties, pC->m_pReaderDataIt,
            &pC->ReaderVideoAU, decoderUserData);
            &pC->pReaderVideoStream->m_basicProperties, pC->m_pReader,
            pC->m_pReaderDataIt, &pC->ReaderVideoAU, decoderUserData);

        if( (M4OSA_UInt32)(M4ERR_DECODER_H263_PROFILE_NOT_SUPPORTED) == err )
        {
@@ -7660,15 +7660,6 @@ static M4OSA_ERR M4MCS_intStepBeginVideoJump( M4MCS_InternalContext *pC )

    }
    /* - CRLV6775 -H.264 Trimming */
    err = pC->m_pReader->m_pFctJump(pC->pReaderContext,
        (M4_StreamHandler *)pC->pReaderVideoStream, &iCts);

    if( M4NO_ERROR != err )
    {
        M4OSA_TRACE1_1(
            "M4MCS_intStepBeginVideoJump: m_pFctJump(V) returns 0x%x!", err);
        return err;
    }

    /**
    * Decode one step */
@@ -7689,7 +7680,7 @@ static M4OSA_ERR M4MCS_intStepBeginVideoJump( M4MCS_InternalContext *pC )
    pC->isRenderDup = M4OSA_FALSE;
    err =
        pC->m_pVideoDecoder->m_pFctDecode(pC->pViDecCtxt, &pC->dViDecCurrentCts,
        M4OSA_TRUE);
        M4OSA_TRUE, 0);

    if( ( M4NO_ERROR != err) && (M4WAR_NO_MORE_AU != err)
        && (err != M4WAR_VIDEORENDERER_NO_NEW_FRAME) )
@@ -7752,7 +7743,7 @@ static M4OSA_ERR M4MCS_intStepBeginVideoDecode( M4MCS_InternalContext *pC )
        pC->dViDecCurrentCts);
    pC->isRenderDup = M4OSA_FALSE;
    err = pC->m_pVideoDecoder->m_pFctDecode(pC->pViDecCtxt, &dDecTarget,
        M4OSA_FALSE);
        M4OSA_FALSE, 0);

    if( ( M4NO_ERROR != err) && (M4WAR_NO_MORE_AU != err)
        && (err != M4WAR_VIDEORENDERER_NO_NEW_FRAME) )
@@ -9273,7 +9264,7 @@ static M4OSA_ERR M4MCS_intVideoTranscoding( M4MCS_InternalContext *pC )
        mtTranscodedTime);
    pC->isRenderDup = M4OSA_FALSE;
    err = pC->m_pVideoDecoder->m_pFctDecode(pC->pViDecCtxt, &mtTranscodedTime,
        M4OSA_FALSE);
        M4OSA_FALSE, 0);

    if( M4WAR_NO_MORE_AU == err )
    {
+3 −1
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ typedef struct {
*/
M4OSA_ERR M4DECODER_NULL_create(M4OSA_Context *pContext,
                                M4_StreamHandler *pStreamHandler,
                                M4READER_GlobalInterface *pReaderGlobalInterface,
                                M4READER_DataInterface *pReaderDataInterface,
                                M4_AccessUnit* pAccessUnit,
                                M4OSA_Void* pUserData) {
@@ -293,7 +294,8 @@ M4OSA_ERR M4DECODER_NULL_setOption(M4OSA_Context context,
 ************************************************************************
*/
M4OSA_ERR M4DECODER_NULL_decode(M4OSA_Context context,
                                M4_MediaTime* pTime, M4OSA_Bool bJump) {
                                M4_MediaTime* pTime, M4OSA_Bool bJump,
                                M4OSA_UInt32 tolerance) {

    // Do nothing; input time stamp itself returned
    return M4NO_ERROR;
+10 −43
Original line number Diff line number Diff line
@@ -209,8 +209,11 @@ M4OSA_ERR M4VSS3GPP_intClipOpen( M4VSS3GPP_ClipContext *pClipCtxt,
        decoderUserData = M4OSA_NULL;

        err = pClipCtxt->ShellAPI.m_pVideoDecoder->m_pFctCreate(
                  &pClipCtxt->pViDecCtxt, &dummyStreamHandler,
                  pClipCtxt->ShellAPI.m_pReaderDataIt, &pClipCtxt->VideoAU,
                  &pClipCtxt->pViDecCtxt,
                  &dummyStreamHandler,
                  pClipCtxt->ShellAPI.m_pReader,
                  pClipCtxt->ShellAPI.m_pReaderDataIt,
                  &pClipCtxt->VideoAU,
                  decoderUserData);

        if (M4NO_ERROR != err) {
@@ -607,6 +610,7 @@ M4OSA_ERR M4VSS3GPP_intClipOpen( M4VSS3GPP_ClipContext *pClipCtxt,
            err = pClipCtxt->ShellAPI.m_pVideoDecoder->m_pFctCreate(
                &pClipCtxt->pViDecCtxt,
                &pClipCtxt->pVideoStream->m_basicProperties,
                pClipCtxt->ShellAPI.m_pReader,
                pClipCtxt->ShellAPI.m_pReaderDataIt,
                &pClipCtxt->VideoAU, decoderUserData);

@@ -792,47 +796,10 @@ M4OSA_ERR M4VSS3GPP_intClipDecodeVideoUpToCts( M4VSS3GPP_ClipContext *pClipCtxt,
    if( M4VSS3GPP_kClipStatus_READ == pClipCtxt->Vstatus )
    {
        /**
        * Jump to the previous RAP in the clip (first get the time, then jump) */
        if(M4VIDEOEDITING_kFileType_ARGB8888 != pClipCtxt->pSettings->FileType) {
            iRapCts = iClipCts;

            err = pClipCtxt->ShellAPI.m_pReader->m_pFctGetPrevRapTime(
                pClipCtxt->pReaderContext,
                (M4_StreamHandler *)pClipCtxt->pVideoStream, &iRapCts);

            if( M4WAR_READER_INFORMATION_NOT_PRESENT == err )
            {
                /* No RAP table, jump backward and predecode */
                iRapCts = iClipCts - M4VSS3GPP_NO_STSS_JUMP_POINT;

                if( iRapCts < 0 )
                    iRapCts = 0;
            }
            else if( M4NO_ERROR != err )
            {
                M4OSA_TRACE1_1(
                    "M4VSS3GPP_intClipDecodeVideoUpToCts: m_pFctGetPrevRapTime returns 0x%x!",
                    err);
                return err;
            }

            err =
                pClipCtxt->ShellAPI.m_pReader->m_pFctJump(pClipCtxt->pReaderContext,
                (M4_StreamHandler *)pClipCtxt->pVideoStream, &iRapCts);

            if( M4NO_ERROR != err )
            {
                M4OSA_TRACE1_1(
                    "M4VSS3GPP_intClipDecodeVideoUpToCts: m_pFctJump returns 0x%x!",
                    err);
                return err;
            }

            /**
            * The decoder must be told that we jumped */
        * The decoder must be told to jump */
        bClipJump = M4OSA_TRUE;
            pClipCtxt->iVideoDecCts = iRapCts;
        }
        pClipCtxt->iVideoDecCts = iClipCts;

        /**
        * Remember the clip reading state */
        pClipCtxt->Vstatus = M4VSS3GPP_kClipStatus_DECODE_UP_TO;
@@ -873,7 +840,7 @@ M4OSA_ERR M4VSS3GPP_intClipDecodeVideoUpToCts( M4VSS3GPP_ClipContext *pClipCtxt,
    pClipCtxt->isRenderDup = M4OSA_FALSE;
    err =
        pClipCtxt->ShellAPI.m_pVideoDecoder->m_pFctDecode(pClipCtxt->pViDecCtxt,
        &dDecodeTime, bClipJump);
        &dDecodeTime, bClipJump, 0);

    if( ( M4NO_ERROR != err) && (M4WAR_NO_MORE_AU != err)
        && (err != M4WAR_VIDEORENDERER_NO_NEW_FRAME) )
+1 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ typedef struct {
    sp<MediaSource>         mReaderSource; /**< Reader access > */

    /* READER */
    M4READER_GlobalInterface *m_pReaderGlobal;
    M4READER_DataInterface  *m_pReader;
    M4_AccessUnit           *m_pNextAccessUnitToDecode;

Loading