A new algorithm for context modeling of binary sources with application to video compression is presented. Our proposed method is based on a tree rearrangement and tree selection process for an optimized modeling of binary context trees. We demonstrate its usefor adapfive context-based codingof selected syntax elements in a video coder. For that purpose we apply our proposed technique to the H.264/AVC standard and evaluate its pei-formanre for different sources and different quantization parameters. Experimental results show that by using our proposed algorithm coding gains similar or superior lo those obtained wilh the H,264/AVC CABAC olgorithni can be achieved.