if (iRetcode)                       return iRetcode; }  if ((pData->bDisplaying) && (pData->bRunning) && (!pData->bFreezing)) { mng_retcode iRetcode = process_display_pplt (pData, iDeltatype, iMax, aIndexentries, aAlphaentries, aUsedentries);
if (!iRetcode)                      iRetcode = process_display_pplt (pData, iDeltatype, iMax, aIndexentries, aAlphaentries, aUsedentries);
READ_CHUNK (read_pplt){  mng_uint8     iDeltatype;  mng_uint8p    pTemp;  mng_uint32    iLen;  mng_uint8     iX, iM;  mng_uint32    iY;  mng_uint32    iMax;  mng_rgbpaltab aIndexentries;  mng_uint8arr  aAlphaentries;  mng_uint8arr  aUsedentries;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_READ_PPLT, MNG_LC_START)#endif                                       /* sequence checks */  if ((!pData->bHasMHDR) && (!pData->bHasDHDR))    MNG_ERROR (pData, MNG_SEQUENCEERROR)  if (iRawlen < 1)                     /* must have at least 1 byte */    MNG_ERROR (pData, MNG_INVALIDLENGTH)  iDeltatype = *pRawdata;                                       /* valid ? */  if (iDeltatype > MNG_DELTATYPE_DELTARGBA)    MNG_ERROR (pData, MNG_INVDELTATYPE)                                       /* must be indexed color ! */  if (pData->iColortype != MNG_COLORTYPE_INDEXED)    MNG_ERROR (pData, MNG_INVALIDCOLORTYPE)  pTemp = pRawdata + 1;  iLen  = iRawlen - 1;  iMax  = 0;  for (iY = 0; iY < 256; iY++)         /* reset arrays */  {    aIndexentries [iY].iRed   = 0;    aIndexentries [iY].iGreen = 0;    aIndexentries [iY].iBlue  = 0;    aAlphaentries [iY]        = 255;    aUsedentries  [iY]        = 0;  }  while (iLen)                         /* as long as there are entries left ... */  {    mng_uint32 iDiff;    if (iLen < 2)      MNG_ERROR (pData, MNG_INVALIDLENGTH)    iX = *pTemp;                       /* get start and end index */    iM = *(pTemp+1);    if (iM < iX)      MNG_ERROR (pData, MNG_INVALIDINDEX)    if ((mng_uint32)iM >= iMax)        /* determine highest used index */      iMax = (mng_uint32)iM + 1;    pTemp += 2;    iLen  -= 2;    if ((iDeltatype == MNG_DELTATYPE_REPLACERGB  ) ||        (iDeltatype == MNG_DELTATYPE_DELTARGB    )    )      iDiff = (iM - iX + 1) * 3;    else    if ((iDeltatype == MNG_DELTATYPE_REPLACEALPHA) ||        (iDeltatype == MNG_DELTATYPE_DELTAALPHA  )    )      iDiff = (iM - iX + 1);    else      iDiff = (iM - iX + 1) * 4;    if (iLen < iDiff)      MNG_ERROR (pData, MNG_INVALIDLENGTH)    if ((iDeltatype == MNG_DELTATYPE_REPLACERGB  ) ||        (iDeltatype == MNG_DELTATYPE_DELTARGB    )    )    {      for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++)      {        aIndexentries [iY].iRed   = *pTemp;        aIndexentries [iY].iGreen = *(pTemp+1);        aIndexentries [iY].iBlue  = *(pTemp+2);        aUsedentries  [iY]        = 1;        pTemp += 3;        iLen  -= 3;      }    }    else    if ((iDeltatype == MNG_DELTATYPE_REPLACEALPHA) ||        (iDeltatype == MNG_DELTATYPE_DELTAALPHA  )    )    {      for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++)      {        aAlphaentries [iY]        = *pTemp;        aUsedentries  [iY]        = 1;        pTemp++;        iLen--;      }    }    else    {      for (iY = (mng_uint32)iX; iY <= (mng_uint32)iM; iY++)      {        aIndexentries [iY].iRed   = *pTemp;        aIndexentries [iY].iGreen = *(pTemp+1);        aIndexentries [iY].iBlue  = *(pTemp+2);        aAlphaentries [iY]        = *(pTemp+3);        aUsedentries  [iY]        = 1;        pTemp += 4;        iLen  -= 4;      }    }  }  switch (pData->iBitdepth)            /* check maximum allowed entries for bitdepth */  {    case MNG_BITDEPTH_1 : {                            if (iMax > 2)                              MNG_ERROR (pData, MNG_INVALIDINDEX)                            break;                          }    case MNG_BITDEPTH_2 : {                            if (iMax > 4)                              MNG_ERROR (pData, MNG_INVALIDINDEX)                            break;                          }    case MNG_BITDEPTH_4 : {                            if (iMax > 16)                              MNG_ERROR (pData, MNG_INVALIDINDEX)                            break;                          }  }#ifdef MNG_SUPPORT_DISPLAY  {                                    /* create animation object */    mng_retcode iRetcode = create_ani_pplt (pData, iDeltatype, iMax,                                            aIndexentries, aAlphaentries,                                            aUsedentries);    if (iRetcode)                      /* on error bail out */      return iRetcode;  }                                       /* execute it now ? */  if ((pData->bDisplaying) && (pData->bRunning) && (!pData->bFreezing))  {    mng_retcode iRetcode = process_display_pplt (pData, iDeltatype, iMax,                                                 aIndexentries, aAlphaentries,                                                 aUsedentries);    if (iRetcode)                      /* on error bail out */      return iRetcode;  }#endif /* MNG_SUPPORT_DISPLAY */#ifdef MNG_STORE_CHUNKS  if (pData->bStorechunks)  {                                    /* initialize storage */    mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk);    if (iRetcode)                      /* on error bail out */      return iRetcode;                                       /* store the fields */    ((mng_ppltp)*ppChunk)->iDeltatype = iDeltatype;    ((mng_ppltp)*ppChunk)->iCount     = iMax;    for (iY = 0; iY < 256; iY++)    {      ((mng_ppltp)*ppChunk)->aEntries [iY].iRed   = aIndexentries [iY].iRed;      ((mng_ppltp)*ppChunk)->aEntries [iY].iGreen = aIndexentries [iY].iGreen;      ((mng_ppltp)*ppChunk)->aEntries [iY].iBlue  = aIndexentries [iY].iBlue;      ((mng_ppltp)*ppChunk)->aEntries [iY].iAlpha = aAlphaentries [iY];      ((mng_ppltp)*ppChunk)->aEntries [iY].bUsed  = (mng_bool)(aUsedentries [iY]);    }  }#endif /* MNG_STORE_CHUNKS */#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_READ_PPLT, MNG_LC_END)#endif  return MNG_NOERROR;                  /* done */}