idx is known, use av_store rather than av_push