avcodec/prosumer: Factorize the 2 loops in fill_elements()