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

Commit a84a5a30 authored by Gopalakrishnan Nallasamy's avatar Gopalakrishnan Nallasamy
Browse files

rate_control.cpp:removed redundant NULL checks

First argument (VideoEncData *) of the functions RC_UpdateBuffer, targetBitCalculation and
calculateQuantizer_Multipass in rate_control.cpp file of libstagefright_m4vh263enc SoftMPEG4Encoder
was checked against NULL after it was already refered successfully.
Hence, those redundant checks are removed now.  Above mentioned functions' VideoEncData pointer
argument can't be null as those functions are called only after successful initialisation in
PVInitVideoEncoder by SoftMPEG4Encoder::initEncoder.
rate_control.cpp is compiled as a part of static library : libstagefright_m4vh263enc.
This library can only be used using SoftMPEG4Encoder wrapper which makes sure VideoEncData * was
allocated required memory.

Bug: 112154365

Test: Encoded a YUV file using test case libstagefright_m4vh263enc_test and generated a bit stream
      output file without any error.

Change-Id: Id7f08cc57350bc70729a82afebbc79ba83dac72d
parent 771ffb62
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -377,15 +377,15 @@ void RC_ResetSkipNextFrame(VideoEncData *video, Int currLayer)
/*  In/out   : Nr, B, Rr                                                    */
/*  Return   : Void                                                         */
/*  Modified :                                                              */
/* Input argument "video" is guaranteed non-null by caller                  */
/* ======================================================================== */


PV_STATUS RC_UpdateBuffer(VideoEncData *video, Int currLayer, Int num_skip)
{
    rateControl *rc  = video->rc[currLayer];
    MultiPass   *pMP = video->pMP[currLayer];

    if (video == NULL || rc == NULL || pMP == NULL)
    if (rc == NULL || pMP == NULL)
        return PV_FAIL;

    rc->VBV_fullness   -= (Int)(rc->bitrate / rc->framerate * num_skip); //rc[currLayer]->Rp;
@@ -524,6 +524,7 @@ PV_STATUS RC_UpdateBXRCParams(void *input)
/*  In/out   : rc->T                                                                */
/*  Return   : Void                                                                 */
/*  Modified :                                                                      */
/* Input argument "input" is guaranteed non-null by caller                          */
/* ================================================================================ */

void targetBitCalculation(void *input)
@@ -537,7 +538,7 @@ void targetBitCalculation(void *input)
    Int diff_counter_BTsrc, diff_counter_BTdst, prev_counter_diff, curr_counter_diff, bound;
    /* BT = Bit Transfer, for pMP->counter_BTsrc, pMP->counter_BTdst */

    if (video == NULL || currVol == NULL || pMP == NULL || rc == NULL)
    if (currVol == NULL || pMP == NULL || rc == NULL)
        return;

    /* some stuff about frame dropping remained here to be done because pMP cannot be inserted into updateRateControl()*/
@@ -693,6 +694,7 @@ void targetBitCalculation(void *input)
/*  In/out   : rc->T and rc->Qc                                                     */
/*  Return   : Void                                                                 */
/*  Modified :                                                                      */
/*  Input argument "input" is guaranteed non-null by caller                         */
/* ================================================================================ */

/* Mad based variable bit allocation + QP calculation with a new quadratic method */
@@ -708,7 +710,7 @@ void calculateQuantizer_Multipass(void *input)
    float curr_mad, prev_mad, curr_RD, prev_RD, average_mad, aver_QP;


    if (video == NULL || currVol == NULL || pMP == NULL || rc == NULL)
    if (currVol == NULL || pMP == NULL || rc == NULL)
        return;

    /* Mad based variable bit allocation */