docs: private void determineFramePal(int index) {
  		if ((inMode != InputMode.VOBSUB && inMode != InputMode.SUPIFO)
  				|| configuration.getPaletteMode() != PaletteMode.KEEP_EXISTING) {
  			// get the primary color from the source palette
  			int rgbSrc[] = subtitleStream.getPalette().getRGB(
  					subtitleStream.getPrimaryColorIndex());
  
  			// match with primary color from 16 color target palette
  			// note: skip index 0 , primary colors at even positions
  			// special treatment for index 1: white
  			Palette trgPallete = currentDVDPalette;
  			int minDistance = 0xffffff; // init > 0xff*0xff*3 = 0x02fa03
  			int colIdx = 0;
  			for (int idx = 1; idx < trgPallete.getSize(); idx += 2) {
  				int rgb[] = trgPallete.getRGB(idx);
  				// distance vector (skip sqrt)
  				int rd = rgbSrc[0] - rgb[0];
  				int gd = rgbSrc[1] - rgb[1];
  				int bd = rgbSrc[2] - rgb[2];
  				int distance = rd * rd + gd * gd + bd * bd;
  				// new minimum distance ?
  				if (distance < minDistance) {
  					colIdx = idx;
  					minDistance = distance;
  					if (minDistance == 0) {
  						break;
  					}
  				}
  				// special treatment for index 1 (white)
  				if (idx == 1) {
  					idx--; // -> continue with index = 2
  				}
  			}
  
  			// set new frame palette
  			int palFrame[] = new int[4];
  			palFrame[0] = 0; // black - transparent color
  			palFrame[1] = colIdx; // primary color
  			if (colIdx == 1) {
  				palFrame[2] = colIdx + 2; // special handling: white + dark grey
  			} else {
  				palFrame[2] = colIdx + 1; // darker version of primary color
  			}
  			palFrame[3] = 0; // black - opaque
  
  			subVobTrg.setAlpha(DEFAULT_ALPHA);
  			subVobTrg.setPal(palFrame);
  
  			trgPal = SupDvdUtil.decodePalette(subVobTrg, trgPallete);
  		}
  	}